我想通过音乐机器人下载几首音乐。这是我的实现。对于特定查询,有时可以正常工作,但有时不能。似乎这await
不起作用,因为它无法按get_messages
功能检索消息。你知道这里有什么问题吗?
async def get_music_url(client, query):
await client.send_message('melobot', query)
messages = await client.get_messages('melobot')
btn_txt_music = find_button(messages[0], "\N{MUSICAL NOTE}")
print("Music: ", btn_txt_music)
await client.send_message('melobot', btn_txt_music)
messages_2 = await client.get_messages('melobot')
btn_txt_128kb = find_button(messages_2[0], "128")
await client.send_message('melobot', btn_txt_128kb)
messages_3 = await client.get_messages('melobot', limit=2)
print('music_url: ', find_url(messages_3[0].message))
await client.disconnect()
def test_music(query):
client = authorize_telegram_client()
loop = asyncio.get_event_loop()
loop.run_until_complete(get_music_url(client, query))
client.run_until_disconnected()