def pin(app: Client, msg: Message): msgid = msg.reply_to_message.message_id app.pin_chat_message(msg.chat.id, msgid) text = f"**Pin** __Shd__ ;)" app.edit_message_text(msg.chat.id, msg.message_id, text) if r.get("autodel") == "on": time.sleep(float(r.get("autodeltime"))) app.delete_messages(msg.chat.id, msg.message_id)
def pin_chat_message(client: Client, cid: int, mid: int) -> Optional[bool]: # Pin a message in a group, channel or your own chat result = None try: result = client.pin_chat_message(chat_id=cid, message_id=mid, disable_notification=True) except FloodWait as e: raise e except (ChannelInvalid, ChannelPrivate, ChatAdminRequired, ChatNotModified, PeerIdInvalid): return False except Exception as e: logger.warning(f"Pin chat message error: {e}", exc_info=True) return result