mirror of
https://github.com/D-Modem/bbs.git
synced 2026-11-28 17:38:04 -08:00
A sysop's main menu has * (and custom menus a sysop action), on every
terminal:
- Watch a node: what a text caller is sent, as it is sent (the text
terminal's connection echoes to bbs.Node.Echo; a slow watcher misses
some, never slows the caller). A key stops; the caller leaving ends
it. Text terminals only.
- Chat with a node: the caller is told and taken into a private chat
(their page's room) at their next menu; the sysop waits there.
- Kick a node.
- Users: level, flags, lock, sysop rights, a new password (not one's
own lock or rights).
- Statistics: totals, and calls, new users, posts and uploads for each
of the last 14 days as bars.
- The bans (lifted by number) and the hack log.
- Scheduled events ([event NAME]: a program run without a shell, daily
at a time or every N minutes, with a timeout; internal/events): when
they run next, the last run's end and output, run now.
- Available: whether pages reach the sysop; when not, a caller who pages
may leave a message.
The API: GET /admin/events, POST /admin/events/{name}/run, PUT
/admin/available. Sysop-Tools is the wiki page.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr
55 lines
1.5 KiB
Go
55 lines
1.5 KiB
Go
package store
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
// What Times counts: a table and its time column.
|
|
var timeColumns = map[string]string{
|
|
"calls": "SELECT at FROM calls WHERE at >= ?",
|
|
"posts": "SELECT created FROM messages WHERE created >= ?",
|
|
"users": "SELECT created FROM users WHERE created >= ?",
|
|
"uploads": "SELECT created FROM files WHERE created >= ?",
|
|
"mail": "SELECT created FROM mail WHERE created >= ?",
|
|
"messages": "SELECT created FROM messages WHERE created >= ?",
|
|
}
|
|
|
|
// Times are when what happened since t: calls, posts, users (made),
|
|
// uploads, mail.
|
|
func (s *Store) Times(what string, since time.Time) ([]time.Time, error) {
|
|
q, ok := timeColumns[what]
|
|
if !ok {
|
|
return nil, fmt.Errorf("no times of %q", what)
|
|
}
|
|
rows, err := s.db.Query(q, since.Unix())
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var out []time.Time
|
|
for rows.Next() {
|
|
var at int64
|
|
if err := rows.Scan(&at); err != nil {
|
|
return nil, err
|
|
}
|
|
out = append(out, unix(at))
|
|
}
|
|
return out, rows.Err()
|
|
}
|
|
|
|
// Totals are how many users, messages, mail, files and calls (kept) there
|
|
// are.
|
|
func (s *Store) Totals() (map[string]int, error) {
|
|
out := map[string]int{}
|
|
for k, q := range map[string]string{"users": "SELECT COUNT(*) FROM users", "messages": "SELECT COUNT(*) FROM messages",
|
|
"mail": "SELECT COUNT(*) FROM mail", "files": "SELECT COUNT(*) FROM files", "calls": "SELECT COUNT(*) FROM calls"} {
|
|
var n int
|
|
if err := s.db.QueryRow(q).Scan(&n); err != nil {
|
|
return nil, err
|
|
}
|
|
out[k] = n
|
|
}
|
|
return out, nil
|
|
}
|