Skip to content

Feat: 按照群内建议修改了chat 顺便修了下网易云热评的api #123

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 19 commits into from
Feb 12, 2022
Merged
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import (

_ "github.com/FloatTech/ZeroBot-Plugin/plugin_manager" // 群管

_ "github.com/FloatTech/ZeroBot-Plugin/plugin_thesaurus" // 不是很ex的基础词库

// ^^^^ //
// ^^^^^^^^^^^^^^ //
// ^^^^^^^高优先级区^^^^^^^ //
Expand Down
18 changes: 1 addition & 17 deletions plugin_chat/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,12 @@ import (
"github.com/FloatTech/zbputils/control/order"
)

const (
dbpath = "data/Chat/"
dbfile = dbpath + "kimoi.json"
)

var (
poke = rate.NewManager(time.Minute*5, 8) // 戳一戳
engine = control.Register("chat", order.AcquirePrio(), &control.Options{
DisableOnDefault: false,
Help: "chat\n- [BOT名字]\n- [戳一戳BOT]\n- 空调开\n- 空调关\n- 群温度\n- 设置温度[正整数]\n- mua | 啾咪 | 摸 | 上你 | 傻 | 裸 | 贴 | 老婆 | 抱 | 亲 | 一下 | 咬 | 操 | 123 | 进去 | 调教 | 搓 | 让 | 捏 | 挤 | 略 | 呐 | 原味 | 胖次 | 内裤 | 内衣 | 衣服 | ghs | 批 | 憨批 | kkp | 咕 | 骚 | 喜欢 | suki | 好き | 看 | 不能 | 砸了 | 透 | 口我 | 草我 | 自慰 | onani | オナニー | 炸了 | 色图 | 涩图 | 告白 | 对不起 | 回来 | 吻 | 软 | 壁咚 | 掰开 | 女友 | 是 | 喵 | 嗷呜 | 叫 | 拜 | 佬 | awsl | 臭 | 香 | 腿 | 张开 | 脚 | 脸 | 头发 | 手 | pr | 舔 | 小穴 | 腰 | 诶嘿嘿 | 可爱 | 扭蛋 | 鼻 | 眼 | 色气 | 推 | 床 | 举 | 手冲 | 饿 | 变 | 敲 | 爬 | 怕 | 冲 | 射 | 不穿 | 迫害 | 猫粮 | 揪尾巴 | 薄荷 | 早 | 晚安 | 揉 | 榨 | 掐 | 胸 | 奶子 | 欧派 | 嫩 | 蹭 | 牵手 | 握手 | 拍照 | w | 睡不着 | 欧尼酱 | 哥 | 爱你 | 过来 | 自闭 | 打不过 | 么么哒 | 很懂 | 膝枕 | 累了 | 安慰 | 洗澡 | 一起睡觉 | 一起 | 多大 | 姐姐 | 糖 | 嗦 | 牛子 | 🐂子 | 🐮子 | 嫌弃 | 紧 | baka | 笨蛋 | 插 | 插进来 | 屁股 | 翘 | 翘起来 | 抬 | 抬起 | 爸 | 傲娇 | rua | 咕噜咕噜 | 咕噜 | 上床 | 做爱 | 吃掉 | 吃 | 揪 | 种草莓 | 种草 | 掀 | 妹 | 病娇 | 嘻",
Help: "chat\n- [BOT名字]\n- [戳一戳BOT]\n- 空调开\n- 空调关\n- 群温度\n- 设置温度[正整数]\n-",
})
kimomap = make(kimo, 256)
chatList = make([]string, 0, 256)
)

func init() { // 插件主体
Expand Down Expand Up @@ -111,13 +104,4 @@ func init() { // 插件主体
))
}
})
initChatList(func() {
engine.OnFullMatchGroup(chatList, zero.OnlyToMe).SetBlock(true).Handle(
func(ctx *zero.Ctx) {
key := ctx.MessageString()
val := *kimomap[key]
text := val[rand.Intn(len(val))]
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text))
})
})
}
38 changes: 38 additions & 0 deletions plugin_thesaurus/chat.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Package thesaurus 修改过的单纯回复插件
package thesaurus

import (
"math/rand"

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

"github.com/FloatTech/zbputils/control/order"
)

const (
dbpath = "data/thesaurus/"
dbfile = dbpath + "kimoi_clear.json"
)

var (
engine = control.Register("thesaurus", order.AcquirePrio(), &control.Options{
DisableOnDefault: false,
Help: "thesaurus\n- 稍微干净一点的chat回复 删掉了一些有点ex的w((",
})
kimogomap = make(kimogo, 256)
chatList = make([]string, 0, 256)
)

func init() {
initthesaurusList(func() {
engine.OnFullMatchGroup(chatList, zero.OnlyToMe).SetBlock(true).Handle(
func(ctx *zero.Ctx) {
key := ctx.MessageString()
val := *kimogomap[key]
text := val[rand.Intn(len(val))]
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text)) // 来自于 https://github.com/Kyomotoi/AnimeThesaurus 的回复 经过二次修改
})
})
}
12 changes: 6 additions & 6 deletions plugin_chat/data.go → plugin_thesaurus/data.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chat
package thesaurus

import (
"encoding/json"
Expand All @@ -12,9 +12,9 @@ import (
"github.com/FloatTech/zbputils/control/order"
)

type kimo = map[string]*[]string
type kimogo = map[string]*[]string

func initChatList(postinit func()) {
func initthesaurusList(postinit func()) {
go func() {
defer order.DoneOnExit()()
process.SleepAbout1sTo2s()
Expand All @@ -23,14 +23,14 @@ func initChatList(postinit func()) {
if err != nil {
panic(err)
}
err = json.Unmarshal(data, &kimomap)
err = json.Unmarshal(data, &kimogomap)
if err != nil {
panic(err)
}
for k := range kimomap {
for k := range kimogomap {
chatList = append(chatList, k)
}
logrus.Infoln("[chat]加载", len(chatList), "条kimoi")
logrus.Infoln("[thesaurus]加载", len(chatList), "条kimoi")
postinit()
}()
}
4 changes: 2 additions & 2 deletions plugin_wangyiyun/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
)

const (
wangyiyunURL = "http://ovooa.com/API/wyrp/api.php?type=text"
wangyiyunReferer = "http://ovooa.com/"
wangyiyunURL = "https://api.gmit.vip/Api/HotComments?format=text"
wangyiyunReferer = "https://api.gmit.vip/"
ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"
)

Expand Down