Class: FastlaneExt::TelegramNotifier
- Inherits:
-
Object
- Object
- FastlaneExt::TelegramNotifier
- Defined in:
- lib/fastlane-ext/telegram_notifier.rb
Instance Method Summary collapse
-
#initialize(bot_api_token:, chat_id:) ⇒ TelegramNotifier
constructor
A new instance of TelegramNotifier.
- #notify(message:, parse_mode: nil, silent: nil) ⇒ Object
Constructor Details
#initialize(bot_api_token:, chat_id:) ⇒ TelegramNotifier
Returns a new instance of TelegramNotifier.
11 12 13 14 15 16 17 |
# File 'lib/fastlane-ext/telegram_notifier.rb', line 11 def initialize(bot_api_token:, chat_id:) raise 'Invalid Bot Api Token' if bot_api_token.empty? raise 'Invalid Chat Id' if chat_id.empty? @bot_api_token = bot_api_token @chat_id = chat_id end |
Instance Method Details
#notify(message:, parse_mode: nil, silent: nil) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/fastlane-ext/telegram_notifier.rb', line 19 def notify(message:, parse_mode: nil, silent: nil) uri = URI.parse("https://api.telegram.org/bot#{@bot_api_token}/sendMessage") params = { text: , chat_id: @chat_id } params[:parse_mode] = parse_mode unless parse_mode.nil? params[:disable_notification] = silent || true Net::HTTP.post_form(uri, params) end |