diff --git a/fjerkroa_bot/discord_bot.py b/fjerkroa_bot/discord_bot.py index eeace01..1d56282 100644 --- a/fjerkroa_bot/discord_bot.py +++ b/fjerkroa_bot/discord_bot.py @@ -73,16 +73,17 @@ class FjerkroaBot(commands.Bot): boreness_interval = float(self.config.get('boreness-interval', 12.0)) elapsed_time = (time.monotonic() - self.last_activity_time) / 3600.0 probability = 1 / (1 + math.exp(-1 * (elapsed_time - (boreness_interval / 2.0)) + math.log(1 / 0.2 - 1))) - prev_messages = await self.chat_channel.history(limit=2).flatten() - last_author = prev_messages[1].author.id if len(prev_messages) > 1 else None - if random.random() < probability and last_author and last_author != self.user.id: - logging.info(f'Borred with {probability} probability after {elapsed_time}') - boreness_prompt = self.config.get('boreness-prompt', 'Pretend that you just now thought of something, be creative.') - message = AIMessage('system', boreness_prompt, self.config.get('chat-channel', 'chat'), True, False) - try: - await self.respond(message, self.chat_channel) - except Exception as err: - logging.warning(f"Failed to activate borringness: {repr(err)}") + if random.random() < probability: + prev_messages = [msg async for msg in self.chat_channel.history(limit=2)] + last_author = prev_messages[1].author.id if len(prev_messages) > 1 else None + if last_author and last_author != self.user.id: + logging.info(f'Borred with {probability} probability after {elapsed_time}') + boreness_prompt = self.config.get('boreness-prompt', 'Pretend that you just now thought of something, be creative.') + message = AIMessage('system', boreness_prompt, self.config.get('chat-channel', 'chat'), True, False) + try: + await self.respond(message, self.chat_channel) + except Exception as err: + logging.warning(f"Failed to activate borringness: {repr(err)}") await asyncio.sleep(7) async def on_ready(self): diff --git a/openai_chat.dat b/openai_chat.dat index 2eaab9c..23a6486 100644 Binary files a/openai_chat.dat and b/openai_chat.dat differ