-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtelegram.py
More file actions
33 lines (23 loc) · 776 Bytes
/
telegram.py
File metadata and controls
33 lines (23 loc) · 776 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
27
28
#!/usr/bin/python3
# coding: utf-8
import requests
import login
class init(object):
""" permet d'envoyer les messages sur Telegram
- bot : l'identifiant du bot
- chatID : identifiant du chat
- send() : envoi un message à Telegram
"""
def __init__(self):
""" charge la configuration """
id = login.init()
self.bot = id.bot
self.chatID = id.chatID
def send(self, message):
""" envoi le message au bot """
url = 'https://api.telegram.org/bot' + self.bot + '/sendMessage?chat_id=' + self.chatID + '&parse_mode=Markdown&text=' + message
toSend = requests.get(url)
return toSend.json()
if __name__ == '__main__':
message = init()
message.send('Test python to telegram')