【发布时间】:2021-10-14 20:15:57
【问题描述】:
import asyncio, redis
from threading import Thread, Timer
db = redis.StrictRedis(host='localhost', port=6379, db=0, charset='UTF-8', decode_responses=True)
txts = ['txt1','txt2','txt3']
async def Send_GP():
async for dialog in bot.iter_dialogs():
if dialog.is_group:
text = random.choice(txts)
await bot.send_message(dialog.id, text)
async def send_chat():
try:
t = asyncio.get_event_loop().create_task(send_chat)
await t()
db.setex('timeleft:',int(db.get('time_chat:')),True)
Timer(int(db.get('time_chat:')), t, []).start()
except Exception as e:
print(e)
你好,代码有什么问题?
是我的错误:
从未等待协程“send_chat” self.function(*self.args, **self.kwargs)
【问题讨论】:
-
请澄清您的具体问题或提供其他详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。
标签: python multithreading bots python-asyncio telethon