-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlogger.py
More file actions
31 lines (23 loc) · 835 Bytes
/
Copy pathlogger.py
File metadata and controls
31 lines (23 loc) · 835 Bytes
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
import traceback
import requests
import utils
class TgLogger:
def __init__(self, bot_token: str, chat_id: str):
self._bot_token = bot_token
self._chat_id = chat_id
self._session = requests.Session()
def close(self):
self._session.close()
def send_tg(self, msg: str):
try:
utils.send_tg(self._session, self._bot_token, self._chat_id, msg, send_async=True)
except Exception:
traceback.print_exc()
pass
def send_tg_doc(self, caption: str, filename: str):
try:
with open(filename, "rb") as file:
file_content = file.read()
utils.send_document(self._session, self._bot_token, self._chat_id, file_content, filename, caption)
except Exception:
traceback.print_exc()