diff options
| -rw-r--r-- | geldschieberbot.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/geldschieberbot.py b/geldschieberbot.py index 2610b54..a4a7179 100644 --- a/geldschieberbot.py +++ b/geldschieberbot.py @@ -20,16 +20,21 @@ group_id = "GELD!!!" send_cmd = "signal-cli -u irgendwer send -g irgendwem" +"""Run without changing the stored state""" +dry_run = False + def record(sender, recipient, donor, amount): """Apply change to the balance and save it""" - balance[donor][recipient] += amount - balance[recipient][donor] -= amount + # Only change anything if this is not a dry run + if not dry_run: + balance[donor][recipient] += amount + balance[recipient][donor] -= amount - if not sender in last_change: - last_change[sender] = [] + if not sender in last_change: + last_change[sender] = [] - last_change[sender].append([recipient, donor, amount]) + last_change[sender].append([recipient, donor, amount]) def to_cent(euro): euro = euro.split('.') @@ -354,6 +359,12 @@ def handle_input(inp): def main(): + + if len(sys.argv) > 1 and sys.argv[1] in ["-d", "--dry-run"]: + global dry_run + dry_run = True + print("Dry Run no changes will apply! + global group_id group_id = os.environ["GSB_GROUP_ID"] |
