support !duckstats for users other than yourself

This commit is contained in:
jesopo 2019-11-11 17:21:40 +00:00
parent 3766262eab
commit 46058c51c5

View file

@ -178,9 +178,13 @@ class Module(ModuleManager.BaseModule):
:help: Get yours, or someone else's, duck stats :help: Get yours, or someone else's, duck stats
:usage: [nickname] :usage: [nickname]
""" """
befs = event["user"].get_channel_settings_per_setting( target_user = event["user"]
if event["args"]:
target_user = event["server"].get_user(event["args_split"][0])
befs = target_user.get_channel_settings_per_setting(
"ducks-befriended") "ducks-befriended")
traps = event["user"].get_channel_settings_per_setting("ducks-shot") traps = target_user.get_channel_settings_per_setting("ducks-shot")
all = [(chan, val, "bef") for chan, val in befs] all = [(chan, val, "bef") for chan, val in befs]
all += [(chan, val, "trap") for chan, val in traps] all += [(chan, val, "trap") for chan, val in traps]
@ -206,5 +210,5 @@ class Module(ModuleManager.BaseModule):
event["stdout"].write( event["stdout"].write(
"%s has befriended %d and trapped %d ducks%s" % "%s has befriended %d and trapped %d ducks%s" %
(event["user"].nickname, overall["bef"], overall["trap"], (target_user.nickname, overall["bef"], overall["trap"],
current_str)) current_str))