Class: Telegram::Bot::Client
- Inherits:
-
Object
- Object
- Telegram::Bot::Client
- Defined in:
- lib/telegram/bot/client.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#update ⇒ Object
readonly
Returns the value of attribute update.
Instance Method Summary collapse
- #handle(params) ⇒ Object
-
#initialize(handler) ⇒ Client
constructor
A new instance of Client.
- #invoke ⇒ Object
Constructor Details
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
5 6 7 |
# File 'lib/telegram/bot/client.rb', line 5 def command @command end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
5 6 7 |
# File 'lib/telegram/bot/client.rb', line 5 def @message end |
#update ⇒ Object (readonly)
Returns the value of attribute update.
5 6 7 |
# File 'lib/telegram/bot/client.rb', line 5 def update @update end |
Instance Method Details
#handle(params) ⇒ Object
13 14 15 16 |
# File 'lib/telegram/bot/client.rb', line 13 def handle(params) parse_request(params) invoke end |
#invoke ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/telegram/bot/client.rb', line 18 def invoke @handler.update = @update @handler. = @message @handler.command = @command if !@command.nil? && @handler.respond_to?("cmd_#{@command}") @handler.public_send("cmd_#{@command}") else @handler.public_send(:cmd_fallback) if @handler.respond_to?(:cmd_fallback) end end |