-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonitor.py
41 lines (32 loc) · 1.39 KB
/
monitor.py
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
37
38
39
40
41
import os
import time
from datetime import datetime, timezone
from telegram.ext import CallbackContext
import constants
latest_message_time = datetime.now(timezone.utc)
messages_received = 0
commands_processed = 0
successful_compilations = 0
inline_queries = 0
user_ids = set()
def get_monitor(bot_username):
return constants.MONITOR.format(f"{constants.VERSION_NUMBER}-{constants.COMMIT_HASH}",
bot_username,
constants.LILY_VERSION,
constants.START_TIME.strftime("%d/%m/%Y %H:%M:%S UTC"),
latest_message_time.strftime("%d/%m/%Y %H:%M:%S UTC"),
len(user_ids),
messages_received,
inline_queries,
commands_processed,
successful_compilations)
# not used anymore
def program_monitor(context: CallbackContext):
os.system('cls' if os.name == 'nt' else 'clear') or None
print(get_monitor(context.bot.username))
def cleanup(context: CallbackContext):
now = time.time()
for file in os.listdir(constants.USER_FILES_DIR):
file = os.path.join(constants.USER_FILES_DIR, file)
if os.path.isfile(file) and os.stat(file).st_mtime < now - 3600:
os.remove(file)