-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtelegram.py
More file actions
26 lines (20 loc) · 803 Bytes
/
Copy pathtelegram.py
File metadata and controls
26 lines (20 loc) · 803 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 os
import requests
bot_token = os.environ['bot_token']
channel_id = os.environ['channel_id']
admin_id = os.environ['chat_id']
footer = os.environ['footer']
def msg_to_admin(args):
text_caps = ''.join(args)
requests.post(
url='https://api.telegram.org/bot{0}/{1}'.format(bot_token, 'sendMessage'),
data={'chat_id': admin_id, 'text': text_caps}
)
def send_article(title, link, date):
message = '<a href="{link}">{title}</a>\n\n<pre>{date}</pre>\n\n{footer}' \
.format(title=title, link=link, date=date,
footer=footer)
return requests.post(
url='https://api.telegram.org/bot{0}/{1}'.format(bot_token, 'sendMessage'),
data={'chat_id': channel_id, 'text': message, 'parse_mode': 'HTML'}
)