This repository has been archived by the owner on Nov 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsystem.py
282 lines (269 loc) · 8.13 KB
/
system.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
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
# PackedBerry System
import requests
import random
import os
import youtubesearchpython
def search_video(query:str):
videosSearch = youtubesearchpython.VideosSearch(str(query), limit = 1)
return videosSearch.result()
def get_video_data(query:dict):
r = {}
d = search_video(query)
for _ in d:
l = d[_]
for e in l:
f = e
for i in f:
if i in ['link', 'title', 'duration', 'viewCoutn']:
r.update({i : f[i]})
return r
def get_title(url: str):
html = requests.get(url).text
title_separator = html.split("<title>")
title = title_separator[1].split("</title>")[0]
return title
vfile = open("data/version", "r")
version = vfile.read()
vfile.close()
hfile = open("data/help", "r")
help_data = hfile.read()
hfile.close()
wfile = open("data/whatsnew", "r")
whatsnew = wfile.read()
wfile.close()
def mute(uid, mute_list, guild_id, mute_server):
id_match = False
for elem in mute_list:
if str(elem) == str(uid):
id_match = True
break
server_match = False
for elem in mute_server:
if str(elem) == str(guild_id):
server_match = True
break
if id_match and server_match:
return True
else:
return False
def out(message, refname, client):
try:
msg = message.content.lower().split(" ")
out = ""
delete = False
connectVoice = False
voiceChannel = ""
song_url = ""
calls = refname
repeat = 1
mutelist = []
unmutelist = []
if msg[0] in refname[1]:
try:
if msg[1] in ["ver", "version"]:
out = version
elif msg[1] in ["whatsnew", "wn"]:
out = whatsnew
elif msg[1] == "help":
if len(msg) < 3:
help_file = open('data/help', 'r')
help_data = help_file.read()
help_file.close()
out = str(help_data)
else:
help_file = open('data/__help__', 'r')
help_data = help_file.read().split("***")
help_data.remove("")
help_file.close()
for _ in help_data:
list_ = _.split("\n")
list_.remove('')
if len(list_) > 0:
if list_[0] == msg[2]:
out = str(_)
break
if out == "":
out = "```yml\n*unavailable```"
elif msg[1] == "ping":
out = f"<@{message.author.id}>"
elif msg[1] == "sitename":
try:
site_url = str(message.content.split(" ")[2])
try:
title = get_title(site_url)
except:
title = "???"
out = title
except:
out = "Please provide URL."
elif msg[1] in ["connect", "join", "vibe"]:
try:
_msg = message.content.split(' ')
del _msg[0]
del _msg[0]
c = " ".join(_msg)
if c.replace(' ', '') == "":
out = "Please enter a valid channel name."
else:
voiceChannel = str(c)
out = f"Connected to {c}."
connectVoice = "<#>"
except Exception as e:
print(e)
elif msg[1] == "vibe-url":
try:
try:
try:
voiceChannel = str(message.content).replace( str(message.content.split(" ")[0]) + " " + str(message.content.split(" ")[1]) + " " + str(message.content.split(" ")[2] + " "), "" )
song_url = str(message.content.split(" ")[2])
try:
title = get_title(song_url)
except:
title = "???"
out = "Now vibing on " + title + "(<" + song_url + ">)!!!"
connectVoice = True
except:
out = "Error."
except:
out = "Please provide a voice channel to vibe in!"
except:
out = "Please provide an url to vibe on!"
elif msg[1] == "vibe-name":
try:
try:
try:
del msg[0]
del msg[0]
search_text = " ".join(msg)
if search_text.replace(' ', '') == '':
out = 'Search Text can not be empty.'
else:
song_url = str(get_video_data(search_text)['link'])
try:
title = get_title(song_url)
except:
title = "???"
out = "Now vibing on " + title + "(<" + song_url + ">)!!!"
connectVoice = True
except:
out = "Error."
except:
out = "Please provide a voice channel to vibe in!"
except:
out = "Please provide an url to vibe on!"
elif msg[1] == "novibe":
connectVoice = "-"
out = "Not vibing anymore."
elif msg[1] == "pausevibe":
connectVoice = "||"
out = "Waiting till start vibing again."
elif msg[1] == "resumevibe":
connectVoice = ">"
out = "Resuming vibing again."
elif msg[1] == "donevibe":
connectVoice = "<"
out = "Stopped vibing."
elif msg[1] == "spam":
if str(message.guild.id) in os.listdir('no-spam'):
out = "You can not use `spam` command in this server. To enable it type `<prefix> set-spam on`. Note by default if already wasn't set to, then spam max limit is 25. Be careful."
else:
try:
try:
try:
sf = open(f'set-spam/{message.guild.id}', 'r')
spam_limit = int(sf.read())
sf.close()
except:
spam_limit = 25
if int(msg[2]) <= spam_limit:
spam_text = ""
try:
spam_text = str(message.content).replace( str(message.content.split(" ")[0]) + " " + str(message.content.split(" ")[1]) + " " + str(message.content.split(" ")[2] + " "), "" )
except:
spam_text = ""
if spam_text.replace(" ", "") == '':
out = "Please provide text to spam."
else:
out = spam_text
repeat = int(msg[2])
else:
out = f"Spam amount limit is 0 to {spam_limit} only."
except:
out = "Spam amount should be a number."
except:
out = "Please specify an amount to spam."
elif msg[1] == "call":
try:
if str(msg[2]) not in calls[1]:
calls[1].append(str(msg[2]))
out = 'Added name option - ' + str(message.content.split(' ')[2]) + '. Now you can use ' + str(message.content.split(' ')[2]) + ' as prefix to start a PackedBerry command.'
except:
all_names = "```"
called = []
for name in calls[1]:
if name not in called:
all_names = all_names + '\n' + str(name)
called.append(name)
all_names = all_names + '\n```'
out = str(all_names)
elif msg[1] == "nocall":
try:
if str(msg[2]) in calls[1]:
calls[1].remove(str(msg[2]))
if str(msg[2]) in calls[0]:
out = 'Can not remove system default names!'
else:
out = 'Removed name option - ' + str(message.content.split(' ')[2]) + '. Now you can not use ' + str(message.content.split(' ')[2]) + ' as prefix to start a PackedBerry command.'
for name in calls[0]:
if name not in calls[1]:
calls[1].append(name)
except:
out = 'Please provide a name!'
elif msg[1] == "mute":
try:
if message.author.guild_permissions.administrator:
id = str(msg[2]).replace('<', '').replace('>', '').replace('!', '').replace('@', '')
if id == str(781701773713997824):
out = ["Dare you talk to my creator like that again. :rage:", "You can not mute a god.", "This is an action of Violence against PackedBerry."][random.randint(0, 2)]
elif id == str(message.author.id):
out = 'Are you serious or just want to punish yourself?'
else:
mutelist.append(str(msg[2]).replace('<', '').replace('>', '').replace('!', '').replace('@', ''))
out = f'{msg[2]} was muted.'
else:
out = 'YOOOOOOOOOOOOOOOOLLLLLLLLlllll! You Not The Admin!'
except:
out = 'Please provide user to mute.'
elif msg[1] == "unmute":
try:
if message.author.guild_permissions.administrator:
unmutelist.append(str(msg[2]).replace('<', '').replace('>', '').replace('!', '').replace('@', ''))
out = f'{msg[2]} was unmuted.'
else:
out = 'YOOOOOOOOOOOOOOOOLLLLLLLLlllll! You Not The Admin!'
except:
out = 'Please provide user to unmute.'
elif msg[1] == "img":
try:
out = f"https://picsum.photos/seed/{ str(msg[2]) }/1920/1080"
except:
out = f"https://picsum.photos/seed/{ random.randint(1, 1000000) }/1920/1080"
except:
out = "Yes!?"
else:
pass
return_value = [
not(out == ""),
out,
delete,
connectVoice,
voiceChannel,
song_url,
repeat,
calls,
mutelist,
unmutelist
]
return return_value
except:
pass