-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
73 lines (52 loc) · 2.24 KB
/
main.py
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
import discord
from dotenv import load_dotenv
import os
import src.pwdlib as pwdlib
# Start of file
pwdlib.initChecks()
TOKEN = pwdlib.getToken()
ScanCommand = pwdlib.parseFromConfig("prefix") + pwdlib.parseFromConfig("scanCommand")
# Init
client = discord.Client()
@client.event
async def on_ready():
print(f'We have logged in as {client.user}')
@client.event
async def on_message(message):
message: discord.Message = message
mastermessage: discord.Message = message
if message.author.id == client.user.id:
return
for WhitelistedGuy in pwdlib.parseFromConfig("allowedUserIds"):
WhitelistedGuy: int = int(WhitelistedGuy)
if message.author.id == WhitelistedGuy:
break
else:
return
contents_lowercase: str = message.content.lower()
if contents_lowercase.startswith(ScanCommand):
await message.reply("Started scanning...", mention_author=False)
allMembers = set()
# Spooky nested loop!
for guild in client.guilds:
print(f"Starting to fetch members from {guild.name}")
totalForGuild = 0
guildMembers = await guild.fetch_members()
for member in guildMembers:
if member not in allMembers:
allMembers.add(member)
totalForGuild += 1
print(f"Got a total of {totalForGuild} for {guild.name}")
print(f"Scanned a total of {len(allMembers)} total")
SpaceWarUsers = 0
for member in allMembers:
if not pwdlib.spacewarDetection(member):
continue
member: discord.Member = member
SpaceWarUsers += 1
messageToSend = f"I caught you at {pwdlib.timenow()} playing the game Spacewar which is commonly known for pirating online games. This incident will be logged. Here is a short message:\n{pwdlib.getPirateMessage()}"
await member.send(messageToSend)
pwdlib.logPirate(member)
print(f"Done! Found a total of {SpaceWarUsers} Spacewar players")
await mastermessage.reply(f"Done! Found a total of {SpaceWarUsers} Spacewar players", mention_author=True)
client.run(TOKEN)