This commit is contained in:
cdle
2023-07-06 18:19:28 +08:00
parent e68441a86b
commit 8ed0cc485f
17 changed files with 183 additions and 142 deletions
+3 -3
View File
@@ -270,7 +270,7 @@ interface Sender {
getUserName(): string; //获取用户昵称 getUserName(): string; //获取用户昵称
getChatId(): string; //获取群聊ID getChatId(): string; //获取群聊ID
getChatName(): string; //获取群聊名称 getChatName(): string; //获取群聊名称
getMessageId(): {message_id: string, error: string}; //获取消息ID getMessageId(): string; //获取消息ID
getContent(): string; //获取消息内容 getContent(): string; //获取消息内容
continue(): void; //使消息继续往下匹配正则,消息正常第一次被匹配就会停止继续匹配 continue(): void; //使消息继续往下匹配正则,消息正常第一次被匹配就会停止继续匹配
setContent(content: string): void; //修改接收到的消息内容,可配合`continue`被其他规则匹配 setContent(content: string): void; //修改接收到的消息内容,可配合`continue`被其他规则匹配
@@ -292,7 +292,7 @@ interface Sender {
isAdmin(): boolean; //判断消息是否来自管理员 isAdmin(): boolean; //判断消息是否来自管理员
getPlatform(): string; //获取消息平台 getPlatform(): string; //获取消息平台
getBotId(): string; //获取机器人ID getBotId(): string; //获取机器人ID
reply(content: string): string; //回复消息,媒体消息推荐使用CQ码实现,返回消息ID reply(content: string): {message_id: string, error: string}; //回复消息,媒体消息推荐使用CQ码实现,返回消息ID
recallMessage(meesageId: string | string[] | number): {error: string}; //撤回消息,number类型时为延时毫秒 recallMessage(meesageId: string | string[] | number): {error: string}; //撤回消息,number类型时为延时毫秒
kick(user_id: string): {error: string}; //移出群聊 kick(user_id: string): {error: string}; //移出群聊
unkick(user_id: string): {error: string}; //取消移出群聊 unkick(user_id: string): {error: string}; //取消移出群聊
@@ -410,7 +410,7 @@ interface Bucket(name: string) {
get(key: string, defaultValue: any): any; // 取值 get(key: string, defaultValue: any): any; // 取值
set(key: string, value: any): Error | null; // 设值 set(key: string, value: any): Error | null; // 设值
watch(key: string, event: (old: any, new_: any, key: string) => void); // 设置监听器,key 值为 * 时将监听整个桶的存储事件 watch(key: string, event: (old: any, new_: any, key: string) => void); // 设置监听器,key 值为 * 时将监听整个桶的存储事件
foreach(func: (key: string, value: any) => void): void; // 遍历 getAll(): []; // 获取全部
delete(key: string): Error | null; // 删值 delete(key: string): Error | null; // 删值
empty(): Error | undefined; // 清空桶 empty(): Error | undefined; // 清空桶
keys(): string[]; // 获取所有键名 keys(): string[]; // 获取所有键名
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -8,6 +8,6 @@
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>
<script src="/admin/umi.6114f405.js"></script> <script src="/admin/umi.1177c492.js"></script>
</body></html> </body></html>
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
View File
@@ -39,6 +39,7 @@ type Function struct {
HasForm bool `json:"has_form"` HasForm bool `json:"has_form"`
Carry bool `json:"carry"` Carry bool `json:"carry"`
Messages interface{} `json:"messages"` Messages interface{} `json:"messages"`
Classes []string `json:"classes"`
} }
type Filter struct { type Filter struct {
BlackMode bool BlackMode bool
+6
View File
@@ -283,6 +283,7 @@ func initPlugin(data string, uuid string) (*common.Function, []func(), error) {
var FindAll bool var FindAll bool
var hasForm bool var hasForm bool
var carry bool var carry bool
var classes = []string{}
ks := map[string]bool{} ks := map[string]bool{}
ress := regexp.MustCompile( ress := regexp.MustCompile(
`\*\s?@([\d\w+-]+)\s+([^\n]+?)\n`, `\*\s?@([\d\w+-]+)\s+([^\n]+?)\n`,
@@ -345,6 +346,9 @@ func initPlugin(data string, uuid string) (*common.Function, []func(), error) {
} else { } else {
rules = append(rules, rule) rules = append(rules, rule)
} }
case "class":
classes = append(classes, regexp.MustCompile(`[\S]+`).FindAllString(res[2], -1)...)
classes = utils.Unique(classes)
case "platform", "imType", "platform+", "imType+": case "platform", "imType", "platform+", "imType+":
var item []string var item []string
for _, i := range regexp.MustCompile(`[\d\w-]+`).FindAllString(res[2], -1) { for _, i := range regexp.MustCompile(`[\d\w-]+`).FindAllString(res[2], -1) {
@@ -399,6 +403,7 @@ func initPlugin(data string, uuid string) (*common.Function, []func(), error) {
BlackMode: true, BlackMode: true,
Items: item, Items: item,
} }
case "admin": case "admin":
admin = strings.TrimSpace(res[2]) == "true" admin = strings.TrimSpace(res[2]) == "true"
case "disable": case "disable":
@@ -623,6 +628,7 @@ func initPlugin(data string, uuid string) (*common.Function, []func(), error) {
FindAll: FindAll, FindAll: FindAll,
HasForm: hasForm, HasForm: hasForm,
Carry: carry, Carry: carry,
Classes: classes,
} }
running = func() bool { running = func() bool {
return f.Running return f.Running
+34
View File
@@ -25,6 +25,7 @@ type RequestPluginResult struct {
Tab2 int `json:"tab2"` Tab2 int `json:"tab2"`
Tab3 int `json:"tab3"` Tab3 int `json:"tab3"`
Time time.Time `json:"time"` Time time.Time `json:"time"`
Classes map[string]int `json:"classes"`
} }
var plugin_list = []*common.Function{} var plugin_list = []*common.Function{}
@@ -121,12 +122,16 @@ func initWebPluginList() {
activeKey := ctx.Query("activeKey") activeKey := ctx.Query("activeKey")
init := ctx.Query("init") init := ctx.Query("init")
keyword := ctx.Query("keyword") keyword := ctx.Query("keyword")
class := ctx.Query("class")
rr := RequestPluginResult{ rr := RequestPluginResult{
Success: true, Success: true,
} }
if pageSize == 0 { if pageSize == 0 {
pageSize = 10 pageSize = 10
} }
if class == "" {
class = "全部"
}
rr.Page = current rr.Page = current
rr.Data = []*common.Function{} rr.Data = []*common.Function{}
if current != 0 { if current != 0 {
@@ -149,7 +154,34 @@ func initWebPluginList() {
tab3 := []*common.Function{} tab3 := []*common.Function{}
fc := []*common.Function{} fc := []*common.Function{}
fc = append(fc, Functions...) fc = append(fc, Functions...)
classes := map[string][]*common.Function{}
classesNum := map[string]int{}
for i := range list { for i := range list {
if len(list[i].Classes) == 0 {
class := "未分类"
if _, ok := classes[class]; !ok {
classes[class] = []*common.Function{}
}
classes[class] = append(classes[class], list[i])
} else {
for _, class := range list[i].Classes {
if _, ok := classes[class]; !ok {
classes[class] = []*common.Function{}
}
classes[class] = append(classes[class], list[i])
}
}
}
for class, fs := range classes {
classesNum[class] = len(fs)
}
classesNum["全部"] = len(list)
if class != "全部" {
list, _ = classes[class]
}
rr.Classes = classesNum
for i := range list { //处理第二分类
ded := false ded := false
for j := range fc { for j := range fc {
if list[i].UUID == fc[j].UUID { if list[i].UUID == fc[j].UUID {
@@ -166,6 +198,7 @@ func initWebPluginList() {
tab2 = append(tab2, list[i]) tab2 = append(tab2, list[i])
} }
} }
if activeKey == "tab2" { if activeKey == "tab2" {
list = tab2 list = tab2
rr.Tab1 = len(tab1) rr.Tab1 = len(tab1)
@@ -232,6 +265,7 @@ func initWebPluginList() {
} }
rr.Data[i].Description = parseReply2(rr.Data[i].Description) rr.Data[i].Description = parseReply2(rr.Data[i].Description)
} }
ctx.JSON(200, rr) ctx.JSON(200, rr)
return return
} }