diff options
Diffstat (limited to 'geldschieberbot.py')
| -rw-r--r-- | geldschieberbot.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/geldschieberbot.py b/geldschieberbot.py index c249dd2..44327e1 100644 --- a/geldschieberbot.py +++ b/geldschieberbot.py @@ -72,9 +72,11 @@ def record(recipient, donor, amount): """Apply changes to the balance""" # Only change anything if this is not a dry run - if not dry_run: - balance[donor][recipient] += amount - balance[recipient][donor] -= amount + if dry_run: + return + + balance[donor][recipient] += amount + balance[recipient][donor] -= amount def to_cent(euro): if '.' in euro: @@ -275,11 +277,14 @@ def split(sender, args, msg): output = f"Split {to_euro(amount)} between {persons} -> {to_euro(amount_per_person)} each\n" change = [args] for p in args[2:]: - if not p in name2num: - output += p + " not known. Please take care manually\n" + if p in name2num: + if p == recipient: + output += f"{p}, you will be charged multiple times. This may not be what you want\n" + else: + record(recipient, p, amount_per_person) + change.append([recipient, p, amount_per_person]) else: - record(recipient, p, amount_per_person) - change.append([recipient, p, amount_per_person]) + output += f"{p} not known. Please take care manually\n" if record_changes and not dry_run: changes[recipient].append(change) @@ -307,6 +312,9 @@ def transaction(sender, args, msg): else: return None, 'recipient not known' + if sender == recipient: + return None, 'you can not transfere money to or from yourself' + try: amount = to_cent(amount) except: |
