mirror of
https://github.com/fumiama/go-onebot-agent.git
synced 2026-06-06 10:40:24 +08:00
chore: remove useless param
This commit is contained in:
7
agent.go
7
agent.go
@@ -46,7 +46,6 @@ type Agent struct {
|
|||||||
perm *Perm
|
perm *Perm
|
||||||
imgpcache *ttl.Cache[uint64, string]
|
imgpcache *ttl.Cache[uint64, string]
|
||||||
mem MemoryStorage
|
mem MemoryStorage
|
||||||
manualaddreq bool
|
|
||||||
manualaddmem bool
|
manualaddmem bool
|
||||||
hasimageapi bool
|
hasimageapi bool
|
||||||
}
|
}
|
||||||
@@ -60,13 +59,13 @@ type Agent struct {
|
|||||||
func NewAgent(
|
func NewAgent(
|
||||||
id int64, batchcap, itemscap int, imgpcachettl time.Duration,
|
id int64, batchcap, itemscap int, imgpcachettl time.Duration,
|
||||||
nickname, sex, characteristics, defaultprompt string, mem MemoryStorage,
|
nickname, sex, characteristics, defaultprompt string, mem MemoryStorage,
|
||||||
manualaddreq, manualaddmem bool,
|
manualaddmem bool,
|
||||||
) (ag Agent) {
|
) (ag Agent) {
|
||||||
ag = Agent{
|
ag = Agent{
|
||||||
id: id, nickname: nickname, sex: sex, chars: characteristics,
|
id: id, nickname: nickname, sex: sex, chars: characteristics,
|
||||||
imgpcache: ttl.NewCache[uint64, string](imgpcachettl),
|
imgpcache: ttl.NewCache[uint64, string](imgpcachettl),
|
||||||
log: chat.NewLog[fmt.Stringer](batchcap, itemscap, "\n", defaultprompt),
|
log: chat.NewLog[fmt.Stringer](batchcap, itemscap, "\n", defaultprompt),
|
||||||
mem: mem, manualaddreq: manualaddreq, manualaddmem: manualaddmem,
|
mem: mem, manualaddmem: manualaddmem,
|
||||||
}
|
}
|
||||||
_ = ag.LoadPermTable()
|
_ = ag.LoadPermTable()
|
||||||
return
|
return
|
||||||
@@ -254,7 +253,7 @@ func (ag *Agent) GetAction(api deepinfra.API, p model.Protocol, grp int64, role
|
|||||||
case !ag.perm.allow(role, r.Action):
|
case !ag.perm.allow(role, r.Action):
|
||||||
err = errors.Wrap(ErrPermissionDenied, r.Action)
|
err = errors.Wrap(ErrPermissionDenied, r.Action)
|
||||||
return
|
return
|
||||||
case !ag.manualaddreq:
|
default:
|
||||||
ag.AddRequest(grp, &r)
|
ag.AddRequest(grp, &r)
|
||||||
if !ag.manualaddmem && r.Action == SVM {
|
if !ag.manualaddmem && r.Action == SVM {
|
||||||
txt, err := extractMemory(&r)
|
txt, err := extractMemory(&r)
|
||||||
|
|||||||
@@ -511,7 +511,7 @@ func (fakemem) Load(grp int64) []string {
|
|||||||
func TestAgent_system(t *testing.T) {
|
func TestAgent_system(t *testing.T) {
|
||||||
ag := NewAgent(
|
ag := NewAgent(
|
||||||
12345, 10, 10, time.Minute, "testname", "testsex", "testchar",
|
12345, 10, 10, time.Minute, "testname", "testsex", "testchar",
|
||||||
"testd", &fakemem{}, false, false,
|
"testd", &fakemem{}, false,
|
||||||
)
|
)
|
||||||
p, err := ag.system(PermRoleAdmin, 123)
|
p, err := ag.system(PermRoleAdmin, 123)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user