add task to reload subscriptions every 24h

This commit is contained in:
un1xx committed 2025-08-27 21:35:35 +05:30
1 parent 4137b8bd36
commit 252c97f5b2
2 files changed
+35 -24

No files matched your search

+9 -8
View File
@@ -7,6 +7,7 @@ from typing import List, Literal, Optional
import discord
from discord.ext import commands, tasks
from discord.guild import GuildChannel
import pnwkit
import pytz
from pnwkit import Order, OrderBy
@@ -33,7 +34,7 @@ class Misc(commands.Cog):
def cog_unload(self):
self.send_daily_message.cancel()
@commands.command(name="sex")
async def sex(self, ctx: CustomCtx):
"""
@@ -74,13 +75,13 @@ class Misc(commands.Cog):
color=0x2F3136,
)
await ctx.send(embed=embed)
@commands.command(name="alliance")
async def alliance(self, ctx: CustomCtx, id: Optional[int] = 10177):
try:
result = await self.kit.query(
"nations",
{"alliance_id": id,
{"alliance_id": id,
"orderBy": OrderBy("cities", Order.DESC),
"first": 300
},
@@ -111,9 +112,9 @@ class Misc(commands.Cog):
await ctx.send(
"> nations not olive:\n" + "\n".join([f"[{n.nation_name}](<https://politicsandwar.com/nation/id={n.id}>) [{n.leader_name}]" for n in nations])
)
def seconds_until_target(self, hour: int, minute: int = 0):
now = datetime.datetime.utcnow()
now = datetime.datetime.now()
target = now.replace(hour=hour, minute=minute, second=0, microsecond=0)
if target < now:
target += datetime.timedelta(days=1)
@@ -135,15 +136,15 @@ class Misc(commands.Cog):
for nation in res.nations:
if nation.vacation_mode_turns != 0:
continue
utcnow = datetime.datetime.utcnow().replace(tzinfo=pytz.utc)
utcnow = datetime.datetime.now().replace(tzinfo=pytz.utc)
delta = utcnow - nation.last_active
if delta > datetime.timedelta(days=4, hours=12):
if delta > datetime.timedelta(days=3, hours=12):
inactives.append(nation)
if inactives:
await channel.send(
"> Inactive nations:\n" + "\n".join([f"[{n.nation_name}](<https://politicsandwar.com/nation/id={n.id}>) [{n.leader_name}] {format_dt(n.last_active)}" for n in inactives])
)
@send_daily_message.before_loop
async def before_send_daily_message(self):