Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpc error code 400: PHONE_NUMBER_BANNED" #135

Closed
cz-theng opened this issue Feb 2, 2021 · 2 comments
Closed

rpc error code 400: PHONE_NUMBER_BANNED" #135

cz-theng opened this issue Feb 2, 2021 · 2 comments

Comments

@cz-theng
Copy link

cz-theng commented Feb 2, 2021

I use td to login in with my telegram account.

it can get some messages. but after a few seconds , I got PHONE_NUMBER_BANNED.
And my account is Banned.

just use these codes:
return client.Run(ctx, func(ctx context.Context) error {
codePrompt := func(ctx context.Context) (string, error) {
// NB: Use "golang.org/x/crypto/ssh/terminal" to prompt password.
fmt.Print("Enter code: ")
code, err := bufio.NewReader(os.Stdin).ReadString('\n')
if err != nil {
return "", err
}
return strings.TrimSpace(code), nil
}
if self, err := client.Self(ctx); err != nil {
if err := telegram.NewAuth(
telegram.CodeOnlyAuth("my_phone_number", telegram.CodeAuthenticatorFunc(codePrompt)),
telegram.SendCodeOptions{},
).Run(ctx, client); err != nil {
log.Error("auth: %s", err.Error())
return err
}
}

	c := tg.NewClient(client)
	for range time.NewTicker(time.Second * 5).C {
		chats, err := c.MessagesGetAllChats(ctx, nil)

		var rpcErr *mtproto.Error
		if errors.As(err, &rpcErr) && rpcErr.Type == "FLOOD_WAIT" {
			// Server told us to wait N seconds before sending next message.
			log.Infow("Sleeping", "seconds", rpcErr.Argument)
			time.Sleep(time.Second * time.Duration(rpcErr.Argument))
			continue
		}

		if err != nil {
			log.Error("failed to get chats: %s", err.Error())
			return err
		}

		switch chats.(type) {
		case *tg.MessagesChats: // messages.chats#64ff9fd5
			log.Info("Chats")
		case *tg.MessagesChatsSlice: // messages.chatsSlice#9cd81144
			log.Info("Slice")
		}
	}

	return nil
})
@cz-theng
Copy link
Author

cz-theng commented Feb 2, 2021

got this tdlib/td#312

@cz-theng cz-theng closed this as completed Feb 2, 2021
@wind-hx
Copy link

wind-hx commented Apr 7, 2022

Hi, I also encountered the same problem, is there any solution to avoid banning users
@cz-theng

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants