Class: Telegraphist::Bot
- Inherits:
-
Object
- Object
- Telegraphist::Bot
- Includes:
- ActiveModel::Model
- Defined in:
- lib/telegraphist/bot.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#first_name ⇒ Object
Returns the value of attribute first_name.
-
#id ⇒ Object
Returns the value of attribute id.
-
#username ⇒ Object
Returns the value of attribute username.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
5 6 7 |
# File 'lib/telegraphist/bot.rb', line 5 def client @client end |
#first_name ⇒ Object
Returns the value of attribute first_name.
5 6 7 |
# File 'lib/telegraphist/bot.rb', line 5 def first_name @first_name end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/telegraphist/bot.rb', line 5 def id @id end |
#username ⇒ Object
Returns the value of attribute username.
5 6 7 |
# File 'lib/telegraphist/bot.rb', line 5 def username @username end |
Class Method Details
Instance Method Details
#send_message(chat_id, text) ⇒ Object
29 30 31 |
# File 'lib/telegraphist/bot.rb', line 29 def (chat_id, text) client.post(:sendMessage, query: {chat_id: chat_id, text: text}) end |
#update_loop(&block) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/telegraphist/bot.rb', line 12 def update_loop(&block) last_update = nil loop do updates(last_update).try(:each) do |update| block.call(update) last_update = [last_update, update.update_id + 1].compact.max end sleep 1 end end |