Commit c1b70cc1 authored by porramet's avatar porramet

fix remove unexpected error for missing src.config

parent c2146014
...@@ -61,3 +61,12 @@ class NotificationCenter: ...@@ -61,3 +61,12 @@ class NotificationCenter:
raise ValueError(f"Unsupported method: {method}") raise ValueError(f"Unsupported method: {method}")
self._sender.send_notification(params["params"],raise_error) 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): ...@@ -49,18 +49,18 @@ class Gmail(NotificationStrategy):
if __name__ == '__main__': # if __name__ == '__main__':
import src.config as _config # import src.config as _config
params = { # params = {
"to" : ["poramet.tan@nectec.or.th"], # "to" : ["poramet.tan@nectec.or.th"],
"subject" : "Test Notification", # "subject" : "Test Notification",
"body" : f""" # "body" : f"""
Hello World # Hello World
""", # """,
"cc" : ["poramet.tan@nectec.or.th"] # "cc" : ["poramet.tan@nectec.or.th"]
} # }
gmail = Gmail(_config.DEFAULT_SMTP_SERVER,_config.DEFAULT_SMTP_PORT) # gmail = Gmail(_config.DEFAULT_SMTP_SERVER,_config.DEFAULT_SMTP_PORT)
gmail.set_sender(_config.DEFAULT_GMAIL_APP_EMAIL,_config.DEFAULT_GMAIL_APP_PASS) # gmail.set_sender(_config.DEFAULT_GMAIL_APP_EMAIL,_config.DEFAULT_GMAIL_APP_PASS)
gmail.send(params) # gmail.send(params)
\ No newline at end of file \ No newline at end of file
...@@ -28,12 +28,12 @@ class Telegram(NotificationStrategy): ...@@ -28,12 +28,12 @@ class Telegram(NotificationStrategy):
requests.get(url,params=request_params) requests.get(url,params=request_params)
if __name__ == '__main__': # if __name__ == '__main__':
import src.config as _config # import src.config as _config
params = { # params = {
"text" :f""" # "text" :f"""
Hello World # Hello World
""", # """,
} # }
tg = Telegram(_config.TG_BOT_TOKEN,_config.TG_CHAT_ID) # tg = Telegram(_config.TG_BOT_TOKEN,_config.TG_CHAT_ID)
tg.send(params) # tg.send(params)
\ No newline at end of file \ 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