Merge pull request #39 from NeoBelerophon/yowsup-2

bot - better handling of autocompletion on mobile devices
This commit is contained in:
Mohammed Yaseen Mowzer 2016-01-06 14:44:26 +02:00
commit 02d2568663

4
bot.py
View file

@ -42,7 +42,7 @@ class Bot():
} }
def parse(self, message): def parse(self, message):
args = message.split(" ") args = message.strip().split(" ")
cmd = args.pop(0) cmd = args.pop(0)
if cmd[0] == '\\': if cmd[0] == '\\':
@ -56,7 +56,7 @@ class Bot():
self.send("a valid command starts with a backslash") self.send("a valid command starts with a backslash")
def call(self, cmd, args = []): def call(self, cmd, args = []):
func = self.commands[cmd] func = self.commands[cmd.lower()]
spec = inspect.getargspec(func) spec = inspect.getargspec(func)
maxs = len(spec.args) - 1 maxs = len(spec.args) - 1
reqs = maxs - len(spec.defaults or []) reqs = maxs - len(spec.defaults or [])