taslim19 commited on
Commit
dbf6a24
Β·
1 Parent(s): 616a9b8

fix: use get_video_info_from_bitflow for Bitflow API in /song and /vsong

Browse files
DragMusic/plugins/plugins/dsong.py CHANGED
@@ -19,7 +19,7 @@ async def vsong_cmd(client, message):
19
  infomsg = await message.reply_text("<b>πŸ” Searching...</b>", quote=False)
20
  query = message.text.split(None, 1)[1]
21
  try:
22
- bitflow = await YouTubeAPI().bitflow_video(query, api_key=BITFLOW_API_KEY)
23
  if not bitflow or bitflow.get("status") != "success":
24
  return await infomsg.edit("<b>πŸ” Searching...\n\n No result from Bitflow API.</b>")
25
  url = bitflow["url"]
@@ -83,7 +83,7 @@ async def song_cmd(client, message):
83
  infomsg = await message.reply_text("<b>πŸ” Searching...</b>", quote=False)
84
  query = message.text.split(None, 1)[1]
85
  try:
86
- bitflow = await YouTubeAPI().bitflow_video(query, api_key=BITFLOW_API_KEY)
87
  if not bitflow or bitflow.get("status") != "success":
88
  return await infomsg.edit("<b>πŸ” Searching...\n\nNo result from Bitflow API.</b>")
89
  url = bitflow["url"]
 
19
  infomsg = await message.reply_text("<b>πŸ” Searching...</b>", quote=False)
20
  query = message.text.split(None, 1)[1]
21
  try:
22
+ bitflow = await YouTubeAPI().get_video_info_from_bitflow(query, video=True)
23
  if not bitflow or bitflow.get("status") != "success":
24
  return await infomsg.edit("<b>πŸ” Searching...\n\n No result from Bitflow API.</b>")
25
  url = bitflow["url"]
 
83
  infomsg = await message.reply_text("<b>πŸ” Searching...</b>", quote=False)
84
  query = message.text.split(None, 1)[1]
85
  try:
86
+ bitflow = await YouTubeAPI().get_video_info_from_bitflow(query, video=False)
87
  if not bitflow or bitflow.get("status") != "success":
88
  return await infomsg.edit("<b>πŸ” Searching...\n\nNo result from Bitflow API.</b>")
89
  url = bitflow["url"]
DragMusic/plugins/plugins/nsfw.py CHANGED
@@ -18,6 +18,7 @@ db_client = AsyncIOMotorClient(MONGO_DB_URI)
18
  db = db_client['AnonXDatabase']
19
  nsfw_chats_collection = db['nsfw_chats']
20
  nsfw_stickers_collection = db['nsfw_stickers']
 
21
 
22
  # Logger configuration
23
  LOGGER_ID = -1002471976725
@@ -74,9 +75,9 @@ async def whoami(client: Client, message: Message):
74
  try:
75
  member = await client.get_chat_member(message.chat.id, message.from_user.id)
76
  await message.reply_text(
77
- f"πŸ‘€ Your user ID: `{message.from_user.id}`\n"
78
- f"πŸ“’ Chat ID: `{message.chat.id}`\n"
79
- f"πŸ›‘οΈ Your status: `{member.status}`",
80
  quote=True,
81
  parse_mode=ParseMode.HTML
82
  )
@@ -98,6 +99,9 @@ async def auto_nsfw_scan(client: Client, message: Message):
98
 
99
  # NSFW scan handler
100
  async def scan_media(media_msg: Message, reply_msg: Message):
 
 
 
101
  media = media_msg.photo or media_msg.video or media_msg.sticker
102
  path = None
103
  image_path = None
@@ -146,32 +150,30 @@ async def scan_media(media_msg: Message, reply_msg: Message):
146
  await media_msg.delete()
147
  except Exception as e:
148
  print(f"[NSFW] Failed to delete message: {e}")
149
- # Button to go to group
 
 
 
 
 
 
 
 
150
  from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
151
  group_link = None
152
  if reply_msg.chat.username:
153
  group_link = f"https://t.me/{reply_msg.chat.username}"
154
  else:
155
- # For private/supergroups, use deep link to the group (no message jump)
156
  group_link = f"https://t.me/c/{str(reply_msg.chat.id)[4:]}" if str(reply_msg.chat.id).startswith("-100") else None
157
  buttons = InlineKeyboardMarkup([
158
  [InlineKeyboardButton("Go to Group", url=group_link)] if group_link else []
159
  ])
160
- await reply_msg.reply(
161
- f"🚫 NSFW Detected ({confidence}%) β€” Message deleted.",
162
- reply_markup=buttons if group_link else None
163
- )
164
- log_text = (
165
- f"🚨 NSFW Content Detected\n"
166
- f"Chat: {reply_msg.chat.title} (`{reply_msg.chat.id}`)\n"
167
- f"User: {media_msg.from_user.mention if media_msg.from_user else 'Unknown'}\n"
168
- f"Confidence: {confidence}%"
169
- )
170
  try:
171
  await app.send_message(
172
  chat_id=LOGGER_ID,
173
  text=log_text,
174
- message_thread_id=LOGGER_TOPIC_ID
 
175
  )
176
  except Exception as log_err:
177
  print(f"[NSFW Logger Error] {log_err}")
@@ -187,3 +189,41 @@ async def scan_media(media_msg: Message, reply_msg: Message):
187
  os.remove(path)
188
  if image_path and os.path.exists(image_path):
189
  os.remove(image_path)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  db = db_client['AnonXDatabase']
19
  nsfw_chats_collection = db['nsfw_chats']
20
  nsfw_stickers_collection = db['nsfw_stickers']
21
+ nauth_collection = db['nsfw_nauth']
22
 
23
  # Logger configuration
24
  LOGGER_ID = -1002471976725
 
75
  try:
76
  member = await client.get_chat_member(message.chat.id, message.from_user.id)
77
  await message.reply_text(
78
+ f"πŸ‘€ Your user ID: {message.from_user.id}\n"
79
+ f"πŸ“’ Chat ID: {message.chat.id}\n"
80
+ f"πŸ›‘οΈ Your status: {member.status}",
81
  quote=True,
82
  parse_mode=ParseMode.HTML
83
  )
 
99
 
100
  # NSFW scan handler
101
  async def scan_media(media_msg: Message, reply_msg: Message):
102
+ # Ignore scan if user is in nauth list
103
+ if await is_nauth(reply_msg.chat.id, media_msg.from_user.id):
104
+ return
105
  media = media_msg.photo or media_msg.video or media_msg.sticker
106
  path = None
107
  image_path = None
 
150
  await media_msg.delete()
151
  except Exception as e:
152
  print(f"[NSFW] Failed to delete message: {e}")
153
+ await reply_msg.reply(
154
+ f"🚫 NSFW Detected ({confidence}%) β€” Message deleted."
155
+ )
156
+ log_text = (
157
+ f"🚨 NSFW Content Detected\n"
158
+ f"Chat: {reply_msg.chat.title} (`{reply_msg.chat.id}`)\n"
159
+ f"User: {media_msg.from_user.mention if media_msg.from_user else 'Unknown'}\n"
160
+ f"Confidence: {confidence}%"
161
+ )
162
  from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
163
  group_link = None
164
  if reply_msg.chat.username:
165
  group_link = f"https://t.me/{reply_msg.chat.username}"
166
  else:
 
167
  group_link = f"https://t.me/c/{str(reply_msg.chat.id)[4:]}" if str(reply_msg.chat.id).startswith("-100") else None
168
  buttons = InlineKeyboardMarkup([
169
  [InlineKeyboardButton("Go to Group", url=group_link)] if group_link else []
170
  ])
 
 
 
 
 
 
 
 
 
 
171
  try:
172
  await app.send_message(
173
  chat_id=LOGGER_ID,
174
  text=log_text,
175
+ message_thread_id=LOGGER_TOPIC_ID,
176
+ reply_markup=buttons if group_link else None
177
  )
178
  except Exception as log_err:
179
  print(f"[NSFW Logger Error] {log_err}")
 
189
  os.remove(path)
190
  if image_path and os.path.exists(image_path):
191
  os.remove(image_path)
192
+
193
+ async def is_nauth(chat_id: int, user_id: int) -> bool:
194
+ doc = await nauth_collection.find_one({"chat_id": chat_id, "user_id": user_id})
195
+ return bool(doc)
196
+
197
+ @app.on_message(filters.command(["nauth"]) & filters.group)
198
+ async def approve_handler(client: Client, message: Message):
199
+ if not await is_admin(client, message.chat.id, message.from_user.id):
200
+ return await message.reply("❌ Only group admins or the group owner can use this command.")
201
+ user_id = None
202
+ if message.reply_to_message and message.reply_to_message.from_user:
203
+ user_id = message.reply_to_message.from_user.id
204
+ elif len(message.command) >= 2:
205
+ try:
206
+ user_id = int(message.command[1])
207
+ except Exception:
208
+ return await message.reply("Invalid user_id.")
209
+ else:
210
+ return await message.reply("Usage: /nauth <user_id> or reply to a user.")
211
+ await nauth_collection.update_one({"chat_id": message.chat.id, "user_id": user_id}, {"$set": {"chat_id": message.chat.id, "user_id": user_id}}, upsert=True)
212
+ await message.reply(f"User {user_id} will now be ignored by NSFW scan.")
213
+
214
+ @app.on_message(filters.command(["dauth"]) & filters.group)
215
+ async def dauth_handler(client: Client, message: Message):
216
+ if not await is_admin(client, message.chat.id, message.from_user.id):
217
+ return await message.reply("❌ Only group admins or the group owner can use this command.")
218
+ user_id = None
219
+ if message.reply_to_message and message.reply_to_message.from_user:
220
+ user_id = message.reply_to_message.from_user.id
221
+ elif len(message.command) >= 2:
222
+ try:
223
+ user_id = int(message.command[1])
224
+ except Exception:
225
+ return await message.reply("Invalid user_id.")
226
+ else:
227
+ return await message.reply("Usage: /dauth <user_id> or reply to a user.")
228
+ await nauth_collection.delete_one({"chat_id": message.chat.id, "user_id": user_id})
229
+ await message.reply(f"User {user_id} will no longer be ignored by NSFW scan.")