x
This commit is contained in:
@@ -303,7 +303,7 @@ interface Sender {
|
|||||||
|
|
||||||
### Express `Request` / `Response`
|
### Express `Request` / `Response`
|
||||||
|
|
||||||
只能说是够用,有需求可联系作者。插件中通过 `Express()` 返回一个对象,或者`require("express")()`。
|
只能说是够用,有需求可联系作者。插件中通过 `Express()` 返回一个对象。
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
interface Request {
|
interface Request {
|
||||||
@@ -392,11 +392,9 @@ class Adapter(botplt: string, botid: string) {
|
|||||||
setIsAdmin(func: (user_id: string) => boolean): void; //设置用户是否是成员函数,默认自动实现
|
setIsAdmin(func: (user_id: string) => boolean): void; //设置用户是否是成员函数,默认自动实现
|
||||||
destroy(): void;//销毁机器人
|
destroy(): void;//销毁机器人
|
||||||
}
|
}
|
||||||
function getAdapter(platform: string, bot_id string): [Adapter: string, error: string]; //获取一个机器人
|
function getAdapter(platform: string, bot_id string): {Adapter: string, error: string}; //获取一个机器人
|
||||||
|
|
||||||
function getAdapters(platform: string, bot_ids ...string): [Adapter: string[], error: string]; //获取多个机器人
|
function getAdapterBotsID(bot_id string): Adapter[]; //获取一个平台的所有机器人
|
||||||
|
|
||||||
function getAdapterBotsID(bot_id string): string[]; //获取一个平台的所有机器人
|
|
||||||
|
|
||||||
function getAdapterBotPlts(platform: string): string[]; //所有机器人平台
|
function getAdapterBotPlts(platform: string): string[]; //所有机器人平台
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -32,7 +32,15 @@ type RequestPluginResult struct {
|
|||||||
|
|
||||||
var plugin_list = []*common.Function{}
|
var plugin_list = []*common.Function{}
|
||||||
|
|
||||||
var cdle_sublink = "link://T4EywWN46ztYBhHNdOl6Tpz8QQsCZGj8JvdRJ5QKatJm0P+mI/G3ruO7AC04guqqKKa29VOvTGR7ATUJGYayRBpG2RFq+6ZPK3vcu6KCDGvRE3S43Gj42EXfvs04M6s4\nlink://T4EywWN46ztYBhHNdOl6Tpz8QQsCZGj8JvdRJ5QKatJYds3a/BticqD0hzidGsOysEx/RK/nKppChxMLb6QGczhWjGC/M2ETxWb+Jl+6q/x+LP4gy+ibeAEzatOYwdZMckI8nN/R6mY/HW2dyBtp0qH1ldICn6Wl+9YowLvvpLU=\nlink://T4EywWN46ztYBhHNdOl6Tpz8QQsCZGj8JvdRJ5QKatL/GWakSkUWVNTd/jJS4YaqGXqvoJOxtEwVxbfBpmsMdTpKFr7K/+9MW/CJFpFsLFGM3yRxh2z8fVsDZUV6GoXei5QhOviIvo5ys7N5b6MRiEmbVATiiTEovz3IBg8nObQ="
|
var cdle_sublink = `
|
||||||
|
//傻妞官方
|
||||||
|
link://T4EywWN46ztYBhHNdOl6Tpz8QQsCZGj8JvdRJ5QKatJm0P+mI/G3ruO7AC04guqqKKa29VOvTGR7ATUJGYayRBpG2RFq+6ZPK3vcu6KCDGvRE3S43Gj42EXfvs04M6s4
|
||||||
|
//大灰机
|
||||||
|
link://T4EywWN46ztYBhHNdOl6ThvHulsS6Fo5vRI+WFDJEtMBltBIFj2gLoSSIFXLSRmeAwYxIkikr+TZUzuTr2QYZ7edh12jsIgAv3s0FR3pqace1TX5/6r2rcc52HlAkCPU
|
||||||
|
//搬运中心
|
||||||
|
link://T4EywWN46ztYBhHNdOl6Tpz8QQsCZGj8JvdRJ5QKatJYds3a/BticqD0hzidGsOysEx/RK/nKppChxMLb6QGczhWjGC/M2ETxWb+Jl+6q/x+LP4gy+ibeAEzatOYwdZMckI8nN/R6mY/HW2dyBtp0qH1ldICn6Wl+9YowLvvpLU=
|
||||||
|
//木子李
|
||||||
|
link://T4EywWN46ztYBhHNdOl6Tpz8QQsCZGj8JvdRJ5QKatL/GWakSkUWVNTd/jJS4YaqGXqvoJOxtEwVxbfBpmsMdTpKFr7K/+9MW/CJFpFsLFGM3yRxh2z8fVsDZUV6GoXei5QhOviIvo5ys7N5b6MRiEmbVATiiTEovz3IBg8nObQ=`
|
||||||
|
|
||||||
func initPluginList() {
|
func initPluginList() {
|
||||||
list := []*common.Function{}
|
list := []*common.Function{}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package core
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@@ -114,82 +113,6 @@ func SetPluginMethod(vm *goja.Runtime, uuid string, on_start bool, running func(
|
|||||||
vm.Set("Bucket", func(name string) interface{} {
|
vm.Set("Bucket", func(name string) interface{} {
|
||||||
return JsBucket(vm, name, uuid, on_start)
|
return JsBucket(vm, name, uuid, on_start)
|
||||||
})
|
})
|
||||||
sillyplusJsIplm := func(call goja.ConstructorCall) *goja.Object {
|
|
||||||
userId := fmt.Sprintf("%d", rand.Int63())
|
|
||||||
call.This.Set("isSlaveMode", func() bool {
|
|
||||||
return utils.SlaveMode
|
|
||||||
})
|
|
||||||
call.This.Set("uuid", func() string {
|
|
||||||
return uuid
|
|
||||||
})
|
|
||||||
call.This.Set("store", func(str string, v interface{}) {
|
|
||||||
store.Store(str, v)
|
|
||||||
})
|
|
||||||
call.This.Set("load", func(str string) interface{} {
|
|
||||||
v, _ := store.Load(str)
|
|
||||||
return v
|
|
||||||
})
|
|
||||||
call.This.Set("delete", func(str string) {
|
|
||||||
store.Delete(str)
|
|
||||||
})
|
|
||||||
call.This.Set("session", func(info interface{}) func(...int) interface{} {
|
|
||||||
msg := ""
|
|
||||||
imTpye := "carry"
|
|
||||||
var chatId string
|
|
||||||
switch info := info.(type) {
|
|
||||||
case string:
|
|
||||||
msg = info
|
|
||||||
default:
|
|
||||||
props := info.(map[string]interface{})
|
|
||||||
for i := range props {
|
|
||||||
switch strings.ToLower(i) {
|
|
||||||
case "imtype":
|
|
||||||
imTpye = props[i].(string)
|
|
||||||
case "platform":
|
|
||||||
imTpye = props[i].(string)
|
|
||||||
case "msg", "message":
|
|
||||||
msg = props[i].(string)
|
|
||||||
case "chatid", "chat_id":
|
|
||||||
chatId = fmt.Sprint(props[i].(string))
|
|
||||||
case "userid", "user_id":
|
|
||||||
userId = props[i].(string)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if msg == "" {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
c := &Faker{
|
|
||||||
Type: imTpye,
|
|
||||||
Message: msg,
|
|
||||||
Carry: make(chan string),
|
|
||||||
UserID: userId,
|
|
||||||
ChatID: chatId,
|
|
||||||
Admin: true,
|
|
||||||
}
|
|
||||||
Messages <- c
|
|
||||||
var f = func(i ...int) interface{} {
|
|
||||||
timeOut := 1000 * 100
|
|
||||||
if len(i) > 0 {
|
|
||||||
timeOut = i[0]
|
|
||||||
}
|
|
||||||
select {
|
|
||||||
case v, ok := <-c.Listen():
|
|
||||||
return map[string]interface{}{
|
|
||||||
"hasNext": ok,
|
|
||||||
"message": v,
|
|
||||||
}
|
|
||||||
case <-time.After(time.Millisecond * time.Duration(timeOut)):
|
|
||||||
return map[string]interface{}{
|
|
||||||
"hasNext": false,
|
|
||||||
"message": "已超时",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return f
|
|
||||||
})
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
registry := require.NewRegistry(require.WithLoader(mapFileSystemSourceLoader(uuid)))
|
registry := require.NewRegistry(require.WithLoader(mapFileSystemSourceLoader(uuid)))
|
||||||
if on_start {
|
if on_start {
|
||||||
var ids = &[]cron.EntryID{}
|
var ids = &[]cron.EntryID{}
|
||||||
@@ -323,7 +246,6 @@ func SetPluginMethod(vm *goja.Runtime, uuid string, on_start bool, running func(
|
|||||||
vm.Set("image", utils.ToImageQrcode)
|
vm.Set("image", utils.ToImageQrcode)
|
||||||
vm.Set("video", utils.ToVideoQrcode)
|
vm.Set("video", utils.ToVideoQrcode)
|
||||||
vm.Set("console", &Console{UUID: uuid})
|
vm.Set("console", &Console{UUID: uuid})
|
||||||
vm.Set("sillyplus", sillyplusJsIplm)
|
|
||||||
vm.Set("call", func(str string) interface{} {
|
vm.Set("call", func(str string) interface{} {
|
||||||
return RegistFuncs[str]
|
return RegistFuncs[str]
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user