From 2cc961b6b870f330ed5028cd8c5ad503fbb7717e Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Wed, 25 Oct 2017 13:35:56 +0200 Subject: make argument positions of zieh|schieb identical --- geldschieberbot.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'geldschieberbot.py') diff --git a/geldschieberbot.py b/geldschieberbot.py index b1ee187..1de7b40 100644 --- a/geldschieberbot.py +++ b/geldschieberbot.py @@ -149,12 +149,20 @@ def handle_input(inp): else: if not sender_number in num2name: send('ERROR: you must register first') - elif not w[2] in name2num: - send('ERROR: recipient not known') else: + if w[1] in name2num: + recipient = w[1] + amount = w[2] + elif w[2] in name2num: + recipient = w[2] + amount = w[1] + else: + send('ERROR: recipient not known') + continue + sender = num2name[sender_number] try: - amount = float(w[1]) + amount = float(amount) except: send("ERROR: amount musst be a number") continue @@ -166,10 +174,10 @@ def handle_input(inp): if w[0] in ["!zieh", "!nimm"]: amount *= -1 - balance[sender][w[2]] -= amount - balance[w[2]][sender] += amount + balance[sender][recipient] -= amount + balance[recipient][sender] += amount - p_balance = balance[sender][w[2]] + p_balance = balance[sender][recipient] send("New Balance: {0} {1} {2:g} {3}\n".format(sender, ("->" if p_balance > 0 else "<-"), abs(p_balance), w[2])) -- cgit v1.2.3