-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.py
More file actions
19 lines (14 loc) · 710 Bytes
/
common.py
File metadata and controls
19 lines (14 loc) · 710 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import requests
from config.config import *
def send_message(msg):
return requests.get(f'{BASE}{TOKEN}{SEND_MSG_API}?chat_id={CHAN_ID}&text={msg}').json()
def send_message_formatted(msg):
return requests.get(f'{BASE}{TOKEN}{SEND_MSG_API}?chat_id={CHAN_ID}&text={msg}&parse_mode=MarkdownV2').json()
def reply_message(id, msg):
return requests.get(f'{BASE}{TOKEN}{SEND_MSG_API}?chat_id={CHAN_ID}&text={msg}&reply_to_message_id={id}&parse_mode=MarkdownV2').json()
def send_photo(img_url):
return requests.get(f'{BASE}{TOKEN}{SEND_PHOTO_API}?chat_id={CHAN_ID}&photo={img_url}').json()
def escape(msg):
for symbol in MD_ESCAPES:
msg = msg.replace(symbol, "\\"+symbol)
return msg