about summary refs log tree commit diff
path: root/src/telegram_handler.py
diff options
context:
space:
mode:
authoruser <user@node5.net>2025-02-08 20:49:16 +0100
committeruser <user@node5.net>2025-02-08 20:49:16 +0100
commit14de1a23248086371671fa45f4057fcd5bdd3205 (patch)
tree23c99c2bb82f6f792a0077f46c3c696a76d5fa0f /src/telegram_handler.py
parent3b86282401dc213a143938cef9eed790e9f8c22d (diff)
Make DB & telegram optional
Diffstat (limited to 'src/telegram_handler.py')
-rw-r--r--src/telegram_handler.py28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/telegram_handler.py b/src/telegram_handler.py
index 0484e9b..6213445 100644
--- a/src/telegram_handler.py
+++ b/src/telegram_handler.py
@@ -4,24 +4,24 @@ import os
 import telegram
 import yaml
 
-with open(os.path.join('configs', 'telegram.yml'), 'r') as file:
-    config = yaml.safe_load(file.read())
 
-bot = telegram.Bot(config['token'])
+class Telegram:
+    def __init__(self, config: dict):
+        config: dict = config
+        bot = telegram.Bot(config['token'])
+        breakpoint()
+        asyncio.run(init_bot())
 
+    def send_message(self, text):
+        asyncio.run(async_send_message(text))
 
-def send_message(text):
-    asyncio.run(async_send_message(text))
 
+    async def async_send_message(self, text):
+        async with bot:
+            await bot.send_message(text=text, chat_id=config['chat_id'])
 
-async def async_send_message(text):
-    async with bot:
-        await bot.send_message(text=text, chat_id=config['chat_id'])
 
+    async def init_bot(self):
+        async with bot:
+            print(await bot.get_me())
 
-async def init_bot():
-    async with bot:
-        print(await bot.get_me())
-
-
-asyncio.run(init_bot())