Improve hack handling.
This commit is contained in:
parent
c85153c490
commit
8f2f18b73b
@ -40,7 +40,7 @@ class AIResponder(object):
|
|||||||
def _message(self, message: AIMessage, limit: Optional[int] = None) -> List[Dict[str, Any]]:
|
def _message(self, message: AIMessage, limit: Optional[int] = None) -> List[Dict[str, Any]]:
|
||||||
messages = []
|
messages = []
|
||||||
system = self.config["system"].replace('{date}', time.strftime('%Y-%m-%d'))\
|
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})
|
messages.append({"role": "system", "content": system})
|
||||||
if limit is None:
|
if limit is None:
|
||||||
history = self.history[:]
|
history = self.history[:]
|
||||||
|
|||||||
@ -71,14 +71,15 @@ class FjerkroaBot(commands.Bot):
|
|||||||
logging.info(f"handle message {str(message)} for channel {channel.name}")
|
logging.info(f"handle message {str(message)} for channel {channel.name}")
|
||||||
async with channel.typing():
|
async with channel.typing():
|
||||||
response = await self.airesponder.send(message)
|
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:
|
if response.staff is not None and self.staff_channel is not None:
|
||||||
async with self.staff_channel.typing():
|
async with self.staff_channel.typing():
|
||||||
await self.staff_channel.send(response.staff)
|
await self.staff_channel.send(response.staff)
|
||||||
if not response.answer_needed:
|
if not response.answer_needed:
|
||||||
return
|
return
|
||||||
if response.hack:
|
|
||||||
logging.warning(f"User {message.user} tried to hack the system.")
|
|
||||||
return
|
|
||||||
if response.picture is not None:
|
if response.picture is not None:
|
||||||
images = [discord.File(fp=await self.airesponder.draw(response.picture), filename="image.png")]
|
images = [discord.File(fp=await self.airesponder.draw(response.picture), filename="image.png")]
|
||||||
await channel.send(response.answer, files=images)
|
await channel.send(response.answer, files=images)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user