Module: Twitchbot::Plugin
- Included in:
- AuthPlugin, ChannelPlugin, DebugPlugin, PingPlugin
- Defined in:
- lib/twitchbot/plugin.rb
Overview
Base Plugin module that listens for IRC commands and calls the associated method of the class that includes it
Constant Summary collapse
- COMMANDS =
The commands that are registered to this base module via classes that include it
Example state during runtime:
{ AuthPlugin: { '376': :request_caps }, ChannelPlugin: { 'CAP': :join_channel, 'JOIN': :process_join, 'PART': :process_part } }
{}
Class Method Summary collapse
-
.included(klass) ⇒ Object
Define a class method called register on each class that includes this module, which allows the user to add methods to the
COMMANDS
constant.
Instance Method Summary collapse
-
#close(handler) ⇒ Object
Method that can be overriden to react to the eventmachine
:close
event. -
#error(handler) ⇒ Object
Method that can be overriden to react to the eventmachine
:error
event. -
#message(handler) ⇒ Object
Method that reacts to the eventmachine
:message
event and processes each message in the EventHandler, calling the appropriate method if available. -
#open(handler) ⇒ Object
Method that can be overriden to react to the eventmachine
:open
event.
Class Method Details
Instance Method Details
#close(handler) ⇒ Object
Method that can be overriden to react to the eventmachine :close
event
37 |
# File 'lib/twitchbot/plugin.rb', line 37 def close(handler) end |
#error(handler) ⇒ Object
Method that can be overriden to react to the eventmachine :error
event
34 |
# File 'lib/twitchbot/plugin.rb', line 34 def error(handler) end |
#message(handler) ⇒ Object
Method that reacts to the eventmachine :message
event and processes each message in the EventHandler, calling the appropriate method if available.
It is not recommended to override this method unless you plan on handling all logic for reacting to methods yourself.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/twitchbot/plugin.rb', line 21 def (handler) handler..each do || command = &.command # Grab all registered methods of the including class commands = COMMANDS[self.class] if !command.nil? && !commands[command].nil? # Call the including class method and pass the EventHandler to it send(commands[command], handler) end end end |
#open(handler) ⇒ Object
Method that can be overriden to react to the eventmachine :open
event
14 |
# File 'lib/twitchbot/plugin.rb', line 14 def open(handler) end |