From 3382cc8a4320072c7995a3800aa75f5f19af3144 Mon Sep 17 00:00:00 2001 From: "Karina J. Kwiatek" Date: Wed, 28 Aug 2024 23:15:45 +0200 Subject: [PATCH 1/3] Change blog refresh interval to 3 minutes --- src/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constants.py b/src/constants.py index b619b1d..218d2a5 100644 --- a/src/constants.py +++ b/src/constants.py @@ -27,4 +27,4 @@ FEED_URL = "https://studentrobotics.org/feed.xml" FEED_CHANNEL_NAME = "blog" -FEED_CHECK_INTERVAL = 10 # seconds +FEED_CHECK_INTERVAL = 60 * 3 # in seconds From 5b85289587ebd8ea9a30588d4cd2eb3c536f4d42 Mon Sep 17 00:00:00 2001 From: "Karina J. Kwiatek" Date: Wed, 28 Aug 2024 23:16:05 +0200 Subject: [PATCH 2/3] Fix handling of deleted subscribed messages --- src/bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bot.py b/src/bot.py index 81ac552..e30cf09 100644 --- a/src/bot.py +++ b/src/bot.py @@ -288,5 +288,5 @@ async def update_subscribed_messages(self) -> None: continue msg = await msg_channel.fetch_message(sub_msg.message_id) await msg.edit(content=message) - except AttributeError: # message is no longer available + except discord.errors.NotFound: # message is no longer available await self.remove_subscribed_message(sub_msg) From 8b52d32fa5ac3f2a0606374d41fe2eaf6da7ab97 Mon Sep 17 00:00:00 2001 From: "Karina J. Kwiatek" Date: Wed, 28 Aug 2024 23:16:18 +0200 Subject: [PATCH 3/3] Log instead of using `print` --- src/bot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bot.py b/src/bot.py index e30cf09..e15bf1b 100644 --- a/src/bot.py +++ b/src/bot.py @@ -263,7 +263,7 @@ async def remove_subscribed_message(self, msg: SubscribedMessage) -> None: if message: # message may have already been deleted manually chan_name = message.channel.name if hasattr(message.channel, 'name') else 'unknown channel' - print(f'Removing message in {chan_name} from {message.author.name}') + self.logger.info(f'Removing message in {chan_name} from {message.author.name}') await message.delete() # remove message from discord # remove message from subscription list and save to file @@ -272,7 +272,7 @@ async def remove_subscribed_message(self, msg: SubscribedMessage) -> None: async def update_subscribed_messages(self) -> None: """Update all subscribed messages.""" - print('Updating subscribed messages') + self.logger.info('Updating subscribed messages') for sub_msg in self.subscribed_messages: # edit all subscribed messages message = self.stats_message( sub_msg.members,