aboutsummaryrefslogtreecommitdiff
path: root/modules/words.py
diff options
context:
space:
mode:
authorGravatar Dax2020-03-08 22:06:14 +0000
committerGravatar Dax2020-03-08 22:12:25 +0000
commitc965a7860ad54804dc2b9150280d68ef463890c1 (patch)
treed1e1d765f3b37d57ea8ff358ea31e8176f7cc4ab /modules/words.py
parentevent["line"][1] -> event["line"].args[1] (diff)
signature
Make !words work in PM
Closes: #210
Diffstat (limited to 'modules/words.py')
-rw-r--r--modules/words.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/modules/words.py b/modules/words.py
index 6f74ecec..0ee1c5a9 100644
--- a/modules/words.py
+++ b/modules/words.py
@@ -105,15 +105,17 @@ class Module(ModuleManager.BaseModule):
self._channel_message(event["server"].get_user(
event["server"].nickname), event)
- @utils.hook("received.command.words", channel_only=True)
+ @utils.hook("received.command.words")
@utils.kwarg("help",
"See how many words you or the given nickname have used")
- @utils.spec("!-channelonly ?<nickname>ouser")
+ @utils.spec("?<nickname>ouser")
def words(self, event):
- target_user = event["spec"][0] or event["user"]
+ if event["spec"][0] and event["is_channel"]:
+ target_user = event["spec"][0]
+ else:
+ target_user = event["user"]
words = dict(self._user_all(target_user))
- this_channel = words.get(event["target"].id, 0)
total = 0
for channel_id in words:
@@ -125,9 +127,14 @@ class Module(ModuleManager.BaseModule):
since = " since %s" % utils.datetime.format.date_human(
utils.datetime.timestamp(first_words))
- event["stdout"].write("%s has used %d words (%d in %s)%s" % (
- target_user.nickname, total, this_channel, event["target"].name,
- since))
+ if event["is_channel"]:
+ this_channel = words.get(event["target"].id, 0)
+ event["stdout"].write("%s has used %d words (%d in %s)%s" % (
+ target_user.nickname, total, this_channel, event["target"].name,
+ since))
+ else:
+ event["stdout"].write("%s has used %d words%s" % (
+ target_user.nickname, total, since))
@utils.hook("received.command.trackword")
@utils.kwarg("help", "Start tracking a word")