diff --git a/.github/workflows/test_and_lint.yml b/.github/workflows/test_and_lint.yml index 9f4355b..4125b15 100644 --- a/.github/workflows/test_and_lint.yml +++ b/.github/workflows/test_and_lint.yml @@ -18,12 +18,14 @@ jobs: steps: - name: Code uses: actions/checkout@v4 + - name: Install Go uses: actions/setup-go@v5 with: go-version: '^1.23' cache: false - run: go get + - run: go install golang.org/x/tools/cmd/stringer - run: go generate ./... - run: go test -v -race ./... @@ -32,15 +34,19 @@ jobs: steps: - name: Code uses: actions/checkout@v4 + - name: Install Go uses: actions/setup-go@v5 with: - cache: false go-version: '^1.23' + cache: false - run: go get + - run: go install golang.org/x/tools/cmd/stringer - run: go generate ./... + - name: Go vet run: go vet ./... + - name: GolangCI-Lint uses: golangci/golangci-lint-action@v6 with: diff --git a/client/loginerror_string.go b/client/loginerror_string.go new file mode 100644 index 0000000..7d302b1 --- /dev/null +++ b/client/loginerror_string.go @@ -0,0 +1,43 @@ +// Code generated by "stringer -type=LoginError"; DO NOT EDIT. + +package client + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[NeedCaptcha-1] + _ = x[OtherLoginError-3] + _ = x[UnsafeDeviceError-4] + _ = x[SMSNeededError-5] + _ = x[TooManySMSRequestError-6] + _ = x[SMSOrVerifyNeededError-7] + _ = x[SliderNeededError-8] + _ = x[UnknownLoginError - -1] +} + +const ( + _LoginError_name_0 = "UnknownLoginError" + _LoginError_name_1 = "NeedCaptcha" + _LoginError_name_2 = "OtherLoginErrorUnsafeDeviceErrorSMSNeededErrorTooManySMSRequestErrorSMSOrVerifyNeededErrorSliderNeededError" +) + +var ( + _LoginError_index_2 = [...]uint8{0, 15, 32, 46, 68, 90, 107} +) + +func (i LoginError) String() string { + switch { + case i == -1: + return _LoginError_name_0 + case i == 1: + return _LoginError_name_1 + case 3 <= i && i <= 8: + i -= 3 + return _LoginError_name_2[_LoginError_index_2[i]:_LoginError_index_2[i+1]] + default: + return "LoginError(" + strconv.FormatInt(int64(i), 10) + ")" + } +} diff --git a/client/oicq.go b/client/oicq.go index 759c1d0..6ed346f 100644 --- a/client/oicq.go +++ b/client/oicq.go @@ -13,6 +13,8 @@ import ( tea "github.com/fumiama/gofastTEA" ) +// ref https://github.com/Mrs4s/MiraiGo/blob/54bdd873e3fed9fe1c944918924674dacec5ac76/client/entities.go#L18 + type ( LoginError int