From a381d134f8c4235a563368f007460ccbd7e76fa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=9B=D0=B0=D1=82?= =?UTF-8?q?=D1=8B=D0=BF=D0=BE=D0=B2?= Date: Mon, 15 Jun 2026 19:47:11 +0400 Subject: [PATCH] Fix unused and ineffectual variables --- cmd/agentbbs/admin.go | 3 ++- cmd/agentbbs/main.go | 3 ++- internal/store/store.go | 13 ++++++++++--- plugins/hello/hello.go | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 plugins/hello/hello.go diff --git a/cmd/agentbbs/admin.go b/cmd/agentbbs/admin.go index 667b004..7b9f340 100644 --- a/cmd/agentbbs/admin.go +++ b/cmd/agentbbs/admin.go @@ -76,11 +76,12 @@ func (r *liveReg) List() []admin.Live { // Kill closes a live session by id. Returns false if it is already gone. func (r *liveReg) Kill(id int64) bool { r.mu.Lock() + defer r.mu.Unlock() e, ok := r.m[id] - r.mu.Unlock() if !ok { return false } + delete(r.m, id) _ = e.s.Close() return true } diff --git a/cmd/agentbbs/main.go b/cmd/agentbbs/main.go index 583f033..24ce2e6 100644 --- a/cmd/agentbbs/main.go +++ b/cmd/agentbbs/main.go @@ -73,6 +73,7 @@ import ( "github.com/profullstack/agentbbs/internal/store" "github.com/profullstack/agentbbs/internal/tor" "github.com/profullstack/agentbbs/plugins/about" + "github.com/profullstack/agentbbs/plugins/hello" "github.com/profullstack/agentbbs/plugins/agentgames" "github.com/profullstack/agentbbs/plugins/arcade" "github.com/profullstack/agentbbs/plugins/members" @@ -175,7 +176,7 @@ func main() { a.mm = games.NewMatchmaker(a.gamesReg, a.st, time.Duration(envInt("AGENTBBS_GAME_MOVE_TIMEOUT", 15))*time.Second, time.Duration(envInt("AGENTBBS_GAME_QUEUE_WAIT", 120))*time.Second) - a.registry = []plugin.Plugin{arcade.Plugin{}, agentgames.New(a.gamesReg), members.Plugin{}, qryptinviteplugin.Plugin{}, about.Plugin{}} + a.registry = []plugin.Plugin{arcade.Plugin{}, agentgames.New(a.gamesReg), members.Plugin{}, qryptinviteplugin.Plugin{}, about.Plugin{}, hello.Plugin{}} // Custom domains: maintain the symlink farm Caddy serves and answer its // on-demand-TLS "ask" query so certs are only issued for mapped domains. diff --git a/internal/store/store.go b/internal/store/store.go index bf6b482..8a4e758 100644 --- a/internal/store/store.go +++ b/internal/store/store.go @@ -5,6 +5,7 @@ package store import ( "database/sql" "errors" + "fmt" "strings" "time" @@ -42,7 +43,9 @@ func scanUser(sc interface{ Scan(...any) error }) (User, error) { u.EmailVerified = verified != 0 u.Premium = premium != 0 u.Banned = banned != 0 - u.CreatedAt, _ = time.Parse(time.RFC3339, created) + if t, err := time.Parse(time.RFC3339, created); err == nil { + u.CreatedAt = t + } return u, nil } @@ -516,8 +519,12 @@ func (s *sqliteStore) EnsureUser(name, kind, fp string) (User, error) { if err != nil { return User{}, err } - id, _ := res.LastInsertId() - return User{ID: id, Name: name, Kind: kind, PubKeyFP: fp, CreatedAt: time.Now().UTC()}, nil + id, err := res.LastInsertId() + if err != nil { + return User{}, fmt.Errorf("get user id after insert: %w", err) + } + return User{ + ID: id, Name: name, Kind: kind, PubKeyFP: fp, CreatedAt: time.Now().UTC()}, nil case err != nil: return User{}, err } diff --git a/plugins/hello/hello.go b/plugins/hello/hello.go new file mode 100644 index 0000000..b3bb549 --- /dev/null +++ b/plugins/hello/hello.go @@ -0,0 +1,37 @@ +package hello + +import ( + tea "github.com/charmbracelet/bubbletea" + "github.com/profullstack/agentbbs/internal/auth" + "github.com/profullstack/agentbbs/internal/plugin" + "github.com/profullstack/agentbbs/internal/ui" +) + +type Plugin struct{} + +func (Plugin) ID() string { return "hello" } +func (Plugin) Title() string { return "Hello World" } +func (Plugin) Description() string { return "A simple hello world plugin by Milla-Agent" } +func (Plugin) RequiresAuth() bool { return false } + +func (Plugin) New(user auth.User, _ plugin.Context) tea.Model { + return model{} +} + +type model struct{} + +func (m model) Init() tea.Cmd { return nil } + +func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { + if k, ok := msg.(tea.KeyMsg); ok { + switch k.String() { + case "esc", "q", "enter", "ctrl+c", " ": + return m, plugin.Exit + } + } + return m, nil +} + +func (m model) View() string { + return ui.Frame.Render("Hello from Milla-Agent!\nThis is a simple module submission.\n\nPress 'q' or 'esc' to exit.") +}