Change wait until after first process
This commit is contained in:
parent
db01059fcf
commit
07975106ef
4 changed files with 12 additions and 6 deletions
|
@ -17,7 +17,6 @@ async def unban(bot: Snake, logger: Logger) -> None:
|
|||
logger: Global logger
|
||||
"""
|
||||
while True:
|
||||
await asyncio.sleep(600)
|
||||
max_time = datetime.utcnow() + timedelta(minutes=10)
|
||||
bans = Ban.find(q(type="temp", active=True))
|
||||
async for ban in bans:
|
||||
|
@ -39,3 +38,6 @@ async def unban(bot: Snake, logger: Logger) -> None:
|
|||
reason="Ban expired",
|
||||
)
|
||||
await u.commit()
|
||||
|
||||
# Check ever 10 minutes
|
||||
await asyncio.sleep(600)
|
||||
|
|
|
@ -18,7 +18,6 @@ async def remind(bot: Snake, logger: Logger) -> None:
|
|||
logger: Global logger
|
||||
"""
|
||||
while True:
|
||||
await asyncio.sleep(5)
|
||||
reminders = Reminder.find(
|
||||
q(remind_at__lte=datetime.utcnow() + timedelta(seconds=5), active=True)
|
||||
)
|
||||
|
@ -69,3 +68,6 @@ async def remind(bot: Snake, logger: Logger) -> None:
|
|||
else:
|
||||
logger.warning("No way to contact user, deleting reminder")
|
||||
await reminder.delete()
|
||||
|
||||
# Check every 5 seconds
|
||||
await asyncio.sleep(5)
|
||||
|
|
|
@ -24,9 +24,6 @@ async def twitter(bot: Snake, logger: Logger) -> None:
|
|||
auth = tweepy.AppAuthHandler(config.twitter["consumer_key"], config.twitter["consumer_secret"])
|
||||
api = tweepy.API(auth)
|
||||
while True:
|
||||
# Only check once a minute
|
||||
await asyncio.sleep(60)
|
||||
|
||||
accounts = TwitterAccount.find()
|
||||
accounts_to_delete = []
|
||||
|
||||
|
@ -85,3 +82,6 @@ async def twitter(bot: Snake, logger: Logger) -> None:
|
|||
for account in accounts_to_delete:
|
||||
logger.info(f"Account {account.handle} has no followers, removing")
|
||||
await account.delete()
|
||||
|
||||
# Only check once a minute
|
||||
await asyncio.sleep(60)
|
||||
|
|
|
@ -17,10 +17,12 @@ async def unwarn(bot: Snake, logger: Logger) -> None:
|
|||
logger: Global logger
|
||||
"""
|
||||
while True:
|
||||
await asyncio.sleep(3600)
|
||||
warns = Warning.find(q(active=True))
|
||||
async for warn in warns:
|
||||
if warn.created_at + timedelta(hours=warn.duration) < datetime.utcnow():
|
||||
logger.debug(f"Deactivating warning {warn.id}")
|
||||
warn.update(q(active=False))
|
||||
await warn.commit()
|
||||
|
||||
# Check every hour
|
||||
await asyncio.sleep(3600)
|
||||
|
|
Loading…
Add table
Reference in a new issue