Module: Tramway::Bots::Telegram::Custom::Notify::File

Extended by:
MessagesManager
Defined in:
lib/tramway/bots/telegram/custom/notify/file.rb

Class Method Summary collapse

Methods included from MessagesManager

log_message, message_to_chat, message_to_user, send_file

Class Method Details

.send_to_chat(bot_id, chat_id, file) ⇒ Object



15
16
17
18
19
20
# File 'lib/tramway/bots/telegram/custom/notify/file.rb', line 15

def send_to_chat(bot_id, chat_id, file)
  bot_record = Bot.find bot_id
  bot = ::Telegram::Bot::Client.new bot_record.token
  bot_message = ::Tramway::Bots::Telegram::Leopold::Message.new file
  send_file bot.api, chat_id, bot_message.file
end

.send_to_user(bot_id, username, file) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/tramway/bots/telegram/custom/notify/file.rb', line 7

def send_to_user(bot_id, username, file)
  bot_record = Bot.find bot_id
  bot = ::Telegram::Bot::Client.new bot_record.token
  chat = ::Tramway::Bots::Telegram::Chat.where(bot_id: bot_id).find_by "options ->> 'username' = '#{username}'"
  bot_message = ::Tramway::Bots::Telegram::Leopold::Message.new file
  send_file bot.api, chat.telegram_chat_id, bot_message
end