Improve hack handling.

This commit is contained in:
OK 2023-03-22 21:52:27 +01:00
parent c85153c490
commit 8f2f18b73b
2 changed files with 5 additions and 4 deletions

View File

@ -40,7 +40,7 @@ class AIResponder(object):
def _message(self, message: AIMessage, limit: Optional[int] = None) -> List[Dict[str, Any]]:
messages = []
system = self.config["system"].replace('{date}', time.strftime('%Y-%m-%d'))\
.replace('{time}', time.strftime('%H-%M-%S'))
.replace('{time}', time.strftime('%H:%M:%S'))
messages.append({"role": "system", "content": system})
if limit is None:
history = self.history[:]

View File

@ -71,14 +71,15 @@ class FjerkroaBot(commands.Bot):
logging.info(f"handle message {str(message)} for channel {channel.name}")
async with channel.typing():
response = await self.airesponder.send(message)
if response.hack:
logging.warning(f"User {message.user} tried to hack the system.")
if response.staff is None:
response.staff = f"User {message.user} try to hack the AI."
if response.staff is not None and self.staff_channel is not None:
async with self.staff_channel.typing():
await self.staff_channel.send(response.staff)
if not response.answer_needed:
return
if response.hack:
logging.warning(f"User {message.user} tried to hack the system.")
return
if response.picture is not None:
images = [discord.File(fp=await self.airesponder.draw(response.picture), filename="image.png")]
await channel.send(response.answer, files=images)