move gotd fork into repo. (#111)
- 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
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
package participants
|
||||
|
||||
import (
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/telegram/query/photos"
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/tg"
|
||||
)
|
||||
|
||||
// UserPhotos returns new user photo query builder for participant.
|
||||
func (e Elem) UserPhotos(raw *tg.Client) (*photos.GetUserPhotosQueryBuilder, bool) {
|
||||
user, ok := e.User()
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
return photos.NewQueryBuilder(raw).GetUserPhotos(user.AsInput()), true
|
||||
}
|
||||
|
||||
// User tries to get participant user object.
|
||||
func (e Elem) User() (*tg.User, bool) {
|
||||
switch part := e.Participant.(type) {
|
||||
case interface{ GetUserID() int64 }:
|
||||
return e.Entities.User(part.GetUserID())
|
||||
case interface{ GetPeer() tg.PeerClass }:
|
||||
user, ok := part.GetPeer().(*tg.PeerUser)
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
return e.Entities.User(user.GetUserID())
|
||||
default:
|
||||
return nil, false
|
||||
}
|
||||
}
|
||||
|
||||
// Creator returns participant user object and meta info if participant is a creator of channel.
|
||||
func (e Elem) Creator() (*tg.User, *tg.ChannelParticipantCreator, bool) {
|
||||
part, ok := e.Participant.(*tg.ChannelParticipantCreator)
|
||||
if !ok {
|
||||
return nil, nil, false
|
||||
}
|
||||
|
||||
user, ok := e.User()
|
||||
if !ok {
|
||||
return nil, nil, false
|
||||
}
|
||||
|
||||
return user, part, true
|
||||
}
|
||||
|
||||
// Admin returns participant user object and meta info if participant is admin of channel.
|
||||
func (e Elem) Admin() (*tg.User, *tg.ChannelParticipantAdmin, bool) {
|
||||
part, ok := e.Participant.(*tg.ChannelParticipantAdmin)
|
||||
if !ok {
|
||||
return nil, nil, false
|
||||
}
|
||||
|
||||
user, ok := e.User()
|
||||
if !ok {
|
||||
return nil, nil, false
|
||||
}
|
||||
|
||||
return user, part, true
|
||||
}
|
||||
Reference in New Issue
Block a user