从机器人向用户发送相同的图像以防止下载两次
Send same image to a user from a bot to prevent downloading it twice
我正在使用 Telegram.Bot 库用 C# 创建一个电报机器人,但我的问题更多是关于电报机器人 api 到特定库,所以任何使用电报机器人 api 的人都可以回答我的问题。
问题是,如果我以正常方式发送到:
,我想多次向用户发送图像
//Code Used in This Specific library to normally send a message with image attached to it
InputOnlineFile imageFile = new InputOnlineFile(new MemoryStream(File.ReadAllBytes("filePath")));
botClient.SendPhotoAsync(ChatId, imageFile, caption);
这会导致每条包含图像的消息都有一个单独的 messageId,因此用户必须单独下载每张图像。
发送相同消息的另一种方法是像上面那样发送一条消息并存储它的 messageId,对于其他消息而不是发送新消息,只需将第一条消息转发给同一用户,如下所示:
//Code Used in This Specific library to forward a message
botClient.ForwardMessageAsync(ChatId, ChatId, firstMessage.messageId)
这解决了问题,但给图片留下了难看的 "Forwarded From botname" 标题。
那么有没有另一种方法来完成整个事情,使每条消息看起来都一样但具有相同的 messageId?有没有办法将第一条消息转发给同一用户但去掉该标题?
提前致谢
send photo from file后,您将获得一个file_id
(.result.photo[4].file_id
:本例中为 AgADBQADLagxGyRN4FQwyg5Z9HLVFVFp0zIABAHza6yG8gXJ86cCAAEC
)
您现在可以 send with file ID:)
我正在使用 Telegram.Bot 库用 C# 创建一个电报机器人,但我的问题更多是关于电报机器人 api 到特定库,所以任何使用电报机器人 api 的人都可以回答我的问题。
问题是,如果我以正常方式发送到:
,我想多次向用户发送图像//Code Used in This Specific library to normally send a message with image attached to it
InputOnlineFile imageFile = new InputOnlineFile(new MemoryStream(File.ReadAllBytes("filePath")));
botClient.SendPhotoAsync(ChatId, imageFile, caption);
这会导致每条包含图像的消息都有一个单独的 messageId,因此用户必须单独下载每张图像。
发送相同消息的另一种方法是像上面那样发送一条消息并存储它的 messageId,对于其他消息而不是发送新消息,只需将第一条消息转发给同一用户,如下所示:
//Code Used in This Specific library to forward a message
botClient.ForwardMessageAsync(ChatId, ChatId, firstMessage.messageId)
这解决了问题,但给图片留下了难看的 "Forwarded From botname" 标题。
那么有没有另一种方法来完成整个事情,使每条消息看起来都一样但具有相同的 messageId?有没有办法将第一条消息转发给同一用户但去掉该标题?
提前致谢
send photo from file后,您将获得一个file_id
(.result.photo[4].file_id
:本例中为 AgADBQADLagxGyRN4FQwyg5Z9HLVFVFp0zIABAHza6yG8gXJ86cCAAEC
)
您现在可以 send with file ID:)