taslim19 commited on
Commit
71c7dff
·
1 Parent(s): 48dd506

feat: apply multiple user-requested changes

Browse files
DragMusic/plugins/goodnight.py DELETED
@@ -1,42 +0,0 @@
1
- import re
2
- from dotenv import load_dotenv
3
- from pyrogram import filters
4
- import random
5
- from pyrogram.types import Message
6
- from pyrogram import Client, filters
7
- from DragMusic import app
8
-
9
-
10
-
11
- # "/gn" command ka handler
12
- @app.on_message(filters.command("oodnight", prefixes="g"))
13
- def goodnight_command_handler(client: Client, message: Message):
14
- # Randomly decide whether to send a sticker or an emoji
15
- send_sticker = random.choice([True, False])
16
-
17
- # Send a sticker or an emoji based on the random choice
18
- if send_sticker:
19
- client.send_sticker(message.chat.id, get_random_sticker())
20
- else:
21
- client.send_message(message.chat.id, get_random_emoji())
22
-
23
- # Function to get a random sticker
24
- def get_random_sticker():
25
- stickers = [
26
- "CAACAgQAAx0Ce9_hCAACaEVlwn7HeZhgwyVfKHc3WUGC_447IAACLgwAAkQwKVPtub8VAR018x4E",
27
- "CAACAgIAAx0Ce9_hCAACaEplwn7dvj7G0-a1v3wlbN281RMX2QACUgwAAligOUoi7DhLVTsNsh4E",
28
- "CAACAgIAAx0Ce9_hCAACaFBlwn8AAZNB9mOUvz5oAyM7CT-5pjAAAtEKAALa7NhLvbTGyDLbe1IeBA",
29
- "CAACAgUAAx0CcmOuMwACldVlwn9ZHHF2-S-CuMSYabwwtVGC3AACOAkAAoqR2VYDjyK6OOr_Px4E",
30
- "CAACAgIAAx0Ce9_hCAACaFVlwn-fG58GKoEmmZpVovxEj4PodAACfwwAAqozQUrt2xSTf5Ac4h4E",
31
- ]
32
- return random.choice(stickers)
33
-
34
- # Function to get a random emoji
35
- def get_random_emoji():
36
- emojis = [
37
- "😴",
38
- "😪",
39
- "💤",
40
-
41
- ]
42
- return random.choice(emojis)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DragMusic/plugins/sudo/gban.py CHANGED
@@ -23,7 +23,13 @@ async def global_ban(client, message: Message, _):
23
  if not message.reply_to_message:
24
  if len(message.command) != 2:
25
  return await message.reply_text(_["general_1"])
26
- user = await extract_user(message)
 
 
 
 
 
 
27
  if user.id == message.from_user.id:
28
  return await message.reply_text(_["gban_1"])
29
  elif user.id == app.id:
@@ -78,7 +84,13 @@ async def global_un(client, message: Message, _):
78
  if not message.reply_to_message:
79
  if len(message.command) != 2:
80
  return await message.reply_text(_["general_1"])
81
- user = await extract_user(message)
 
 
 
 
 
 
82
  is_gbanned = await is_banned_user(user.id)
83
  if not is_gbanned:
84
  return await message.reply_text(_["gban_7"].format(user.mention))
 
23
  if not message.reply_to_message:
24
  if len(message.command) != 2:
25
  return await message.reply_text(_["general_1"])
26
+ user = message.command[1]
27
+ if "@" in user:
28
+ user = user.replace("@", "")
29
+ user = await app.get_users(user)
30
+ else:
31
+ user = await extract_user(message)
32
+
33
  if user.id == message.from_user.id:
34
  return await message.reply_text(_["gban_1"])
35
  elif user.id == app.id:
 
84
  if not message.reply_to_message:
85
  if len(message.command) != 2:
86
  return await message.reply_text(_["general_1"])
87
+ user = message.command[1]
88
+ if "@" in user:
89
+ user = user.replace("@", "")
90
+ user = await app.get_users(user)
91
+ else:
92
+ user = await extract_user(message)
93
+
94
  is_gbanned = await is_banned_user(user.id)
95
  if not is_gbanned:
96
  return await message.reply_text(_["gban_7"].format(user.mention))
DragMusic/plugins/sudo/restart.py CHANGED
@@ -31,7 +31,7 @@ async def is_heroku():
31
  @language
32
  async def log_(client, message, _):
33
  try:
34
- await message.reply_document(document="log.txt")
35
  except:
36
  await message.reply_text(_["server_1"])
37
 
 
31
  @language
32
  async def log_(client, message, _):
33
  try:
34
+ await message.reply_document(document="/tmp/logs.txt")
35
  except:
36
  await message.reply_text(_["server_1"])
37
 
DragMusic/plugins/tools/chatlog.py CHANGED
@@ -47,9 +47,6 @@ async def on_left_chat_member(_, message: Message):
47
  await app.send_message(
48
  LOG_GROUP_ID,
49
  text=left,
50
- reply_markup=InlineKeyboardMarkup([
51
- [InlineKeyboardButton(f"ᴀᴅᴅ ᴍᴇ ʟᴏᴠᴇ", url=f"https://t.me/{(await app.get_me()).username}?startgroup=true")]
52
- ]),
53
  message_thread_id=12279
54
  )
55
  except Exception as e:
 
47
  await app.send_message(
48
  LOG_GROUP_ID,
49
  text=left,
 
 
 
50
  message_thread_id=12279
51
  )
52
  except Exception as e:
DragMusic/plugins/tools/welcome.py DELETED
@@ -1,312 +0,0 @@
1
- import os
2
- from PIL import ImageDraw, Image, ImageFont, ImageChops
3
- from pyrogram import *
4
- from pyrogram.types import *
5
- from logging import getLogger
6
- from DragMusic import app
7
- from typing import Union
8
- import textwrap
9
-
10
-
11
-
12
-
13
-
14
- LOGGER = getLogger(__name__)
15
-
16
- class WelDatabase:
17
- def __init__(self):
18
- self.data = {}
19
-
20
- async def find_one(self, chat_id):
21
- return chat_id in self.data
22
-
23
- async def add_wlcm(self, chat_id):
24
- self.data[chat_id] = {}
25
-
26
- async def rm_wlcm(self, chat_id):
27
- if chat_id in self.data:
28
- del self.data[chat_id]
29
-
30
- wlcm = WelDatabase()
31
-
32
- class temp:
33
- ME = None
34
- CURRENT = 2
35
- CANCEL = False
36
- MELCOW = {}
37
- U_NAME = None
38
- B_NAME = None
39
-
40
- # ... (rest of your code remains unchanged)
41
-
42
- # ... (FUCK you randi ke bacvhhe )
43
-
44
- def circle(pfp, size=(500, 500)):
45
- pfp = pfp.resize(size, Image.ANTIALIAS).convert("RGBA")
46
- bigsize = (pfp.size[0] * 3, pfp.size[1] * 3)
47
- mask = Image.new("L", bigsize, 0)
48
- draw = ImageDraw.Draw(mask)
49
- draw.ellipse((0, 0) + bigsize, fill=255)
50
- mask = mask.resize(pfp.size, Image.ANTIALIAS)
51
- mask = ImageChops.darker(mask, pfp.split()[-1])
52
- pfp.putalpha(mask)
53
- return pfp
54
-
55
- def welcomepic(pic, user, chatname, id, uname):
56
- background = Image.open("DragMusic/assets/wel2.png")
57
- pfp = Image.open(pic).convert("RGBA")
58
- pfp = circle(pfp)
59
- pfp = pfp.resize((825, 824))
60
- draw = ImageDraw.Draw(background)
61
- font = ImageFont.truetype('DragMusic/assets/font.ttf', size=110)
62
- welcome_font = ImageFont.truetype('DragMusic/assets/font.ttf', size=60)
63
- draw.text((2100, 1420), f'ID: {id}', fill=(12000, 12000, 12000), font=font)
64
- pfp_position = (1990, 435)
65
- background.paste(pfp, pfp_position, pfp)
66
- background.save(f"/tmp/downloads/welcome#{id}.png")
67
- return f"/tmp/downloads/welcome#{id}.png"
68
-
69
- # FUCK you bhosadiwale
70
-
71
-
72
- @app.on_message(filters.command("wel") & ~filters.private)
73
- async def auto_state(_, message):
74
- usage = "**Usage:**\n⦿/wel [on|off]"
75
- if len(message.command) == 1:
76
- return await message.reply_text(usage)
77
- chat_id = message.chat.id
78
- user = await app.get_chat_member(message.chat.id, message.from_user.id)
79
- if user.status in (
80
- enums.ChatMemberStatus.ADMINISTRATOR,
81
- enums.ChatMemberStatus.OWNER,
82
- ):
83
- A = await wlcm.find_one(chat_id)
84
- state = message.text.split(None, 1)[1].strip().lower()
85
- if state == "on":
86
- if A:
87
- return await message.reply_text("Special Welcome Already Enabled")
88
- elif not A:
89
- await wlcm.add_wlcm(chat_id)
90
- await message.reply_text(f"Enabled Special Welcome in {message.chat.title}")
91
- elif state == "off":
92
- if not A:
93
- return await message.reply_text("Special Welcome Already Disabled")
94
- elif A:
95
- await wlcm.rm_wlcm(chat_id)
96
- await message.reply_text(f"Disabled Special Welcome in {message.chat.title}")
97
- else:
98
- await message.reply_text(usage)
99
- else:
100
- await message.reply("Only Admins Can Use This Command")
101
-
102
- # ... (copy paster teri maa ki chut )
103
-
104
- @app.on_chat_member_updated(filters.group, group=-3)
105
- async def greet_group(_, member: ChatMemberUpdated):
106
- chat_id = member.chat.id
107
- A = await wlcm.find_one(chat_id)
108
- if not A:
109
- return
110
- if (
111
- not member.new_chat_member
112
- or member.new_chat_member.status in {"banned", "left", "restricted"}
113
- or member.old_chat_member
114
- ):
115
- return
116
- user = member.new_chat_member.user if member.new_chat_member else member.from_user
117
- try:
118
- pic = await app.download_media(
119
- user.photo.big_file_id, file_name=f"/tmp/downloads/pp{user.id}.png"
120
- )
121
- except AttributeError:
122
- pic = "DragMusic/assets/upic.png"
123
- if (temp.MELCOW).get(f"welcome-{member.chat.id}") is not None:
124
- try:
125
- await temp.MELCOW[f"welcome-{member.chat.id}"].delete()
126
- except Exception as e:
127
- LOGGER.error(e)
128
- try:
129
- welcomeimg = welcomepic(
130
- pic, user.first_name, member.chat.title, user.id, user.username
131
- )
132
- temp.MELCOW[f"welcome-{member.chat.id}"] = await app.send_photo(
133
- member.chat.id,
134
- photo=welcomeimg,
135
- caption=f"""
136
- **❀ ᴡᴇʟᴄᴏᴍᴇ ᴛᴏ ᴛʜᴇ {member.chat.title} ɢʀᴏᴜᴘ ❀
137
-
138
- ๏ ɴᴀᴍᴇ ➛ {user.mention}
139
- ๏ ɪᴅ ➛ {user.id}
140
- ๏ ᴜsᴇʀɴᴀᴍᴇ ➛ @{user.username}
141
- """,
142
- reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(f"ᴀᴅᴅ ᴍᴇ ʙᴀʙʏ", url=f"https://t.me/{(await app.get_me()).username}?startgroup=true")]])
143
- )
144
- except Exception as e:
145
- LOGGER.error(e)
146
- try:
147
- os.remove(f"/tmp/downloads/welcome#{user.id}.png")
148
- os.remove(f"/tmp/downloads/pp{user.id}.png")
149
- except Exception as e:
150
- pass
151
-
152
- # ... (resfuxbk
153
-
154
- @app.on_message(filters.new_chat_members & filters.group, group=-1)
155
- async def bot_wel(_, message):
156
- for u in message.new_chat_members:
157
- if u.id == app.me.id:
158
- await app.send_message(message.chat.id, "Thanks for adding me to your group.")
159
-
160
- async def welcome_captcha(
161
- _, message: Message, cb_data: dict, failed: bool = False
162
- ) -> Union[int, bool]:
163
- if failed:
164
- photo = (
165
- "https://telegra.ph/file/223695233211590f7ac71.jpg"
166
- )
167
- else:
168
- photo = (
169
- "https://telegra.ph/file/223695233211590f7ac71.jpg"
170
- )
171
- background = Image.open(photo)
172
- background = background.resize((1280, 720))
173
-
174
- #
175
- image3 = Image.new("RGBA", (1280, 720))
176
- image3.paste(background, (0, 0))
177
- #
178
-
179
- # Drawing with Impact Font
180
- draw = ImageDraw.Draw(image3)
181
- font = ImageFont.truetype("DragMusic/assets/font.ttf", 60)
182
- font2 = ImageFont.truetype("DragMusic/assets/font2.ttf", 70)
183
- arial = ImageFont.truetype("DragMusic/assets/font2.ttf", 40)
184
- gfont = ImageFont.truetype("DragMusic/assets/font2.tf", 40)
185
- para = textwrap.wrap(title, width=32)
186
- j = 0
187
- try:
188
- if para[0]:
189
- draw.text(
190
- (5, 5),
191
- f"{para[0]}",
192
- fill="white",
193
- stroke_width=3,
194
- stroke_fill="black",
195
- font=font,
196
- )
197
- if para[1]:
198
- draw.text(
199
- (5, 70),
200
- f"{para[1]}",
201
- fill="white",
202
- stroke_width=3,
203
- stroke_fill="black",
204
- font=font,
205
- )
206
- except:
207
- pass
208
- text_w, text_h = draw.textsize(f"Welcome to {ctitle}", font=gfont)
209
- draw.text(
210
- ((1280 - text_w) / 2, 615),
211
- f"Welcome to {ctitle}",
212
- fill="white",
213
- font=gfont,
214
- )
215
- draw.text((740, 480), "NAME:", fill="white", font=arial)
216
- draw.text(
217
- (915, 480),
218
- f"{fullname}",
219
- fill="white",
220
- font=arial,
221
- )
222
- draw.text(
223
- (740, 530),
224
- f"USERNAME : @{uname}",
225
- (255, 255, 255),
226
- font=arial,
227
- )
228
-
229
- background.save(f"/tmp/downloads/welcome#{id}.png")
230
- return f"/tmp/downloads/welcome#{id}.png"
231
-
232
-
233
- async def on_new_chat_member(client, message: Message):
234
- if not await is_approved(message.chat.id):
235
- return await message.reply_text(
236
- f"Greetings {message.from_user.mention}, and welcome to {message.chat.title}.\n\n{app.mention} do not have permission to work here. You must request permission from my owner."
237
- )
238
- if message.from_user.id in BANNED_USERS:
239
- return
240
- if (await client.get_me()).id in [user.id for user in message.new_chat_members]:
241
- return
242
- for user in message.new_chat_members:
243
- if await is_gbanned_user(user.id):
244
- await message.chat.ban_member(user.id)
245
- await message.reply_text(
246
- f"{user.mention} was globally banned, so I'm kicking them. Sorry for the inconvenience."
247
- )
248
- return
249
- if user.is_bot:
250
- return
251
- if not await is_welcome_on(message.chat.id):
252
- continue
253
- # Check if the user is a bot
254
- if user.is_bot:
255
- return # Do not send a welcome message to bots
256
-
257
- # Get the welcome message and buttons for the chat
258
- welcome, buttons = await get_welcome(str(message.chat.id))
259
-
260
- # Replace placeholders in the welcome message with user and chat information
261
- mention = user.mention
262
- title = message.chat.title
263
- fullname = user.first_name + " " + user.last_name if user.last_name else user.first_name
264
- username = f"@{user.username}" if user.username else "NO USERNAME"
265
- user_id = user.id
266
- # Send the welcome message with the custom buttons
267
- await client.send_message(
268
- chat_id=message.chat.id,
269
- text=welcome.format(
270
- mention=mention,
271
- title=title,
272
- fullname=fullname,
273
- username=username,
274
- id=user_id,
275
- ),
276
- reply_markup=InlineKeyboardMarkup(buttons),
277
- disable_web_page_preview=True,
278
- )
279
-
280
-
281
- async def on_user_left(client, message: Message):
282
- if not await is_goodbye_on(message.chat.id):
283
- return
284
- if await is_gbanned_user(message.left_chat_member.id):
285
- return
286
-
287
- left = message.left_chat_member
288
- if left.is_bot:
289
- return # Do not send a goodbye message to bots
290
-
291
- # Get the goodbye message and buttons for the chat
292
- goodbye, buttons = await get_goodbye(str(message.chat.id))
293
-
294
- # Replace placeholders in the goodbye message with user and chat information
295
- mention = left.mention
296
- title = message.chat.title
297
- fullname = left.first_name + " " + left.last_name if left.last_name else left.first_name
298
- username = f"@{left.username}" if left.username else "NO USERNAME"
299
- user_id = left.id
300
- # Send the goodbye message with the custom buttons
301
- await client.send_message(
302
- chat_id=message.chat.id,
303
- text=goodbye.format(
304
- mention=mention,
305
- title=title,
306
- fullname=fullname,
307
- username=username,
308
- id=user_id,
309
- ),
310
- reply_markup=InlineKeyboardMarkup(buttons),
311
- disable_web_page_preview=True,
312
- )