-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
28 lines (21 loc) · 847 Bytes
/
bot.py
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
27
28
import requests
from config import API_TOKEN
CHANNEL_ID = -1001609474777
BASE_URL = f"https://api.telegram.org/bot{API_TOKEN}"
def send_message(text):
url = f"{BASE_URL}/sendMessage"
payload = {"chat_id": CHANNEL_ID, "text": text,
"parse_mode": "MarkdownV2", "disable_web_page_preview": True}
response = requests.post(url, data=payload)
return response.json()
def send_message_plain(text):
url = f"{BASE_URL}/sendMessage"
payload = {"chat_id": CHANNEL_ID, "text": text,
"disable_web_page_preview": True}
response = requests.post(url, data=payload)
return response.json()
def pin_message(message_id):
url = f"{BASE_URL}/pinChatMessage"
payload = {"chat_id": CHANNEL_ID, "message_id": message_id}
response = requests.post(url, data=payload)
return response.json()