taslim19 commited on
Commit
28baa10
·
1 Parent(s): db044f6

Fix quotly.py: remove await on bytes object in all cases

Browse files
DragMusic/plugins/management/kang.py CHANGED
@@ -15,7 +15,7 @@ from pyrogram.errors import (
15
  from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message
16
 
17
  from DragMusic import app
18
- from config import BOT_USERNAME
19
  from DragMusic.utils.errors import capture_err
20
  from DragMusic.utils.files import (
21
  get_document_from_file_id,
@@ -115,18 +115,19 @@ async def kang(client, message: Message):
115
  print(format_exc())
116
  return
117
 
118
- # Packname sanitization
119
- bot_username = BOT_USERNAME.lstrip("@").strip("_")
 
120
  packnum = 0
121
 
122
- def sanitize_packname(base: str) -> str:
 
123
  base = base.replace("__", "_").strip("_")
124
  if not base[0].isalpha():
125
- base = f"a{base}"
126
  return base
127
 
128
- base_packname = sanitize_packname(f"f{message.from_user.id}_by_{bot_username}")
129
- packname = base_packname
130
  limit = 0
131
 
132
  try:
@@ -149,7 +150,7 @@ async def kang(client, message: Message):
149
  elif stickerset.set.count >= MAX_STICKERS:
150
  packnum += 1
151
  packname = sanitize_packname(
152
- f"f{packnum}_{message.from_user.id}_by_{bot_username}"
153
  )
154
  limit += 1
155
  continue
 
15
  from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message
16
 
17
  from DragMusic import app
18
+ from config import BOT_USERNAME # Still used elsewhere, but not for short name anymore
19
  from DragMusic.utils.errors import capture_err
20
  from DragMusic.utils.files import (
21
  get_document_from_file_id,
 
115
  print(format_exc())
116
  return
117
 
118
+ # --- LIVE BOT USERNAME & VALID SHORT_NAME ---
119
+ me = await client.get_me()
120
+ bot_username = me.username
121
  packnum = 0
122
 
123
+ def sanitize_packname(uid: int, bot_username: str, packnum: int = 0) -> str:
124
+ base = f"{'f' if packnum == 0 else f'f{packnum}_'}{uid}_by_{bot_username}"
125
  base = base.replace("__", "_").strip("_")
126
  if not base[0].isalpha():
127
+ base = "a" + base
128
  return base
129
 
130
+ packname = sanitize_packname(message.from_user.id, bot_username, packnum)
 
131
  limit = 0
132
 
133
  try:
 
150
  elif stickerset.set.count >= MAX_STICKERS:
151
  packnum += 1
152
  packname = sanitize_packname(
153
+ message.from_user.id, bot_username, packnum
154
  )
155
  limit += 1
156
  continue
DragMusic/plugins/management/quotly.py CHANGED
@@ -250,7 +250,7 @@ async def msg_quotly_cmd(client, ctx: Message):
250
  return await ctx.reply_text("🤷🏻‍♂️")
251
  try:
252
  make_quotly = await pyrogram_to_quotly(messages, is_reply=is_reply)
253
- bio_sticker = BytesIO(await make_quotly)
254
  bio_sticker.name = "misskatyquote_sticker.webp"
255
  return await ctx.reply_sticker(bio_sticker)
256
  except Exception:
@@ -265,7 +265,7 @@ async def msg_quotly_cmd(client, ctx: Message):
265
  return await ctx.reply("🤷🏻‍♂️")
266
  try:
267
  make_quotly = await pyrogram_to_quotly(messages, is_reply=is_reply)
268
- bio_sticker = BytesIO(await make_quotly)
269
  bio_sticker.name = "misskatyquote_sticker.webp"
270
  return await ctx.reply_sticker(bio_sticker)
271
  except Exception as e:
 
250
  return await ctx.reply_text("🤷🏻‍♂️")
251
  try:
252
  make_quotly = await pyrogram_to_quotly(messages, is_reply=is_reply)
253
+ bio_sticker = BytesIO(make_quotly)
254
  bio_sticker.name = "misskatyquote_sticker.webp"
255
  return await ctx.reply_sticker(bio_sticker)
256
  except Exception:
 
265
  return await ctx.reply("🤷🏻‍♂️")
266
  try:
267
  make_quotly = await pyrogram_to_quotly(messages, is_reply=is_reply)
268
+ bio_sticker = BytesIO(make_quotly)
269
  bio_sticker.name = "misskatyquote_sticker.webp"
270
  return await ctx.reply_sticker(bio_sticker)
271
  except Exception as e: