helpers.telegramhelper.sendalert()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 6
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nop 2
dl 0
loc 6
rs 10
c 0
b 0
f 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