x
This commit is contained in:
+22
-12
@@ -104,23 +104,32 @@ func GetMessageByUUID(uuid string) string {
|
||||
}
|
||||
|
||||
func GetAdapter(botplt string, bots_id ...string) (*Factory, error) {
|
||||
BotsLocker.RLock()
|
||||
defer BotsLocker.RUnlock()
|
||||
|
||||
var bots = []*Factory{}
|
||||
var select_bots = []*Factory{}
|
||||
for i := range Bots {
|
||||
plt, id := i[0], i[1]
|
||||
// fmt.Println("plt", plt, "id", id, botplt, bots_id)
|
||||
for j := range bots_id {
|
||||
if plt == botplt && bots_id[j] == id {
|
||||
select_bots = append(select_bots, Bots[i])
|
||||
}
|
||||
if plt == botplt {
|
||||
bots = append(bots, Bots[i])
|
||||
var tries = 0
|
||||
Try:
|
||||
func() {
|
||||
BotsLocker.RLock()
|
||||
defer BotsLocker.RUnlock()
|
||||
for i := range Bots {
|
||||
plt, id := i[0], i[1]
|
||||
for j := range bots_id {
|
||||
if plt == botplt && bots_id[j] == id {
|
||||
select_bots = append(select_bots, Bots[i])
|
||||
}
|
||||
if plt == botplt {
|
||||
bots = append(bots, Bots[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
if len(bots) == 0 {
|
||||
if tries < 8 {
|
||||
tries++
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
goto Try
|
||||
}
|
||||
return nil, ErrNotFind
|
||||
}
|
||||
if len(select_bots) != 0 {
|
||||
@@ -672,6 +681,7 @@ type PUSH string
|
||||
|
||||
func (sender *CustomSender) Action(options map[string]interface{}) (interface{}, error) {
|
||||
if sender.F.action != nil {
|
||||
|
||||
return sender.F.action(options), nil
|
||||
}
|
||||
var platform = sender.F.botplt
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ type Language struct {
|
||||
}
|
||||
|
||||
var plugin_dir = utils.ExecPath + "/plugins"
|
||||
var release = "20230730"
|
||||
var release = "20230731"
|
||||
|
||||
var languages = []Language{
|
||||
{
|
||||
|
||||
@@ -342,6 +342,7 @@ var typeat = `declare class Sender {
|
||||
getPlatform(): Promise<string>;
|
||||
getBotId(): Promise<string>;
|
||||
getContent(): Promise<string>;
|
||||
isAdmin(): Promise<boolean>;
|
||||
param(key: number | string): Promise<string>;
|
||||
setContent(content: string): Promise<undefined>;
|
||||
continue(): Promise<undefined>;
|
||||
@@ -427,6 +428,8 @@ interface CQParams {
|
||||
declare let utils: {
|
||||
buildCQTag: (type: string, params: CQParams, prefix?: string) => string;
|
||||
parseCQText: (text: string, prefix?: string) => (string | CQItem)[];
|
||||
image: (url: string) => string;
|
||||
video: (url: string) => string;
|
||||
};
|
||||
declare let console: {
|
||||
log(...args: any[]): void;
|
||||
@@ -447,5 +450,10 @@ func defaultScript(title string) string {
|
||||
* @version v1.0.0
|
||||
*/
|
||||
|
||||
const { sender: s, Bucket, Adapter, sleep, utils, console } = require("sillygirl");`
|
||||
const {
|
||||
sender: s,
|
||||
Bucket,
|
||||
utils: { buildCQTag, image, video },
|
||||
} = require("sillygirl");
|
||||
`
|
||||
}
|
||||
|
||||
@@ -30,6 +30,14 @@ func (sg *SillyGirlService) SenderGetUserName(ctx context.Context, req *srpc.Sen
|
||||
return &srpc.Default{Value: s.GetUserName()}, nil
|
||||
}
|
||||
|
||||
func (sg *SillyGirlService) SenderIsAdmin(ctx context.Context, req *srpc.SenderRequest) (*srpc.BoolResponse, error) {
|
||||
s, err := getRegisterSenderByCtx(ctx, req.Uuid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &srpc.BoolResponse{Value: s.IsAdmin()}, nil
|
||||
}
|
||||
|
||||
func (sg *SillyGirlService) SenderGetChatId(ctx context.Context, req *srpc.SenderRequest) (*srpc.Default, error) {
|
||||
s, err := getRegisterSenderByCtx(ctx, req.Uuid)
|
||||
if err != nil {
|
||||
|
||||
@@ -121,6 +121,7 @@ func initPlugins() {
|
||||
fin = &storage.Final{
|
||||
Now: storage.EMPTY,
|
||||
}
|
||||
|
||||
}
|
||||
if isNameUuid(key) {
|
||||
if new == "install" {
|
||||
|
||||
@@ -215,7 +215,7 @@ func pluginParse(script string, uuid string) (*common.Function, []func()) {
|
||||
carry = strings.TrimSpace(res[2]) == "true"
|
||||
case "encrypt":
|
||||
encrypt = strings.TrimSpace(res[2]) == "true"
|
||||
case "on_start":
|
||||
case "on_start", "service":
|
||||
onStart = strings.TrimSpace(res[2]) == "true"
|
||||
case "form":
|
||||
hasForm = true
|
||||
|
||||
Reference in New Issue
Block a user