diff options
Diffstat (limited to 'jeeves/duck.py')
| -rw-r--r-- | jeeves/duck.py | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/jeeves/duck.py b/jeeves/duck.py index be998b1..03804d1 100644 --- a/jeeves/duck.py +++ b/jeeves/duck.py @@ -11,6 +11,7 @@ Spawn times, flee timeout, and idle threshold are runtime-configurable via !set. !hunt - show hunt state !hunt start - start the hunt (op/owner) !hunt stop - stop the hunt (op/owner) + !hunt idle <n> - set idle rounds before auto-stop (0=off) (op/owner) """ import os as _os, sys as _sys @@ -283,6 +284,27 @@ def cmd_hunt(bot, trigger): st["next_spawn"] = float("inf") bot.say("the hunt is over.", channel) + elif sub == "idle": + if not jv.is_authorized(bot, trigger): + return + parts = arg.split() + if len(parts) < 2: + bot.say("usage: !hunt idle <rounds> (0 = no auto-stop)", channel) + return + try: + n = int(parts[1]) + if n < 0: + raise ValueError + except ValueError: + bot.say("idle rounds must be a non-negative integer", channel) + return + with bot.memory["jv_lock"]: + ch = jv.chan_db(bot, channel) + ch["config"]["duck_idle_rounds"] = n + jv.save(bot) + idle_str = f"{n} round(s)" if n > 0 else "off" + bot.say(f"idle auto-stop set to {idle_str}", channel) + else: with bot.memory["dk_lock"]: st = _chan_state(bot, channel) @@ -311,4 +333,4 @@ def cmd_hunt(bot, trigger): else: bot.say(f"hunt: {state}", channel) if jv.is_authorized(bot, trigger): - bot.notice("use !hunt start | !hunt stop to control | timing via !set duck_spawn_min/max/flee_time", trigger.nick) + bot.notice("use !hunt start|stop|idle <n> | timing via !set duck_spawn_min/max/flee_time", trigger.nick) |
