tucnak/telebot

How to check that user blocked and stop bot?

region23 opened this issue · 1 comments

How to check that user blocked and stop bot?
Can't found this in docs or code.

You can try sending a message and check if the err is equal to ErrBlockedByUser.

msg, err := b.Send(&tele.User{ID: id}, "Hello")

if err != nil {
fmt.Println(err)
}

fmt.Println(err == tele.ErrBlockedByUser)

I blocked the bot and tried to send a Message, and in this case, it printed true in console:

image