v1.0.0 beta 12
This commit is contained in:
28
examples/basic/example.go
Normal file
28
examples/basic/example.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"git.nix13.pw/scuroneko/laniakea"
|
||||
)
|
||||
|
||||
func pong(ctx *laniakea.MsgContext, db *laniakea.NoDB) {
|
||||
ctx.Answer(ctx.Msg.Text)
|
||||
}
|
||||
|
||||
func main() {
|
||||
bot := laniakea.NewBot[laniakea.NoDB](laniakea.LoadOptsFromEnv())
|
||||
defer bot.Close()
|
||||
|
||||
p := laniakea.NewPlugin[laniakea.NoDB]("ping")
|
||||
p.NewCommand(pong, "ping")
|
||||
|
||||
bot = bot.ErrorTemplate(
|
||||
"Error\n\n%s",
|
||||
).AddPlugins(p)
|
||||
|
||||
if err := bot.AutoGenerateCommands(); err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
bot.Run()
|
||||
}
|
||||
Reference in New Issue
Block a user