class Capistrano::Telegram

Public Class Methods

new(env) click to toggle source
# File lib/capistrano/telegram.rb, line 13
def initialize(env)
  @telegram_bot_key = fetch(:telegram_bot_key, nil)
  @telegram_chat_id = fetch(:telegram_chat_id, nil)
  @message = Capistrano::Messaging::Telegram.new
end

Public Instance Methods

send(action) click to toggle source
# File lib/capistrano/telegram.rb, line 19
def send(action)
  payload = @message.payload_for(action)
  send_to_telegram(payload)
end

Private Instance Methods

send_to_telegram(message) click to toggle source
# File lib/capistrano/telegram.rb, line 25
def send_to_telegram(message)
  ::Telegram::Bot::Client.run(@telegram_bot_key) do |bot|
    bot.api.send_message(chat_id: @telegram_chat_id, text: message)
  end
end