Class: TelegramWebProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/telegram_web_proxy.rb,
lib/telegram_web_proxy/version.rb

Overview

WebProxy for a Telegram bot which handles chats and process messages

Constant Summary collapse

VERSION =
'0.2.0'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bot) ⇒ TelegramWebProxy

Returns a new instance of TelegramWebProxy.



12
13
14
# File 'lib/telegram_web_proxy.rb', line 12

def initialize(bot)
  self.bot = bot
end

Instance Attribute Details

#botObject

Returns the value of attribute bot.



10
11
12
# File 'lib/telegram_web_proxy.rb', line 10

def bot
  @bot
end

Instance Method Details

#message_processorsObject



16
17
18
# File 'lib/telegram_web_proxy.rb', line 16

def message_processors
  @message_processors ||= {}
end

#process(message) ⇒ Object



20
21
22
23
24
# File 'lib/telegram_web_proxy.rb', line 20

def process(message)
  chat = get_chat(message)
  message_processors[chat.id] ||= MessageProcessor.new(bot, chat)
  message_processors[chat.id].process(message)
end