Class: Pug::Bot
- Inherits:
-
Object
- Object
- Pug::Bot
- Defined in:
- lib/pug/bot.rb
Overview
Coordinates the Client with the provided Actions
Class Method Summary collapse
-
.run ⇒ Bot
Convenience method used to setup the Bot with the user defined Configuration.
Instance Method Summary collapse
-
#initialize(client, actions) ⇒ Bot
constructor
A new instance of Bot.
-
#start ⇒ void
Starts the handling of all messages received via the Client.
Constructor Details
#initialize(client, actions) ⇒ Bot
Returns a new instance of Bot.
19 20 21 22 |
# File 'lib/pug/bot.rb', line 19 def initialize(client, actions) @client = client @handler = MessageHandler.default(actions) end |
Class Method Details
.run ⇒ Bot
Convenience method used to setup the Bot with the user defined Configuration
10 11 12 13 14 15 |
# File 'lib/pug/bot.rb', line 10 def self.run config = Pug.configuration config.validate client = Clients::Factory.client_for_config(config) Bot.new(client, config.actions).start end |
Instance Method Details
#start ⇒ void
This method returns an undefined value.
Starts the handling of all messages received via the Client
26 27 28 29 30 |
# File 'lib/pug/bot.rb', line 26 def start @client.listen do || handle() end end |