如何更改音频标题?

问题描述 投票:0回答:1

我试图用我的电报机器人向我自己发送音频文件,上传到电报服务器并首先获取file_id:

response = requests.post(
url='https://api.telegram.org/bot{0}/{1}'.format(token, method),
data={'chat_id': v, 'audio': 
'http://www.largesound.com/ashborytour/sound/brobob.mp3'}).json()
print(response)

然后我得到了这个回应

{'duration': 29, 'mime_type': 'audio/mpeg', 'file_id': 
'CQADBAADCAADVt71UQINbAiCs0snAg', 'file_size': 355968}

如何使用我自己的音频标题通过file_id重新发送音频?因为如果我这样做

response = requests.post(
url='https://api.telegram.org/bot{0}/{1}'.format(token, method),
data={'chat_id': v, 'audio': 'CQADBAADCAADVt71UQINbAiCs0snAg', 'title': 'Awesome bass', 'perfomer': 'Bass'}).json()

我的机器人名为brobob.mp3的mp3文件,所以标题更改不起作用。我做错了什么?或者我怎么做到这一点?

python-3.x audio telegram-bot python-telegram-bot
1个回答
0
投票

好的,15分钟,这里是答案(使用PyTelegramBotApi):

file_id = response['result']['audio']['file_id']
path = bot.get_file(file_id)
file = path.file_path
download = bot.download_file(file)
bot.send_audio(chat_id=v, audio=download, title="Awesome bass", 
performer="Bass", duration=120)
© www.soinside.com 2019 - 2024. All rights reserved.