Module: ChatgptAssistant::Bots::Telegram::EventsController

Included in:
TelegramBot
Defined in:
lib/chatgpt_assistant/bots/telegram/events_controller.rb

Instance Method Summary collapse

Instance Method Details

#action_eventsObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/chatgpt_assistant/bots/telegram/events_controller.rb', line 14

def action_events
  return auth_events if auth_event?
  return new_chat_event if msg.text.include?("new_chat/")
  return select_chat_event if msg.text.include?("sl_chat/")
  return telegram_chat_event unless telegram_actions?

  raise InvalidCommandError
rescue InvalidCommandError => e
  send_message e.message, msg.chat.id
end

#auth_eventsObject



7
8
9
10
11
12
# File 'lib/chatgpt_assistant/bots/telegram/events_controller.rb', line 7

def auth_events
  return  if msg.text.include?("login/")
  return register_event if msg.text.include?("register/")
  return sign_out_event if msg.text.include?("sign_out/")
  return  if msg.text.include?("confirm/* ")
end

#text_eventsObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/chatgpt_assistant/bots/telegram/events_controller.rb', line 25

def text_events
  case msg.text
  when "/start"
    start_event
  when "/help"
    help_event
  when "/hist"
    hist_event
  when "/list"
    list_event
  when "/stop"
    stop_event
  when nil
    raise NilError
  else
    action_events
  end
rescue NilError => e
  send_message e.message, msg.chat.id
end