mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 22:00:11 +08:00
✏️ make lint happy
This commit is contained in:
parent
67a493ee84
commit
596c75eeca
@ -19,7 +19,7 @@ import (
|
|||||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||||
|
|
||||||
"github.com/FloatTech/ZeroBot-Plugin/control"
|
"github.com/FloatTech/ZeroBot-Plugin/control"
|
||||||
"github.com/FloatTech/ZeroBot-Plugin/utils/encode"
|
ub "github.com/FloatTech/ZeroBot-Plugin/utils/binary"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -130,12 +130,12 @@ func login(username, password string) {
|
|||||||
client := &http.Client{
|
client := &http.Client{
|
||||||
Jar: gCurCookieJar,
|
Jar: gCurCookieJar,
|
||||||
}
|
}
|
||||||
usernameData, err := encode.Utf8ToGbk(helper.StringToBytes(username))
|
usernameData, err := ub.UTF82GBK(helper.StringToBytes(username))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorln("[novel]", err)
|
log.Errorln("[novel]", err)
|
||||||
}
|
}
|
||||||
usernameGbk := helper.BytesToString(usernameData)
|
usernameGbk := helper.BytesToString(usernameData)
|
||||||
passwordData, err := encode.Utf8ToGbk(helper.StringToBytes(password))
|
passwordData, err := ub.UTF82GBK(helper.StringToBytes(password))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorln("[novel]", err)
|
log.Errorln("[novel]", err)
|
||||||
}
|
}
|
||||||
@ -154,7 +154,7 @@ func login(username, password string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func search(searchKey string) (searchHtml string) {
|
func search(searchKey string) (searchHtml string) {
|
||||||
searchKeyData, err := encode.Utf8ToGbk(helper.StringToBytes(searchKey))
|
searchKeyData, err := ub.UTF82GBK(helper.StringToBytes(searchKey))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorln("[novel]", err)
|
log.Errorln("[novel]", err)
|
||||||
}
|
}
|
||||||
@ -177,7 +177,7 @@ func search(searchKey string) (searchHtml string) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("[novel] get response for url=%s got error=%s\n", searchURL, err.Error())
|
log.Errorf("[novel] get response for url=%s got error=%s\n", searchURL, err.Error())
|
||||||
}
|
}
|
||||||
searchData, err = encode.GbkToUtf8(searchData)
|
searchData, err = ub.GBK2UTF8(searchData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorln("[novel]", err)
|
log.Errorln("[novel]", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
package encode
|
package binary
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
@ -8,8 +8,8 @@ import (
|
|||||||
"golang.org/x/text/transform"
|
"golang.org/x/text/transform"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GBK 转 UTF-8
|
// GBK2UTF8 GBK 转 UTF-8
|
||||||
func GbkToUtf8(s []byte) ([]byte, error) {
|
func GBK2UTF8(s []byte) ([]byte, error) {
|
||||||
reader := transform.NewReader(bytes.NewReader(s), simplifiedchinese.GBK.NewDecoder())
|
reader := transform.NewReader(bytes.NewReader(s), simplifiedchinese.GBK.NewDecoder())
|
||||||
d, e := ioutil.ReadAll(reader)
|
d, e := ioutil.ReadAll(reader)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
@ -18,8 +18,8 @@ func GbkToUtf8(s []byte) ([]byte, error) {
|
|||||||
return d, nil
|
return d, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// UTF-8 转 GBK
|
// UTF82GBK UTF-8 转 GBK
|
||||||
func Utf8ToGbk(s []byte) ([]byte, error) {
|
func UTF82GBK(s []byte) ([]byte, error) {
|
||||||
reader := transform.NewReader(bytes.NewReader(s), simplifiedchinese.GBK.NewEncoder())
|
reader := transform.NewReader(bytes.NewReader(s), simplifiedchinese.GBK.NewEncoder())
|
||||||
d, e := ioutil.ReadAll(reader)
|
d, e := ioutil.ReadAll(reader)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
Loading…
Reference in New Issue
Block a user