Python telethon回复来自个人帐户的邮件

Python telethon回复来自个人帐户的邮件,python,asynchronous,python-asyncio,telegram,telethon,Python,Asynchronous,Python Asyncio,Telegram,Telethon,我有一个向电报频道发送消息的代码,有两件事我需要帮助: a) 如何从另一台计算机或电话号码创建另一个客户机,该客户机将检查是否有人在频道中说了“嗨”,并会回答一些问题?当我的代码显示“嗨”时,其他计算机将加入该频道,请查看我是否已发布该频道并回复我的消息? b) 代码运行一次或两次,然后我发现“main未定义”问题?是asyncio.run的问题吗,因为我已经定义了main函数,它运行hi消息:) from telethon.sync import TelegramClient from tel

我有一个向电报频道发送消息的代码,有两件事我需要帮助:

a) 如何从另一台计算机或电话号码创建另一个客户机,该客户机将检查是否有人在频道中说了“嗨”,并会回答一些问题?当我的代码显示“嗨”时,其他计算机将加入该频道,请查看我是否已发布该频道并回复我的消息? b) 代码运行一次或两次,然后我发现“main未定义”问题?是asyncio.run的问题吗,因为我已经定义了main函数,它运行hi消息:)

from telethon.sync import TelegramClient
from telethon.tl.functions.channels import JoinChannelRequest
from telethon.errors.rpcerrorlist import FloodWaitError
import time
from dotenv import load_dotenv
import os
import asyncio
channel_list=[
'viliuscool']

client = TelegramClient('session_name',
2583714,
'blablabla')

client.start()
async def main():
    for values in channel_list:
        try:
            destination_channel_username=values
            entity=client.get_entity(destination_channel_username)
            client(JoinChannelRequest(channel=values))
            client.send_message(entity=entity,message='HI!')

            time.sleep(20)
        except:
            continue
            time.sleep(20)
    client.stop()
asyncio.run(main())