diff --git a/fjerkroa_bot/ai_responder.py b/fjerkroa_bot/ai_responder.py index 1c28f25..f24dd6c 100644 --- a/fjerkroa_bot/ai_responder.py +++ b/fjerkroa_bot/ai_responder.py @@ -99,6 +99,8 @@ class AIResponder(object): if type(answer) != dict: answer = answer.to_dict() response = json.loads(answer['content']) + if 'hack' not in response or type(response.get('picture', None)) not in (type(None), str): + continue logging.info(f"got this answer:\n{pformat(response)}") except openai.error.InvalidRequestError as err: if 'maximum context length is' in str(err) and limit > 4: diff --git a/fjerkroa_bot/discord_bot.py b/fjerkroa_bot/discord_bot.py index fba2fcc..751136f 100644 --- a/fjerkroa_bot/discord_bot.py +++ b/fjerkroa_bot/discord_bot.py @@ -72,7 +72,11 @@ class FjerkroaBot(commands.Bot): message_content = str(message.content).strip() if len(message_content) < 1: return - msg = AIMessage(message.author.name, message_content, str(message.channel.name)) + if hasattr(message.channel, 'name'): + channel_name = str(message.channel.name) + else: + channel_name = str(message.channel.id) + msg = AIMessage(message.author.name, message_content, channel_name) await self.respond(msg, message.channel) async def respond(self, message: AIMessage, channel: TextChannel) -> None: