Help us measure site usage?

With your permission, we use self-hosted analytics to understand page usage. It is optional and does not affect the Service. Learn more.

PerladvancedbackendAI generated

Real-time IRC Bot Framework with Plugin System

Build an IRC chat bot in Perl with a plugin system: the bot connects to an IRC server, joins channels and responds to commands such as !help, !quote or !remind, and every command comes from a plugin, a Perl module you drop into a plugins folder. The bot is built on POE, Perl's event-driven framework, with POE::Component::IRC for the IRC protocol, so it handles many events at once without threads. A plugin that crashes is caught and logged without taking the bot down, and plugins can be reloaded without restarting. Test it on your own IRC server (for example one running in Docker) or a channel you run. You'll learn event-driven programming, the IRC protocol, dynamic module loading, designing a plugin API, and error isolation.

Estimate
~11h
Steps
6
Completed by
0
Proposed by
codeseed.app

POE · POE::Component::IRC · DBI · SQLite

Project roadmap

  1. 01

    Connect to IRC

    ~2h

    Run a local IRC server for testing (for example ngircd or InspIRCd in Docker). Install POE and POE::Component::IRC, and write a bot that connects, sets its nickname (trying another when it's taken), joins the channels from a config file, and prints channel messages. Reconnect automatically with increasing waits when the connection drops (for example with POE::Component::IRC::Plugin::Connector). Done when: the bot joins your test channel and logs messages.

  2. 02

    Design the plugin interface

    ~1.5h

    Write a base module Bot::Plugin that plugins inherit from, with methods name, commands (returning a list of command names with help text and a handler for each), and optional init and shutdown. Handlers receive a context object with the nick, channel, arguments and a reply function, so plugins never talk to POE directly. Document the interface in PLUGINS.md. Done when: PLUGINS.md describes the interface, and a trivial plugin compiles against it.

  3. 03

    Load plugins dynamically

    ~2h

    At startup, scan the plugins folder, load each module with require (checking the file name is a valid module name), check it inherits from Bot::Plugin, and register its commands, refusing duplicate command names with a warning. Route messages starting with ! to the right handler. Add an admin-only !reload command that unloads and reloads plugins. Done when: dropping a new plugin file and running !reload makes its command available.

  4. 04

    Write example plugins

    ~2h

    Write at least three plugins: help (lists commands with their help text), quotes (add, random and search quotes stored in SQLite through DBI), and remind (!remind 10m stretch, using POE delays to reply later, and persisting reminders so they survive restarts). Done when: all three plugins work in the test channel.

  5. 05

    Isolate errors and limit abuse

    ~1.5h

    Wrap every handler call in eval (or Try::Tiny) so a plugin that dies is logged with its name and the error, and the bot replies with a short message instead of crashing. Add a timeout for slow handlers, limit how often each user can run commands, and never let replies exceed IRC's message length. Done when: a deliberately broken plugin doesn't affect the bot or other plugins.

  6. 06

    Test it

    ~2h

    Write Test::More tests for the plugin loader and command routing using fake context objects, and for each example plugin's logic (quote storage, parsing reminder times). Add an integration test that runs the bot against the local IRC server and checks a few commands. Done when: prove -l t/ passes.

Ready to build this?

Get a GitHub repo and start building. Your AI reviewer checks each step as you go.

~11h · 6 steps

Tech stack

POEPOE::Component::IRCDBISQLite