Skip to content

Commit

Permalink
莲红第一次增加的插件,修复网易云
Browse files Browse the repository at this point in the history
  • Loading branch information
lianhong2758 committed Oct 1, 2022
1 parent f9b84f8 commit 1dfd2c4
Show file tree
Hide file tree
Showing 12 changed files with 290 additions and 85 deletions.
53 changes: 53 additions & 0 deletions lianhong/chehui/chehui.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//Package chehui莲红cv的防撤回插件,自动转达给主人群内的撤回消息与闪照
package chehui

import (
"strconv"
"strings"
"time"

ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)

func init() {
engine := control.Register("chehui", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: true,
Help: "自动反闪照、反撤回给bot主人",
})
engine.OnRegex(`^\[CQ:image.*`, zero.KeywordRule("type=flash")).SetBlock(false).
Handle(func(ctx *zero.Ctx) {
su := zero.BotConfig.SuperUsers[0]
now := time.Unix(ctx.Event.Time, 0).Format("2006-01-02 15:04:05")
raw := ctx.Event.RawMessage
uid := ctx.Event.UserID
gid := ctx.Event.GroupID
username := ctx.CardOrNickName(uid)
groupname := ctx.GetGroupInfo(gid, true).Name
img := strings.ReplaceAll(raw, "type=flash,", "")
text := message.UnescapeCQCodeText("捕捉到了一个闪照!\n" +
"时间:" + now + "\n" +
"来自用户:[" + username + "](" + strconv.FormatInt(uid, 10) + ")\n" +
"来自群聊:[" + groupname + "](" + strconv.FormatInt(gid, 10) + ")\n" +
"以下是原图:\n" + img)
ctx.SendPrivateMessage(su, message.ParseMessageFromString(text))
})
engine.On("notice/group_recall").SetBlock(false).
Handle(func(ctx *zero.Ctx) {
su := zero.BotConfig.SuperUsers[0]
now := time.Unix(ctx.Event.Time, 0).Format("2006-01-02 15:04:05")
raw := ctx.GetMessage(message.NewMessageIDFromInteger(ctx.Event.MessageID.(int64))).Elements.String()
uid := ctx.Event.UserID
gid := ctx.Event.GroupID
username := ctx.CardOrNickName(uid)
groupname := ctx.GetGroupInfo(gid, true).Name
text := message.UnescapeCQCodeText("捕捉到了一条撤回的消息!\n" +
"时间:" + now + "\n" +
"来自用户:[" + username + "](" + strconv.FormatInt(uid, 10) + ")\n" +
"来自群聊:[" + groupname + "](" + strconv.FormatInt(gid, 10) + ")\n" +
"以下是源消息:\n" + raw)
ctx.SendPrivateMessage(su, message.ParseMessageFromString(text))
})
}
27 changes: 27 additions & 0 deletions lianhong/jianbao/jianbao.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Package jianbao 每日60秒读懂世界
package jianbao

import (
"github.com/FloatTech/floatbox/web"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)

func init() {
engine := control.Register("jianbao", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "查看每日60秒读懂世界简报\n" +
"- 简报\n",
})
engine.OnFullMatch("简报").SetBlock(true).
Handle(func(ctx *zero.Ctx) {
data, err := web.GetData("http://bh.ayud.top/mrjb")
if err != nil {
ctx.SendChain(message.Text("获取简报失败惹", err))
return
}
ctx.SendChain(message.ImageBytes(data))
})
}
97 changes: 97 additions & 0 deletions lianhong/tupian/tupian.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// Package tupian 图片获取集合
package tupian

import (
"github.com/FloatTech/floatbox/web"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)

func init() {
engine := control.Register("tupian", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "全部图片指令\n" +
"- 兽耳\n" +
"- 白毛\n" +
"- !原神\n" +
"- 黑丝\n" +
"- 白丝\n" +
"- 随机壁纸\n" +
"- 星空\n" +
"- 涩涩哒咩/我要涩涩\n",
})
engine.OnFullMatch("兽耳").SetBlock(true).
Handle(func(ctx *zero.Ctx) {
data, err := web.GetData("https://iw233.cn/api.php?sort=cat&type")
if err != nil {
ctx.SendChain(message.Text("获取图片失败惹", err))
return
}
ctx.SendChain(message.ImageBytes(data))
})
engine.OnFullMatch("白丝").SetBlock(true).
Handle(func(ctx *zero.Ctx) {
data, err := web.GetData("http://api.iw233.cn/api.php?sort=swbs")
if err != nil {
ctx.SendChain(message.Text("获取图片失败惹", err))
return
}
ctx.SendChain(message.ImageBytes(data))
})
engine.OnFullMatch("黑丝").SetBlock(true).
Handle(func(ctx *zero.Ctx) {
data, err := web.GetData("http://api.iw233.cn/api.php?sort=swhs")
if err != nil {
ctx.SendChain(message.Text("获取图片失败惹", err))
return
}
ctx.SendChain(message.ImageBytes(data))
})
engine.OnFullMatch("随机壁纸").SetBlock(true).
Handle(func(ctx *zero.Ctx) {
data, err := web.GetData("https://iw233.cn/api.php?sort=iw233&type")
if err != nil {
ctx.SendChain(message.Text("获取图片失败惹", err))
return
}
ctx.SendChain(message.ImageBytes(data))
})
engine.OnFullMatch("白毛").SetBlock(true).
Handle(func(ctx *zero.Ctx) {
data, err := web.GetData("https://iw233.cn/api.php?sort=yin&type")
if err != nil {
ctx.SendChain(message.Text("获取图片失败惹", err))
return
}
ctx.SendChain(message.ImageBytes(data))
})
engine.OnFullMatch("星空").SetBlock(true).
Handle(func(ctx *zero.Ctx) {
data, err := web.GetData("https://iw233.cn/api.php?sort=xing&type")
if err != nil {
ctx.SendChain(message.Text("获取图片失败惹", err))
return
}
ctx.SendChain(message.ImageBytes(data))
})
engine.OnFullMatch("!原神").SetBlock(true).
Handle(func(ctx *zero.Ctx) {
data, err := web.GetData("https://sakura.iw233.cn/Tag/API/web/api/op.php")
if err != nil {
ctx.SendChain(message.Text("获取图片失败惹", err))
return
}
ctx.SendChain(message.ImageBytes(data))
})
engine.OnFullMatchGroup([]string{"涩涩哒咩", "我要涩涩"}).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
data, err := web.GetData("http://api.iw233.cn/api.php?sort=st")
if err != nil {
ctx.SendChain(message.Text("获取图片失败惹", err))
return
}
ctx.SendChain(message.ImageBytes(data))
})
}
52 changes: 52 additions & 0 deletions lianhong/yiyan/yiyan.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Package yiyan 每日一言
package yiyan

import (
"encoding/json"

ctrl "github.com/FloatTech/zbpctrl"

"github.com/FloatTech/floatbox/web"
"github.com/FloatTech/zbputils/control"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)

const url = "https://v1.hitokoto.cn/?c=a&c=b&c=c&c=d&c=h&c=i" // 动漫 漫画 游戏 文学 影视 诗词

type RspData struct {
Id int `json:"id"`
Uuid string `json:"uuid"`
Hitokoto string `json:"hitokoto"`
Type string `json:"type"`
From string `json:"from"`
FromWho string `json:"from_who"`
Creator string `json:"creator"`
CreatorUid int `json:"creator_uid"`
Reviewer int `json:"reviewer"`
CommitFrom string `json:"commit_from"`
CreatedAt string `json:"created_at"`
Length int `json:"length"`
}

func init() {
engine := control.Register("yiyan", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "- 每日一言(建议配合job插件净化群友心灵)\n",
})
engine.OnFullMatch("每日一言").SetBlock(true).Handle(handle)
}
func handle(ctx *zero.Ctx) {
var rsp RspData
data, err := web.GetData(url)
if err != nil {
ctx.SendChain(message.Text("Err:", err))
}
json.Unmarshal(data, &rsp)
msg := ""
msg += rsp.Hitokoto + "\n出自:" + rsp.From + "\n"
if len(rsp.FromWho) != 0 {
msg += "作者:" + rsp.FromWho
}
ctx.SendChain(message.Text(msg))
}
19 changes: 11 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ import (
// vvvvvvv中优先级区vvvvvvv //
// vvvvvvvvvvvvvv //
// vvvv //

_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ahsai" // ahsai tts
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ai_false" // 服务器监控
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/aiwife" // 随机老婆
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/b14" // base16384加解密
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/baidu" // 百度一下
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/bilibili" // b站相关
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/book_review" // 哀伤雪刃吧推书记录
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/breakrepeat" // 打断复读
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/cangtoushi" // 藏头诗
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/char_reverser" // 英文字符翻转
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/choose" // 选择困难症帮手
Expand All @@ -89,7 +89,6 @@ import (
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/image_finder" // 关键字搜图
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/inject" // 注入指令
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jandan" // 煎蛋网无聊图
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jikipedia" // 小鸡词典
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/juejuezi" // 绝绝子生成器
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/lolicon" // lolicon 随机图片
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/midicreate" // 简易midi音乐制作
Expand Down Expand Up @@ -123,6 +122,11 @@ import (
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wordle" // 猜单词
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ymgal" // 月幕galgame

_ "github.com/FloatTech/ZeroBot-Plugin/lianhong/chehui" //撤回插件
_ "github.com/FloatTech/ZeroBot-Plugin/lianhong/jianbao" //每日简报
_ "github.com/FloatTech/ZeroBot-Plugin/lianhong/tupian" //图片返回
_ "github.com/FloatTech/ZeroBot-Plugin/lianhong/yiyan" //每日一言

// _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wtf" // 鬼东西

// ^^^^ //
Expand All @@ -147,8 +151,6 @@ import (

_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ai_reply" // 人工智能回复

_ "github.com/FloatTech/ZeroBot-Plugin/plugin/breakrepeat" // 打断复读

// ^^^^ //
// ^^^^^^^^^^^^^^ //
// ^^^^^^^低优先级区^^^^^^^ //
Expand Down Expand Up @@ -187,14 +189,15 @@ func init() {
// 直接写死 URL 时,请更改下面第二个参数
url := flag.String("u", "ws://127.0.0.1:6700", "Set Url of WSClient.")
// 默认昵称
adana := flag.String("n", "椛椛", "Set default nickname.")
adana := flag.String("n", "雪儿", "Set default nickname.")
prefix := flag.String("p", "/", "Set command prefix.")
runcfg := flag.String("c", "", "Run from config file.")
save := flag.String("s", "", "Save default config to file and exit.")

flag.Parse()

if *h {
kanban.PrintBanner()
fmt.Println("Usage:")
flag.PrintDefaults()
os.Exit(0)
Expand All @@ -216,8 +219,8 @@ func init() {
}

// 通过代码写死的方式添加主人账号
// sus = append(sus, 12345678)
// sus = append(sus, 87654321)
sus = append(sus, 2758988938)
sus = append(sus, 330937859)

if *runcfg != "" {
f, err := os.Open(*runcfg)
Expand All @@ -240,7 +243,7 @@ func init() {

config.W = []*driver.WSClient{driver.NewWebSocketClient(*url, *token)}
config.Z = zero.Config{
NickName: append([]string{*adana}, "ATRI", "atri", "亚托莉", "アトリ"),
NickName: append([]string{*adana}, "雪儿", "梦雪", "", "梦雪儿"),
CommandPrefix: *prefix,
SuperUsers: sus,
Driver: []zero.Driver{config.W[0]},
Expand Down
Loading

0 comments on commit 1dfd2c4

Please sign in to comment.