Class: Kanal::Interfaces::Telegram::Plugins::TelegramIntegrationPlugin

Inherits:
Core::Plugins::Plugin
  • Object
show all
Defined in:
lib/kanal/interfaces/telegram/plugins/telegram_integration_plugin.rb

Overview

This class registers properties and hooks for telegram bot library integration

Instance Method Summary collapse

Instance Method Details

#nameObject



9
10
11
# File 'lib/kanal/interfaces/telegram/plugins/telegram_integration_plugin.rb', line 9

def name
  :telegram_properties
end

#register_hooks(core) ⇒ Object



37
38
39
40
41
42
43
44
45
# File 'lib/kanal/interfaces/telegram/plugins/telegram_integration_plugin.rb', line 37

def register_hooks(core)
  core.hooks.attach :input_just_created do |input|
    input.source = :telegram
  end

  core.hooks.attach :output_before_returned do |input, output|
    output.tg_chat_id = input.tg_chat_id if output.tg_chat_id.nil?
  end
end

#register_parameters(core) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/kanal/interfaces/telegram/plugins/telegram_integration_plugin.rb', line 18

def register_parameters(core)
  core.register_input_parameter :tg_chat_id, readonly: true
  core.register_input_parameter :tg_username, readonly: true
  core.register_input_parameter :tg_text, readonly: true
  core.register_input_parameter :tg_button_pressed, readonly: true
  core.register_input_parameter :tg_image_link, readonly: true
  core.register_input_parameter :tg_audio_link, readonly: true
  core.register_input_parameter :tg_video_link, readonly: true
  core.register_input_parameter :tg_document_link, readonly: true

  core.register_output_parameter :tg_chat_id
  core.register_output_parameter :tg_text
  core.register_output_parameter :tg_image_path
  core.register_output_parameter :tg_audio_path
  core.register_output_parameter :tg_video_path
  core.register_output_parameter :tg_document_path
  core.register_output_parameter :tg_reply_markup
end

#setup(core) ⇒ Object



13
14
15
16
# File 'lib/kanal/interfaces/telegram/plugins/telegram_integration_plugin.rb', line 13

def setup(core)
  register_parameters core
  register_hooks core
end