-
Notifications
You must be signed in to change notification settings - Fork 0
/
send.py
33 lines (28 loc) · 945 Bytes
/
send.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
29
30
31
32
33
from twx.botapi import TelegramBot
import cfg
token = cfg.readcfg('config.yml')['token']
channel = cfg.readcfg('config.yml')['channel']
bot = TelegramBot(token)
bot.update_bot_info()
def sendtextonly(message):
try:
bot.send_message(channel, message, disable_web_page_preview=True)
except Exception:
sendtextonly(message)
def sendtextandphoto(photourl, message):
try:
bot.send_photo(channel, photourl).wait()
bot.send_message(channel, message, disable_web_page_preview=True)
except Exception:
sendtextandphoto(photourl, message)
def sendtextandvideo(message):
try:
bot.send_message(channel, message, parse_mode='HTML')
except Exception:
sendtextandvideo(message)
def sendtextandgif(gifurl, message):
try:
bot.send_video(channel, gifurl).wait()
bot.send_message(channel, message)
except Exception:
sendtextandgif(gifurl, message)