WatchWebsite module: dusting & fix unwatch authorizations
This commit is contained in:
parent
d985b71373
commit
c15127feb8
@ -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>
|
|
@ -24,6 +24,11 @@ def help_full ():
|
|||||||
|
|
||||||
def load(context):
|
def load(context):
|
||||||
"""Register watched website"""
|
"""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")
|
DATAS.setIndex("url", "watch")
|
||||||
for site in DATAS.getNodes("watch"):
|
for site in DATAS.getNodes("watch"):
|
||||||
if site.hasNode("alert"):
|
if site.hasNode("alert"):
|
||||||
@ -62,7 +67,7 @@ def del_site(msg):
|
|||||||
site = DATAS.index[url]
|
site = DATAS.index[url]
|
||||||
for a in site.getNodes("alert"):
|
for a in site.getNodes("alert"):
|
||||||
if a["channel"] == msg.channel:
|
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.")
|
raise IRCException("vous ne pouvez pas supprimer cette URL.")
|
||||||
site.delChild(a)
|
site.delChild(a)
|
||||||
if not site.hasNode("alert"):
|
if not site.hasNode("alert"):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user