helpers.telegramhelper   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 3

3 Functions

Rating   Name   Duplication   Size   Complexity  
A sendalert() 0 6 1
A sendphoto() 0 6 1
A echo() 0 3 1
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