phpoxford / spires

Spires IRC bot
MIT License
1 stars 4 forks source link

Design plugin architecture #8

Open garethellis36 opened 8 years ago

garethellis36 commented 8 years ago

Brainstorming my thoughts on architecture.

Class Bot will use an IrcClient interface (phpoxford/spires-irc) to connect to Freenode and join the channel. The Bot will need a loop (assuming non-blocking) which receives messages from IRC (messages being chat messages, join notices, quit notices, etc).

Bot will need a MessageParser, which will need an EventDispatcher. The parser will parse the messages and trigger events as required (for example a quit notice could trigger event called UserQuitIrc).

Plugins should listen for certain events and have a method to handle the given event Pluginnable::handleEvent(?).

Plugin event handlers should would in turn need to emit a Result event which the Bot class can consume. This way multiple plugins could handle one command and the bot could process each result event separately.

Thoughts? Too complex? Not complex enough? Idiotic?

ascii-soup commented 8 years ago

I will describe the architecture we chose to you tomorrow, or sooner if you prefer :-)