Repository navigation
Expand file tree
/
Copy pathMainScript.py
More file actions
121 lines (93 loc) · 3.57 KB
/
Copy pathMainScript.py
File metadata and controls
121 lines (93 loc) · 3.57 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# 490 Solemn Enumeration by Jared Marriner
# Development began 5/13/2021
# kill me
import discord
import asyncio
import tokens
TOKEN = tokens.token
client = discord.Client()
server = client.guilds
channel_map = {}
# Things to think about: I feel uncomfy writing the banned slurs into the repo even though it's private/used to ban them
# Until then I guess I'll need to suck it up and hard code the no-nos
# May god have mercy on my soul
banned_words = tokens.banned
async def roleCheck(place):
found = False
roles = place.roles
for spot in roles:
if spot.name == "Cryptum":
found = True
break
if not found:
perms = discord.Permissions(send_messages=False,stream=False,change_nickname=False,administrator=False)
await place.create_role("Cryptum", perms, reason="Protocol dictates I apprehend and assign this restraint to those who misbehave.")
def mapChans():
global channel_map
global client
servers = client.guilds
for serv in servers:
nom = serv.name
chans = serv.text_channels
channel_map.update({nom: chans})
def checkWord(msg: str):
global banned_words
msgStr = msg.split()
for word in msgStr:
word = word.lower()
for slur in banned_words:
if word == slur:
print('UNACCEPTABLE')
return True
return False
# What do for pyunishmunchen?
# Perhaps track strikes in JSON dict
# Create jail role and store the time of the strike in the JSON
# 3 strikes and kick. Simple as.
# Stikes can expire. Once time served, remove jail role.
# Maybe remember the user on kick. If they return, ban instead of kick
@client.event
async def on_message(message):
# we do not want the bot to reply to itself
if message.author == client.user:
print("message detected")
return
else:
print("Message detected. Authored by a Reclaimer!")
cont = message.content.lower()
if cont.startswith("~hello"):
await message.channel.send("Greetings! I am 490 Solemn Enumeration! I am the monitor of installation "+message.guild.name)
return
elif cont.startswith("~leave"):
# Add perms check - we don't want smart asses shutting it down for a laugh
perms = message.author.guild_permissions
if not perms.administrator:
print("not an admin")
return
await client.close()
await client.logout()
if checkWord(message.content.lower()): # probe for slurs
print("checkWord returned true")
# kick message author
await message.channel.send("Protocol dictates action! Such behavior is unacceptable!")
#await message.delete()
#await message.author.kick(reason="Protocol dictates action! Such behavior is unacceptable!")
server = message.guild
offender = message.author
await message.delete()
await server.ban(user=offender, reason="Your behavior is most unacceptable, Reclaimer. Protocol gives me no choice but to exile you.")
@client.event
async def on_ready():
#global server
#global channel_map
#mapChans()
greet = 'Greetings! I am 490 Solemn Enumeration!\n'+"I am the monitor of this installation!"
print(greet)
# for serv in server:
# key = serv.name
# greet2 = 'Greetings! I am 490 Solemn Enumeration!\n' + "I am the monitor of installation "+key+"!"
#
# chans = channel_map[key]
# target = chans[0]
# await target.send(greet2)
client.run(TOKEN)