aboutsummaryrefslogtreecommitdiff
path: root/geldschieberbot.py
diff options
context:
space:
mode:
Diffstat (limited to 'geldschieberbot.py')
-rw-r--r--geldschieberbot.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/geldschieberbot.py b/geldschieberbot.py
index 27f87ae..875ab30 100644
--- a/geldschieberbot.py
+++ b/geldschieberbot.py
@@ -168,6 +168,12 @@ def add_to_balance(name):
balance[name] = nb
+def remove_from_balance(name):
+ del balance[name]
+ for m in balance:
+ del balance[m][name]
+
+
def create_help():
return """
Usage: send a message starting with '!' followed by a command
@@ -191,6 +197,7 @@ cars [cmd] - interact with the available cars
cars [list | ls] - list available cars and their service charge
cars add car-name service-charge - add new car
cars new car-name service-charge - add new car
+cars remove car-name - remove new car
cars pay car-name amount - pay a bill for the specified car
tanken amount [person] [car] [info] - calculate fuel costs, service charge and add them to the person's and car's balance respectively
@@ -482,6 +489,19 @@ def cars(sender, args, msg):
available_cars[car] = service_charge
add_to_balance(car)
return f'added "{car}" as an available car', None
+
+ # remove car
+ if args[1] in ["rm", "remove"]:
+ if len(args) < 3:
+ return None, f'not in form "{args[0]} {args[1]} car-name"'
+
+ car = args[2]
+ if car not in available_cars:
+ return None, f'A car with the name "{car}" does not exists'
+
+ del available_cars[car]
+ remove_from_balance(car)
+ return f'removed "{car}" from the available cars', None
# pay bill
if args[1] in ["pay"]: