mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 13:59:39 +08:00
commit
760e6334cd
124
.idea/workspace.xml
Normal file
124
.idea/workspace.xml
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ChangeListManager">
|
||||||
|
<list default="true" id="075d8bd1-a584-4439-8e19-b0c2acd4ed59" name="Default Changelist" comment="修了个body包数据为空的bug,虽然不知道发生了啥,但它确实是被修好了" />
|
||||||
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
|
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||||
|
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||||
|
</component>
|
||||||
|
<component name="GOROOT" url="file://$PROJECT_DIR$/../../gosdk/go1.16" />
|
||||||
|
<component name="Git.Settings">
|
||||||
|
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||||
|
</component>
|
||||||
|
<component name="GoLibraries">
|
||||||
|
<option name="indexEntireGoPath" value="false" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectId" id="1uihCVlCP3LZiTROCGKX2A0l3rd" />
|
||||||
|
<component name="ProjectViewState">
|
||||||
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
|
<option name="showLibraryContents" value="true" />
|
||||||
|
</component>
|
||||||
|
<component name="PropertiesComponent">
|
||||||
|
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
|
||||||
|
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
|
||||||
|
<property name="WebServerToolWindowFactoryState" value="false" />
|
||||||
|
<property name="go.import.settings.migrated" value="true" />
|
||||||
|
<property name="go.sdk.automatically.set" value="true" />
|
||||||
|
<property name="go.tried.to.enable.integration.vgo.integrator" value="true" />
|
||||||
|
<property name="last_opened_file_path" value="$PROJECT_DIR$/../Apsara" />
|
||||||
|
<property name="node.js.detected.package.eslint" value="true" />
|
||||||
|
<property name="node.js.path.for.package.eslint" value="project" />
|
||||||
|
<property name="node.js.path.for.package.tslint" value="project" />
|
||||||
|
<property name="node.js.selected.package.eslint" value="(autodetect)" />
|
||||||
|
<property name="node.js.selected.package.tslint" value="(autodetect)" />
|
||||||
|
<property name="settings.editor.selected.configurable" value="go.sdk" />
|
||||||
|
</component>
|
||||||
|
<component name="RemoteSynchronizer">
|
||||||
|
<option name="targetMappings">
|
||||||
|
<list>
|
||||||
|
<TargetMappings>
|
||||||
|
<option name="name" value="Default" />
|
||||||
|
</TargetMappings>
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
<component name="RunManager" selected="Go Build.go build main.go">
|
||||||
|
<configuration default="true" type="GoApplicationRunConfiguration" factoryName="Go Application">
|
||||||
|
<working_directory value="$PROJECT_DIR$" />
|
||||||
|
<go_parameters value="-i" />
|
||||||
|
<kind value="FILE" />
|
||||||
|
<filePath value="$PROJECT_DIR$" />
|
||||||
|
<package value="github.com/FloatTech/ZeroBot-Plugin" />
|
||||||
|
<directory value="$PROJECT_DIR$" />
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
<configuration name="go build github.com/FloatTech/ZeroBot-Plugin" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true" nameIsGenerated="true">
|
||||||
|
<module name="ZeroBot-Plugin" />
|
||||||
|
<working_directory value="$PROJECT_DIR$" />
|
||||||
|
<kind value="PACKAGE" />
|
||||||
|
<filePath value="$PROJECT_DIR$/main.go" />
|
||||||
|
<package value="github.com/FloatTech/ZeroBot-Plugin" />
|
||||||
|
<directory value="$PROJECT_DIR$" />
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
<configuration name="go build info.go" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true" nameIsGenerated="true">
|
||||||
|
<module name="ZeroBot-Plugin" />
|
||||||
|
<working_directory value="$PROJECT_DIR$" />
|
||||||
|
<kind value="FILE" />
|
||||||
|
<filePath value="$PROJECT_DIR$/plugin_bilibili/info.go" />
|
||||||
|
<package value="github.com/FloatTech/ZeroBot-Plugin" />
|
||||||
|
<directory value="$PROJECT_DIR$" />
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
<configuration name="go build main.go" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true" nameIsGenerated="true">
|
||||||
|
<module name="ZeroBot-Plugin" />
|
||||||
|
<working_directory value="$PROJECT_DIR$" />
|
||||||
|
<kind value="FILE" />
|
||||||
|
<filePath value="$PROJECT_DIR$/main.go" />
|
||||||
|
<package value="github.com/FloatTech/ZeroBot-Plugin" />
|
||||||
|
<directory value="$PROJECT_DIR$" />
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
<configuration default="true" type="GoTestRunConfiguration" factoryName="Go Test">
|
||||||
|
<working_directory value="$PROJECT_DIR$" />
|
||||||
|
<go_parameters value="-i" />
|
||||||
|
<framework value="gotest" />
|
||||||
|
<kind value="DIRECTORY" />
|
||||||
|
<package value="github.com/FloatTech/ZeroBot-Plugin" />
|
||||||
|
<directory value="$PROJECT_DIR$" />
|
||||||
|
<filePath value="$PROJECT_DIR$" />
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
<recent_temporary>
|
||||||
|
<list>
|
||||||
|
<item itemvalue="Go Build.go build main.go" />
|
||||||
|
<item itemvalue="Go Build.go build info.go" />
|
||||||
|
<item itemvalue="Go Build.go build github.com/FloatTech/ZeroBot-Plugin" />
|
||||||
|
</list>
|
||||||
|
</recent_temporary>
|
||||||
|
</component>
|
||||||
|
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
||||||
|
<component name="TypeScriptGeneratedFilesManager">
|
||||||
|
<option name="version" value="3" />
|
||||||
|
</component>
|
||||||
|
<component name="Vcs.Log.Tabs.Properties">
|
||||||
|
<option name="TAB_STATES">
|
||||||
|
<map>
|
||||||
|
<entry key="MAIN">
|
||||||
|
<value>
|
||||||
|
<State />
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
<option name="oldMeFiltersMigrated" value="true" />
|
||||||
|
</component>
|
||||||
|
<component name="VcsManagerConfiguration">
|
||||||
|
<MESSAGE value="修了个body包数据为空的bug,虽然不知道发生了啥,但它确实是被修好了" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value="修了个body包数据为空的bug,虽然不知道发生了啥,但它确实是被修好了" />
|
||||||
|
</component>
|
||||||
|
<component name="VgoProject">
|
||||||
|
<integration-enabled>true</integration-enabled>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@ -39,11 +39,11 @@ func FansDaily(groupID int64) {
|
|||||||
func fansData(groupID int64) {
|
func fansData(groupID int64) {
|
||||||
zero.RangeBot(func(id int64, ctx *zero.Ctx) bool {
|
zero.RangeBot(func(id int64, ctx *zero.Ctx) bool {
|
||||||
var (
|
var (
|
||||||
diana = fensiapi("672328094")
|
diana = fansapi("672328094")
|
||||||
ava = fensiapi("672346917")
|
ava = fansapi("672346917")
|
||||||
eileen = fensiapi("672342685")
|
eileen = fansapi("672342685")
|
||||||
bella = fensiapi("672353429")
|
bella = fansapi("672353429")
|
||||||
carol = fensiapi("351609538")
|
carol = fansapi("351609538")
|
||||||
)
|
)
|
||||||
ctx.SendGroupMessage(
|
ctx.SendGroupMessage(
|
||||||
groupID,
|
groupID,
|
||||||
@ -104,7 +104,7 @@ func fansData(groupID int64) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 请求api
|
// 请求api
|
||||||
func fensiapi(uid string) *follower {
|
func fansapi(uid string) *follower {
|
||||||
|
|
||||||
url := "https://api.vtbs.moe/v1/detail/" + uid
|
url := "https://api.vtbs.moe/v1/detail/" + uid
|
||||||
resp, err := http.Get(url)
|
resp, err := http.Get(url)
|
||||||
|
|||||||
@ -1,52 +1,53 @@
|
|||||||
package plugin_bilibili
|
package plugin_bilibili
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
zero "github.com/wdvxdr1123/ZeroBot"
|
zero "github.com/wdvxdr1123/ZeroBot"
|
||||||
"github.com/wdvxdr1123/ZeroBot/message"
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// 查成分的
|
||||||
func init() {
|
func init() {
|
||||||
zero.OnRegex(`^>user info\s(.{1,25})$`).
|
zero.OnRegex(`^>user info\s(.{1,25})$`).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
keyword := ctx.State["regex_matched"].([]string)[1]
|
keyword := ctx.State["regex_matched"].([]string)[1]
|
||||||
res, err := uid(keyword)
|
rest, err := uid(keyword)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.SendChain(message.Text("ERROR: ", err))
|
ctx.SendChain(message.Text("ERROR: ", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
id := res.Get("data.result.0.mid").Int()
|
id := rest.Get("data.result.0.mid").String()
|
||||||
url := fmt.Sprintf("https://api.bilibili.com/x/relation/same/followings?vmid=%d", id)
|
url := "https://api.bilibili.com/x/relation/same/followings?vmid=" + id
|
||||||
|
method := "GET"
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
req, err := http.NewRequest("GET", url, nil)
|
req, err := http.NewRequest(method, url, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.SendChain(message.Text("ERROR: ", err))
|
ctx.SendChain(message.Text("ERROR: ", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
req.Header.Add("cookie", "CURRENT_FNVAL=80; _uuid=772B88E8-3ED1-D589-29BB-F6CB5214239A06137infoc; blackside_state=1; bfe_id=6f285c892d9d3c1f8f020adad8bed553; rpdid=|(umY~Jkl|kJ0J'uYkR|)lu|); fingerprint=0ec2b1140fb30b56d7b5e415bc3b5fb1; buvid_fp=C91F5265-3DF4-4D5A-9FF3-C546370B14C0143096infoc; buvid_fp_plain=C91F5265-3DF4-4D5A-9FF3-C546370B14C0143096infoc; SESSDATA=9e0266f6%2C1639637127%2Cb0172%2A61; bili_jct=96ddbd7e22d527abdc0501339a12d4d3; DedeUserID=695737880; DedeUserID__ckMd5=0117660e75db7b01; sid=5labuhaf; PVID=1; bfe_id=1e33d9ad1cb29251013800c68af42315")
|
req.Header.Add("cookie", "CURRENT_FNVAL=80; _uuid=772B88E8-3ED1-D589-29BB-F6CB5214239A06137infoc; blackside_state=1; bfe_id=6f285c892d9d3c1f8f020adad8bed553; rpdid=|(umY~Jkl|kJ0J'uYkR|)lu|); fingerprint=0ec2b1140fb30b56d7b5e415bc3b5fb1; buvid_fp=C91F5265-3DF4-4D5A-9FF3-C546370B14C0143096infoc; buvid_fp_plain=C91F5265-3DF4-4D5A-9FF3-C546370B14C0143096infoc; SESSDATA=9e0266f6%2C1639637127%2Cb0172%2A61; bili_jct=96ddbd7e22d527abdc0501339a12d4d3; DedeUserID=695737880; DedeUserID__ckMd5=0117660e75db7b01; sid=5labuhaf; PVID=1; bfe_id=1e33d9ad1cb29251013800c68af42315")
|
||||||
resp, err := client.Do(req)
|
res, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.SendChain(message.Text("ERROR: ", err))
|
ctx.SendChain(message.Text("ERROR: ", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp.Body.Close()
|
defer res.Body.Close()
|
||||||
if resp.StatusCode != http.StatusOK {
|
|
||||||
ctx.SendChain(message.Text("ERROR: code ", resp.StatusCode))
|
body, err := ioutil.ReadAll(res.Body)
|
||||||
|
if err != nil {
|
||||||
|
ctx.SendChain(message.Text("ERROR: ", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data, _ := ioutil.ReadAll(resp.Body)
|
data := string(body)
|
||||||
json := gjson.ParseBytes(data)
|
|
||||||
ctx.SendChain(message.Text(
|
ctx.SendChain(message.Text(
|
||||||
"uid: ", res.Get("data.result.0.mid").Int(), "\n",
|
"uid: ", rest.Get("data.result.0.mid").Int(), "\n",
|
||||||
"name: ", res.Get("data.result.0.uname").Str, "\n",
|
"name: ", rest.Get("data.result.0.uname").Str, "\n",
|
||||||
"sex: ", []string{"", "", "女", "男"}[res.Get("data.result.0.gender").Int()], "\n",
|
"sex: ", []string{"", "", "女", "男"}[rest.Get("data.result.0.gender").Int()], "\n",
|
||||||
"sign: ", res.Get("data.result.0.usign").Str, "\n",
|
"sign: ", rest.Get("data.result.0.usign").Str, "\n",
|
||||||
"level: ", res.Get("data.result.0.level").Int(), "\n",
|
"level: ", rest.Get("data.result.0.level").Int(), "\n",
|
||||||
"follow: ", json.Get("data.list.#.uname"),
|
"follow: ", gjson.Get(data, "data.list.#.uname"),
|
||||||
))
|
))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,6 @@ package plugin_bilibili
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
@ -12,6 +11,7 @@ import (
|
|||||||
"github.com/wdvxdr1123/ZeroBot/message"
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// 查vup粉丝数据
|
||||||
func init() {
|
func init() {
|
||||||
zero.OnRegex(`^>vup info\s?(.{1,25})$`).
|
zero.OnRegex(`^>vup info\s?(.{1,25})$`).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
@ -21,36 +21,25 @@ func init() {
|
|||||||
ctx.SendChain(message.Text("ERROR: ", err))
|
ctx.SendChain(message.Text("ERROR: ", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
id := res.Get("data.result.0.mid").Int()
|
id := res.Get("data.result.0.mid").String()
|
||||||
// 获取详情
|
// 获取详情
|
||||||
api := fmt.Sprintf("https://api.vtbs.moe/v1/detail/%d", id)
|
json := fansapi(id)
|
||||||
resp, err := http.Get(api)
|
|
||||||
if err != nil {
|
|
||||||
ctx.SendChain(message.Text("ERROR: ", err))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp.Body.Close()
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
|
||||||
ctx.SendChain(message.Text("ERROR: code ", resp.StatusCode))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
data, _ := ioutil.ReadAll(resp.Body)
|
|
||||||
json := gjson.ParseBytes(data)
|
|
||||||
ctx.SendChain(message.Text(
|
ctx.SendChain(message.Text(
|
||||||
"uid: ", json.Get("mid").Int(), "\n",
|
"uid: ", json.Mid, "\n",
|
||||||
"名字: ", json.Get("uname").Str, "\n",
|
"名字: ", json.Uname, "\n",
|
||||||
"当前粉丝数: ", json.Get("follower").Int(), "\n",
|
"当前粉丝数: ", json.Follower, "\n",
|
||||||
"24h涨粉数: ", json.Get("rise").Int(), "\n",
|
"24h涨粉数: ", json.Rise, "\n",
|
||||||
"视频投稿数: ", json.Get("video").Int(), "\n",
|
"视频投稿数: ", json.Video, "\n",
|
||||||
"直播间id: ", json.Get("roomid").Int(), "\n",
|
"直播间id: ", json.Roomid, "\n",
|
||||||
"舰队: ", json.Get("guardNum").Int(), "\n",
|
"舰队: ", json.GuardNum, "\n",
|
||||||
"直播总排名: ", json.Get("areaRank").Int(), "\n",
|
"直播总排名: ", json.AreaRank, "\n",
|
||||||
"数据来源: ", "https://vtbs.moe/detail/", uid, "\n",
|
"数据来源: ", "https://vtbs.moe/detail/", json.Mid, "\n",
|
||||||
"数据获取时间: ", time.Now().Format("2006-01-02 15:04:05"),
|
"数据获取时间: ", time.Now().Format("2006-01-02 15:04:05"),
|
||||||
))
|
))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 搜索api:通过把触发指令传入的昵称找出uid返回
|
||||||
func uid(keyword string) (gjson.Result, error) {
|
func uid(keyword string) (gjson.Result, error) {
|
||||||
api := "http://api.bilibili.com/x/web-interface/search/type?search_type=bili_user&&user_type=1&keyword=" + keyword
|
api := "http://api.bilibili.com/x/web-interface/search/type?search_type=bili_user&&user_type=1&keyword=" + keyword
|
||||||
resp, err := http.Get(api)
|
resp, err := http.Get(api)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user