-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
135 lines (116 loc) · 5.49 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
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# some code sourced from https://realpython.com/how-to-make-a-discord-bot-python/
import os
import random
import util as u
import discord
from dotenv import load_dotenv
# fancy tech stuff - gets the secrets
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
# useful variables
prefix = u.textRead("settings.txt")[3]
client = discord.Client()
rps = False
# displays when bot connects
@client.event
async def on_ready():
print(f'{client.user.name} has connected to Discord!')
@client.event
async def on_message(message):
global rps
if message.author == client.user:
return
if message.content.startswith(prefix + "rps"):
await message.channel.send("Ok let's play. You go first.")
rps = True
return
if rps:
if message.content.lower() == "rock":
await message.channel.send("Paper")
await message.channel.send("Ha ha! I win!")
await message.channel.send(u.randomYourMomJoke())
elif message.content.lower() == "scissors":
await message.channel.send("Rock")
await message.channel.send("Ha ha! I win!")
await message.channel.send(u.randomYourMomJoke())
elif message.content.lower() == "paper":
await message.channel.send("Scissors")
await message.channel.send("Ha ha! I win!")
await message.channel.send(u.randomYourMomJoke())
else:
await message.channel.send("That's not rock, paper, or scissors. I don't play with cheaters.")
rps = False
return
if message.content.startswith(prefix + "insult"):
insultRequest = message.content.split(" ")
if len(insultRequest) > 1 and insultRequest[1].startswith("<@"):
await message.channel.send(u.randomYourMomJoke(insultRequest[1]))
if random.randrange(100) > 100 - int(u.textRead("settings.txt")[2]):
await message.channel.send(file=discord.File('insults/roastedgifs/roasted'+str(random.randint(1, 5))+ '.gif'))
else:
await message.channel.send(u.randomYourMomJoke())
if random.randrange(100) > 100 - int(u.textRead("settings.txt")[2]):
await message.channel.send(file=discord.File('insults/roastedgifs/roasted'+str(random.randint(1, 5))+ '.gif'))
return
elif message.content.startswith(prefix + "geninsult"):
insultRequest = message.content.split(" ")
if len(insultRequest) > 1 and insultRequest[1].startswith("<@"):
await message.channel.send(u.generateYourMomJoke(insultRequest[1]))
if random.randrange(100) > 100 - int(u.textRead("settings.txt")[2]):
await message.channel.send(file=discord.File('insults/roastedgifs/roasted'+str(random.randint(1, 5))+ '.gif'))
else:
await message.channel.send(u.generateYourMomJoke())
if random.randrange(100) > 100 - int(u.textRead("settings.txt")[2]):
await message.channel.send(file=discord.File('insults/roastedgifs/roasted'+str(random.randint(1, 5))+ '.gif'))
return
elif message.content.startswith(prefix + "help"):
await message.channel.send(f"""
Hello! I'm a very accurate representation of an annoying adolescent, created by a group of annoying adolescents. I tell the best your mom jokes you've ever encountered. Try some of these commands!
**don't spam commands. we'll get rate limited.**
Command prefix: {prefix}
{prefix}**help**
The help command.
{prefix}**insult** *[optional_target]*
Get a your mom joke. If you ping someone after the command, I'll insult their mom instead of yours.
{prefix}**geninsult** *[optional_target]*
I'll generate a your mom joke instead of choosing one from my premade list as with {prefix} insult. If you ping someone after the command, I'll insult their mom instead of yours.
{prefix}**rps**
We'll play a game of rock paper scissors. You'll definitely be able to win if you try hard enough.
Coming soon: commands for changing the frequency of random responses to messages
Curse another Discord server with my presence!
https://discord.com/api/oauth2/authorize?client_id=944652303632322591&permissions=277025459264&redirect_uri=https%3A%2F%2Fdiscord.com%2Fchannels%2F%40me&response_type=code&scope=bot%20messages.read
*I'm dedicated to ZA!* You know what you said about my mother.
*This is a submission for Hack Kean 2022*
""")
return
animal = u.containsAny(message.content, u.textRead("insults/animals.txt"))
if random.randrange(100) > 100 - int(u.textRead("settings.txt")[0]) and animal:
await message.channel.send(f'{animal.title()}? Like your mom?')
return
if random.randrange(100) > 100 - int(u.textRead("settings.txt")[1]):
if (
message.content.lower().startswith("who ") or
message.content.lower().startswith("what ") or
message.content.lower().startswith("when ") or
message.content.lower().startswith("where ") or
message.content.lower().startswith("why ") or
message.content.lower().startswith("how ") or
message.content.lower().startswith("do") or
message.content.lower().startswith("does") or
message.content.lower().startswith("can") or
message.content.lower().startswith("has") or
message.content.lower().startswith("have") or
message.content.lower().startswith("will ") or
message.content.lower().startswith("won't ") or
message.content.lower().startswith("would") or
message.content.lower().startswith("should") or
message.content.lower().startswith("could") or
message.content[-1] == "?"
):
await message.channel.send('your mom LMAO xD')
return
else:
await message.channel.send('i literally didn\'t ask')
return
keep_alive()
client.run(TOKEN)