diff --git a/modules/networking/__init__.py b/modules/networking/__init__.py index 8d62c54..670c423 100644 --- a/modules/networking/__init__.py +++ b/modules/networking/__init__.py @@ -127,6 +127,15 @@ def cmd_watch(msg, diffType="diff"): return watchWebsite.add_site(msg.args[0], msg.frm, msg.channel, msg.server, diffType) +@hook("cmd_hook", "listwatch") +def cmd_listwatch(msg): + wl = watchWebsite.watchedon(msg.channel) + if len(wl): + return Response(wl, channel=msg.channel, title="URL watched on this channel") + else: + return Response("No URL are currently watched. Use !watch URL to watch one.", channel=msg.channel) + + @hook("cmd_hook", "unwatch") def cmd_unwatch(msg): if not len(msg.args): diff --git a/modules/networking/watchWebsite.py b/modules/networking/watchWebsite.py index 32bf79f..d37a19b 100644 --- a/modules/networking/watchWebsite.py +++ b/modules/networking/watchWebsite.py @@ -36,6 +36,20 @@ def load(datas): #DATAS.delChild(site) +def watchedon(channel): + """Get a list of currently watched URL on the given channel. + """ + + res = list() + for site in DATAS.getNodes("watch"): + if site.hasNode("alert"): + for a in site.getNodes("alert"): + if a["channel"] == channel: + res.append("%s (%s)" % (site["url"], site["type"])) + break + return res + + def del_site(url, nick, channel, frm_owner): """Remove a site from watching list