[英]Telepot on python, can't send multiple photos with sendGroupMedia
I'm trying to send 2 or 3 photos at the same time, so they're displayed as one message on my channel.我试图同时发送 2 或 3 张照片,因此它们在我的频道上显示为一条消息。 To send one photos I used python's
requests
library, with this line of code;为了发送一张照片,我使用了 python 的
requests
库,以及这行代码;
pic = {'photo' : open('p.jpeg', 'rb')}
print(requests.get(f'https://api.telegram.org/bot{apiKey}/sendPhoto?chat_id={chat_id}?disable_notification=True', files=pic))
Now to send more at once I use telepot
.现在要一次发送更多,我使用
telepot
。 I'm doing this:我这样做:
bot = telepot.Bot(apiKey)
bot.sendMediaGroup(
chat_id=chat_id,
media=[
{'media' : open( 'p.jpeg', 'rb')},
{'media' : open('p1.jpeg', 'rb')}
],
disable_notification=True
)
The problem is I don't precise the type of media being transferred.问题是我没有准确说明正在传输的媒体类型。 I tried doing:
我试着做:
media = {'media' :
{'photo' : open( 'p.jpeg', 'rb')},
{'photo' : open('p1.jpeg', 'rb')}
}
But media
parameter must be an array.但是
media
参数必须是一个数组。
I also tried to pass a double sized dictionary as argument to requests.get(...)
, it didn't work either.我还尝试将双倍大小的字典作为参数传递给
requests.get(...)
,它也没有用。
Could you guys help me out?你们能帮帮我吗? Thank you
谢谢
Well, problem solved, eventually I had to do this:好吧,问题解决了,最终我不得不这样做:
bot.sendMediaGroup(
chat_id=chat_id,
media=[
{'media' : open( 'p.jpeg', 'rb'), 'type' : 'photo'},
{'media' : open('p1.jpeg', 'rb'), 'type' : 'photo'}
],
disable_notification=True
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.