pack to package

This commit is contained in:
Rykov7
2022-08-21 14:48:14 +03:00
parent eae8735797
commit d76da989c3
7 changed files with 41 additions and 37 deletions
+19
View File
@@ -0,0 +1,19 @@
import csv
from os.path import exists
import datetime as dt
def logging(message):
log_file_csv = f'logs/log_{dt.datetime.now().strftime("%Y-%m")}.csv'
if not exists(log_file_csv):
with open(log_file_csv, 'a') as f:
logs = csv.writer(f)
logs.writerow(['DATE AND TIME', 'ID', 'FIRST NAME', 'USERNAME',
'CHAT', 'LANG', 'PREMIUM', 'QUERY'])
with open(log_file_csv, 'a') as f:
logs = csv.writer(f)
logs.writerow(
[dt.datetime.now().strftime('%Y-%m-%d %H:%H'), message.from_user.id,
message.from_user.first_name, message.from_user.username,
message.chat.id, message.from_user.language_code, message.from_user.is_premium, message.text])