v1.0.0 beta 14
This commit is contained in:
@@ -6,20 +6,22 @@ import (
|
||||
"git.nix13.pw/scuroneko/laniakea"
|
||||
)
|
||||
|
||||
func pong(ctx *laniakea.MsgContext, db *laniakea.NoDB) {
|
||||
ctx.Answer(ctx.Msg.Text)
|
||||
func echo(ctx *laniakea.MsgContext, db *laniakea.NoDB) {
|
||||
ctx.Answer(ctx.Text) // User input WITHOUT command
|
||||
}
|
||||
|
||||
func main() {
|
||||
bot := laniakea.NewBot[laniakea.NoDB](laniakea.LoadOptsFromEnv())
|
||||
opts := &laniakea.BotOpts{Token: "TOKEN"}
|
||||
bot := laniakea.NewBot[laniakea.NoDB](opts)
|
||||
defer bot.Close()
|
||||
|
||||
p := laniakea.NewPlugin[laniakea.NoDB]("ping")
|
||||
p.NewCommand(pong, "ping")
|
||||
p.AddCommand(p.NewCommand(echo, "echo"))
|
||||
p.AddCommand(p.NewCommand(func(ctx *laniakea.MsgContext, db *laniakea.NoDB) {
|
||||
ctx.Answer("Pong")
|
||||
}, "ping"))
|
||||
|
||||
bot = bot.ErrorTemplate(
|
||||
"Error\n\n%s",
|
||||
).AddPlugins(p)
|
||||
bot = bot.ErrorTemplate("Error\n\n%s").AddPlugins(p)
|
||||
|
||||
if err := bot.AutoGenerateCommands(); err != nil {
|
||||
log.Println(err)
|
||||
|
||||
Reference in New Issue
Block a user