aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2017-10-25 13:35:56 +0200
committerFlorian Fischer <florian.fl.fischer@fau.de>2017-10-25 13:35:56 +0200
commit2cc961b6b870f330ed5028cd8c5ad503fbb7717e (patch)
tree922f85c4d9e20fa5d4275f02680199016384846a
parentc6dc8f6727dba0e3f93773d1d1854c8d212187ad (diff)
downloadgeldschieberbot-2cc961b6b870f330ed5028cd8c5ad503fbb7717e.tar.gz
geldschieberbot-2cc961b6b870f330ed5028cd8c5ad503fbb7717e.zip
make argument positions of zieh|schieb identical
-rw-r--r--geldschieberbot.py20
1 files changed, 14 insertions, 6 deletions
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]))