Commit c1b70cc1 authored by porramet's avatar porramet

fix remove unexpected error for missing src.config

parent c2146014
......@@ -61,3 +61,12 @@ class NotificationCenter:
raise ValueError(f"Unsupported method: {method}")
self._sender.send_notification(params["params"],raise_error)
def send_telegram_text_notification(self,text:str,raise_error:Optional[bool]=False):
params : NotificationMessageParams = {
"method" : "telegram",
"params" : {"text":text}
}
self.send_notification(params,text,raise_error=False)
\ No newline at end of file
......@@ -49,18 +49,18 @@ class Gmail(NotificationStrategy):
if __name__ == '__main__':
import src.config as _config
params = {
"to" : ["poramet.tan@nectec.or.th"],
"subject" : "Test Notification",
"body" : f"""
Hello World
""",
"cc" : ["poramet.tan@nectec.or.th"]
}
gmail = Gmail(_config.DEFAULT_SMTP_SERVER,_config.DEFAULT_SMTP_PORT)
gmail.set_sender(_config.DEFAULT_GMAIL_APP_EMAIL,_config.DEFAULT_GMAIL_APP_PASS)
gmail.send(params)
\ No newline at end of file
# if __name__ == '__main__':
# import src.config as _config
# params = {
# "to" : ["poramet.tan@nectec.or.th"],
# "subject" : "Test Notification",
# "body" : f"""
# Hello World
# """,
# "cc" : ["poramet.tan@nectec.or.th"]
# }
# gmail = Gmail(_config.DEFAULT_SMTP_SERVER,_config.DEFAULT_SMTP_PORT)
# gmail.set_sender(_config.DEFAULT_GMAIL_APP_EMAIL,_config.DEFAULT_GMAIL_APP_PASS)
# gmail.send(params)
\ No newline at end of file
......@@ -28,12 +28,12 @@ class Telegram(NotificationStrategy):
requests.get(url,params=request_params)
if __name__ == '__main__':
import src.config as _config
params = {
"text" :f"""
Hello World
""",
}
tg = Telegram(_config.TG_BOT_TOKEN,_config.TG_CHAT_ID)
tg.send(params)
\ No newline at end of file
# if __name__ == '__main__':
# import src.config as _config
# params = {
# "text" :f"""
# Hello World
# """,
# }
# tg = Telegram(_config.TG_BOT_TOKEN,_config.TG_CHAT_ID)
# tg.send(params)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment