Skip to content

Commit 2f16e31

Browse files
committed
Ensure that solved or locked help threads are never auto-deleted in 'helpforums_pre' extension
1 parent 57a3926 commit 2f16e31

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

pcbot/exts/anti_crosspost.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,14 @@ async def on_message(self, message: discord.Message):
261261
f"Found crosspost for user {message.author.name}, message URL {message.jump_url}!!!!!!!!!!"
262262
)
263263
alert_channel = cast(MessageableGuildChannel, message.channel)
264-
if self.exclude_alert_channel_ids and not await self._check_channel(
265-
alert_channel, deny=self.exclude_alert_channel_ids
264+
if (
265+
self.exclude_alert_channel_ids
266+
and not await self._check_channel(
267+
alert_channel, deny=self.exclude_alert_channel_ids
268+
)
266269
):
267270
# Attempt to find the next best channel to alert in
268-
print( [ msg.content for msg in messages[:-1] ])
271+
print([msg.content for msg in messages[:-1]])
269272
for message in reversed(messages[:-1]):
270273
alert_channel = cast(
271274
MessageableGuildChannel, message.channel
@@ -279,7 +282,7 @@ async def on_message(self, message: discord.Message):
279282
f"No allowed alerting channel for user {message.author.name} found"
280283
)
281284
break # Don't issue an alert if not possible
282-
285+
283286
if message.id in user_cache["message_to_alert_map"]:
284287
logger.debug(
285288
f"Message {message.id} is already being alerted for user {message.author.name}"

pcbot/exts/helpforums_pre/cogs.py

+16-2
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,16 @@ async def on_raw_member_remove(self, payload: discord.RawMemberRemoveEvent):
761761
forum_channel.threads,
762762
[thr async for thr in forum_channel.archived_threads(limit=20)],
763763
):
764-
if help_thread.owner_id == payload.user.id:
764+
if (
765+
help_thread.owner_id == payload.user.id
766+
and not (
767+
help_thread.locked
768+
or any(
769+
tag.name.lower() in ("solved", "invalid")
770+
for tag in help_thread.applied_tags
771+
)
772+
)
773+
):
765774
snakecore.utils.hold_task(
766775
asyncio.create_task(
767776
self.help_thread_deletion_below_size_threshold(
@@ -800,7 +809,12 @@ async def on_raw_message_delete(self, payload: discord.RawMessageDeleteEvent):
800809
):
801810
return
802811

803-
if not thread.locked:
812+
if not (
813+
thread.locked
814+
or any(
815+
tag.name.lower() in ("solved", "invalid") for tag in thread.applied_tags
816+
)
817+
):
804818
await self.help_thread_deletion_below_size_threshold(
805819
thread,
806820
300,

0 commit comments

Comments
 (0)