7a04f298d2
- update to latest telegram layer - remove some references to fields in tg.Entities that don't exist in the schema - originally added here: https://github.com/beeper/td/commit/820929062a2ba0104397bc01235ab58a9cff780e - referenced here - https://github.com/mautrix/telegramgo/commit/124f0967ed195b5a380c9bd02e170ada9710dde3 - https://github.com/mautrix/telegramgo/commit/4205047aab2e0639217148b5d125bfaab668bd8e
41 lines
932 B
Go
41 lines
932 B
Go
package peer
|
|
|
|
import (
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/tg"
|
|
)
|
|
|
|
// ToInputUser converts given peer to input user if possible.
|
|
func ToInputUser(user tg.InputPeerClass) (tg.InputUserClass, bool) {
|
|
switch u := user.(type) {
|
|
case *tg.InputPeerUser:
|
|
v := new(tg.InputUser)
|
|
v.FillFrom(u)
|
|
return v, true
|
|
case *tg.InputPeerUserFromMessage:
|
|
v := new(tg.InputUserFromMessage)
|
|
v.FillFrom(u)
|
|
return v, true
|
|
case *tg.InputPeerSelf:
|
|
v := new(tg.InputUserSelf)
|
|
return v, true
|
|
default:
|
|
return nil, false
|
|
}
|
|
}
|
|
|
|
// ToInputChannel converts given peer to input channel if possible.
|
|
func ToInputChannel(channel tg.InputPeerClass) (tg.InputChannelClass, bool) {
|
|
switch u := channel.(type) {
|
|
case *tg.InputPeerChannel:
|
|
v := new(tg.InputChannel)
|
|
v.FillFrom(u)
|
|
return v, true
|
|
case *tg.InputPeerChannelFromMessage:
|
|
v := new(tg.InputChannelFromMessage)
|
|
v.FillFrom(u)
|
|
return v, true
|
|
default:
|
|
return nil, false
|
|
}
|
|
}
|