change: Decoupling of notification module

This commit is contained in:
EstrellaXD
2023-05-31 19:31:02 +08:00
parent 294bd966b5
commit e36d66f9fe
8 changed files with 72 additions and 48 deletions

View File

@@ -1,7 +1,12 @@
import logging
from module.network.request_contents import RequestContent
logger = logging.getLogger(__name__)
class TelegramNotification(RequestContent):
def __init__(self):
def __init__(self, token, chat_id):
super().__init__()
self.notification_url = f"https://api.telegram.org/bot{token}/sendMessage"
self.chat_id = chat_id
@@ -14,4 +19,4 @@ class TelegramNotification(RequestContent):
}
resp = self.post_data(self.notification_url, data)
logger.debug(f"Telegram notification: {resp.status_code}")
return resp.status_code == 200
return resp.status_code == 200