| Total Complexity | 3 |
| Total Lines | 22 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | '''telegram api''' |
||
| 2 | import datetime |
||
| 3 | from telegram import Bot |
||
| 4 | |||
| 5 | def echo(bot, update): |
||
| 6 | """Echo the user message.""" |
||
| 7 | update.message.reply_text(update.message.text) |
||
| 8 | |||
| 9 | def sendalert(message, service): |
||
| 10 | '''send the message''' |
||
| 11 | print("telegramhelper.py:{0} {1}".format(str(datetime.datetime.now()), message)) |
||
| 12 | chat_id = service.user |
||
| 13 | bot = Bot(token=service.password) |
||
| 14 | bot.send_message(chat_id=chat_id, text=message) |
||
| 15 | |||
| 16 | def sendphoto(file, service): |
||
| 17 | '''send the photo''' |
||
| 18 | print("telegramhelper.py:{0} {1}".format(str(datetime.datetime.now()), file)) |
||
| 19 | chat_id = service.user |
||
| 20 | bot = Bot(token=service.password) |
||
| 21 | bot.send_photo(chat_id, photo=open(file, 'rb')) |
||
| 22 |