Class: ExceptionNotifier::TelegramNotifier

Inherits:
Object
  • Object
show all
Defined in:
lib/exception_notification_telegram.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ TelegramNotifier

Returns a new instance of TelegramNotifier.

Raises:

  • (ArgumentError)


8
9
10
11
12
13
# File 'lib/exception_notification_telegram.rb', line 8

def initialize(options)
  @token = options.delete(:token)
  @channel = options.delete(:channel)

  raise ArgumentError, "You must provide 'token' and 'channel' option" unless @token && @channel
end

Instance Method Details

#call(exception, options = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/exception_notification_telegram.rb', line 15

def call(exception, options = {})
  @options = options
  @exception = exception

  @formatter = Formatter.new(exception, options)

  url = "https://api.telegram.org/bot#{@token}/sendMessage"
  HTTParty.post(url, httparty_options)
end