-
Notifications
You must be signed in to change notification settings - Fork 2k
👍 添加查成分功能,修改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
Conversation
# Conflicts: # plugin/bilibili/info.go # plugin/bilibili/live_info.go
plugin/bilibili/api.go
Outdated
) | ||
|
||
// 搜索api:通过把触发指令传入的昵称找出uid返回 | ||
func search(keyword string) (*gjson.Result, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
应当直接返回uid而非gjson
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
之前的>user info [xxx]用了这个接口,这是复用接口
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
一起改掉也行
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以
plugin/bilibili/api.go
Outdated
return result, nil | ||
} | ||
|
||
func followings(uid string) (*gjson.Result, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同理,应当直接返回uname
plugin/bilibili/api.go
Outdated
return result, err | ||
} | ||
cardStr := binary.BytesToString(data) | ||
result.Name = gjson.Get(cardStr, "card.name").String() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议直接用json.Unmarshal()
plugin/bilibili/api.go
Outdated
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上,建议直接用json.Unmarshal()
plugin/bilibili/api.go
Outdated
} | ||
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\"") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议将此err定义为全局变量ErrNeedCookie
plugin/bilibili/model.go
Outdated
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/" |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个颜色顺序是正确的吗,我不知道啊
plugin/bilibili/model.go
Outdated
|
||
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" |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bytes.NewReader()
No description provided.