-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathtelegram.py
More file actions
26 lines (21 loc) · 726 Bytes
/
telegram.py
File metadata and controls
26 lines (21 loc) · 726 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import requests
from config import BOT_ID, TOKEN
def bot_token_acces(bot_id, token):
url = f"https://api.telegram.org/bot{bot_id}{token}/sendMessage"
return url
def send_message(user_id, text):
urls = bot_token_acces(BOT_ID, TOKEN)
payload = {
"chat_id": user_id,
"text": text,
"disable_web_page_preview": True,
"disable_notification": False,
"reply_to_message_id": None,
}
headers = {
"accept": "application/json",
"User-Agent": "Telegram Bot SDK - (https://github.com/irazasyed/telegram-bot-sdk)",
"content-type": "application/json",
}
response = requests.post(urls, json=payload, headers=headers)
return response.text