what is the correct method call for checking if a message is pinned or not in telethon 1.36?
i searched a lot, i read docs but it confuses me.
Here’s the snippet:
if command_name == 'unpin':
message = event.message
if not message.is_reply:
await event.reply("Please reply to a pinned message to unpin it! Usage: /unpin <reply>")
return
try:
chat = await event.get_input_chat()
replied_message = await message.get_reply_message()
pinned_messages = await client.get_pinned_messages(chat)
is_pinned = any(msg.id == replied_message for msg in pinned_messages)
if is_pinned:
await client.unpin_message(chat, replied_message)
await event.reply("unpinned message from group")
else:
await event.reply("can't unpin, maybe bot don't have required permission or another errors occurred.")
except ValueError:
await event.reply("An error occurred.")
except Exception as e:
await event.reply(f"Error pinning message: {str(e)}")
i tried pinned_messages = await client.get_pinned_messages(chat)
and got this: 'TelegramClient' object has no attribute 'get_pinned_messages'
New contributor
mamadop is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.