Skip to content

👍 添加查成分功能,修改bilibili插件的正则 #171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Mar 29, 2022
Merged

👍 添加查成分功能,修改bilibili插件的正则 #171

merged 13 commits into from
Mar 29, 2022

Conversation

guohuiyuan
Copy link
Contributor

No description provided.

)

// 搜索api:通过把触发指令传入的昵称找出uid返回
func search(keyword string) (*gjson.Result, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应当直接返回uid而非gjson

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

之前的>user info [xxx]用了这个接口,这是复用接口

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

一起改掉也行

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以

return result, nil
}

func followings(uid string) (*gjson.Result, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同理,应当直接返回uname

return result, err
}
cardStr := binary.BytesToString(data)
result.Name = gjson.Get(cardStr, "card.name").String()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议直接用json.Unmarshal()

if gjson.Get(medalStr, "code").Int() != 0 {
err = errors.New(gjson.Get(medalStr, "message").String())
}
gjson.Get(medalStr, "data.list").ForEach(func(key, value gjson.Result) bool {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上,建议直接用json.Unmarshal()

}
medalStr := binary.BytesToString(data)
if gjson.Get(medalStr, "code").Int() == -101 {
return result, errors.New("查牌子需要设置b站cookie,请发送命令设置cookie,例如\"设置b站cookie SESSDATA=82da790d,1663822823,06ecf*31\"")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议将此err定义为全局变量ErrNeedCookie

vtbURLs = [...]string{"https://api.vtbs.moe/v1/short", "https://api.tokyo.vtbs.moe/v1/short", "https://vtbs.musedash.moe/v1/short"}
dbfile = engine.DataFolder() + "bilibili.db"
vdb *vupdb
cachePath = engine.DataFolder() + "cache/"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不要做为全局变量,在engine被赋值前调用会出错。

}
}

func int2rbg(t int64) (int64, int64, int64) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应当用

var buf [8]byte
binary.LittleEndian.PutInt64(buf[:], t)
b, g, r := int64(buf[0]), int64(buf[1]), int64(buf[2])

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个颜色顺序是正确的吗,我不知道啊


var (
vtbURLs = [...]string{"https://api.vtbs.moe/v1/short", "https://api.tokyo.vtbs.moe/v1/short", "https://vtbs.musedash.moe/v1/short"}
dbfile = engine.DataFolder() + "bilibili.db"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不要做为全局变量,在engine被赋值前调用会出错。

}
defer response.Body.Close()
data, err := io.ReadAll(response.Body)
data, err := web.PostData(liveListURL, "application/json", bytes.NewBuffer(b))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bytes.NewReader()

@fumiama fumiama merged commit 006ef6f into FloatTech:master Mar 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants