12
commands.go
12
commands.go
@@ -17,11 +17,15 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/bwmarrin/discordgo"
|
||||||
"github.com/skip2/go-qrcode"
|
"github.com/skip2/go-qrcode"
|
||||||
|
|
||||||
"maunium.net/go/mautrix"
|
"maunium.net/go/mautrix"
|
||||||
@@ -142,7 +146,13 @@ func fnLoginQR(ce *WrappedCommandEvent) {
|
|||||||
|
|
||||||
user, err := client.Result()
|
user, err := client.Result()
|
||||||
if err != nil || len(user.Token) == 0 {
|
if err != nil || len(user.Token) == 0 {
|
||||||
ce.Reply("Error logging in: %v", err)
|
if restErr := (&discordgo.RESTError{}); errors.As(err, &restErr) &&
|
||||||
|
restErr.Response.StatusCode == http.StatusBadRequest &&
|
||||||
|
bytes.Contains(restErr.ResponseBody, []byte("captcha-required")) {
|
||||||
|
ce.Reply("Error logging in: %v\n\nCAPTCHAs are currently not supported - use token login instead", err)
|
||||||
|
} else {
|
||||||
|
ce.Reply("Error logging in: %v", err)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
} else if err = ce.User.Login(user.Token); err != nil {
|
} else if err = ce.User.Login(user.Token); err != nil {
|
||||||
ce.Reply("Error connecting after login: %v", err)
|
ce.Reply("Error connecting after login: %v", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user