From 516cc0b544e1eabbc476492c4c1eef11a9fd5355 Mon Sep 17 00:00:00 2001 From: paspo Date: Tue, 26 Dec 2017 22:33:49 +0100 Subject: [PATCH] added version --- TODO | 9 +++++++++ telegram-notify.conf | 2 +- telegram-notify.conf.default | 1 + telegram-notify.py | 21 ++++++++++++++++++++- 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/TODO b/TODO index f3c14be..e82bf36 100644 --- a/TODO +++ b/TODO @@ -1 +1,10 @@ - banlist (after XX attempts ban for XX hours, banned users list in config file) +- add service difinition +- add deb packaging +- logging +- message localization +- put config in /etc, if doesn't exist, load local file +- user settings (activation time, etc) +- command extension (/record for recording audio) +- unpair other usernames +- directory monitoring, for message spooling diff --git a/telegram-notify.conf b/telegram-notify.conf index a87d414..58f86db 100644 --- a/telegram-notify.conf +++ b/telegram-notify.conf @@ -2,6 +2,7 @@ daemon = false token = 347279594:AAH33Q3F2YYhAH3gkD6h2M3EqpH9H6Ht32c pair_pin = 1234 +spool_dir = ./spool [id-173581] username = zuzu @@ -12,4 +13,3 @@ lastname = Pao username = pasperti firstname = Paolo lastname = Asperti - diff --git a/telegram-notify.conf.default b/telegram-notify.conf.default index 40badcb..d69c86b 100644 --- a/telegram-notify.conf.default +++ b/telegram-notify.conf.default @@ -2,3 +2,4 @@ daemon = false token = aaaaaaaaaaaaaaaaaaaaaaaaa pair_pin = 1234 +spool_dir = /var/spool/telegram-notify diff --git a/telegram-notify.py b/telegram-notify.py index 6950df3..3ffe474 100644 --- a/telegram-notify.py +++ b/telegram-notify.py @@ -6,8 +6,10 @@ import re import ConfigParser import telepot import json +import sys from telepot.loop import MessageLoop +version = 0.1 def writeconfig(): global configParser @@ -30,8 +32,8 @@ def handle(msg): paired_user = [x for x in chat_ids if x['id'] == chat_id] is_paired = len(paired_user) > 0 + # if text starts with '/' then it's a command if re.match('/',msg['text']): - # e' un comando command = re.sub(r"\s.*",'',msg['text']) param = re.sub(r"^([^\s]+)\s","",msg['text']) @@ -87,6 +89,23 @@ def handle(msg): users = [x['username'] + ' (' + x['firstname'] + ' ' + x['lastname'] + ')\n' for x in chat_ids] bot.sendMessage(chat_id, 'Paired users:\n' + "".join([str(i) for i in users]) ) + elif command == '/start': + bot.sendMessage(chat_id, 'Started:\n' ) + + elif command == '/help': + bot.sendMessage(chat_id, 'Help:\n' ) + + elif command == '/settings': + bot.sendMessage(chat_id, 'Settings:\n' ) + + + +for arg in sys.argv: + if arg=='-v' or arg=='--version': + print 'telegram-notify version %s - Copyright (C) 2018 by Paolo Asperti.' % version + sys.exit(0) + + configParser = ConfigParser.RawConfigParser() configParser.read('telegram-notify.conf')