Self-hosted alternative to one of the big bots managed by big companies…
Find a file
Knut Ahlers 34fa7bed17
Move dev-dependencies into their designated section
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2023-06-12 23:08:59 +02:00
.github [ci] Update archrepo URL 2023-06-09 19:47:50 +02:00
ci [editor] Rework to use esbuild / Vue component files (#12) 2021-12-06 17:25:19 +01:00
docs Allow to customize token 2021-04-04 20:26:32 +02:00
editor [editor] Rework to use esbuild / Vue component files (#12) 2021-12-06 17:25:19 +01:00
internal [respond] Expose API route to send messages directly to chat 2023-05-29 01:56:06 +02:00
pkg [eventsub] Add debug logging for subscribed topics 2023-05-21 16:01:22 +02:00
plugins [core] Fix: Message matcher matched also event content 2023-04-08 02:18:09 +02:00
src [editor] Remove character limit for AutoMessage template 2023-05-11 15:49:29 +02:00
wiki [template] Add mention function 2023-05-27 21:59:19 +02:00
.dockerignore [editor] Rework to use esbuild / Vue component files (#12) 2021-12-06 17:25:19 +01:00
.eslintrc.js [editor] Update node dependencies 2023-03-24 23:24:40 +01:00
.gitignore [core] Move storage to SQLite database (#30) 2022-09-10 13:39:07 +02:00
.golangci.yml [ci] Remove linter gone haywire 2023-06-05 23:30:26 +02:00
action_script.go Lint: Fix linter errors 2023-03-24 22:32:00 +01:00
actions.go [eventmod] Add eventmod actor 2023-02-20 19:41:03 +01:00
actorDocs.go prepare release v3.0.0 2022-11-02 22:54:52 +01:00
actorDocs.tpl [quotedb] Add new actor 2021-10-19 00:22:05 +02:00
auth.go [editor] Notify frontend to reload data after token change 2023-02-06 23:41:54 +01:00
automessage.go Lint: Fix linter errors 2023-03-24 22:32:00 +01:00
botEditor.go prepare release v3.0.0 2022-11-02 22:54:52 +01:00
botUserState.go prepare release v3.0.0 2022-11-02 22:54:52 +01:00
chatcommands.go prepare release v3.0.0 2022-11-02 22:54:52 +01:00
cli.go [core] Split out cli commands 2023-03-24 21:41:38 +01:00
cli_actorDocs.go [core] Split out cli commands 2023-03-24 21:41:38 +01:00
cli_apiToken.go [core] Split out cli commands 2023-03-24 21:41:38 +01:00
cli_migrateV2.go [core] Split out cli commands 2023-03-24 21:41:38 +01:00
cli_resetSecrets.go [core] Split out cli commands 2023-03-24 21:41:38 +01:00
cli_validateConfig.go [core] Split out cli commands 2023-03-24 21:41:38 +01:00
config.go [editor] Add validation for template fields 2023-04-02 15:04:51 +02:00
configEditor.go [editor] Add notification in case bot is missing default-scopes 2023-01-20 12:36:43 +01:00
configEditor_automessage.go Lint: Fix linter errors 2023-03-24 22:32:00 +01:00
configEditor_dev.go [editor] Rework to use esbuild / Vue component files (#12) 2021-12-06 17:25:19 +01:00
configEditor_general.go Lint: Fix linter errors 2023-03-24 22:32:00 +01:00
configEditor_global.go [editor] Add validation for template fields 2023-04-02 15:04:51 +02:00
configEditor_prod.go [editor] Rework to use esbuild / Vue component files (#12) 2021-12-06 17:25:19 +01:00
configEditor_rules.go Lint: Fix linter errors 2023-03-24 22:32:00 +01:00
configRemoteUpdate.go [core] Fix: Remote-update cron broken as of missing field 2023-01-01 16:29:27 +01:00
configwatch.go Fix: Do not spam events when file is gone for longer 2021-05-24 18:00:50 +02:00
cors.go [core] Fix: Allow PATCH method in CORS 2022-03-29 00:56:10 +02:00
default_config.yaml Breaking: Add configuration interface and switch to more generic config format (#7) 2021-09-22 15:36:45 +02:00
Dockerfile [editor] Update nodejs build version and deps 2022-02-26 17:26:02 +01:00
events.go [eventsub] Add poll_begin, poll_end, poll_progress events 2023-05-21 14:59:06 +02:00
fields.go Expose user_id in events 2022-06-17 22:13:47 +02:00
functions.go prepare release v3.0.0 2022-11-02 22:54:52 +01:00
functions_irc.go [template] Add mention function 2023-05-27 21:59:19 +02:00
functions_test.go Lint: Fix linter errors 2023-03-24 22:32:00 +01:00
functions_twitch.go [template] Add lastPoll function 2023-05-21 15:28:10 +02:00
git.go [core] Allow the bot to track config editor changes through Git 2021-10-22 17:09:39 +02:00
go.mod [core] Update Go dependencies 2023-05-15 23:09:29 +02:00
go.sum [core] Update Go dependencies 2023-05-15 23:09:29 +02:00
helpers.go [core] Move storage to SQLite database (#30) 2022-09-10 13:39:07 +02:00
History.md prepare release v3.12.0 2023-06-07 18:56:43 +02:00
hooker.go [editor] Notify frontend to reload data after token change 2023-02-06 23:41:54 +01:00
irc.go [core] Remove "host" related functionality 2023-04-08 02:18:15 +02:00
LICENSE Add META 2020-12-21 01:55:48 +01:00
main.go [core] Reduce variance of Sentry errors containing IPs 2023-05-27 16:46:33 +02:00
Makefile [linkprotect] Add Link-, Clip-Detector and Link-Protection actor (#42) 2023-04-08 00:41:00 +02:00
msgformatter.go Lint: Fix linter errors 2023-03-24 22:32:00 +01:00
package-lock.json Move dev-dependencies into their designated section 2023-06-12 23:08:59 +02:00
package.json Move dev-dependencies into their designated section 2023-06-12 23:08:59 +02:00
plugins.go prepare release v3.0.0 2022-11-02 22:54:52 +01:00
plugins_core.go [template] Add subCount, subPoints template functions 2023-04-22 22:23:35 +02:00
plugins_unsupported.go Add plugin support to allow extending of functionality (#6) 2021-08-19 15:33:56 +02:00
README.md [eventsub] Switch to Websocket transport (#46) 2023-05-18 15:09:25 +02:00
scopes.go [template] Add subCount, subPoints template functions 2023-04-22 22:23:35 +02:00
status.go [core] Fix type warnings for Swagger documentation 2023-03-24 21:02:30 +01:00
swagger.go Lint: Fix linter errors 2023-03-24 22:32:00 +01:00
swagger.html [openapi] Allow subdir serving 2021-10-10 01:40:44 +02:00
twitchWatcher.go [eventsub] Add status field to poll_end event 2023-06-05 22:55:45 +02:00
writeAuth.go [overlays] Add overlays server capability (#14) 2022-02-08 19:58:19 +01:00
wrNoOpCloser.go Add raw-log functionality 2021-04-09 18:14:44 +02:00

Go Report Card

Luzifer / twitch-bot

Twitch-Bot is intended as an alternative to having a bot managed by Streamlabs or Streamelements and therefore having more control over it, the availability and how it works.

At the moment it is a work-in-progress and does not yet implment all features it shall in the future.

Configuration

Please see the Wiki for documentation of the configuration file.

# twitch-bot --help
Usage of twitch-bot:
      --base-url string                  External URL of the config-editor interface (used to generate auth-urls)
      --command-timeout duration         Timeout for command execution (default 30s)
  -c, --config string                    Location of configuration file (default "./config.yaml")
      --log-level string                 Log level (debug, info, warn, error, fatal) (default "info")
      --plugin-dir string                Where to find and load plugins (default "/usr/lib/twitch-bot")
      --rate-limit duration              How often to send a message (default: 20/30s=1500ms, if your bot is mod everywhere: 100/30s=300ms, different for known/verified bots) (default 1.5s)
      --sentry-dsn string                Sentry / GlitchTip DSN for error reporting
      --storage-conn-string string       Connection string for the database (default "./storage.db")
      --storage-conn-type string         One of: mysql, postgres, sqlite (default "sqlite")
      --storage-encryption-pass string   Passphrase to encrypt secrets inside storage (defaults to twitch-client:twitch-client-secret)
      --twitch-client string             Client ID to act as
      --twitch-client-secret string      Secret for the Client ID
      --twitch-token string              OAuth token valid for client (fallback if no token was set in interface)
  -v, --validate-config                  Loads the config, logs any errors and quits with status 0 on success
      --version                          Prints current version and exits
      --wait-for-selfcheck duration      Maximum time to wait for the self-check to respond when behind load-balancers (default 1m0s)

# twitch-bot help
Supported sub-commands are:
  actor-docs                                 Generate markdown documentation for available actors
  api-token <token-name> <scope> [...scope]  Generate an api-token to be entered into the config
  migrate-v2 <old-file>                      Migrate old (*.json.gz) storage file into new database
  reset-secrets                              Remove encrypted data to reset encryption passphrase
  validate-config                            Try to load configuration file and report errors if any

Database Connection Strings

Currently these databases are supported and need their corresponding connection strings:

MySQL

[username[:password]@][protocol[(address)]]/dbname[?param1=value1&...&paramN=valueN]

Recommended parameters:
  ?charset=utf8mb4&parseTime=True&loc=Local
  • Create your database as follows:
    CREATE DATABASE twbot_tezrian DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci;
    
  • Start your bot:
    # twitch-bot \
        --storage-conn-type mysql \
        --storage-conn-string 'tezrian:mypass@tcp(mariadb:3306)/twbot_tezrian?charset=utf8mb4&parseTime=True&loc=Local' \
        ...
    

See driver documentation for more details on parameters.

Postgres

host=localhost port=5432 dbname=mydb connect_timeout=10

See Postgres documentation for more details in paramters.

SQLite

storage.db

Just pass the filename you want to use.

  • Start your bot:
    # twitch-bot \
        --storage-conn-type sqlite \
        --storage-conn-string 'storage.db' \
        ...
    

Upgrade from v2.x to v3.x

With the release of v3.0.0 the bot changed a lot introducing a new storage format. As that storage backend is not compatible with the v2.x storage you need to migrate it manually before starting a v3.x bot version the first time.

Before starting the migration make sure to fully stop the bot!

This section assumes you were starting your v2.x bot the following way:

# twitch-bot \
  --storage-file storage.json.gz
  --twitch-client <clientid> \
  --twitch-client-secret <secret>

To execute the migration we need to provide the same storage-encryption-pass or twitch-client / twitch-client-secret combination if no storage-encryption-pass was used.

# twitch-bot \
  --storage-conn-type <database type> \
  --storage-conn-string <database connection string> \
  --twitch-client <clientid> \
  --twitch-client-secret <secret> \
  migrate-v2 storage.json.gz
WARN[0000] No storage encryption passphrase was set, falling back to client-id:client-secret
WARN[0000] Module registered unhandled query-param type  module=status type=integer
WARN[0000] Overlays dir not specified, no dir or non existent  dir=
INFO[0000] Starting migration...                         module=variables
INFO[0000] Starting migration...                         module=mod_punish
INFO[0000] Starting migration...                         module=mod_overlays
INFO[0000] Starting migration...                         module=mod_quotedb
INFO[0000] Starting migration...                         module=core
INFO[0000] Starting migration...                         module=counter
INFO[0000] Starting migration...                         module=permissions
INFO[0000] Starting migration...                         module=timers
INFO[0000] v2 storage file was migrated

If you see the v2 storage file was migrated message the contents of your old storage file were migrated to the new database. The old file is not modified in this step.

Afterwards your need to adjust the start parameters of the bot:

# twitch-bot \
  --storage-conn-type <database type> \
  --storage-conn-string <database connection string> \
  --twitch-client <clientid> \
  --twitch-client-secret <secret> \