admin

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

admin 包提供一个超级用户命令插件。

Index

Constants

This section is empty.

Variables

View Source
var Plugin = absdk.Define(absdk.Spec[Config]{
	Manifest:      absdk.Manifest{Name: "admin", Version: "1.0.2", Description: "超级用户命令"},
	DefaultConfig: Config{},
	Setup: func(ctx *absdk.Context, cfg Config) error {
		route := ctx.Command("admin").Name("command")
		if len(cfg.Users) > 0 {
			users := make([]any, len(cfg.Users))
			for i, user := range cfg.Users {
				users[i] = user
			}
			route.Use(absdk.SuperUser(users...))
		} else {
			route.Use(absdk.RequireSuperUser())
		}
		route.Handle(func(c *absdk.EventContext) error {
			args := strings.TrimSpace(c.Args())
			if args == "" {
				args = "权限正常"
			}
			_, err := c.ReplyText(args)
			return err
		})
		return nil
	},
})

Functions

This section is empty.

Types

type Config

type Config struct {
	Users []string `yaml:"users"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL