aboutsummaryrefslogtreecommitdiff
path: root/modules/in.py
diff options
context:
space:
mode:
authorGravatar jesopo2019-02-10 13:18:25 +0000
committerGravatar jesopo2019-02-10 13:18:25 +0000
commit93dd75ff316c9f355c2421f5823a7840a1742b57 (patch)
treec6cf6a65cbd6ab7c5cf92234aa5acf3f8719670d /modules/in.py
parentAdd TimersContext.find_all (diff)
signature
Added !inlist, to list !in reminders (in.py)
Diffstat (limited to 'modules/in.py')
-rw-r--r--modules/in.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/modules/in.py b/modules/in.py
index 5d0bfd56..2bef5adf 100644
--- a/modules/in.py
+++ b/modules/in.py
@@ -38,3 +38,35 @@ class Module(ModuleManager.BaseModule):
target = server.get_target(event["target"])
self.events.on("send.stdout").call(target=target, module_name="In",
server=server, message=message)
+
+ @utils.hook("received.command.inlist")
+ def in_list(self, event):
+ """
+ :help: List reminders
+ :usage: [index]
+ """
+ timers = self.timers.find_all("in")
+ found = []
+ for timer in timers:
+ nickname_match = (event["server"].irc_lower(
+ timer.kwargs["nickname"]) == event["user"].nickname_lower)
+ target_match = timer.kwargs["target"] == event["target"].name
+
+ if nickname_match and target_match:
+ found.append(timer)
+
+ if len(event["args_split"]) > 0:
+ index = event["args_split"][0]
+ if not index.isdigit() or index == "0":
+ raise utils.EventError("Please provide a valid reminder index")
+
+ index = int(index)
+ actual_index = index-1
+ if actual_index > len(found):
+ raise utils.EventError("You do not have that many reminders")
+
+ timer = found[actual_index]
+ event["stdout"].write("Reminder %d: %s" % (index, timer["message"]))
+ else:
+ event["stdout"].write("%s: you have %d reminders" % (
+ event["user"].nickname, len(found)))