aboutsummaryrefslogtreecommitdiff
path: root/geldschieberbot.py
diff options
context:
space:
mode:
Diffstat (limited to 'geldschieberbot.py')
-rw-r--r--geldschieberbot.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/geldschieberbot.py b/geldschieberbot.py
index d74cca5..7ae6454 100644
--- a/geldschieberbot.py
+++ b/geldschieberbot.py
@@ -190,7 +190,7 @@ 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
-fuck - rewind last change
+fuck [change] - rewind last or specific change
list-changes [n] [first] - list the last n changes starting at first
weekly name cmd - repeat cmd each week
@@ -595,11 +595,22 @@ def fuck(sender, args, msg):
else:
name = num2name[sender]
- if len(changes[name]) == 0:
+ nchanges = len(changes[name])
+ if nchanges == 0:
return "Nothing to rewind", None
+ change_to_rewind = -1
+ if len(args) >= 2:
+ try:
+ change_to_rewind = int(args[1]) - 1
+ except ValueError:
+ return None, "change to rewind must be a number"
+
+ if change_to_rewind > nchanges:
+ return None, "change to rewind is bigger than there are changes"
+
# pop last item
- last_changes = changes[name].pop()
+ last_changes = changes[name].pop(change_to_rewind)
args, last_changes = last_changes[0], last_changes[1:]
output = name + ": sorry I fucked up!\nRewinding:\n"