lunarflu HF staff commited on
Commit
d711c84
1 Parent(s): f516149

if message.channel.id == 1162396480825462935:

Browse files
Files changed (1) hide show
  1. discord_bot/client/client.py +33 -28
discord_bot/client/client.py CHANGED
@@ -98,33 +98,38 @@ class DiscordClient(discord.Client):
98
 
99
 
100
  async def on_message(self, message):
101
- """
102
- Callback function to be called when a message is received.
103
-
104
- Args:
105
- message (discord.Message): The received message.
106
- """
107
- if message.author == self.user:
108
- return
109
- if self.enable_commands and message.content.startswith('!'):
110
- if message.content == '!clear':
111
- await message.channel.purge()
112
  return
113
-
114
- last_messages = await self.get_last_messages(message)
115
- context = '\n'.join(last_messages)
116
-
117
- logger.info('Received message: {0.content}'.format(message))
118
- response = self.qa_engine.get_response(
119
- question=message.content,
120
- messages_context=context
121
- )
122
- logger.info('Sending response: {0}'.format(response))
123
- try:
124
- await self.send_message(
125
- message,
126
- response.get_answer(),
127
- response.get_sources_as_text()
 
128
  )
129
- except Exception as e:
130
- logger.error('Failed to send response: {0}'.format(e))
 
 
 
 
 
 
 
 
98
 
99
 
100
  async def on_message(self, message):
101
+ if message.channel.id == 1162396480825462935:
102
+ """
103
+ Callback function to be called when a message is received.
104
+
105
+ Args:
106
+ message (discord.Message): The received message.
107
+ """
108
+ if message.author == self.user:
 
 
 
109
  return
110
+
111
+ """
112
+ if self.enable_commands and message.content.startswith('!'):
113
+ if message.content == '!clear':
114
+ await message.channel.purge()
115
+ return
116
+ """
117
+
118
+
119
+ last_messages = await self.get_last_messages(message)
120
+ context = '\n'.join(last_messages)
121
+
122
+ logger.info('Received message: {0.content}'.format(message))
123
+ response = self.qa_engine.get_response(
124
+ question=message.content,
125
+ messages_context=context
126
  )
127
+ logger.info('Sending response: {0}'.format(response))
128
+ try:
129
+ await self.send_message(
130
+ message,
131
+ response.get_answer(),
132
+ response.get_sources_as_text()
133
+ )
134
+ except Exception as e:
135
+ logger.error('Failed to send response: {0}'.format(e))