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)
|
||||
|
||||
@@ -2,7 +2,11 @@ module example/basic
|
||||
|
||||
go 1.26.1
|
||||
|
||||
require git.nix13.pw/scuroneko/laniakea v1.0.0-beta.12
|
||||
require git.nix13.pw/scuroneko/laniakea v1.0.0-beta.13
|
||||
|
||||
replace (
|
||||
git.nix13.pw/scuroneko/laniakea v1.0.0-beta.13 => ../../
|
||||
)
|
||||
|
||||
require (
|
||||
git.nix13.pw/scuroneko/extypes v1.2.1 // indirect
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
git.nix13.pw/scuroneko/extypes v1.2.1 h1:IYrOjnWKL2EAuJYtYNa+luB1vBe6paE8VY/YD+5/RpQ=
|
||||
git.nix13.pw/scuroneko/extypes v1.2.1/go.mod h1:uZVs8Yo3RrYAG9dMad6qR6lsYY67t+459D9c65QAYAw=
|
||||
git.nix13.pw/scuroneko/laniakea v1.0.0-beta.12 h1:IpcLF5OTZKOsYhj7AULDsDPrCUdtSnS5LgApOyMIRYU=
|
||||
git.nix13.pw/scuroneko/laniakea v1.0.0-beta.12/go.mod h1:M8jwm195hzAl9bj9Bkl95WfHmWvuBX6micsdtOs/gmE=
|
||||
git.nix13.pw/scuroneko/laniakea v1.0.0-beta.13 h1:mRVxYh7CNrm8ccob+u6XxLzZRbs1fLNRg/nXaXY78yw=
|
||||
git.nix13.pw/scuroneko/laniakea v1.0.0-beta.13/go.mod h1:M8jwm195hzAl9bj9Bkl95WfHmWvuBX6micsdtOs/gmE=
|
||||
git.nix13.pw/scuroneko/slog v1.0.2 h1:vZyUROygxC2d5FJHUQM/30xFEHY1JT/aweDZXA4rm2g=
|
||||
git.nix13.pw/scuroneko/slog v1.0.2/go.mod h1:3Qm2wzkR5KjwOponMfG7TcGSDjmYaFqRAmLvSPTuWJI=
|
||||
github.com/alitto/pond/v2 v2.7.0 h1:c76L+yN916m/DRXjGCeUBHHu92uWnh/g1bwVk4zyyXg=
|
||||
|
||||
Reference in New Issue
Block a user