package upconv
import "github.com/gotd/td/tg"
func convertOptional (msg *tg .Message , i tg .UpdatesClass ) {
if u , ok := i .(interface {
GetFwdFrom () (tg .MessageFwdHeader , bool )
}); ok {
if v , ok := u .GetFwdFrom (); ok {
msg .SetFwdFrom (v )
}
}
if u , ok := i .(interface { GetViaBotID () (int64 , bool ) }); ok {
if v , ok := u .GetViaBotID (); ok {
msg .SetViaBotID (v )
}
}
if u , ok := i .(interface {
GetReplyTo () (tg .MessageReplyHeader , bool )
}); ok {
if v , ok := u .GetReplyTo (); ok {
msg .SetReplyTo (&v )
}
}
if u , ok := i .(interface {
GetEntities () ([]tg .MessageEntityClass , bool )
}); ok {
if v , ok := u .GetEntities (); ok {
msg .SetEntities (v )
}
}
if u , ok := i .(interface {
GetMedia () (tg .MessageMediaClass , bool )
}); ok {
if v , ok := u .GetMedia (); ok {
msg .SetMedia (v )
}
}
}
func ShortMessage (u *tg .UpdateShortMessage ) *tg .UpdateShort {
msg := &tg .Message {
ID : u .ID ,
PeerID : &tg .PeerUser {UserID : u .UserID },
Message : u .Message ,
Date : u .Date ,
}
msg .SetOut (u .Out )
msg .SetMentioned (u .Mentioned )
msg .SetMediaUnread (u .MediaUnread )
msg .SetSilent (u .Silent )
if !u .Out {
msg .SetFromID (&tg .PeerUser {UserID : u .UserID })
}
convertOptional (msg , u )
return &tg .UpdateShort {
Update : &tg .UpdateNewMessage {
Message : msg ,
Pts : u .Pts ,
PtsCount : u .PtsCount ,
},
Date : u .Date ,
}
}
func ShortChatMessage (u *tg .UpdateShortChatMessage ) *tg .UpdateShort {
msg := &tg .Message {
ID : u .ID ,
PeerID : &tg .PeerChat {ChatID : u .ChatID },
Message : u .Message ,
Date : u .Date ,
}
msg .SetFromID (&tg .PeerUser {UserID : u .FromID })
msg .SetOut (u .Out )
msg .SetMentioned (u .Mentioned )
msg .SetMediaUnread (u .MediaUnread )
msg .SetSilent (u .Silent )
convertOptional (msg , u )
return &tg .UpdateShort {
Update : &tg .UpdateNewMessage {
Message : msg ,
Pts : u .Pts ,
PtsCount : u .PtsCount ,
},
Date : u .Date ,
}
}
func ShortSentMessage (u *tg .UpdateShortSentMessage ) *tg .UpdateShort {
msg := &tg .Message {
ID : u .ID ,
Date : u .Date ,
}
msg .SetOut (u .Out )
convertOptional (msg , u )
return &tg .UpdateShort {
Update : &tg .UpdateNewMessage {
Message : msg ,
Pts : u .Pts ,
PtsCount : u .PtsCount ,
},
Date : u .Date ,
}
}
The pages are generated with Golds v0.6.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds .