-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathchecker.py
More file actions
104 lines (63 loc) · 2.42 KB
/
checker.py
File metadata and controls
104 lines (63 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import urllib.request as urllib2
import discord
import platform
import os
from colorama import Fore
import sys
from bs4 import BeautifulSoup
import urllib.request
import datetime
import json
from discord.ext import commands
categories = open('categories.txt').read().splitlines()
x = datetime.datetime.now()
if not os.path.isfile("config.json"):
sys.exit("'config.json' not found! Please add it and try again!")
else:
with open("config.json") as file:
config = json.load(file)
intents = discord.Intents().all()
astral = commands.Bot(command_prefix=config["prefix"], intents=intents)
@astral.event
async def on_ready():
print("-------------------")
print(Fore.BLUE + (f"Logged in as {astral.user}"))
print(Fore.RED + (f"Discord.py API version: {discord.__version__}"))
print(Fore.CYAN + (f"Python version: {platform.python_version()}"))
print(Fore.GREEN + (f"Running on: {platform.system()} {platform.release()} ({os.name})"))
print("-------------------")
@astral.event
async def on_message(message):
if message.author == astral.user or message.author.bot:
return
await astral.process_commands(message)
@astral.event
async def on_command_error(ctx, error):
await ctx.send("An error has occured. Please ask the bot owner to check their command prompt for a detailed stacktrace. Sorry for the inconvenience!")
raise error
@astral.command()
async def check(ctx):
await ctx.message.attachments[0].save(f"{ctx.author.name}.txt")
links = open(f"{ctx.author.name}.txt").read().splitlines()
for url in links:
print(url)
requestURL = "https://archive.lightspeedsystems.com/SubmitDomain.php?Domain=" + url
opener = urllib.request.FancyURLopener({})
f = opener.open(requestURL)
content = f.read()
blocked = False
with open("tempFile.txt", "w") as f:
f.write(BeautifulSoup(str(content), 'html.parser').prettify())
f.close()
with open("tempFile.txt","r") as f:
for l in f:
for i in categories:
if i in l:
await ctx.send(f"{url} is blocked for {i}.")
blocked = True
break
if blocked != True:
await ctx.send(f"{url} is not blocked.")
f.close()
os.remove("tempFile.txt")
astral.run(config["token"])