-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuntil_date.py
More file actions
36 lines (28 loc) · 1.07 KB
/
until_date.py
File metadata and controls
36 lines (28 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# requires apscheduler
import datetime
import logging
from apscheduler.schedulers.asyncio import AsyncIOScheduler
from .. import loader, utils
logger = logging.getLogger(__name__)
@loader.tds
class UntilDateMod(loader.Module):
"""Tells you how much time left before an event\nMade with love by @Art3sius"""
strings = {
'name': 'UntilDate'
}
async def client_ready(self, client, db):
self.client = client
scheduler = AsyncIOScheduler()
scheduler.add_job(self.checks, 'interval', seconds=10)
scheduler.start()
async def checks(self):
now = datetime.datetime.now()
target = datetime.datetime(2021, 8, 31, 12, 30)
res = target - now
if res.days < 0 or res.seconds < 0:
return
res_string = f'{str(res.days * 24 + res.seconds // 3600)}:{str(res.seconds % 3600 // 60)}:{str(res.seconds % 60)}'
try:
await self.client.edit_message(1588152056, 33404, '<i>До апокаліпсису лишилось: ' + res_string + '</i>')
except:
pass