github.com/fumiama/NanoBot@v0.0.0-20231122134259-c22d8183efca/example/echo/main.go (about)

     1  package echo
     2  
     3  import (
     4  	ctrl "github.com/FloatTech/zbpctrl"
     5  	nano "github.com/fumiama/NanoBot"
     6  )
     7  
     8  func init() {
     9  	nano.Register("echo", &ctrl.Options[*nano.Ctx]{
    10  		DisableOnDefault: false,
    11  		Help:             "- echo xxx",
    12  	}).OnMessagePrefix("echo").SetBlock(true).
    13  		Handle(func(ctx *nano.Ctx) {
    14  			args := ctx.State["args"].(string)
    15  			if args == "" {
    16  				return
    17  			}
    18  			_, _ = ctx.SendChain(nano.ReplyTo(ctx.Message.Author.ID), nano.Text(args))
    19  		})
    20  }