Class: Konsierge::Notifier::Adapters::Telegram

Inherits:
BaseAdapter
  • Object
show all
Defined in:
lib/konsierge/notifier/adapters/telegram.rb

Constant Summary collapse

TELEGRAM_CHAT_ID_NOT_SET =
'Telegram Chat ID is not set'
TELEGRAM_BOT_ERROR =
'TelegramBot Error: %s'
TELEGRAM_BOT_DISABLED =
'TelegramBot is disabled! Message not sent.'
PATH_OR_CHAT_ID_NOT_PROVIDED =
'Please, provide path and chat_id'

Instance Method Summary collapse

Instance Method Details

#send_error(error, context: {}, source: nil, **options) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/konsierge/notifier/adapters/telegram.rb', line 33

def send_error(error, context: {}, source: nil, **options)
  chat_id = options.delete(:chat_id)

  template_params = {
    app_name: Notifier.config.app_name,
    error:    error,
    source:   source,
    context:  context
  }

  send_with_message_template(
    path:            Notifier.config.error_template_path,
    chat_id:         chat_id,
    template_params: template_params
  )
end

#send_message(message, context: {}, **options) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/konsierge/notifier/adapters/telegram.rb', line 17

def send_message(message, context: {}, **options)
  chat_id = options.delete(:chat_id)

  template_params = {
    app_name: Notifier.config.app_name,
    message:  message,
    context:  context
  }

  send_with_message_template(
    path:            Notifier.config.message_template_path,
    chat_id:         chat_id,
    template_params: template_params
  )
end