-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
224 lines (180 loc) · 8.78 KB
/
Copy pathmain.py
File metadata and controls
224 lines (180 loc) · 8.78 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
import discord
from discord.ext import commands
from discord.ext import tasks
import random
import datetime
import asyncio
from PIL import Image, ImageDraw, ImageFont
with open('discord_token', 'r') as f:
token = f.readline().strip()
class WutardBot(commands.Bot):
def __init__(self):
intents = discord.Intents.all()
super().__init__(
command_prefix='super ',
help_command=None,
intents=intents
)
async def setup_hook(self):
await self.load_extension('programming_cog')
await self.tree.sync()
print("Slash commands synced")
super_every_day.start()
client = WutardBot()
@client.event
async def on_ready():
await client.change_presence(status=discord.Status.idle, activity=discord.Game(name='Ahh..Super!'))
print('Logged in\n')
@client.event
async def on_guild_join(guild):
channels = guild.channels
for c in channels:
if isinstance(c, discord.TextChannel):
await c.send('Hello! How\'s it goin\'? I\'m Mr. Woodard, and I am your computer '
'teacher. As the year begins, I lecture a lot, and as it goes on, I '
'lecture a little. Everyone ready for the bell ringer? Ah, super!')
break
@client.event
async def on_message(message):
client_user = client.user
if client_user is None:
return
if message.author == client_user:
return
if message.author.bot:
return
ignored_channels = [1292666640256991282, 1013977098370699305]
if client_user and client_user.mention in message.content and message.channel.id not in ignored_channels:
if message.author.id == 597056424803303435:
await message.channel.send('Jiujiu, I need you to sit down and be quiet. Ah, that\'s life.')
else:
try:
await message.channel.send(f'Ah, {message.author.mention}, hello! Hey there! How are you?')
await client.wait_for('message',
check=lambda m: m.channel == message.channel and m.author == message.author,
timeout=20.0)
await message.channel.send('Yes,')
except asyncio.exceptions.TimeoutError:
await message.channel.send('Ah, you ignored me. That\'s life!')
return
if message.content.lower() == 'super':
await message.channel.send('Ah, super!')
return
elif random.randint(0, 19) == 0:
if message.channel.id != 1013977098370699305:
if random.randint(0, 5) == 0:
await message.channel.send('Ah, super!')
else:
await message.channel.send('Ah, super!')
return
await client.process_commands(message)
@client.hybrid_command(name='help', description='ask for help')
async def help(ctx):
await ctx.send('Sorry, I can\'t help you. Ah, that\'s life. I think <@377907768071553024> over there can though.',
allowed_mentions=discord.AllowedMentions(everyone=False, users=False, roles=False))
@client.hybrid_command(name='close_of_business', description='leave', aliases=['leave', 'close'])
async def close_of_business(ctx):
await ctx.send('Take care!')
@client.hybrid_command(name='start_of_class', description='start class', aliases=['start', 'start_of_dice'])
async def start_of_class(ctx):
if random.randint(0, 1) == 0:
message = 'Hello! How\'s it going. '
else:
if datetime.datetime.now().hour < 5:
time = 'night'
elif datetime.datetime.now().hour < 12:
time = 'morning'
elif datetime.datetime.now().hour < 18:
time = 'afternoon'
elif datetime.datetime.now().hour < 21:
time = 'evening'
else:
time = 'night'
message = f'Good {time}! '
phrases = ['It is a super day! ', 'Ah, that\'s life. ', 'Who\'s ready for the bell ringer? I surely am. ',
'How\'s it goin\', ladies? ', 'Ah, super! ', 'Alright! ', 'Go on in and sit down! ']
for i in range(random.randint(1, 7)):
current = phrases
index = random.randint(0, len(current) - 1)
message += current[index]
del current[index]
message = message[0:-1]
await ctx.send(message)
@client.hybrid_command(name='roll_the_dice', description='roll dice', aliases=['dice'])
async def roll_the_dice(ctx):
dice = random.randint(1, 6)
if dice == 1:
message = f'Everyone ready for the bell ringer? Time to roll the dice! It\'s a {dice}! Turn \'em in!' \
f' I will rip them out of your hands now. Who got A? '
else:
message = f'Everyone ready for the bell ringer? Time to roll the dice! It\'s a {dice}! Who got A? '
ans = random.randint(1, 5)
letters = ['A', 'B', 'C', 'D', 'E']
source = ['Benchmarking', 'Crowd-sourcing', 'The back of the book', 'The textbook', 'CodeHS']
if ans > 1:
message += 'Who got B? '
if ans > 2:
message += 'Who got C? '
if ans > 3:
message += 'Who got D? '
if ans > 4:
message += 'Who got E? '
message += f'{random.choice(source)} says the answer is {letters[ans - 1]}! '
message += 'Super!'
if random.randint(0, 5) == 0:
message += ' Onguh free free!'
await ctx.send(message)
@client.hybrid_command(name='lecture_time', description='it\'s lecture time', aliases=['lecture'])
async def lecture_time(ctx):
lectures = ['Unit 1 Primitive Types', 'Unit 2 Using Objects', 'Unit 3 Boolean Expression and if Statements',
'Unit 4 Iteration', 'Unit 5 Writing Classes', 'Unit 6 Array', 'Unit 7 ArrayList', 'Unit 8 2DArray',
'Unit 9 Inheritance', 'Unit 10 Recursion']
lessons = ['What all computer user face?', 'The power to be proactive', 'You if seen this, but are stressed',
'Which RDP does being proactive fall under?', '"Hey! Look what Zog do!"', 'How to tame email',
'You have a knowledge of time management, but no an understanding', 'Benchmarking successful people',
'How to manage files', 'The power of Win-Win', 'Win - Win - Teams', 'Why this is powerful?',
'Lack of planning = easy jobs are easy', 'Lack of planning = hard projects get hard', 'ChatGDP!']
message = f'Alright! Lecture time. {random.choice(lectures)}! But first, better today then yesterday! ' \
f'{random.choice(lessons)}'
await ctx.send(message)
@client.hybrid_command(name='chinese', description='ask woodard if he knows anything foreign',
aliases=['foreign_language', 'black', 'muslim', 'hispanic', 'arab', 'korean'])
async def chinese(ctx):
ethnicities = ['Chinese', 'Japanese', 'Korean', 'Vietnamese', 'Filipino', 'Indian', 'Thai', 'Indonesian', 'African',
'South American', 'Native American', 'Middle Eastern', 'Muslim', 'Black', 'Hispanic', 'Minority']
await ctx.send(f'Konichiwa! Yes, I am friends with a lot of {random.choice(ethnicities)} people.')
@client.hybrid_command(name='slides', description='create slides')
async def slides(ctx, *, msg: str):
image = Image.open('assets/vapor_trail.png')
draw = ImageDraw.Draw(image)
font = ImageFont.truetype('assets/verdana.ttf', 75)
draw.text((100, 200), msg, fill=(255, 255, 255), font=font)
image.save('_slides.png')
with open('_slides.png', 'rb') as image_f:
upload_image = discord.File(image_f, spoiler=False)
await ctx.send(file=upload_image)
@client.hybrid_command(name='calc1', description='ask woodard about his Calc 1 experience',
aliases=['calc_one', 'calc', 'calculus'])
async def calc1(ctx):
await ctx.send(
'Ah, that\'s life. I took calc twice and failed, so I had to take it a third time. Third time\'s the charm! '
'Ah, super.')
@client.hybrid_command(name='gpa', description='ask woodard about his gpa in college',
aliases=['college_gpa', 'gpa_in_college'])
async def gpa(ctx):
await ctx.send('Ah, not super. When I started college, my GPA was in the points! That\'s life.')
@client.hybrid_command(name='work_smart', description='woodard likes to work smart by self plagiarizing!',
aliases=['plagiarize', 'self_plagiarize'])
async def work_smart(ctx):
await ctx.send(
'Ah, super! Remember to work smart, as I did in college, when I turned in a paper I had for an assignment in '
'a previous'
'class as the final paper in another class. That is very super and very smart!')
@tasks.loop(time=datetime.time(hour=18, minute=30))
async def super_every_day():
await client.wait_until_ready()
channel = client.get_channel(1013977098370699305)
if isinstance(channel, discord.TextChannel):
await channel.send('Ah, super!')
if __name__ == '__main__':
client.run(token)