Skip to content

Commit 65f5f37

Browse files
author
Foxlet
committed
Safe Browsing - issafe.py
1 parent 5e9b917 commit 65f5f37

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

plugins/issafe.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from cloudbot import hook
2+
import requests
3+
4+
API_SB = "https://sb-ssl.google.com/safebrowsing/api/lookup"
5+
6+
7+
@hook.on_start()
8+
def load_api(bot):
9+
global dev_key
10+
11+
dev_key = bot.config.get("api_keys", {}).get("google_dev_key", None)
12+
13+
@hook.command()
14+
def issafe(text):
15+
parsed = requests.get(API_SB, params={"url": text, "client": "cloudbot", "key": dev_key, "pver": "3.1", "appver": "1.0"})
16+
if str(parsed) == "<Response [204]>":
17+
condition = "This website is safe."
18+
else:
19+
condition = "This site is known to contain: {}".format(parsed.text)
20+
return condition

0 commit comments

Comments
 (0)