td
td copied to clipboard
Ошибка при пересылке сообщения внутри канала из группы от анонимного админа
1) функциональность: юзер-бот копирует сообщения из channel_1 в channel_2 2) предварительное условие: руками в телеге выполнил форвард сообщения из группы old_group от анонимного админа в channel_1 3) промежуточный результат: юзер-бот скопировал верно сообщение из channel_1 в channel_2 4) действие: руками в телеге выполняю повторный форвард этого же сообщения из channel_1 в channel_1 5) ошибка: юзер-бот копирует совсем другое сообщение из группы old_group в channel_2 6) дополнительно: ошибка воспроизводится только для группы old_group (для new_group - getOriginMessage() 404 Not Found) 7) причина: origin.ChatId - ChatId от old_group, но origin.MessageId - MessageId от channel_1 (!!)
if origin, ok := message.ForwardInfo.Origin.(*client.MessageForwardOriginChannel); ok {
log.Print("**** ", origin.ChatId, origin.MessageId)
}
via https://github.com/zelenin/go-tdlib
Ошибка воспроизводится только при пересылке сообщения из старой группы от анонимного админа. Для сообщения из канала - origin.MessageId имеет ожидаемое значение от origin.ChatId.
If another message is copied, then message identifier of that message was specified. MessageForwardOriginChannel contains identifier of the original channel chat and identifier of a message in that channel.
Не знаю, как ещё описать ошибку. С двух сторон попытался зайти. :)
The error is likely to be in your code. You need to recheck everything again. If this will not help, you can send log with verbosity level 4 to @tdlib_bot.
If this will not help, you can send log with verbosity level 4 to @tdlib_bot.
I'll try to log it tonight, when other channels are sleeping.
// step 1: forward this message (from anonimus admin) from group -1001439193008 to channel -1001217753711
if messageLinkInfo, err := tdlibClient.GetMessageLinkInfo(
&client.GetMessageLinkInfoRequest{Url: "https://t.me/c/1439193008/109978"}); err == nil {
log.Printf("step 1: %#v", messageLinkInfo.Message) // ChatId -1001439193008 / MessageId 115320291328
}
// step 2: get info about forwarded message
if messageLinkInfo, err := tdlibClient.GetMessageLinkInfo(
&client.GetMessageLinkInfoRequest{Url: "https://t.me/c/1217753711/2"}); err == nil {
log.Printf("step 2: %#v", messageLinkInfo.Message) // ChatId -1001217753711 / MessageId 2097152
}
// step 3: forward message from step 2 to -1001217753711 again
for update := range listener.Updates {
if update.GetClass() == client.ClassUpdate {
if updateNewMessage, ok := update.(*client.UpdateNewMessage); ok {
src := updateNewMessage.Message
if src.ForwardInfo != nil {
if origin, ok := src.ForwardInfo.Origin.(*client.MessageForwardOriginChannel); ok {
log.Printf("step 3: %#v", origin) // ChatId -1001439193008 / MessageId 2097152 (wrong!)
// expected: ChatId -1001439193008 / MessageId 115320291328
}
}
}
}
}
2021/06/15 16:53:06 main.go:207: Start...
2021/06/15 16:53:06 main.go:214: TDLib version: 1.7.3
2021/06/15 16:53:06 main.go:220: Me: Andrew Ka2 [@AndrewKa2]
2021/06/15 16:53:06 main.go:245: step 1: &client.Message{meta:client.meta{Type:"", Extra:"", ClientId:0}, Id:115320291328, Sender:(*client.MessageSenderChat)(0xc00568a210), ChatId:-1001439193008, SendingState:client.MessageSendingState(nil), SchedulingState:client.MessageSchedulingState(nil), IsOutgoing:true, IsPinned:false, CanBeEdited:true, CanBeForwarded:true, CanBeDeletedOnlyForSelf:false, CanBeDeletedForAllUsers:true, CanGetStatistics:false, CanGetMessageThread:true, IsChannelPost:false, ContainsUnreadMention:false, Date:1623756349, EditDate:0, ForwardInfo:(*client.MessageForwardInfo)(nil), InteractionInfo:(*client.MessageInteractionInfo)(0xc0056a0080), ReplyInChatId:0, ReplyToMessageId:0, MessageThreadId:115320291328, Ttl:0, TtlExpiresIn:0, ViaBotUserId:0, AuthorSignature:"копировальщик", MediaAlbumId:0, RestrictionReason:"", Content:(*client.MessageText)(0xc0056a0100), ReplyMarkup:client.ReplyMarkup(nil)}
2021/06/15 16:53:06 main.go:252: step 2: &client.Message{meta:client.meta{Type:"", Extra:"", ClientId:0}, Id:2097152, Sender:(*client.MessageSenderChat)(0xc00555ede0), ChatId:-1001217753711, SendingState:client.MessageSendingState(nil), SchedulingState:client.MessageSchedulingState(nil), IsOutgoing:false, IsPinned:false, CanBeEdited:false, CanBeForwarded:true, CanBeDeletedOnlyForSelf:false, CanBeDeletedForAllUsers:true, CanGetStatistics:true, CanGetMessageThread:false, IsChannelPost:true, ContainsUnreadMention:false, Date:1623775444, EditDate:0, ForwardInfo:(*client.MessageForwardInfo)(0xc005550600), InteractionInfo:(*client.MessageInteractionInfo)(0xc005684380), ReplyInChatId:0, ReplyToMessageId:0, MessageThreadId:0, Ttl:0, TtlExpiresIn:0, ViaBotUserId:0, AuthorSignature:"", MediaAlbumId:0, RestrictionReason:"", Content:(*client.MessageText)(0xc0056843c0), ReplyMarkup:client.ReplyMarkup(nil)}
2021/06/15 16:53:22 main.go:263: step 3: &client.MessageForwardOriginChannel{meta:client.meta{Type:"messageForwardOriginChannel", Extra:"", ClientId:0}, ChatId:-1001439193008, MessageId:2097152, AuthorSignature:"копировальщик"}
2021/06/15 16:53:25 main.go:231: Stop...
The issue is now more clear, but I still need TDLib logs with verbosity level 4.
Done :)
forward_info = messageForwardInfo {
origin = messageForwardOriginChat {
sender_chat_id = -1001439193008
author_signature = "копировальщик"
}
date = 1623756349
public_service_announcement_type = ""
from_chat_id = 0
from_message_id = 0
}
After first forward there is no message_id there (and there should be no, because this is a message originated from a supergroup).
And after this message is forwarded again, server incorrectly adds message_id to the forward header:
fwd_from = messageFwdHeader {
flags = 13
from_id = peerChannel {
channel_id = 1439193008
}
date = 1623756349
channel_post = 2
post_author = "копировальщик"
}
I will report that.
The server-side bug has been fixed some time ago., so the issue can be closed now.