Module: ChatgptAssistant::Bots::Discord::Events

Included in:
DiscordBot
Defined in:
lib/chatgpt_assistant/bots/discord/events.rb

Instance Method Summary collapse

Instance Method Details

#ask_eventObject



72
73
74
75
76
77
78
79
80
81
# File 'lib/chatgpt_assistant/bots/discord/events.rb', line 72

def ask_event
  bot.command :ask do |event|
    @evnt = event
    @message = event.message.content.split[1..].join(" ")
    event.respond error_messages[:user_not_logged_in] if user.nil?
    event.respond error_messages[:account_not_verified] if user && !user.active?
    ask_action if user&.active?
    "OK"
  end
end

#help_eventObject



43
44
45
46
47
48
49
# File 'lib/chatgpt_assistant/bots/discord/events.rb', line 43

def help_event
  bot.command :help do |event|
    @evnt = event
    help_action
    "OK"
  end
end

#hist_eventObject



33
34
35
36
37
38
39
40
41
# File 'lib/chatgpt_assistant/bots/discord/events.rb', line 33

def hist_event
  bot.command :hist do |event|
    @evnt = event
    @chat = user.current_chat
    event.respond error_messages[:chat_not_found] if chat.nil? && user
    hist_action if user && chat
    "OK"
  end
end

#list_eventObject



25
26
27
28
29
30
31
# File 'lib/chatgpt_assistant/bots/discord/events.rb', line 25

def list_event
  bot.command :list do |event|
    @evnt = event
    list_action if valid_for_list_action?
    "OK"
  end
end

#login_eventObject



16
17
18
19
20
21
22
23
# File 'lib/chatgpt_assistant/bots/discord/events.rb', line 16

def 
  bot.command :login do |event|
    @message = event.message.content.split[1]
    @evnt = event
    message.nil? ? event.respond(common_messages[:login]) : 
    "OK"
  end
end

#new_chat_eventObject



51
52
53
54
55
56
57
58
59
# File 'lib/chatgpt_assistant/bots/discord/events.rb', line 51

def new_chat_event
  bot.command :new_chat do |event|
    @evnt = event
    event.respond error_messages[:user_not_logged_in] if user.nil?
    event.respond error_messages[:account_not_verified] if user && !user.active?
    create_chat_action if user&.active?
    "OK"
  end
end

#private_message_eventObject



123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/chatgpt_assistant/bots/discord/events.rb', line 123

def private_message_event
  bot.message do |event|
    @evnt = event
    @visitor = discord_visited?(@evnt.user.id)
    next if discord_next_action?

    @message = event.message.content
    @chat = user.current_chat if user
    private_message_action if user && !chat.nil?
    "OK"
  end
end

#sl_chat_eventObject



61
62
63
64
65
66
67
68
69
70
# File 'lib/chatgpt_assistant/bots/discord/events.rb', line 61

def sl_chat_event
  bot.command :sl_chat do |event|
    @evnt = event
    chat_to_select = event.message.content.split[1..].join(" ")
    event.respond error_messages[:user_not_logged_in] if user.nil?
    event.respond error_messages[:account_not_verified] if user && !user.active?
    sl_chat_action(chat_to_select) if user&.active?
    "OK"
  end
end

#speak_eventObject



111
112
113
114
115
116
117
118
119
120
121
# File 'lib/chatgpt_assistant/bots/discord/events.rb', line 111

def speak_event
  bot.command :speak do |event|
    @evnt = event
    @message = event.message.content.split[1..].join(" ")
    @chat = user.current_chat
    speak_connect_checker_action
    speak_connection_checker_action
    ask_to_speak_action if user && event.user.voice_channel && event.voice && !chat.nil?
    "OK"
  end
end

#start_eventObject



7
8
9
10
11
12
13
14
# File 'lib/chatgpt_assistant/bots/discord/events.rb', line 7

def start_event
  bot.command :start do |event|
    @evnt = event
    @user = event.user
    start_action
    "Ok"
  end
end

#voice_connect_eventObject



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/chatgpt_assistant/bots/discord/events.rb', line 83

def voice_connect_event
  bot.command :connect do |event|
    @evnt = event
    if user && !user.active?
      event.respond error_messages[:account_not_verified]
    elsif user&.current_chat_id.nil?
      event.respond error_messages[:no_chat_selected]
    elsif user&.current_chat_id
      @chat = Chat.find(user.current_chat_id)
      voice_connect_checker_action
      voice_connection_checker_action
      bot.voice_connect(event.user.voice_channel)
    else
      event.respond error_messages[:user_not_logged_in]
    end
    "OK"
  end
end

#voice_disconnect_eventObject



102
103
104
105
106
107
108
109
# File 'lib/chatgpt_assistant/bots/discord/events.rb', line 102

def voice_disconnect_event
  bot.command :disconnect do |event|
    @evnt = event
    disconnect_checker_action
    disconnect_action if user && event.user.voice_channel && event.voice
    "OK"
  end
end