Class: TelegramWebProxy::MessageProcessor
- Inherits:
-
Object
- Object
- TelegramWebProxy::MessageProcessor
- Defined in:
- lib/telegram_web_proxy/message_processor.rb
Instance Attribute Summary collapse
-
#message ⇒ Object
Returns the value of attribute message.
-
#page ⇒ Object
Returns the value of attribute page.
Instance Method Summary collapse
Instance Attribute Details
#message ⇒ Object
Returns the value of attribute message.
4 5 6 |
# File 'lib/telegram_web_proxy/message_processor.rb', line 4 def @message end |
#page ⇒ Object
Returns the value of attribute page.
4 5 6 |
# File 'lib/telegram_web_proxy/message_processor.rb', line 4 def page @page end |
Instance Method Details
#process(message) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/telegram_web_proxy/message_processor.rb', line 6 def process() self. = if .instance_of? Telegram::Bot::Types::CallbackQuery process_callback else end end |
#process_callback ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/telegram_web_proxy/message_processor.rb', line 15 def process_callback command, args = .data.split ' ' case command when '/f' send_fragment(args.to_i) end end |
#process_message ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/telegram_web_proxy/message_processor.rb', line 23 def command, args = .text.split(' ', 2) case command when '/h' send_text(text: "Supported requests: \n/h - help \n/o URL (or just URL without /o) - open URL\n/s REQUEST - search with DuckDuckGo\n/e - echo\n/t - just a test") when '/o' #puts "Opening page: #{args}" send_large_html(TelegramWebProxy::PageFetcher.new(args).get) when '/s' # puts "Search for: #{args}" send_large_html(TelegramWebProxy::PageFetcher.new('https://duckduckgo.com/lite').post(q: args)) when '/e' # puts "Echo: #{args}" send_text(text: args) when '/f' #actually user shouldn't use this manually, see #process_callback send_fragment(args.to_i) when '/' puts 'Do nothing' when '/t' text = "A ! <a href='tg:msg?text=test&to=wprox_bot'> click here</a> <a href='https://techcrunch.com/2017/07/14/startup-battlefield-application-deadline-extended-for-disrupt-sf-2/'>TC instant view</a> <a href='http://reddit.com'>Reddit</a>." send_text(text: text)#, parse_mode: 'HTML', reply_markup: markup) else if true #just url given puts "Trying to open page: #{command}" send_large_html(TelegramWebProxy::PageFetcher.new(command).get) end end end |