-5
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)

Hello, what is the problem with the code ?


is my error :

coroutine 'send_chat' was never awaited self.function(*self.args, **self.kwargs)

REZA TG
  • 1
  • 1
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Oct 15 '21 at 19:25

1 Answers1

0

This error practically always means that there is an await keyword missing somewhere behind an async function. Check everywhere where send_chat is called.

Also, it looks like you are making some sort of recursive call of send_chat at line t = asyncio.get_event_loop().create_task(send_chat), which is probably not intended.

Louis Lac
  • 5,298
  • 1
  • 21
  • 36