-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTelegramBot.py
More file actions
23 lines (17 loc) · 861 Bytes
/
TelegramBot.py
File metadata and controls
23 lines (17 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import telegram
class TelegramBot:
def __init__(self, token=None):
self._token = token
self._client = telegram.Bot(token=self._token)
def send_message(self, receipt, text):
self._client.send_message(chat_id=receipt, text=text)
def send_markdown_message(self, receipt, text):
self._client.send_message(chat_id=receipt, text=text, parse_mode="Markdown")
def send_html_message(self, receipt, text):
self._client.send_message(chat_id=receipt, text=text, parse_mode="HTML")
def send_picture(self, receipt, filepath):
with open(filepath, 'rb') as f:
return self._client.send_photo(receipt, photo=f, timeout=50).photo
def send_video(self, receipt, filepath):
with open(filepath, 'rb') as f:
return self._client.send_video(receipt, video=f, timeout=50).video