Class: EurekaBot::Tg::Controller

Inherits:
Controller
  • Object
show all
Extended by:
ActiveSupport::Autoload
Includes:
RepliesConcern
Defined in:
lib/eureka_bot/tg/controller.rb

Direct Known Subclasses

SystemController

Defined Under Namespace

Modules: RepliesConcern Classes: Response, SystemController

Instance Method Summary collapse

Methods included from RepliesConcern

#global_reply_markup, #reply_markup

Instance Method Details

#answer(params = {}) ⇒ Object



11
12
13
# File 'lib/eureka_bot/tg/controller.rb', line 11

def answer(params={})
  super({params: {chat_id: chat_id}}.deep_merge(params))
end

#chatObject



19
20
21
# File 'lib/eureka_bot/tg/controller.rb', line 19

def chat
  message.dig('message', 'chat') || message.dig('callback_query', 'message', 'chat') || raise("Cant find chat in #{message}")
end

#chat_idObject



27
28
29
# File 'lib/eureka_bot/tg/controller.rb', line 27

def chat_id
  chat['id']
end

#clientObject



39
40
41
# File 'lib/eureka_bot/tg/controller.rb', line 39

def client
  EurekaBot::Tg.client
end

#fromObject



23
24
25
# File 'lib/eureka_bot/tg/controller.rb', line 23

def from
  message.dig('message', 'from') || message.dig('callback_query', 'from') || raise("Cant find from in #{message}")
end

#message_idObject



31
32
33
# File 'lib/eureka_bot/tg/controller.rb', line 31

def message_id
  message.dig('message', 'message_id') || message.dig('callback_query', 'message', 'message_id') || raise("Cant find message_id in #{message}")
end

#reply(params = {}) ⇒ Object



15
16
17
# File 'lib/eureka_bot/tg/controller.rb', line 15

def reply(params={})
  answer(params.deep_merge({params: {reply_to_message_id: message_id}}))
end

#response_classObject



35
36
37
# File 'lib/eureka_bot/tg/controller.rb', line 35

def response_class
  EurekaBot::Tg::Controller::Response
end