Skip to content

Commit

Permalink
fix file downloads critical bug + stuck, improve efficienty of cachin…
Browse files Browse the repository at this point in the history
…g, bug fixes. #129
  • Loading branch information
AmarnathCJD committed Aug 5, 2024
1 parent 455d8fa commit a139b83
Show file tree
Hide file tree
Showing 7 changed files with 212 additions and 184 deletions.
4 changes: 0 additions & 4 deletions internal/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ func (*PingParams) CRC() uint32 {

type UpdatesGetStateParams struct{}

func (*UpdatesGetStateParams) CRC() uint32 {
return 0xedd4882a
}

func NewMsgIDGenerator() func(timeOffset int64) int64 {
var (
mu sync.Mutex
Expand Down
2 changes: 1 addition & 1 deletion mtproto.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func (m *MTProto) SetAppID(appID int32) {
m.appID = appID
}

func (m *MTProto) ReconnectToNewDC(dc int) (*MTProto, error) {
func (m *MTProto) SwitchDc(dc int) (*MTProto, error) {
if m.noRedirect {
return m, nil
}
Expand Down
8 changes: 4 additions & 4 deletions telegram/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (c *Client) LoginBot(botToken string) error {
}
if au, e := c.IsAuthorized(); !au {
if dc, code := getErrorCode(e); code == 303 {
err = c.switchDc(dc)
err = c.SwitchDc(dc)
if err != nil {
return err
}
Expand All @@ -100,7 +100,7 @@ func (c *Client) SendCode(phoneNumber string) (hash string, err error) {
})
if err != nil {
if dc, code := getErrorCode(err); code == 303 {
err = c.switchDc(dc)
err = c.SwitchDc(dc)
if err != nil {
return "", err
}
Expand Down Expand Up @@ -564,7 +564,7 @@ func (q *QrToken) Wait(timeout ...int32) error {
QrResponseSwitch:
switch req := resp.(type) {
case *AuthLoginTokenMigrateTo:
q.client.switchDc(int(req.DcID))
q.client.SwitchDc(int(req.DcID))
resp, err = q.client.AuthImportLoginToken(req.Token)
if err != nil {
return err
Expand Down Expand Up @@ -602,7 +602,7 @@ func (c *Client) QRLogin(IgnoreIDs ...int64) (*QrToken, error) {
)
switch qr := qr.(type) {
case *AuthLoginTokenMigrateTo:
c.switchDc(int(qr.DcID))
c.SwitchDc(int(qr.DcID))
return c.QRLogin(IgnoreIDs...)
case *AuthLoginTokenObj:
qrToken = qr.Token
Expand Down
Loading

0 comments on commit a139b83

Please sign in to comment.