Class: Qbot::Base
- Inherits:
-
Object
- Object
- Qbot::Base
- Defined in:
- lib/qbot/base.rb
Class Method Summary collapse
Instance Method Summary collapse
- #cache ⇒ Object
- #call(message) ⇒ Object
-
#initialize(pattern, &block) ⇒ Base
constructor
A new instance of Base.
- #post(text, **options) ⇒ Object
Constructor Details
#initialize(pattern, &block) ⇒ Base
Returns a new instance of Base.
39 40 41 42 |
# File 'lib/qbot/base.rb', line 39 def initialize(pattern, &block) @pattern = pattern @callback = block end |
Class Method Details
.cron(pattern, &block) ⇒ Object
21 22 23 |
# File 'lib/qbot/base.rb', line 21 def cron(pattern, &block) schedule(pattern, &block) end |
Instance Method Details
#cache ⇒ Object
60 61 62 |
# File 'lib/qbot/base.rb', line 60 def cache Qbot.app.storage.namespace(self.class.name) end |
#call(message) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/qbot/base.rb', line 44 def call() @message = return unless @pattern =~ @message.text.to_s.strip begin Qbot.app.logger.debug("#{self.class} - Recieve message: '#{.text}'") instance_exec($~, &@callback) rescue => e Qbot.app.logger.error("#{self.class} - Error: #{e}") end end |