Open FunkyYang opened 3 years ago
and message type is updateNewMessage
this is the code
ack := &tdlib.UpdateNewMessage{}
if err := json.Unmarshal(update.Raw, ack); err != nil {
log.Printf("解码失败,原因:%s", err.Error())
continue
}
log.Printf("会话id:%d", ack.Message.ChatID)
switch ack.Message.Content.(type) {
case *tdlib.MessageText:
content := ack.Message.Content.(*tdlib.MessageText)
if content.Text != nil {
log.Printf("内容:%s", content.Text.Text)
entityes := content.Text.Entities
for _, e := range entityes {
log.Printf("offset:%d,length:%d,type:%v", e.Offset, e.Length, e.Type)
switch e.Type.(type) {
case *tdlib.TextEntityTypeTextURL:
eType := e.Type.(*tdlib.TextEntityTypeTextURL)
log.Printf("URL:%s", eType.URL)
}
}
}
default:
}
I can't get e.Type
the issue is in the code generator.
the parser runs replaceKeyWords
on enum type names and this causes words like Url
to become URL
.
but tdlib returns the original types in the @type
field so when the library tries to compare textEntityTypeTextUrl
with textEntityTypeTextURL
this happens.
link to what causes this
I actually re-wrote the entire codegen and parser parts but they're private for now (I'm planning on open-sourcing it)
when I receive a message from tdlib,I saw the original string contains textEntityTypeTextUrl,but when I use tdlib.UpdateNewMessage to umarshal it,I can't find which field contains textEntityTypeTextUrl,so any one could help