Class: Pug::Bot

Inherits:
Object
  • Object
show all
Defined in:
lib/pug/bot.rb

Overview

Coordinates the Client with the provided Actions

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, actions) ⇒ Bot

Returns a new instance of Bot.

Parameters:



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

.runBot

Convenience method used to setup the Bot with the user defined Configuration

Returns:

  • (Bot)

    A new instance of Bot.

See Also:



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

#startvoid

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 |message|
    handle(message)
  end
end