Update Packages, Add Status Command, and Bugfixes
This commit is contained in:
parent
44d45b7394
commit
a869b8529e
8
Makefile
8
Makefile
@ -24,10 +24,13 @@ go-generate:
|
||||
@go generate $(generate)
|
||||
|
||||
go-get:
|
||||
@go env -w GOPRIVATE=github.com/meteoritesolutions
|
||||
@echo " > Checking if there is any missing dependencies..."
|
||||
@go get $(get)
|
||||
|
||||
go-get-upgrade:
|
||||
@echo " > Updating dependencies..."
|
||||
@go get $(get) -u
|
||||
|
||||
go-install:
|
||||
@echo " > Running go install..."
|
||||
@go install $(GOFILES)
|
||||
@ -56,6 +59,9 @@ docker-push: docker-build
|
||||
## install: Download and install dependencies
|
||||
install: go-get
|
||||
|
||||
## upgrade: Update Go packages
|
||||
upgrade: go-get-upgrade
|
||||
|
||||
# clean: Runs go clean
|
||||
clean: go-clean
|
||||
|
||||
|
@ -4,10 +4,11 @@ import "strings"
|
||||
|
||||
// Config is used to modify the behavior of birdbot externally
|
||||
type Config struct {
|
||||
Discord DiscordConfig `yaml:"discord"`
|
||||
Mastodon MastodonConfig `yaml:"mastodon"`
|
||||
Feedback Feedback `yaml:"feedback"`
|
||||
Features Features `yaml:"features"`
|
||||
Discord DiscordConfig `yaml:"discord"`
|
||||
Mastodon MastodonConfig `yaml:"mastodon"`
|
||||
Feedback Feedback `yaml:"feedback"`
|
||||
StatusPortal StatusPortal `yaml:"status_portal"`
|
||||
Features Features `yaml:"features"`
|
||||
}
|
||||
|
||||
// DiscordConfig contains discord specific configuration
|
||||
@ -33,6 +34,10 @@ type Feedback struct {
|
||||
FailureMessage string `yaml:"failure_message"`
|
||||
}
|
||||
|
||||
type StatusPortal struct {
|
||||
URL string `yaml:"url" env:"BIRD_STATUS_PORTAL_URL"`
|
||||
}
|
||||
|
||||
type RoleSelectionConfig struct {
|
||||
Title string `yaml:"title"`
|
||||
Description string `yaml:"description"`
|
||||
@ -63,6 +68,7 @@ type Features struct {
|
||||
RoleSelection Feature `yaml:"role_selection" env:"BIRD_ROLE_SELECTION"`
|
||||
Feedback Feature `yaml:"feedback" env:"BIRD_FEEDBACK"`
|
||||
LoadGamePlugins Feature `yaml:"load_game_plugins" env:"BIRD_LOAD_GAME_PLUGINS"`
|
||||
StatusPortal Feature `yaml:"status_portal" env:"BIRD_STATUS_PORTAL"`
|
||||
}
|
||||
|
||||
// Feature is a boolean string used to toggle functionality
|
||||
|
23
go.mod
23
go.mod
@ -1,29 +1,32 @@
|
||||
module github.com/yeslayla/birdbot
|
||||
|
||||
go 1.20
|
||||
go 1.21
|
||||
|
||||
toolchain go1.21.5
|
||||
|
||||
require (
|
||||
github.com/bwmarrin/discordgo v0.27.1
|
||||
github.com/ilyakaznacheev/cleanenv v1.4.2
|
||||
github.com/bwmarrin/discordgo v0.27.2-0.20240104191117-afc57886f91a
|
||||
github.com/ilyakaznacheev/cleanenv v1.5.0
|
||||
github.com/mattn/go-mastodon v0.0.6
|
||||
github.com/mattn/go-sqlite3 v1.14.17
|
||||
github.com/rubenv/sql-migrate v1.4.0
|
||||
github.com/mattn/go-sqlite3 v1.14.19
|
||||
github.com/rubenv/sql-migrate v1.6.0
|
||||
github.com/stretchr/testify v1.8.4
|
||||
github.com/yeslayla/birdbot-common v0.1.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v1.3.2 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/go-gorp/gorp/v3 v3.1.0 // indirect
|
||||
github.com/gorilla/websocket v1.5.0 // indirect
|
||||
github.com/gorilla/websocket v1.5.1 // indirect
|
||||
github.com/joho/godotenv v1.5.1 // indirect
|
||||
github.com/magefile/mage v1.14.0 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/stretchr/objx v0.5.0 // indirect
|
||||
github.com/stretchr/objx v0.5.1 // indirect
|
||||
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 // indirect
|
||||
github.com/yeslayla/birdbot-common v0.1.0 // indirect
|
||||
golang.org/x/crypto v0.10.0 // indirect
|
||||
golang.org/x/sys v0.9.0 // indirect
|
||||
golang.org/x/crypto v0.18.0 // indirect
|
||||
golang.org/x/net v0.20.0 // indirect
|
||||
golang.org/x/sys v0.16.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
olympos.io/encoding/edn v0.0.0-20201019073823-d3554ca0b0a3 // indirect
|
||||
)
|
||||
|
23
go.sum
23
go.sum
@ -67,6 +67,8 @@ github.com/bwmarrin/discordgo v0.26.1 h1:AIrM+g3cl+iYBr4yBxCBp9tD9jR3K7upEjl0d89
|
||||
github.com/bwmarrin/discordgo v0.26.1/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY=
|
||||
github.com/bwmarrin/discordgo v0.27.1 h1:ib9AIc/dom1E/fSIulrBwnez0CToJE113ZGt4HoliGY=
|
||||
github.com/bwmarrin/discordgo v0.27.1/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY=
|
||||
github.com/bwmarrin/discordgo v0.27.2-0.20240104191117-afc57886f91a h1:I1j/9FoqDN+W0ZXiSU91lJXwKCvnKBLgJKlBLYAbim4=
|
||||
github.com/bwmarrin/discordgo v0.27.2-0.20240104191117-afc57886f91a/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||
@ -196,6 +198,8 @@ github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0U
|
||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
||||
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
|
||||
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
|
||||
@ -232,6 +236,8 @@ github.com/ilyakaznacheev/cleanenv v1.4.0 h1:Gvwxt6wAPUo9OOxyp5Xz9eqhLsAey4AtbCF
|
||||
github.com/ilyakaznacheev/cleanenv v1.4.0/go.mod h1:i0owW+HDxeGKE0/JPREJOdSCPIyOnmh6C0xhWAkF/xA=
|
||||
github.com/ilyakaznacheev/cleanenv v1.4.2 h1:nRqiriLMAC7tz7GzjzUTBHfzdzw6SQ7XvTagkFqe/zU=
|
||||
github.com/ilyakaznacheev/cleanenv v1.4.2/go.mod h1:i0owW+HDxeGKE0/JPREJOdSCPIyOnmh6C0xhWAkF/xA=
|
||||
github.com/ilyakaznacheev/cleanenv v1.5.0 h1:0VNZXggJE2OYdXE87bfSSwGxeiGt9moSR2lOrsHHvr4=
|
||||
github.com/ilyakaznacheev/cleanenv v1.5.0/go.mod h1:a5aDzaJrLCQZsazHol1w8InnDcOX0OColm64SlIi6gk=
|
||||
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
|
||||
github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
@ -263,6 +269,8 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||
github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo=
|
||||
github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
|
||||
github.com/magefile/mage v1.15.0 h1:BvGheCMAsG3bWUDbZ8AyXXpCNwU9u5CB6sM+HNb9HYg=
|
||||
github.com/magefile/mage v1.15.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
|
||||
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||
github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
|
||||
github.com/markbates/errx v1.1.0/go.mod h1:PLa46Oex9KNbVDZhKel8v1OT7hD5JZ2eI7AHhA0wswc=
|
||||
@ -290,6 +298,8 @@ github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwp
|
||||
github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
||||
github.com/mattn/go-sqlite3 v1.14.17 h1:mCRHCLDUBXgpKAqIKsaAaAsrAlbkeomtRFKXh2L6YIM=
|
||||
github.com/mattn/go-sqlite3 v1.14.17/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
||||
github.com/mattn/go-sqlite3 v1.14.19 h1:fhGleo2h1p8tVChob4I9HpmVFIAkKGpiukdrgQbWfGI=
|
||||
github.com/mattn/go-sqlite3 v1.14.19/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
|
||||
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
|
||||
@ -345,6 +355,8 @@ github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6po
|
||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||
github.com/rubenv/sql-migrate v1.4.0 h1:y4ndB3hq5tmjvQ8jcuqhLgeEqoxIjEidN5RaCkKOAAE=
|
||||
github.com/rubenv/sql-migrate v1.4.0/go.mod h1:lRxHt4vTgRJtpGbulUUYHA9dzfbBJXRt+PwUF/jeNYo=
|
||||
github.com/rubenv/sql-migrate v1.6.0 h1:IZpcTlAx/VKXphWEpwWJ7BaMq05tYtE80zYz+8a5Il8=
|
||||
github.com/rubenv/sql-migrate v1.6.0/go.mod h1:m3ilnKP7sNb4eYkLsp6cGdPOl4OBcXM6rcbzU+Oqc5k=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
||||
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
|
||||
@ -375,6 +387,8 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/objx v0.5.1 h1:4VhoImhV/Bm0ToFkXFi8hXNXwpDRZ/ynw3amt82mzq0=
|
||||
github.com/stretchr/objx v0.5.1/go.mod h1:/iHQpkQwBD6DLUmQ4pE+s1TXdob1mORJ4/UFdrifcy0=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
@ -385,6 +399,7 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
||||
@ -443,6 +458,8 @@ golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE=
|
||||
golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU=
|
||||
golang.org/x/crypto v0.10.0 h1:LKqV2xt9+kDzSTfOhx4FrkEBcMrAgHSYgzywV9zcGmM=
|
||||
golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I=
|
||||
golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc=
|
||||
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||
@ -522,6 +539,10 @@ golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qx
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
|
||||
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
|
||||
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
|
||||
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
|
||||
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
|
||||
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
@ -607,6 +628,8 @@ golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
|
||||
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s=
|
||||
golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
|
||||
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
|
||||
|
5
main.go
5
main.go
@ -29,7 +29,7 @@ func main() {
|
||||
var db_file string
|
||||
var version bool
|
||||
flag.StringVar(&config_file, "c", defaultConfigPath, "Path to config file")
|
||||
flag.StringVar(&db_file, "db", defaultDBPath, "Path to store persistant data")
|
||||
flag.StringVar(&db_file, "db", defaultDBPath, "Path to store persistent data")
|
||||
flag.BoolVar(&version, "v", false, "List version")
|
||||
flag.Parse()
|
||||
|
||||
@ -80,6 +80,9 @@ func main() {
|
||||
if cfg.Features.RecurringEvents.IsEnabled() {
|
||||
loader.LoadComponent(modules.NewRecurringEventsComponent(bot.Session))
|
||||
}
|
||||
if cfg.Features.StatusPortal.IsEnabled() {
|
||||
loader.LoadComponent(modules.NewStatusComponent(cfg.StatusPortal.URL))
|
||||
}
|
||||
|
||||
if cfg.Features.RoleSelection.IsEnabledByDefault() {
|
||||
for _, v := range cfg.Discord.RoleSelections {
|
||||
|
@ -29,7 +29,7 @@ func NewFeedbackWebhookComponent(webhookURL string, config FeedbackWebhookConfig
|
||||
m := &feedbackWebhookModule{
|
||||
webhookURL: webhookURL,
|
||||
payloadType: "default",
|
||||
successMessage: "Feedback recieved!",
|
||||
successMessage: "Feedback received!",
|
||||
failureMessage: "Failed to send feedback!",
|
||||
}
|
||||
|
||||
|
@ -14,17 +14,17 @@ type roleSelectionModule struct {
|
||||
session *discord.Discord
|
||||
db persistence.Database
|
||||
|
||||
cfg core.RoleSelectionConfig
|
||||
exlusive bool
|
||||
cfg core.RoleSelectionConfig
|
||||
exclusive bool
|
||||
}
|
||||
|
||||
// NewRoleSelectionComponent creates a new component
|
||||
func NewRoleSelectionComponent(discord *discord.Discord, db persistence.Database, cfg core.RoleSelectionConfig) common.Module {
|
||||
return &roleSelectionModule{
|
||||
session: discord,
|
||||
cfg: cfg,
|
||||
db: db,
|
||||
exlusive: true,
|
||||
session: discord,
|
||||
cfg: cfg,
|
||||
db: db,
|
||||
exclusive: true,
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,27 +49,30 @@ func (c *roleSelectionModule) Initialize(birdbot common.ModuleManager) error {
|
||||
btn := c.session.NewButton(fmt.Sprint(c.cfg.Title, role.Name), role.Name)
|
||||
btn.OnClick(func(user common.User) {
|
||||
|
||||
// Remove other roles if exclusive
|
||||
if c.exlusive {
|
||||
for _, r := range roles {
|
||||
if r.ID == role.ID {
|
||||
continue
|
||||
}
|
||||
// Assign the roles asynchronously to avoid Discord's response timeout
|
||||
go func() {
|
||||
// Remove other roles if exclusive
|
||||
if c.exclusive {
|
||||
for _, r := range roles {
|
||||
if r.ID == role.ID {
|
||||
continue
|
||||
}
|
||||
|
||||
if c.session.HasRole(user, r) {
|
||||
c.session.UnassignRole(user, r)
|
||||
if c.session.HasRole(user, r) {
|
||||
c.session.UnassignRole(user, r)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Toggle role
|
||||
if c.session.HasRole(user, role) {
|
||||
if err := c.session.UnassignRole(user, role); err != nil {
|
||||
log.Printf("Failed to unassign role: %s", err)
|
||||
// Toggle role
|
||||
if c.session.HasRole(user, role) {
|
||||
if err := c.session.UnassignRole(user, role); err != nil {
|
||||
log.Printf("Failed to unassign role: %s", err)
|
||||
}
|
||||
} else if err := c.session.AssignRole(user, role); err != nil {
|
||||
log.Printf("Failed to assign role: %s", err)
|
||||
}
|
||||
} else if err := c.session.AssignRole(user, role); err != nil {
|
||||
log.Printf("Failed to assign role: %s", err)
|
||||
}
|
||||
}()
|
||||
|
||||
})
|
||||
|
||||
|
31
modules/status.go
Normal file
31
modules/status.go
Normal file
@ -0,0 +1,31 @@
|
||||
package modules
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/yeslayla/birdbot-common/common"
|
||||
)
|
||||
|
||||
type statusModule struct {
|
||||
portalURL string
|
||||
}
|
||||
|
||||
// NewStatusComponent creates a new component
|
||||
func NewStatusComponent(portalURL string) common.Module {
|
||||
m := &statusModule{
|
||||
portalURL: portalURL,
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (c *statusModule) Initialize(birdbot common.ModuleManager) error {
|
||||
birdbot.RegisterCommand("status", common.ChatCommandConfiguration{
|
||||
Description: "Gets the current status of the bot",
|
||||
EphemeralResponse: false,
|
||||
}, func(user common.User, args map[string]any) string {
|
||||
|
||||
return fmt.Sprintf("The bot is currently OK.\nSee Status Portal for more information: %s", c.portalURL)
|
||||
})
|
||||
return nil
|
||||
}
|
@ -21,7 +21,6 @@ discord:
|
||||
# - name: Blue
|
||||
# color: "#1a88ff"
|
||||
|
||||
|
||||
# mastodon:
|
||||
# server: https://mastodon.social
|
||||
# username: my_user
|
||||
@ -29,10 +28,14 @@ discord:
|
||||
# client_id: 1234
|
||||
# client_secret: secret2
|
||||
|
||||
# status_portal:
|
||||
# url: https://status.example.com
|
||||
|
||||
# # Feature flags can be used to
|
||||
# # disable specific features
|
||||
# features:
|
||||
# manage_event_channels: true
|
||||
# announce_events: true
|
||||
# recurring_events: true
|
||||
# role_selection: true
|
||||
# role_selection: true
|
||||
# status_portal: false
|
Loading…
Reference in New Issue
Block a user