v1.0.0 beta 14

This commit is contained in:
2026-03-12 15:00:00 +03:00
parent 0574222608
commit 3b6bb82e04
7 changed files with 434 additions and 20 deletions
+9 -7
View File
@@ -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)