Add support of short path messages, which are not send to the AI but just added to the history.
This commit is contained in:
@@ -74,6 +74,28 @@ class TestFunctionality(TestBotBase):
|
||||
await self.bot.on_message(message)
|
||||
message.channel.send.assert_called_once_with("Hello!", suppress_embeds=True)
|
||||
|
||||
async def test_on_message_stort_path(self) -> None:
|
||||
async def acreate(*a, **kw):
|
||||
answer = {'answer': 'Hello!',
|
||||
'answer_needed': True,
|
||||
'staff': None,
|
||||
'picture': None,
|
||||
'hack': False}
|
||||
return {'choices': [{'message': {'content': json.dumps(answer)}}]}
|
||||
message = self.create_message("Hello there! How are you?")
|
||||
message.author.name = 'madeup_name'
|
||||
message.channel.name = 'some_channel'
|
||||
self.bot.config['short-path'] = [[r'some.*', r'madeup.*']]
|
||||
with patch.object(openai.ChatCompletion, 'acreate', new=acreate):
|
||||
await self.bot.on_message(message)
|
||||
self.assertEqual(self.bot.airesponder.history[-1]["content"],
|
||||
'{"user": "madeup_name", "message": "Hello, how are you?", "channel": "some_channel"}')
|
||||
message.author.name = 'different_name'
|
||||
await self.bot.on_message(message)
|
||||
self.assertEqual(self.bot.airesponder.history[-2]["content"],
|
||||
'{"user": "different_name", "message": "Hello, how are you?", "channel": "some_channel"}')
|
||||
message.channel.send.assert_called_once_with("Hello!", suppress_embeds=True)
|
||||
|
||||
async def test_on_message_event2(self) -> None:
|
||||
async def acreate(*a, **kw):
|
||||
answer = {'answer': 'Hello!',
|
||||
|
||||
Reference in New Issue
Block a user