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