diff options
author | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2023-09-29 23:59:13 +0300 |
---|---|---|
committer | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2023-09-29 23:59:13 +0300 |
commit | 02578440cd02ceb6716f17acd9a77288bda1a561 (patch) | |
tree | 2405de01d64efb93c034a67b29ee0bd00d6b09ca /telegram | |
parent | 47fa7bca492f9d78c3bea009c7686a6bf4d8fc3b (diff) |
Detect the "Have no write access to the chat" error from Telegram
Diffstat (limited to 'telegram')
-rw-r--r-- | telegram/utils.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/telegram/utils.go b/telegram/utils.go index eba500c..cab450f 100644 --- a/telegram/utils.go +++ b/telegram/utils.go @@ -1304,6 +1304,13 @@ func (c *Client) returnMessage(returnJid string, chatID int64, text string, code } func (c *Client) returnError(returnJid string, chatID int64, msg string, err error, code int, isGroupchat bool) { + responseError, ok := err.(client.ResponseError) + log.Debugf("responseError: %#v", responseError) + if ok && responseError.Err != nil { + if responseError.Err.Message == "Have no write access to the chat" { + code = 403 + } + } c.returnMessage(returnJid, chatID, fmt.Sprintf("%s: %s", msg, err.Error()), code, isGroupchat) } |