Class: Cognition::Bot
- Inherits:
-
Object
- Object
- Cognition::Bot
- Defined in:
- lib/cognition/bot.rb
Instance Attribute Summary collapse
-
#matchers ⇒ Object
writeonly
Sets the attribute matchers.
-
#plugins ⇒ Object
writeonly
Sets the attribute plugins.
Instance Method Summary collapse
- #help ⇒ Object
-
#initialize ⇒ Bot
constructor
A new instance of Bot.
- #plugin_names ⇒ Object
- #process(msg, metadata = {}) ⇒ Object
- #register(klass) ⇒ Object
- #reset ⇒ Object
Constructor Details
Instance Attribute Details
#matchers=(value) ⇒ Object
Sets the attribute matchers
9 10 11 |
# File 'lib/cognition/bot.rb', line 9 def matchers=(value) @matchers = value end |
#plugins=(value) ⇒ Object
Sets the attribute plugins
9 10 11 |
# File 'lib/cognition/bot.rb', line 9 def plugins=(value) @plugins = value end |
Instance Method Details
#help ⇒ Object
39 40 41 |
# File 'lib/cognition/bot.rb', line 39 def help matchers.flat_map(&:help) end |
#plugin_names ⇒ Object
35 36 37 |
# File 'lib/cognition/bot.rb', line 35 def plugin_names plugins.map { |p| p.class.name } end |
#process(msg, metadata = {}) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/cognition/bot.rb', line 16 def process(msg, = {}) if msg.respond_to? :command process_msg(msg) else process_string(msg.to_s, ) end end |
#register(klass) ⇒ Object
24 25 26 27 |
# File 'lib/cognition/bot.rb', line 24 def register(klass) return false if plugin_names.include? klass.to_s plugins << klass.new(self) end |