Sha256: 1dc7165fd6a5eb5070d304ad0a796f189a6a6b4079d17ae904cdc4b439b3b9df
Contents?: true
Size: 955 Bytes
Versions: 1
Compression:
Stored size: 955 Bytes
Contents
# frozen_string_literal: true module Boppers module Notifier class Telegram attr_reader :api_token, :channel_id, :subscribe def initialize(api_token:, channel_id:, subscribe: nil) require "telegram_bot" @api_token = api_token @channel_id = channel_id @subscribe = subscribe end def call(title, message, options) telegram_options = options.fetch(:telegram, {}) title = telegram_options.delete(:title) { title } message = telegram_options.delete(:message) { message } bot = TelegramBot.new(token: api_token) notification = TelegramBot::OutMessage.new notification.chat = TelegramBot::Channel.new(id: channel_id) notification.text = "#{title}\n\n#{message}" telegram_options.each do |key, value| notification.public_send("#{key}=", value) end notification.send_with(bot) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
boppers-0.0.8 | lib/boppers/notifier/telegram.rb |