Tsitsi19 commited on
Commit
27ec034
·
verified ·
1 Parent(s): 171c797

Create telegram_bot.py

Browse files
Files changed (1) hide show
  1. telegram_bot.py +15 -0
telegram_bot.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import requests
3
+ from command_router import process_command
4
+
5
+ BOT = os.getenv("BOT_TELEGRAM")
6
+ CHANNEL = os.getenv("CHANNEL_TELEGRAM")
7
+
8
+ def send(msg):
9
+ url = f"https://api.telegram.org/bot{BOT}/sendMessage"
10
+ data = {"chat_id": CHANNEL, "text": msg}
11
+ requests.post(url, data=data)
12
+
13
+ def handle_update(message):
14
+ reply = process_command(message)
15
+ send(reply)