From 02578440cd02ceb6716f17acd9a77288bda1a561 Mon Sep 17 00:00:00 2001 From: Bohdan Horbeshko Date: Fri, 29 Sep 2023 16:59:13 -0400 Subject: Detect the "Have no write access to the chat" error from Telegram --- telegram/utils.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'telegram/utils.go') 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) } -- cgit v1.2.3