[networking] New function to get a list of watched URL
This commit is contained in:
parent
c27540eb87
commit
d1c28fc4a3
@ -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):
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user