Detect the "Have no write access to the chat" error from Telegram
This commit is contained in:
parent
47fa7bca49
commit
02578440cd
|
@ -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) {
|
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)
|
c.returnMessage(returnJid, chatID, fmt.Sprintf("%s: %s", msg, err.Error()), code, isGroupchat)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,6 +140,9 @@ func sendMessageWrapper(to, from, body, subject, id string, component *xmpp.Comp
|
||||||
case 400:
|
case 400:
|
||||||
message.Error.Type = stanza.ErrorTypeModify
|
message.Error.Type = stanza.ErrorTypeModify
|
||||||
message.Error.Reason = "bad-request"
|
message.Error.Reason = "bad-request"
|
||||||
|
case 403:
|
||||||
|
message.Error.Type = stanza.ErrorTypeAuth
|
||||||
|
message.Error.Reason = "forbidden"
|
||||||
case 404:
|
case 404:
|
||||||
message.Error.Type = stanza.ErrorTypeCancel
|
message.Error.Type = stanza.ErrorTypeCancel
|
||||||
message.Error.Reason = "item-not-found"
|
message.Error.Reason = "item-not-found"
|
||||||
|
|
Loading…
Reference in a new issue