Class: Abot::Info::TelegramSender
- Inherits:
-
Object
- Object
- Abot::Info::TelegramSender
- Defined in:
- lib/abot/info/telegram_sender.rb
Constant Summary collapse
- SENDED_LOST_COINS =
{}
- SENDED_ERROR =
{}
- SENDED_SELL_ERROR =
{}
Instance Attribute Summary collapse
-
#chat_id ⇒ Object
readonly
Returns the value of attribute chat_id.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
-
#initialize ⇒ TelegramSender
constructor
A new instance of TelegramSender.
- #send_lost_coins(coins_without_order) ⇒ Object
- #send_message(text) ⇒ Object
Constructor Details
#initialize ⇒ TelegramSender
Returns a new instance of TelegramSender.
11 12 13 14 |
# File 'lib/abot/info/telegram_sender.rb', line 11 def initialize @chat_id = DatabaseTable::TG_NAME @token = DatabaseTable::TG_TOKEN end |
Instance Attribute Details
#chat_id ⇒ Object (readonly)
Returns the value of attribute chat_id.
6 7 8 |
# File 'lib/abot/info/telegram_sender.rb', line 6 def chat_id @chat_id end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
6 7 8 |
# File 'lib/abot/info/telegram_sender.rb', line 6 def token @token end |
Instance Method Details
#send_lost_coins(coins_without_order) ⇒ Object
25 26 27 28 29 |
# File 'lib/abot/info/telegram_sender.rb', line 25 def send_lost_coins(coins_without_order) coins_without_order.each do |coin| ("WARNING обнаружена монета без ордера: #{coin}") if SENDED_LOST_COINS[coin].to_i == 3 end end |
#send_message(text) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/abot/info/telegram_sender.rb', line 16 def (text) Telegram::Bot::Client.run(token) do |bot| = bot.api.(chat_id: chat_id, text: text) if ['ok'] == true bot.api.(chat_id: chat_id, message_id: .dig('result', 'message_id')) end end end |