WatchWebsite module: dusting & fix unwatch authorizations

This commit is contained in:
nemunaire 2014-08-06 16:20:51 +02:00
parent d985b71373
commit c15127feb8
2 changed files with 6 additions and 7 deletions

View File

@ -1,6 +0,0 @@
<?xml version="1.0" ?>
<nemubotmodule name="watchWebsite">
<message type="cmd" name="watch" call="add_site" data="diff" />
<message type="cmd" name="updown" call="add_site" data="updown" />
<message type="cmd" name="unwatch" call="del_site" />
</nemubotmodule>

View File

@ -24,6 +24,11 @@ def help_full ():
def load(context):
"""Register watched website"""
from hooks import Hook
add_hook("cmd_hook", Hook(add_site, "watch", data="diff"))
add_hook("cmd_hook", Hook(add_site, "updown", data="updown"))
add_hook("cmd_hook", Hook(del_site, "unwatch"))
DATAS.setIndex("url", "watch")
for site in DATAS.getNodes("watch"):
if site.hasNode("alert"):
@ -62,7 +67,7 @@ def del_site(msg):
site = DATAS.index[url]
for a in site.getNodes("alert"):
if a["channel"] == msg.channel:
if (msg.sender == a["sender"] or msg.is_owner):
if not (msg.sender == a["sender"] or msg.is_owner):
raise IRCException("vous ne pouvez pas supprimer cette URL.")
site.delChild(a)
if not site.hasNode("alert"):