Also optionally (attempt to) kick users that send malicious urls in
check_urls.py
This commit is contained in:
parent
abc9d92c9d
commit
14a9e4a6a4
1 changed files with 10 additions and 3 deletions
|
@ -13,8 +13,12 @@ class Module(object):
|
||||||
events.on("received.message.channel").hook(self.message)
|
events.on("received.message.channel").hook(self.message)
|
||||||
events.on("postboot").on("configure").on(
|
events.on("postboot").on("configure").on(
|
||||||
"channelset").assure_call(setting="check-urls",
|
"channelset").assure_call(setting="check-urls",
|
||||||
help="Enable/Disable automatically checking for malicious urls",
|
help="Enable/Disable automatically checking for malicious URLs",
|
||||||
validate=Utils.bool_or_none)
|
validate=Utils.bool_or_none)
|
||||||
|
events.on("postboot").on("configure").on(
|
||||||
|
"channelset").assure_call(setting="check-urls-kick",
|
||||||
|
help="Enable/Disable automatically kicking users that send "
|
||||||
|
"malicious URLs", validate=Utils.bool_or_none)
|
||||||
|
|
||||||
def message(self, event):
|
def message(self, event):
|
||||||
match = RE_URL.search(event["message"])
|
match = RE_URL.search(event["message"])
|
||||||
|
@ -25,8 +29,11 @@ class Module(object):
|
||||||
"apikey": self.bot.config["virustotal-api-key"],
|
"apikey": self.bot.config["virustotal-api-key"],
|
||||||
"resource": url}, json=True)
|
"resource": url}, json=True)
|
||||||
|
|
||||||
if page:
|
if page and page.get("positives", 0) > 1:
|
||||||
if page.get("positives", 0) > 1:
|
if event["channel"].get_setting("check-urls-kick", False):
|
||||||
|
event["channel"].send_kick(event["user"].nickname,
|
||||||
|
"Don't send malicious URLs!")
|
||||||
|
else:
|
||||||
self.events.on("send.stdout").call(
|
self.events.on("send.stdout").call(
|
||||||
module_name="CheckURL", target=event["channel"],
|
module_name="CheckURL", target=event["channel"],
|
||||||
message="%s just send a malicous URL!" %
|
message="%s just send a malicous URL!" %
|
||||||
|
|
Loading…
Reference in a new issue