diff options
| author | 2019-09-18 17:49:24 +0100 | |
|---|---|---|
| committer | 2019-09-18 17:49:24 +0100 | |
| commit | 9ec81f8c8a7d67c463d3bb93cd443e12d61ef5ee (patch) | |
| tree | 9aa60eafaefd69a468be5927f8dbbd9ca74b93e4 /modules/check_urls.py | |
| parent | move botsnack to bitbot-modules (diff) | |
| signature | ||
move check_urls.py to bitbot-modules
Diffstat (limited to 'modules/check_urls.py')
| -rw-r--r-- | modules/check_urls.py | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/modules/check_urls.py b/modules/check_urls.py deleted file mode 100644 index c8e81642..00000000 --- a/modules/check_urls.py +++ /dev/null @@ -1,37 +0,0 @@ -#--depends-on commands -#--depends-on config -#--require-config virustotal-api-key - -import re -from src import ModuleManager, utils - -URL_VIRUSTOTAL = "https://www.virustotal.com/vtapi/v2/url/report" -RE_URL = re.compile(r"https?://\S+", re.I) - -@utils.export("channelset", utils.BoolSetting("check-urls", - "Enable/Disable automatically checking for malicious URLs")) -@utils.export("serverset", utils.BoolSetting("check-urls", - "Enable/Disable automatically checking for malicious URLs")) -@utils.export("channelset", utils.BoolSetting("check-urls-kick", - "Enable/Disable automatically kicking users that send malicious URLs")) -class Module(ModuleManager.BaseModule): - @utils.hook("received.message.channel") - def message(self, event): - match = RE_URL.search(event["message"]) - if match and event["channel"].get_setting("check-urls", - event["server"].get_setting("check-urls", False)): - url = match.group(0) - page = utils.http.request(URL_VIRUSTOTAL, get_params={ - "apikey": self.bot.config["virustotal-api-key"], - "resource": url}, json=True) - - if page and page.data.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( - module_name="CheckURL", target=event["channel"], - message="%s just send a malicous URL!" % - event["user"].nickname, server=event["server"]) - |
