aboutsummaryrefslogtreecommitdiff
path: root/geldschieberbot.py
diff options
context:
space:
mode:
Diffstat (limited to 'geldschieberbot.py')
-rw-r--r--geldschieberbot.py24
1 files changed, 8 insertions, 16 deletions
diff --git a/geldschieberbot.py b/geldschieberbot.py
index d42f15f..d6fb9b1 100644
--- a/geldschieberbot.py
+++ b/geldschieberbot.py
@@ -91,7 +91,10 @@ def to_cent(euro):
euro[1] = int(euro[1]) * 10
else:
euro[1] = int(euro[1])
- return euro[0] * 100 + euro[1]
+ amount = euro[0] * 100 + euro[1]
+ if amount < 0:
+ raise ValueError
+ return amount
def to_euro(cents):
return str(cents/100)
@@ -236,7 +239,7 @@ def split(sender, args, msg):
try:
amount = to_cent(args[1])
except:
- return None, "amount must be a number"
+ return None, "amount must be a positive number"
# len(args) - cmd - amount + sender
persons = len(args) - 2 + 1
@@ -287,10 +290,7 @@ def transaction(sender, args, msg):
try:
amount = to_cent(amount)
except:
- return None, "amount must be a number"
-
- if amount < 0:
- return None, "amount must be positiv"
+ return None, "amount must be a positive number"
if args[0] in ["!zieh", "!nimm"]:
amount *= -1
@@ -328,12 +328,7 @@ def transfer(sender, args, msg):
try:
amount = int(args[1])
except:
- send("ERROR: amount must be a number")
- return 1
-
- if amount < 0:
- send("ERROR: amount must be positiv")
- return 1
+ return None, "ERROR: amount must be a positive number"
source, destination = args[2:4]
if source not in balance:
@@ -416,10 +411,7 @@ def cars(sender, args, msg):
try:
service_charge = to_cent(args[3])
except:
- return None, "service_charge must be a number"
-
- if not service_charge > 0:
- return None, "service-charge must be greater than 0"
+ return None, "service-charge must be a positive number"
available_cars[car] = service_charge