-
Notifications
You must be signed in to change notification settings - Fork 2
/
client.py
508 lines (401 loc) · 17 KB
/
client.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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
from json import load
import discord
from discord import embeds
from discord.ext import commands, tasks
import json
from difflib import SequenceMatcher
import aiohttp
import youtube_dl
from youtube_dl import YoutubeDL
import json
import bs4
import asyncio
import random
from functools import partial
from bs4 import BeautifulSoup
TOKEN = "توکن بات"
intents = discord.Intents.all()
intents.members = True
client = commands.Bot(command_prefix="-", help_command=None, intents=intents)
count = 0
@client.event
async def on_ready():
changing.start()
print('im ready!@ :DD')
await playsong()
print("voice ready dude")
async def playsong():
minehack = client.get_guild(771435036468838451)
vcchannel = minehack.get_channel(827272150095233054)
def playagain(source, vc):
source = discord.FFmpegPCMAudio(
f'sound.mp3')
vc.play(source, after=lambda e: playagain(source, vc))
try:
vc = await vcchannel.connect()
source = discord.FFmpegPCMAudio(
f'sound.mp3')
vc.play(
source, after=lambda e: playagain(source, vc))
except Exception as ex:
print(ex)
@tasks.loop(minutes=30)
async def changing():
global count
guild = client.get_guild(771435036468838451)
count = guild.member_count
await client.change_presence(status=discord.Status.dnd,
activity=discord.Activity(type=discord.ActivityType.watching,
name=f" {str(count)} Members in MineHack"))
@client.event
async def on_member_join(member):
channel = client.get_channel(771438539178639383)
rules = client.get_channel(771443829999665192)
embed = discord.Embed(
title="خوش اومدی به جامعه ی ماین هک!",
description=f"""قبل از شروع حتما چنل ({rules.mention}) رو مطلعه کن \n امیدوارم لحظات خوبی رو سرپی کنی.""",
color=0x1C2732
)
embed.set_thumbnail(url=member.avatar_url)
embed.set_footer(text="By MineHack Community")
await channel.send(embed=embed, content=f"{member.mention}")
@client.command()
async def help(ctx):
embed = discord.Embed(
title="راهنمای استفاده از بات",
description="-info [تاپیک] \n -thx تشکر کردن زیبا \n -noobsanj [ @Member (optional) ] \n -addpand [pand] \n -google [سرچ]",
color=0x1C2732
)
await ctx.send(embed=embed)
@client.command()
async def thx(ctx):
embed = discord.Embed(
title="ممون که به سوالم جواب دادی",
description="اینم به افتخار شما",
color=0xf47fff
)
embed.set_image(url="https://cdn.discordapp.com/attachments/771804409981567016/824733947316928513/7c57-ezgif-com-gif-maker-1-.gif")
await ctx.send(embed=embed)
@client.command()
# https://www.spigotmc.org/search/235/?q={key}&t=resource_update&o=relevance&c[title_only]
async def search(ctx, *, key=None):
# params={
# "api_key": "KHQTJ01Y4LQVFL65GIM0XP6BD0GL6FLK8FNACWN57N5XOC8OJSAQF42NJUR8YRVQFLD8SI03E9BHUMZ6",
# "url": f"https://www.spigotmc.org/search/235/?q={key}&t=resource_update&o=relevance&c[title_only]",
# "premium_proxy": "true",
# "country_code":"se"
# }
# async with aiohttp.request("GET", f"https://app.scrapingbee.com/api/v1/", params=params) as r:
# response = await r.read()
# print(response)
# embed = discord.Embed(
# title="در حال جستجو....",
# description="در حال جستجوی پلاگین ها در اسپیگات، لطفا کی صبر کنید.",
# color=0x1C2732
# )
# embed.set_footer(text=f"By Minehack Community - Seach requested by: {ctx.author.name}")
# msg = await ctx.send(embed=embed)
# searches = {}
# soup = BeautifulSoup(response, "html.parser")
# all = soup.find_all('h3', class_="title")
# authors = soup.find_all('a', class_="username")
# count = -1
# for i in all:
# count = count + 1
# title = i.a.text
# link = "https://www.spigotmc.org/" + i.a["href"]
# searches[title] = {}
# searches[title]["link"] = link
# searches[title]["author"] = authors[count].text
# if len(authors) == 0:
# embed = discord.Embed(
# title="چیزی پیدا نکردم...",
# description="متاسفانه نتونستم پلاگینی با این اسم پیدا کنم.",
# color=0x1C2732
# )
# embed.set_footer(text=f"By Minehack Community - Seach requested by: {ctx.author.name}")
# await msg.edit(embed=embed)
# else:
# laststring = ""
# for i in searches:
# title = i
# link = searches[i]["link"]
# author = searches[i]["author"]
# if not len(laststring + f"[{title}]({link}) | **By {author}** \n ") > 2048:
# laststring = laststring + f"[{title}]({link}) | **By {author}** \n "
# embed = discord.Embed(
# title=f"{str(len(authors))} نتیجه پیدا کردم.",
# description=laststring,
# color=0x1C2732
# )
# embed.set_footer(text=f"By Minehack Community - Seach requested by: {ctx.author.name}")
# await msg.edit(embed=embed)
await ctx.send("این قابلیت به دلیل مطابقت نداشتن با قوانین اسپیگات حذف شد.")
async def getHelpEmbed(ctx):
embed = discord.Embed(
title="راهنمای استفاده:",
description="""
دیدن توضیحات یک تاپیک
``-info اسم تاپیک``
Topic Managers Role:
اینجاد توضیحات درباره یک تاپیک
``-info create [اسم تاپیک ( 1 کلمه)] [توضیحات تاپیک]``
پاک کردن یک تاپیک:
``-info delete [اسم تاپیک]``
ادیت تاپیک:
``-info edit [اسم تاپیک ( 1 کلمه)] [توضیحات تاپیک]``
""",
color=0x1C2732
)
embed.set_author(name=ctx.author.name, icon_url=ctx.author.avatar_url)
embed.set_footer(text="By Minehack Community - Author: Dead_Light")
return embed
async def checkForOtherArguments(usage, key, description):
if usage == "create" or usage == "edit":
if key == "" or description == "":
return False
else:
return True
elif usage == "delete":
if key == "":
return False
else:
return True
async def rightPerm(ctx):
roles = [771437443755802664, 780513428799356951, 758428780422496280, 771437918857199617]
roleids = ctx.author.roles
memberid = ctx.author.id
result = False
if memberid in roles:
result = True
for i in roleids:
if i.id in roles:
result = True
return result
async def rightpandgiver(ctx):
roles = [824736294176555008]
roleids = ctx.author.roles
memberid = ctx.author.id
result = False
if memberid in roles:
result = True
for i in roleids:
if i.id in roles:
result = True
return result
def similar(a, b):
return SequenceMatcher(None, a, b).ratio()
#info create login aodpmawpdawpdawdo
@client.command()
async def info(ctx, usage="", key="", *, description=""):
#help command
if usage == "":
embed = await getHelpEmbed(ctx)
await ctx.send(embed=embed)
elif usage.lower() == "create":
if await checkForOtherArguments(usage.lower(), key, description) == False:
await ctx.send(embed=await getHelpEmbed())
else:
if await rightPerm(ctx):
with open("data.json", "r") as f:
loaded = json.load(f)
if key.lower() in loaded:
await ctx.send("این تاپیک قبلا به ثبت رسیده!")
else:
loaded[key.lower()] = {}
loaded[key.lower()]["description"] = description
loaded[key.lower()]["by"] = ctx.author.name
with open('data.json', 'w') as f:
json.dump(loaded, f)
embed = discord.Embed(
title=f"تاپیک ({key}) با موفقیت ثبت شد",
description=f"""
توضیحات تاپیک:
\n
{description}
``-info {key}``
"""
)
embed.set_footer(text=f"By Minehack Community - {ctx.author.name}")
await ctx.send(embed=embed)
else:
await ctx.send("دسترسی این کار برای شما وجود ندارد.")
elif usage.lower() == "delete":
if await checkForOtherArguments(usage.lower(), key, description) == False:
await ctx.send(embed=await getHelpEmbed(ctx))
else:
if await rightPerm(ctx):
with open("data.json", "r") as f:
loaded = json.load(f)
if not key.lower() in loaded:
await ctx.send("این تاپیک وجود ندارد.")
else:
del loaded[key.lower()]
with open('data.json', 'w') as f:
json.dump(loaded, f)
await ctx.send("این تاپیک با موفقیت حذف شد.")
else:
await ctx.send("دسترسی این کار برای شما وجود ندارد.")
elif usage.lower() == "edit":
if await checkForOtherArguments(usage.lower(), key, description) == False:
await ctx.send(embed=await getHelpEmbed(ctx))
else:
if await rightPerm(ctx):
with open("data.json", "r") as f:
loaded = json.load(f)
if not key.lower() in loaded:
await ctx.send("این تاپیک وجود ندارد.")
else:
loaded[key.lower()]["description"] = description
loaded[key.lower()]["by"] = ctx.author.name
with open('data.json', 'w') as f:
json.dump(loaded, f)
await ctx.send("توضیحات این تاپیک ادیت شد.")
else:
await ctx.send("دسترسی این کار برای شما وجود ندارد.")
else:
usage = usage.lower()
with open("data.json", "r") as f:
loaded = json.load(f)
if usage in loaded:
description = loaded[usage]["description"]
by = loaded[usage]["by"]
embed = discord.Embed(
title=f"درباره تاپیک: {usage}",
description=description,
color=0x1C2732
)
embed.set_footer(text=f"By Minehack Community - {by}")
await ctx.send(embed=embed)
else:
list = []
results = []
for i in loaded:
list.append(i)
for i in list:
if i in usage or usage in i:
results.append(i)
description = ''
if len(results) != 0:
for i in results:
description = description + f"\n ``-info {i}``"
embed = discord.Embed(
title="منظور شما این بود؟",
description=description,
color=0x1C2732
)
embed.set_author(name=ctx.author.name, icon_url=ctx.author.avatar_url)
embed.set_footer(text="By Minehack Community - Author: Dead_Light")
await ctx.send(embed=embed)
else:
results = []
for i in list:
if similar(i, usage.lower()) >= 0.5:
results.append(i)
if len(results) != 0:
for i in results:
description = description + f"\n ``-info {i}``"
embed = discord.Embed(
title="منظور شما این بود؟",
description=description,
color=0x1C2732
)
embed.set_author(name=ctx.author.name, icon_url=ctx.author.avatar_url)
embed.set_footer(text="By Minehack Community - Author: Dead_Light")
await ctx.send(embed=embed)
else:
await ctx.send("این تاپیک وجود ندارد.")
@commands.cooldown(1, 30, commands.BucketType.user)
@client.command()
async def noobsanj(ctx, member : discord.Member = None):
num1 = random.randint(0, 100)
randompand = await getArandomPand()
randompand = randompand.replace("*", f"{num1}")
if member is None:
member = ctx.author
if num1 > 80:
embed = discord.Embed(
title=f"شما مرز های نوبیت رو رد کردید!",
description=randompand,
color=0xFF5733
)
embed.set_thumbnail(url="https://cdn.discordapp.com/attachments/771804409981567016/824725361915854848/sticker4webp.webp")
await ctx.send(content=member.mention, embed=embed)
elif num1 > 50:
embed = discord.Embed(
title=f"شما به طور نا متعادلی نوب هستید",
description=randompand,
color=0xFF5733
)
embed.set_thumbnail(url="https://cdn.discordapp.com/attachments/771804409981567016/824725309144039445/sticker2.webp")
await ctx.send(content=member.mention, embed=embed)
elif num1 > 20:
embed = discord.Embed(
title=f"شما فقط نوبی با درصد کم هستید",
description=randompand,
color=0xFF5733
)
embed.set_thumbnail(url="https://cdn.discordapp.com/attachments/771804409981567016/824725280005423194/sticker.webp")
await ctx.send(content=member.mention, embed=embed)
elif num1 > 0:
embed = discord.Embed(
title=f"شما درصد نوبیت قابل قبولی دارید",
description=randompand,
color=0xFF5733
)
embed.set_thumbnail(url="https://cdn.discordapp.com/attachments/771804409981567016/824725337074040862/sticker3.webp")
await ctx.send(content=member.mention, embed=embed)
# @client.event
# async def on_message(message):
# if message.guild.id == 771435036468838451:
# print(message.content)
async def getArandomPand():
with open("noobsanj.json", "r") as f:
loaded = json.load(f)
pands = len(loaded["pands"])
randnum = random.randint(0, pands - 1)
return loaded["pands"][randnum]
@commands.cooldown(1, 3600, commands.BucketType.user)
@client.command()
async def addpand(ctx):
result = await rightpandgiver(ctx)
if result:
if "*" in ctx.message.content:
with open("noobsanj.json", "r") as f:
loaded = json.load(f)
loaded["pands"].append(ctx.message.content.replace("-addpand", ""))
with open('noobsanj.json', 'w') as f:
json.dump(loaded, f)
await ctx.send("پند شما اضافه شد")
else:
await ctx.send("حتما در پند خود از * به عنوان درصد نوبیت فرد استفاده کنید")
else:
await ctx.send("شما رول پند دهنده را ندارید! - برای دریافت این رول به ماین هک در سایت دیسکورد فا رای دهید")
@noobsanj.error
async def noobsanjerror(ctx, error):
if isinstance(error, commands.CommandOnCooldown):
msg = "شما هر 30 ثانیه میتوانید از نوب سنج استفاده کنید"
await ctx.send(msg)
else:
raise error
@addpand.error
async def addpanderror(ctx, error):
if isinstance(error, commands.CommandOnCooldown):
msg = "شما هر 1 ساعت می توانید 3 پند اضافه کنید."
await ctx.send(msg)
else:
raise error
@client.command()
async def google(ctx, *, content):
link = f"https://letmegooglethat.com/?q={content}".replace(" ", "+")
embed = discord.Embed(
title="جواب سوال شما پیدا شد - کلیک کنید",
url=link
)
embed.set_thumbnail(url="https://cdn.discordapp.com/attachments/771804409981567016/825030603740938281/3.jpg")
await ctx.send(embed=embed)
@client.command()
async def bego(ctx, *, content):
channel = client.get_channel(771438539178639383)
await channel.send(content)
client.run(TOKEN)