Small fixes.
This commit is contained in:
parent
95e810db7a
commit
7007a0bfd5
@ -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:
|
||||
|
||||
@ -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:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user