From 7d686367510eed57c43b9cc71c05d560037dc6f9 Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Mitterer Date: Thu, 23 Mar 2017 22:39:54 +0100 Subject: [PATCH] Add method to create menu, improve mention handling --- bottools/methods.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bottools/methods.py b/bottools/methods.py index 84f32ce..c86c50c 100644 --- a/bottools/methods.py +++ b/bottools/methods.py @@ -60,6 +60,9 @@ def toggleTweet(bot, update): def unknown(bot, update): update.message.reply_text(bottools.strings.unknownCommand) +def makeMenu(buttons, columns): + return [buttons[i:i + columns] for i in range(0, len(buttons), columns)] + # Authentication process def auth(bot, update): @@ -176,7 +179,7 @@ def reply(bot, update, args): pass for m in mentions: - if m in args + [("@%s" % two.whoami().strip("@"))] + [("@%s" % sender.strip("@"))]: + if m in args or m =="@%s" % two.whoami().strip("@") or m == "@%s" % sender.strip("@"): mentions.remove(m) else: @@ -185,7 +188,11 @@ def reply(bot, update, args): if "@%s" % sender.strip("@") != "@%s" % two.whoami().strip("@"): first = ["@%s" % sender.strip("@")] else: - first = [""] + try: + first = [mentions[0]] + mentions.remove(mentions[0]) + except: + first = [""] pargs = first + args[1:] + mentions