From 710e5092e6823302181dacbf2251c752f8f182f3 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Sun, 15 Jan 2017 23:30:32 +0000 Subject: [PATCH] =?UTF-8?q?=D0=BE=D0=BF=D0=BE=D0=B2=D0=B5=D1=89=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- taskapp/handle.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 taskapp/handle.py diff --git a/taskapp/handle.py b/taskapp/handle.py new file mode 100644 index 0000000..ff33edb --- /dev/null +++ b/taskapp/handle.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +from chatbot.telebot import send_notify + + +def handle(task, author, recipient, abon_group): + print author, recipient + dst_account = recipient + text = u'Задача' + # Если сигнал самому себе то молчим + if author == recipient: + return + # Если задача 'На выполнении' то молчим + if task.state == b'C': + return + # Если задача завершена + elif task.state == b'F': + text = u'Задача завершена' + # Меняем телефон назначения на телефон автора, т.к. при завершении + # идёт оповещение автору о выполнении + dst_account = author + fulltext=u"%s: %s. " % (text, task.abon.get_full_name()) + if task.abon: + fulltext += u"по адресу %s тел. %s. " % ( + task.abon.address, task.abon.telephone + ) + fulltext += u"с. %s. Тип задачи - %s. " % (abon_group.title, task.get_mode_display()) + fulltext += task.descr if task.descr else u'<без описания>' + send_notify(fulltext, dst_account)