Skip to content

Commit

Permalink
fix replying to audio files in bot pm. (UsergeTeam#429)
Browse files Browse the repository at this point in the history
* fix replying to audio files in bot pm.

* pep8

* group
  • Loading branch information
subinps authored Jan 1, 2022
1 parent 2b20e02 commit 7582243
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
2 changes: 1 addition & 1 deletion userge/plugins/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ async def wrapper(_, c_q: CallbackQuery):
return wrapper

@userge.bot.on_message(
filters.private & filters.user(list(Config.OWNER_ID)) & filters.command("start")
filters.private & filters.user(list(Config.OWNER_ID)) & filters.command("start"), group=-1
)
async def pm_help_handler(_, msg: Message):
cmd = msg.command[1] if len(msg.command) > 1 else ''
Expand Down
23 changes: 7 additions & 16 deletions userge/plugins/utils/botpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,20 +137,9 @@ async def start(_, msg: PyroMessage):
return
text = "Hey, you can configure me here."
markup = InlineKeyboardMarkup([[InlineKeyboardButton("Settings", callback_data="stngs")]])
cmd = msg.command[1] if len(msg.command) > 1 else ''
if cmd and ' ' not in msg.text:
commands = userge.manager.enabled_commands
key = Config.CMD_TRIGGER + cmd
key_ = Config.SUDO_TRIGGER + cmd
if cmd in commands:
out_str = f"<code>{cmd}</code>\n\n{commands[cmd].about}"
elif key in commands:
out_str = f"<code>{key}</code>\n\n{commands[key].about}"
elif key_ in commands:
out_str = f"<code>{key_}</code>\n\n{commands[key_].about}"
else:
out_str = f"<i>No Command Found for</i>: <code>{cmd}</code>"
return await msg.reply(out_str, parse_mode='html', disable_web_page_preview=True)
if len(msg.command) > 1:
# https://github.com/UsergeTeam/Userge/blob/alpha/userge/plugins/help.py#L104
return
await send_start_text(msg, text, path, markup)

@bot.on_message(
Expand Down Expand Up @@ -446,9 +435,11 @@ async def handle_incoming_message(msg: PyroMessage):
_USERS.append(user_id)
await USERS.insert_one({"user_id": user_id})
try:
if msg.sticker:
await bot.send_message(userge_id, f"{msg.from_user.mention} sent you a sticker.")
m = await msg.forward(userge_id)
if msg.audio:
await bot.send_message(userge_id, f"{msg.from_user.mention} sent you a audio file.",
reply_to_message_id=m.message_id)
m.forward_sender_name = msg.from_user.first_name
if m.forward_from or m.forward_sender_name or m.forward_date:
id_ = 0
for a, b in _U_ID_F_M_ID.items():
Expand Down

0 comments on commit 7582243

Please sign in to comment.