微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

python Telethon中的秘密聊天会话

如何解决python Telethon中的秘密聊天会话

如何使用 Telethon 开始秘密聊天会话?我在网上找到了解决方案; https://pypi.org/project/telethon-secret-chat/,但我不确定它应该如何工作。我了解所有其他内容,但是 manager.start_secret_chat(target) 函数中应该包含哪些内容

from telethon import TelegramClient
from telethon_secret_chat import SecretChatManager

client = TelegramClient('log',app_id,app_hash)

async def replier(event):
    # all events are encrypted by default
    if event.decrypted_event.message and event.decrypted_event.message == "hello":
        await event.reply("**hi**") # parse_mode is markdown by default


async def new_chat(chat,created_by_me):
    if created_by_me:
        print("User {} has accepted our secret chat request".format(chat))
    else:
        print("We have accepted the secret chat request of {}".format(chat))


manager = SecretChatManager(client,auto_accept=True,new_chat_created=new_chat)  # automatically accept new secret chats
manager.add_secret_event_handler(func=replier)  # we can specify the type of the event

with client:
    client.run_until_disconnected()

manager.start_secret_chat(target)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。