feat(bot): ✨ Show notification when users are calling of shutdown when p.shutdown has been ran.

This commit is contained in:
Nyeki.py
2024-10-24 00:30:32 -03:00
parent b5872df034
commit b3184fafdf
+51 -12
View File
@@ -76,7 +76,9 @@ class Calls(base.Cog):
if len(hung_up_channel_ids) > 0:
await models.Channel.filter(id__in=hung_up_channel_ids).update(call_id=None)
await self.bot.redis.srem(constants.CHANNELS_ONCALL_SET, *hung_up_channel_ids)
await self.bot.redis.srem(
constants.CHANNELS_ONCALL_SET, *hung_up_channel_ids
)
@commands.command(aliases=["c"])
@commands.guild_only()
@@ -153,7 +155,9 @@ class Calls(base.Cog):
if last_calls_rss_channels_map[call_rs.call_id] != call_rs.channel_id:
last_calls_other_channels_ids.add(call_rs.channel_id)
other_channel_id: int = await self.bot.redis.spop(constants.CHANNELS_SEARCH_QUEUE)
other_channel_id: int = await self.bot.redis.spop(
constants.CHANNELS_SEARCH_QUEUE
)
i = 0
while True:
@@ -171,9 +175,13 @@ class Calls(base.Cog):
i += 1
if other_channel_id in last_calls_other_channels_ids:
await self.bot.redis.sadd(constants.CHANNELS_SEARCH_QUEUE, str(other_channel_id))
await self.bot.redis.sadd(
constants.CHANNELS_SEARCH_QUEUE, str(other_channel_id)
)
other_channel_id = await self.bot.redis.spop(constants.CHANNELS_SEARCH_QUEUE)
other_channel_id = await self.bot.redis.spop(
constants.CHANNELS_SEARCH_QUEUE
)
if other_channel_id is None:
break
@@ -219,7 +227,9 @@ class Calls(base.Cog):
str(channel_id),
str(other_channel_id),
)
await self.bot.redis.sadd(constants.CHANNELS_SEARCH_QUEUE, str(channel_id))
await self.bot.redis.sadd(
constants.CHANNELS_SEARCH_QUEUE, str(channel_id)
)
msg_phone_answered = ""
await ctx.send(
@@ -227,6 +237,11 @@ class Calls(base.Cog):
f"**TIP**: {secrets.choice(constants.TIPS).replace("{prefix}", ctx.clean_prefix)}\n"
f"☎️ {secrets.choice(constants.MSGS_PHONE_CALLING)}\n"
)
+ (
"⚡ The phone will be hung up soon due to a scheduled restart.\n"
if self.bot.shutdown.value
else ""
)
+ msg_phone_answered
)
@@ -238,6 +253,11 @@ class Calls(base.Cog):
f"**TIP**: {secrets.choice(constants.TIPS).replace("{prefix}", ctx.clean_prefix)}\n"
f"☎️ {secrets.choice(constants.MSGS_PHONE_CALLING)}\n"
)
+ (
"⚡ The phone will be hung up soon due to a scheduled restart.\n"
if self.bot.shutdown.value
else ""
)
)
@commands.command(aliases=["s"])
@@ -334,7 +354,9 @@ class Calls(base.Cog):
if last_calls_rss_channels_map[call_rs.call_id] != call_rs.channel_id:
last_calls_other_channels_ids.add(call_rs.channel_id)
other_channel_id: int = await self.bot.redis.spop(constants.CHANNELS_SEARCH_QUEUE)
other_channel_id: int = await self.bot.redis.spop(
constants.CHANNELS_SEARCH_QUEUE
)
i = 0
while True:
@@ -352,9 +374,13 @@ class Calls(base.Cog):
i += 1
if other_channel_id in last_calls_other_channels_ids:
await self.bot.redis.sadd(constants.CHANNELS_SEARCH_QUEUE, str(other_channel_id))
await self.bot.redis.sadd(
constants.CHANNELS_SEARCH_QUEUE, str(other_channel_id)
)
other_channel_id = await self.bot.redis.spop(constants.CHANNELS_SEARCH_QUEUE)
other_channel_id = await self.bot.redis.spop(
constants.CHANNELS_SEARCH_QUEUE
)
if other_channel_id is None:
break
@@ -398,7 +424,9 @@ class Calls(base.Cog):
str(channel_id),
str(other_channel_id),
)
await self.bot.redis.sadd(constants.CHANNELS_SEARCH_QUEUE, str(channel_id))
await self.bot.redis.sadd(
constants.CHANNELS_SEARCH_QUEUE, str(channel_id)
)
msg_phone_answered = ""
await ctx.send(
@@ -406,6 +434,11 @@ class Calls(base.Cog):
f"**TIP**: {secrets.choice(constants.TIPS).replace("{prefix}", ctx.clean_prefix)}\n"
f"☎️ You skipped the call.\n"
)
+ (
"⚡ The phone will be hung up soon due to a scheduled restart.\n"
if self.bot.shutdown.value
else ""
)
+ (
msg_phone_answered
if msg_phone_answered
@@ -425,6 +458,11 @@ class Calls(base.Cog):
f"☎️ You skipped the call.\n"
f"☎️ {secrets.choice(constants.MSGS_PHONE_CALLING)}\n"
)
+ (
"⚡ The phone will be hung up soon due to a scheduled restart.\n"
if self.bot.shutdown.value
else ""
)
)
@commands.command(aliases=["hang", "h"], extras={"help_name": "Hang Up"})
@@ -752,8 +790,7 @@ class Calls(base.Cog):
if message.reference:
embed, replying_message = await embeds.ReplyEmbed(
self.bot.redis,
message.reference, call_id=call.id
self.bot.redis, message.reference, call_id=call.id
)
if replying_message is not None:
@@ -875,7 +912,9 @@ class Calls(base.Cog):
orjson.dumps(message_dict),
)
other_channel = await models.Channel.get_or_none(id=message.propagation_channel_id)
other_channel = await models.Channel.get_or_none(
id=message.propagation_channel_id
)
if other_channel is None:
return