Skip to content

Repository files navigation

modbot

Chat moderation bot for strims.gg.

running

FlagDefaultPurpose
-cookiejwt used for chat auth and API access (required)
-chatwss://chat.strims.gg/wschat websocket url
-apihttps://strims.gg/apibackend api base url
-log/tmp/chatlog/chatlog.logchat log file, rotated on SIGHUP (see modbot-rotate)
-commandscommands.jsonstatic !command store, written by !addcommand
-attokenangelthump admin token, needed for !(un)drop
-omdbkeyOMDb api key, needed for !imdb
-logonlyfalsereply to the log instead of chat, for debugging
-versionprint the built commit and exit

See monitoring for -metrics, -pinginterval and -healthcheck.

SIGINT/SIGTERM shut down cleanly; SIGHUP reopens the log file.

development

Requires Go (version pinned in go.mod) and just.

just # list recipes
just check # fmt, vet, test -race, lint, tidy -- what CI runs
just build
just image # build the container image

mod commands

CommandArgumentsExampleExtra
!modify{service/username, username} [nsfw|hidden|afk|promoted]...!modify youtube/6n3pFFPSlW4 hidden !nsfwTo invert options (remove modifier), prefix with "!".
!renameoldUsername newUsername!rename ihatememes ilovememesUser has to reconnect after. Alternatively ban for 1 second.
!addcommand[!]commandname output!addcommand test i like testsOverwrites an existing command of the same name.
!delcommand[!]commandname!delcommand testRemoves the given command.
!saystring!say something niceAlways replies in public chat, even when issued over PM.
!muteusernameLimited functionality, default 10m duration.
!nukestring!nuke badword123default 10m duration.
!nukeregexregexp!nukeregex (MiyanoHype ){10,}default 10m duration.
!aegis_undo all past nukes.
!(un)dropAT_name!undrop testBan or unban user from angelthump service.

public commands

CommandArgumentsExampleExtra
!stream|!strim_Prints lists of top streams.
!checkAT_name!check testCheck status of an AT stream.
!imdb[-tv|-s] title [year]!imdb dune 2021Looks up a movie by default; -tv looks up a series instead; -s searches and lists up to 5 matches. Requires -omdbkey to be set.

monitoring

/metrics (prometheus) and /healthz are served on -metrics (default :9090). The container publishes no ports; it is scraped by name over the strims docker network.

FlagDefaultMeaning
-metrics:9090listen address for /metrics and /healthz
-pinginterval30skeepalive PING interval, which drives modbot_connected
-healthcheckfalseprobe a running instance and exit; used by the container HEALTHCHECK

Health is the websocket being up, not chat being busy -- an idle chat would otherwise look like a dead socket and get itself restarted. SendPing fails when the socket is gone, so a ping write landing is the signal; the PONG is never read.

Series: modbot_connected, modbot_last_message_received_timestamp_seconds, modbot_ws_reconnects_total, modbot_command_persist_failures_total, plus the usual go_* and process_*. Nothing is labelled by nick -- unbounded cardinality, and it would make the metrics store a record of user behaviour.

The image is FROM scratch, so HEALTHCHECK runs the binary's own -healthcheck mode. Change it alongside -metrics if you move the port.

All mod-commands can also be issued via PMs to Bot. E.g. /w Bot !modify youtube/6n3pFFPSlW4 hidden !nsfw. Replies come back on the channel the command arrived on, so a command sent over PM is answered over PM. !say is the exception and always speaks in public chat.

About

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages