Skip to content

Commit

Permalink
add: pulgin qunyou
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiama committed Dec 1, 2023
1 parent 2b285de commit f0c5432
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions plugin/qunyou/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Package qunyou ...
package qunyou

import (
"os/exec"
"strings"

nano "github.com/fumiama/NanoBot"

"github.com/FloatTech/NanoBot-Plugin/utils/ctxext"
ctrl "github.com/FloatTech/zbpctrl"
)

func init() {
en := nano.Register("qunyou", &ctrl.Options[*nano.Ctx]{
DisableOnDefault: false,
Help: "随机群友怪话\n- 看看群友",
})
en.OnMessagePrefix("看看群友").Limit(ctxext.LimitByGroup).Handle(func(ctx *nano.Ctx) {
prompt := ctx.State["args"].(string)
sb := strings.Builder{}
cmd := exec.Cmd{
Path: "/usr/local/bin/llama2.run",
Args: []string{"model.bin"},
Dir: "/usr/local/src/llama2.c",
Stdout: &sb,
}
if prompt != "" {
cmd.Args = append(cmd.Args, "-i", prompt)
}
err := cmd.Run()
if err != nil {
ctx.SendChain(nano.Text("ERROR: ", err))

Check failure on line 33 in plugin/qunyou/main.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `ctx.SendChain` is not checked (errcheck)
return
}
ctx.SendChain(nano.Text(sb.String()))

Check failure on line 36 in plugin/qunyou/main.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `ctx.SendChain` is not checked (errcheck)
})
}

0 comments on commit f0c5432

Please sign in to comment.