From 420e59ce53f87e8266d3740d21a6b36394749629 Mon Sep 17 00:00:00 2001 From: highesttt Date: Wed, 17 Jun 2026 09:29:20 -0500 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=F0=9F=90=9B=20more=20descriptive=20?= =?UTF-8?q?error=20for=20"blocked=20user"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/connector/connector.go | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/pkg/connector/connector.go b/pkg/connector/connector.go index bf9d78b..3549ee3 100644 --- a/pkg/connector/connector.go +++ b/pkg/connector/connector.go @@ -230,12 +230,20 @@ func loginErrorInstructions(message string) string { if message == "" { return "Could not log in to LINE. Please check your email and password and try again." } + if strings.EqualFold(message, loginTooManyAttemptsReason) || isBlockedUserLoginError(message) { + return loginTooManyAttemptsInstructions + } if strings.EqualFold(message, "Account ID or password is invalid") { return "LINE rejected the email or password. Make sure you used the email from LINE Settings -> Account -> Email Address, then try again." } return fmt.Sprintf("Could not log in to LINE: %s", message) } +const ( + loginTooManyAttemptsReason = "Too many login attempts" + loginTooManyAttemptsInstructions = "Too many login attempts. LINE has locked login for this account temporarily." +) + func loginErrorReason(err error) string { if err == nil { return "" @@ -248,13 +256,28 @@ func loginErrorReason(err error) string { } var payload struct { Data struct { - Reason string `json:"reason"` + Message string `json:"message"` + Reason string `json:"reason"` } `json:"data"` } if err := json.Unmarshal([]byte(msg[start:end+1]), &payload); err != nil { + if isBlockedUserLoginError(msg) { + return loginTooManyAttemptsReason + } return "" } - return payload.Data.Reason + reason := payload.Data.Reason + if reason == "" { + reason = payload.Data.Message + } + if isBlockedUserLoginError(reason) || isBlockedUserLoginError(msg) { + return loginTooManyAttemptsReason + } + return reason +} + +func isBlockedUserLoginError(message string) bool { + return strings.Contains(strings.ToLower(message), "blocked user") } func (ll *LineEmailLogin) Wait(ctx context.Context) (*bridgev2.LoginStep, error) { From f1d8bee192b5d1b0c2ca1857705dbe06656a528b Mon Sep 17 00:00:00 2001 From: highesttt Date: Wed, 17 Jun 2026 09:36:37 -0500 Subject: [PATCH 2/2] fix: nudges from indent --- pkg/connector/connector.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/pkg/connector/connector.go b/pkg/connector/connector.go index 3549ee3..1d953a8 100644 --- a/pkg/connector/connector.go +++ b/pkg/connector/connector.go @@ -20,6 +20,11 @@ import ( "github.com/highesttt/matrix-line-messenger/pkg/line" ) +const ( + loginTooManyAttemptsReason = "Too many login attempts" + loginTooManyAttemptsInstructions = "Too many login attempts. LINE has locked login for this account temporarily." +) + type LineConnector struct { br *bridgev2.Bridge } @@ -239,11 +244,6 @@ func loginErrorInstructions(message string) string { return fmt.Sprintf("Could not log in to LINE: %s", message) } -const ( - loginTooManyAttemptsReason = "Too many login attempts" - loginTooManyAttemptsInstructions = "Too many login attempts. LINE has locked login for this account temporarily." -) - func loginErrorReason(err error) string { if err == nil { return "" @@ -261,23 +261,20 @@ func loginErrorReason(err error) string { } `json:"data"` } if err := json.Unmarshal([]byte(msg[start:end+1]), &payload); err != nil { - if isBlockedUserLoginError(msg) { - return loginTooManyAttemptsReason - } return "" } reason := payload.Data.Reason if reason == "" { reason = payload.Data.Message } - if isBlockedUserLoginError(reason) || isBlockedUserLoginError(msg) { + if isBlockedUserLoginError(reason) { return loginTooManyAttemptsReason } return reason } func isBlockedUserLoginError(message string) bool { - return strings.Contains(strings.ToLower(message), "blocked user") + return strings.EqualFold(strings.TrimSpace(message), "blocked user") } func (ll *LineEmailLogin) Wait(ctx context.Context) (*bridgev2.LoginStep, error) {