From 64f0119153aad2feb5b7c72ee285ed2ca560ff46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20M=C3=BCller?= Date: Thu, 26 Oct 2023 23:50:00 +0200 Subject: [PATCH] feat(musicbot): configure discord musicbot --- .../apps/discord/kustomization.yaml | 7 + .../discord/musicbot/app/helm-release.yaml | 59 +++++++ .../discord/musicbot/app/kustomization.yaml | 17 ++ .../apps/discord/musicbot/app/options.ini | 164 ++++++++++++++++++ .../apps/discord/musicbot/flux-sync.yaml | 17 ++ .../talos-flux/apps/discord/namespace.yaml | 7 + .../flux/config/cluster-secrets.sops.yaml | 7 +- 7 files changed, 275 insertions(+), 3 deletions(-) create mode 100644 kubernetes/talos-flux/apps/discord/kustomization.yaml create mode 100644 kubernetes/talos-flux/apps/discord/musicbot/app/helm-release.yaml create mode 100644 kubernetes/talos-flux/apps/discord/musicbot/app/kustomization.yaml create mode 100644 kubernetes/talos-flux/apps/discord/musicbot/app/options.ini create mode 100644 kubernetes/talos-flux/apps/discord/musicbot/flux-sync.yaml create mode 100644 kubernetes/talos-flux/apps/discord/namespace.yaml diff --git a/kubernetes/talos-flux/apps/discord/kustomization.yaml b/kubernetes/talos-flux/apps/discord/kustomization.yaml new file mode 100644 index 000000000..ef730407f --- /dev/null +++ b/kubernetes/talos-flux/apps/discord/kustomization.yaml @@ -0,0 +1,7 @@ +--- +# yaml-language-server: $schema=https://json.schemastore.org/kustomization +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./namespace.yaml + - ./musicbot/flux-sync.yaml diff --git a/kubernetes/talos-flux/apps/discord/musicbot/app/helm-release.yaml b/kubernetes/talos-flux/apps/discord/musicbot/app/helm-release.yaml new file mode 100644 index 000000000..4d1fbecd1 --- /dev/null +++ b/kubernetes/talos-flux/apps/discord/musicbot/app/helm-release.yaml @@ -0,0 +1,59 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/fluxcd-community/flux2-schemas/main/helmrelease-helm-v2beta1.json +apiVersion: helm.toolkit.fluxcd.io/v2beta1 +kind: HelmRelease +metadata: + name: mussicbot +spec: + interval: 15m + chart: + spec: + chart: app-template + version: 2.0.3 + sourceRef: + kind: HelmRepository + name: bjw-s-charts + namespace: flux-system + maxHistory: 15 + install: + createNamespace: true + remediation: + retries: 3 + upgrade: + cleanupOnFail: true + remediation: + retries: 3 + uninstall: + keepHistory: false + values: + # https://github.com/bjw-s/helm-charts/tree/main/charts/other/app-template + # https://github.com/Just-Some-Bots/MusicBot + controllers: + main: + containers: + main: + image: + repository: harbor.techtales.io:443/library/github/musicbot + tag: release-250723 + resources: + requests: + cpu: 100m + memory: 100Mi + limits: + memory: 100Mi + probes: + liveness: &probes + enabled: false + readiness: *probes + startup: *probes + + persistence: + config: + type: configMap + name: musicbot-config + advancedMounts: + main: + main: + - path: /musicbot/config/options.ini + readOnly: true + subPath: options.ini diff --git a/kubernetes/talos-flux/apps/discord/musicbot/app/kustomization.yaml b/kubernetes/talos-flux/apps/discord/musicbot/app/kustomization.yaml new file mode 100644 index 000000000..fdc424257 --- /dev/null +++ b/kubernetes/talos-flux/apps/discord/musicbot/app/kustomization.yaml @@ -0,0 +1,17 @@ +--- +# yaml-language-server: $schema=https://json.schemastore.org/kustomization +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: discord +resources: + - ./helm-release.yaml +commonLabels: + app.kubernetes.io/name: musicbot + app.kubernetes.io/instance: musicbot +configMapGenerator: + - name: musicbot-config + behavior: create + files: + - options.ini +generatorOptions: + disableNameSuffixHash: true diff --git a/kubernetes/talos-flux/apps/discord/musicbot/app/options.ini b/kubernetes/talos-flux/apps/discord/musicbot/app/options.ini new file mode 100644 index 000000000..745fac9a0 --- /dev/null +++ b/kubernetes/talos-flux/apps/discord/musicbot/app/options.ini @@ -0,0 +1,164 @@ +# This is the configuration file for MusicBot. Do not edit this file using Notepad. +# Use Notepad++ or a code editor like Visual Studio Code. +# For help, see: https://just-some-bots.github.io/MusicBot/ + +[Credentials] +# Your Discord bot account token. Required to run the bot. +Token = ${SECRET_DISCORD_MUSICBOT_TOKEN} + +# The bot supports converting Spotify links and URIs to YouTube videos and +# playing them. You can either enter your own Spotify developer app credentials +# below, or the bot will use public credentials to communicate with Spotify. +Spotify_ClientID = +Spotify_ClientSecret = + +[Permissions] +# This option determines which user has full permissions and control of the bot. +# Only one user can be the bot's owner. You can generally leave this as "auto". +OwnerID = auto + +# This option determines which users have access to developer-only commands. +# You should leave this blank unless you know what you are doing. +DevIDs = + +# This bot ignores other bots by default. You can add other bot's IDs here to +# allow MusicBot to listen to their messages. +BotExceptionIDs = + +[Chat] +# Determines the prefix that must be used before commands in the Discord chat. +# e.g if you set this to *, the play command would be triggered using *play. +CommandPrefix = ! + +# Restricts the bot to only listening to certain text channels. +# Space-separated list of text channel IDs. +BindToChannels = + +# Setting this to "yes" will allow the MusicBot to work in any channel on servers +# which do not have a "bound" channel set above. +AllowUnboundServers = no + +# Allows the bot to automatically join voice channels on startup. +# Space-separated list of voice channel IDs. +AutojoinChannels = + +# If set to "yes", the bot will send a DM to the user who requested a song when their +# song begins to play, rather than posting a message in the text channel. +DMNowPlaying = no + +# Disable now playing messages for entries automatically added by the bot, via the autoplaylist. +DisableNowPlayingAutomatic = no + +# Force the bot to send "now playing" messages in specific text channels. +# If this is empty, the bot will send the messages in the channel where the song was requested. +NowPlayingChannels = + +# If "yes", delete the "now playing" messages after a small period of time. +DeleteNowPlaying = yes + +[MusicBot] +# The volume of the bot's audio output, between 0.01 and 1.0. +DefaultVolume = 0.25 + +# The number of people voting to skip in order for a song to be skipped successfully, +# whichever value is lower will be used. Ratio refers to the percentage of undefeaned, non- +# owner users in the channel. +SkipsRequired = 4 +SkipRatio = 0.5 + +# Determines if downloaded videos will be saved to the audio_cache folder permanently. +# If "yes", videos will not be re-downloaded if queued again, at the cost of hard-drive space. +SaveVideos = yes + +# Mentions the user who queued a song when it starts to play. +NowPlayingMentions = no + +# Automatically joins the owner's voice channel on startup, if possible. The bot must be on +# the same server and have permission to join the channel. +AutoSummon = yes + +# Start playing songs from the autoplaylist.txt file after joining a channel. This does not +# stop users from queueing songs, you can do that by restricting command access in permissions.ini. +UseAutoPlaylist = yes + +# Sets if the autoplaylist should play through songs in a random order when enabled. If no, +# songs will be played in a sequential order instead. +AutoPlaylistRandom = yes + +# Pause the music when nobody is in a voice channel, until someone joins again. +AutoPause = yes + +# Automatically cleanup the bot's messages after a small period of time. +DeleteMessages = yes + +# If this and DeleteMessages is enabled, the bot will also try to delete messages from other +# users that called commands. The bot requires the 'Manage Messages' permission for this. +DeleteInvoking = no + +# Regularly saves the queue to the disk. If the bot is then shut down, the queue will +# resume from where it left off. +PersistentQueue = yes + +# Determines what messages are logged to the console. The default level is INFO, which is +# everything an average user would need. Other levels include CRITICAL, ERROR, WARNING, +# DEBUG, VOICEDEBUG, FFMPEG, NOISY, and EVERYTHING. You should only change this if you +# are debugging, or you want the bot to have a quieter console output. +DebugLevel = INFO + +# Specify a custom message to use as the bot's status. If left empty, the bot +# will display dynamic info about music currently being played in its status instead. +StatusMessage = + +# Write what the bot is currently playing to the data//current.txt FILE. +# This can then be used with OBS and anything else that takes a dynamic input. +WriteCurrentSong = no + +# Allows the person who queued a song to skip their OWN songs instantly, similar to the +# functionality that owners have where they can skip every song instantly. +AllowAuthorSkip = yes + +# Enables experimental equalization code. This will cause all songs to sound similar in +# volume at the cost of higher processing consumption when the song is initially being played. +UseExperimentalEqualization = no + +# Enables the use of embeds throughout the bot. These are messages that are formatted to +# look cleaner, however they don't appear to users who have link previews disabled in their +# Discord settings. +UseEmbeds = yes + +# The amount of items to show when using the queue command. +QueueLength = 10 + +# Remove songs from the autoplaylist if an error occurred while trying to play them. +# If enabled, unplayable songs will be moved to another file and out of the autoplaylist. +# You may want to disable this if you have internet issues or frequent issues playing songs. +RemoveFromAPOnError = yes + +# Whether to show the configuration for the bot in the console when it launches. +ShowConfigOnLaunch = no + +# Whether to use legacy skip behaviour. This will change it so that those with permission +# do not need to use "skip f" to force-skip a song, they will instead force-skip by default. +LegacySkip = no + +# Leave servers if the owner is not found in them. +LeaveServersWithoutOwner = no + +# Use command aliases defined in aliases.json. +UseAlias = yes + +# Use an alternate way to display the results from search command. +SearchList = no + +# Set the amount of search results returned by default. +DefaultSearchResults = 3 + +# Specify a custom message to use as the bots embed footer. +CustomEmbedFooter = + +# Sets if you'd like the bot to deafen when joining a voice channel +SelfDeafen = yes + +[Files] +# Path to your i18n file. Do not set this if you do not know what it does. +i18nFile = diff --git a/kubernetes/talos-flux/apps/discord/musicbot/flux-sync.yaml b/kubernetes/talos-flux/apps/discord/musicbot/flux-sync.yaml new file mode 100644 index 000000000..b4d700248 --- /dev/null +++ b/kubernetes/talos-flux/apps/discord/musicbot/flux-sync.yaml @@ -0,0 +1,17 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/fluxcd-community/flux2-schemas/main/kustomization-kustomize-v1beta2.json +apiVersion: kustomize.toolkit.fluxcd.io/v1beta2 +kind: Kustomization +metadata: + name: apps-musicbot + namespace: flux-system + labels: + substitution.flux.home.arpa/enabled: "true" +spec: + interval: 10m + path: ./kubernetes/talos-flux/apps/discord/musicbot/app + prune: true + sourceRef: + kind: GitRepository + name: home-ops + wait: true diff --git a/kubernetes/talos-flux/apps/discord/namespace.yaml b/kubernetes/talos-flux/apps/discord/namespace.yaml new file mode 100644 index 000000000..d8e322c9c --- /dev/null +++ b/kubernetes/talos-flux/apps/discord/namespace.yaml @@ -0,0 +1,7 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: discord + labels: + kustomize.toolkit.fluxcd.io/prune: disabled diff --git a/kubernetes/talos-flux/flux/config/cluster-secrets.sops.yaml b/kubernetes/talos-flux/flux/config/cluster-secrets.sops.yaml index 2d2fc9f86..3bf6c3b42 100644 --- a/kubernetes/talos-flux/flux/config/cluster-secrets.sops.yaml +++ b/kubernetes/talos-flux/flux/config/cluster-secrets.sops.yaml @@ -32,6 +32,7 @@ stringData: SECRET_CLOUDNATIVE_PG_SUPERUSER: ENC[AES256_GCM,data:8HEUr7FKG3A=,iv:X+m5jG7Nk6bSqNU8VU8hPsKYM6f4LE1NpYlGZLg/00s=,tag:uzaeQVSoUqXHK2LuP6mE2g==,type:str] SECRET_CLOUDNATIVE_PG_PASSWORD: ENC[AES256_GCM,data:jI097bYeQFlgDGKnMRQXpBNvS/3/JvVouFBIsvz6MYDbvnqoOjBuWdS1qXjlA3CAjP2tasvQUs1fD+iY3ObCdAUuPlceUuL1rCrUoiI6XmU32Qpc7m12ww==,iv:T9m/dqIx9hGJBrKKCjmEHn80flbmXaEvLZEh2lpdtOM=,tag:FXcSvPcUWuN1jaqIbLKoog==,type:str] SECRET_GH_PAT: ENC[AES256_GCM,data:PbBjBdv/DkkIU0MRwWC+BoDyCLI5erMhlpVSnKE3ONexl84rJ0bUzQ==,iv:A7cghJgrI7uLVbj+1Lr4MFXoRwpXCCElYhh4goDylQ4=,tag:Gnls1nEZVJxqqlUMoagSEw==,type:str] + SECRET_DISCORD_MUSICBOT_TOKEN: ENC[AES256_GCM,data:w0L8J+VTF7Ec1G2l4UveZ6W4dNCo5Q5pMldAGU0X6wNVQQezXhBIOmHQC/jt3eN4tWhmeEoilH0ykIjI+6Vd8EYXWdrjP3SH,iv:LTYqYLZ0Gsf7GYX1F+QF1Cq4KoGQJ+UwT4/ePUJoXRg=,tag:gEK24XV0sSTIkqFIVDVn6w==,type:str] sops: kms: [] gcp_kms: [] @@ -47,8 +48,8 @@ sops: SThDODl4ZFFMMUlxM3BneWlrNDdjdUUKm16agevW+HLV4al0q2m5W/SyS84E5SXh QfWlkG1byRaLRQ+tMeTuCN0tk2A2asmSPygQ1IKo4AO9kMirDEjQ6w== -----END AGE ENCRYPTED FILE----- - lastmodified: "2023-07-30T19:34:43Z" - mac: ENC[AES256_GCM,data:r1I/o/KiPUsZT2dwNx/lDsvL8fGygG8P28x3CA0lf+kMWsynH1zsWyh2+c328nJub2YcpCRfTkkqV3jYkBeROhawoIlGrgp5yr4s0ZJrw5uH4tqk9EJMcvuoUMn7Qhh7/VsdgdKVhgwfSgJvKKLYgFU/DvoFB/2ATQt85AmGiXA=,iv:jz81lRHYlM1iDp+EYfmMiSicagu/DT8mZd4UoMscSH4=,tag:IOq/4S2no6eDLbc7s6TqNw==,type:str] + lastmodified: "2023-10-26T21:37:52Z" + mac: ENC[AES256_GCM,data:hBaPNCzyIOl8mVnB/HiE2hDZF0YAJRstXjTXBwgtZ1NuleKIzV5FhwdCvZX1tgKvUPipuRdScn4ITHryyUejAmg4rc3xTsHi4iVc3fkTqwr8c4KFgxlbMbleogSeOJqZrrZUjJVZbFahzgJkEbVMAIyM8FxiPphgDqmn8/MFZCo=,iv:pK2UkN24OUYoNihZeENiau9lPxTqCvXM8n/kXwFzqd4=,tag:HmPHRBRIzdl0gHj89V7d7w==,type:str] pgp: [] encrypted_regex: ^(data|stringData)$ - version: 3.7.3 + version: 3.8.1