-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
171 lines (136 loc) · 5.11 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
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
import os
import nextcord
from dotenv import load_dotenv
import random
from datetime import datetime
import pytz
import repostThisMouse as rtm
import heypat as hp
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
client = nextcord.Client()
# For saying funny things
def convert(string):
r = list(string.split(" "))
return r
def splitLetters(string):
return ([i for item in string for i in item.split()])
@client.event
async def on_message(message):
if message.author == client.user:
return
# shut down
if (message.author.id == 228379182369996801 and
message.content == "go away"):
await message.channel.send("simp")
await client.close()
# say something funny
if (message.author.bot is False and
message.channel.id != 480600076729712650):
# 1/25 chance to trigger
rng = random.randint(1, 50)
if rng == 14:
# Choose funny to do to sentence
rng2 = random.randint(1, 6)
# what u say
if rng2 == 1:
finalMessage = 'what'
# Removes some words and adds yes to the end
if rng2 == 2:
# split sentence into words
sentence = convert(message.content)
for word in list(sentence):
rng3 = random.randint(1, 2)
if rng3 == 1:
pass
elif rng3 == 2:
sentence.remove(word)
finalMessage = ' '.join(sentence) + ' yes'
# man
if rng2 == 5:
finalMessage = '>.<'
if rng2 == 6:
finalMessage = 'yo mom'
await message.channel.send(finalMessage)
else:
pass
# saves all messages (not from a bot) to txt file
if (message.author.bot is False and message.content != 'go away' and
message.content.lower() != 'hey pat' and
len((message.content).split()) > 7 and
message.channel.id == 714934718155456663):
hp.updateBrain(message.content)
hp.updateTransitions()
if (message.content.lower() == "hey pat" and
message.channel.id == 714934718155456663):
rawText = hp.rawText
hp.updateTransitions()
finalMessage = hp.sample_sentence(rawText, random.randint(2, 30), 1000)
await message.channel.send(finalMessage)
if (message.content == "hey pat get brain damage" and
message.author.id == 228379182369996801):
hp.deleteBrain()
hp.updateTransitions()
await message.channel.send('fuck')
if (message.content == "hey pat ping" and
message.author.id == 228379182369996801):
await message.channel.send('pong')
if (message.content == "hey pat show the leaderboard"):
await rtm.send_leaderboard(message.channel.id)
@client.event
async def on_voice_state_update(member, before, after):
before = before.channel
after = after.channel
# Test channel: 317823555725295626
# Main channel: 525446332010463262
channel = client.get_channel(525446332010463262)
tz = pytz.timezone('America/Los_Angeles')
now = datetime.now(tz)
emoji_path = "https://cdn.discordapp.com/emojis/"
if before != after:
# Joined channel
if before is None and after is not None:
embedVar = nextcord.Embed(
description=(str(member) + ' joined **' + after.name + '**'),
color=0x00ff00
)
embedVar.set_author(
name='Channel Join',
icon_url=(emoji_path + '728459179194318969.png?v=1')
)
embedVar.set_footer(text=(now.strftime("%m/%d/%Y %H:%M:%S PST")))
await channel.send(embed=embedVar)
# Left channel
if after is None and before is not None:
embedVar = nextcord.Embed(
description=(str(member) + ' left **' + before.name + '**'),
color=0xff0000
)
embedVar.set_author(
name='Channel Left',
icon_url=(emoji_path + '653139080820817920.png?v=1')
)
embedVar.set_footer(text=(now.strftime("%m/%d/%Y %H:%M:%S PST")))
await channel.send(embed=embedVar)
# Switched channel
if after is not None and before is not None:
embedVar = nextcord.Embed(
description=(
str(member) + ' switched from **' + before.name +
'** to **' + after.name + "**"),
color=0xFF7F50
)
embedVar.set_author(
name='Channel Switched',
icon_url=(emoji_path + '712882086603784233.png?v=1')
)
embedVar.set_footer(text=(now.strftime("%m/%d/%Y %H:%M:%S PST")))
await channel.send(embed=embedVar)
@client.event
async def on_ready():
game = nextcord.Game('fortnite')
await client.change_presence(activity=game)
print(f'{client.user} has connected to Discord!')
rtm.client = client
client.loop.create_task(rtm.repost_this_mouse())
client.run(TOKEN)