diff --git a/telegram/channels.go b/telegram/channels.go index 90c86358..f23e6a4e 100755 --- a/telegram/channels.go +++ b/telegram/channels.go @@ -593,7 +593,16 @@ func (c *Client) DeleteChannel(channelID any) (*Updates, error) { return &u, nil } -func (c *Client) GetChatJoinRequests(channelID any, lim int, query ...string) ([]*UserObj, error) { +type JoinRequest struct { + User *UserObj + Date int32 + ApprovedBy int64 + Requested bool + About string + ViaChatlist bool +} + +func (c *Client) GetChatJoinRequests(channelID any, lim int, query ...string) ([]*JoinRequest, error) { var currentOffsetUser InputUser = &InputUserEmpty{} currentOffsetDate := 0 @@ -609,7 +618,7 @@ func (c *Client) GetChatJoinRequests(channelID any, lim int, query ...string) ([ return nil, err } - var allUsers []*UserObj + var allUsers []*JoinRequest // Loop until lim is reached for { @@ -630,12 +639,20 @@ func (c *Client) GetChatJoinRequests(channelID any, lim int, query ...string) ([ break } + c.Cache.UpdatePeersToCache(chatInviteImporters.Users, []Chat{}) // Add all UserObj objects to allUsers slice - for _, user := range chatInviteImporters.Users { - u, ok := user.(*UserObj) - if !ok { - c.Logger.Debug("user is not a UserObj") - continue + for _, user := range chatInviteImporters.Importers { + userObj, err := c.GetUser(user.UserID) + if err != nil { + userObj = &UserObj{ID: user.UserID} + } + u := &JoinRequest{ + User: userObj, + Date: user.Date, + ApprovedBy: user.ApprovedBy, + Requested: user.Requested, + About: user.About, + ViaChatlist: user.ViaChatlist, } allUsers = append(allUsers, u) current++ diff --git a/telegram/const.go b/telegram/const.go index 8d1cc5fd..9ca5ccbd 100644 --- a/telegram/const.go +++ b/telegram/const.go @@ -4,7 +4,7 @@ import "regexp" const ( ApiVersion = 194 - Version = "v1.4.1" + Version = "v1.4.2" LogDebug = "debug" LogInfo = "info" diff --git a/telegram/media.go b/telegram/media.go index c018a273..fd084432 100644 --- a/telegram/media.go +++ b/telegram/media.go @@ -62,7 +62,7 @@ func (wp *WorkerPool) FreeWorker(s *Sender) { } type Source struct { - Source any + Source interface{} } func (s *Source) GetSizeAndName() (int64, string) { @@ -119,7 +119,7 @@ func (s *Source) GetReader() io.Reader { return nil } -func (c *Client) UploadFile(src any, Opts ...*UploadOptions) (InputFile, error) { +func (c *Client) UploadFile(src interface{}, Opts ...*UploadOptions) (InputFile, error) { opts := getVariadic(Opts, &UploadOptions{}) if src == nil { return nil, errors.New("file can not be nil") @@ -413,7 +413,7 @@ func (mb *Destination) Close() error { return nil } -func (c *Client) DownloadMedia(file any, Opts ...*DownloadOptions) (string, error) { +func (c *Client) DownloadMedia(file interface{}, Opts ...*DownloadOptions) (string, error) { opts := getVariadic(Opts, &DownloadOptions{}) location, dc, size, fileName, err := GetFileLocation(file) if err != nil { @@ -485,6 +485,7 @@ func (c *Client) DownloadMedia(file any, Opts ...*DownloadOptions) (string, erro case <-progressTicker: return case <-ticker.C: + fmt.Println(opts.ProgressManager.GetStats(doneBytes.Load())) opts.ProgressManager.editFunc(size, doneBytes.Load()) } } @@ -694,6 +695,7 @@ func NewProgressManager(editInterval int) *ProgressManager { } } +// a: total size, b: current size func (pm *ProgressManager) Edit(editFunc func(a, b int64)) { pm.editFunc = editFunc }