fix(chat): stop caching messages in DMs
This commit is contained in:
parent
c0d902dd85
commit
8f0e35ba79
15
bot.py
15
bot.py
@ -109,7 +109,15 @@ class Bot:
|
|||||||
if self.discord.user == message.author:
|
if self.discord.user == message.author:
|
||||||
# don't respond to ourselves
|
# don't respond to ourselves
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Do not respond with llm in private messages
|
||||||
|
if isinstance(message.channel, discord.DMChannel):
|
||||||
|
response = DiscordResponse(message)
|
||||||
|
if self.discord.user.mentioned_in(message):
|
||||||
|
await response.write(message, 'I am sorry, I am unable to respond in private messages.')
|
||||||
|
return
|
||||||
|
|
||||||
|
# Do not respond to messages that don't mention us
|
||||||
if not self.discord.user.mentioned_in(message) or message.author.bot or '@everyone' in message.content or '@here' in message.content:
|
if not self.discord.user.mentioned_in(message) or message.author.bot or '@everyone' in message.content or '@here' in message.content:
|
||||||
# don't respond to messages that don't mention us, but save it for context
|
# don't respond to messages that don't mention us, but save it for context
|
||||||
await self.save_message(str(message.channel.id), self.message(message, message.content), 'user')
|
await self.save_message(str(message.channel.id), self.message(message, message.content), 'user')
|
||||||
@ -119,16 +127,11 @@ class Bot:
|
|||||||
if (random.random() * 1000) > 0.1:
|
if (random.random() * 1000) > 0.1:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Clean message
|
||||||
content = message.content.replace(f'<@{self.discord.user.id}>', self.bot_name.title()).strip()
|
content = message.content.replace(f'<@{self.discord.user.id}>', self.bot_name.title()).strip()
|
||||||
if not content:
|
if not content:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Do not respond with llm in private messages
|
|
||||||
if isinstance(message.channel, discord.DMChannel):
|
|
||||||
response = DiscordResponse(message)
|
|
||||||
await response.write(message, 'I am sorry, I am unable to respond in private messages.')
|
|
||||||
return
|
|
||||||
|
|
||||||
# Admin commands
|
# Admin commands
|
||||||
if content == 'RESET' and str(message.author.id) == self.admin_id:
|
if content == 'RESET' and str(message.author.id) == self.admin_id:
|
||||||
await self.flush_channel(str(message.channel.id))
|
await self.flush_channel(str(message.channel.id))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user