Compare commits
4 Commits
dependabot
...
build_2025
| Author | SHA1 | Date | |
|---|---|---|---|
|
eb6c40c2f5
|
|||
|
19119e5c77
|
|||
|
1e3f62d3c4
|
|||
|
|
5af815d99f |
81
.gitea/workflows/build-and-push.yml
Normal file
81
.gitea/workflows/build-and-push.yml
Normal file
@@ -0,0 +1,81 @@
|
||||
name: Build and Push Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
tags:
|
||||
- 'build_*'
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
env:
|
||||
REGISTRY: rgy.angels-dev.fr
|
||||
PATH: prod
|
||||
IMAGE_NAME: bot_tamiseur
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '22'
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Extract metadata
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.PATH }}/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
# Tag avec le nom de la branche
|
||||
type=ref,event=branch
|
||||
# Tag avec le nom du tag Git
|
||||
type=ref,event=tag
|
||||
# Tag avec le SHA du commit
|
||||
type=sha,prefix={{branch}}-
|
||||
# Tag latest pour la branche master
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
labels: |
|
||||
org.opencontainers.image.title=${{ env.IMAGE_NAME }}
|
||||
org.opencontainers.image.description=Bot Discord
|
||||
org.opencontainers.image.url=https://gitea.zac.ovh/zachary/bot_Tamiseur
|
||||
org.opencontainers.image.source=https://gitea.zac.ovh/zachary/bot_Tamiseur
|
||||
org.opencontainers.image.revision=${{ github.sha }}
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm64 # Multi-architecture si nécessaire
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
- name: Generate artifact attestation
|
||||
uses: actions/attest-build-provenance@v1
|
||||
with:
|
||||
subject-name: ${{ env.REGISTRY }}/${{ env.PATH }}/${{ env.IMAGE_NAME }}
|
||||
subject-digest: ${{ steps.build.outputs.digest }}
|
||||
push-to-registry: true
|
||||
22
Makefile
Normal file
22
Makefile
Normal file
@@ -0,0 +1,22 @@
|
||||
# =====================
|
||||
# Build new application
|
||||
# =====================
|
||||
|
||||
|
||||
.PHONY: tag-build
|
||||
tag-build: ## DEV : Build a prod version with a timestamped tag
|
||||
@export TIMESTAMP=build_`date +"%G-%m-%d_%Hh%M"`; \
|
||||
echo TAG = $$TIMESTAMP; \
|
||||
git tag $$TIMESTAMP; \
|
||||
git push origin $$TIMESTAMP;
|
||||
|
||||
# ===============
|
||||
# Deployment tags
|
||||
# ===============
|
||||
|
||||
.PHONY: tag-deploy
|
||||
tag-deploy: ## DEV : Set tag to current HEAD to deploy in production
|
||||
@export TIMESTAMP=deploy_`date +"%G-%m-%d_%Hh%M"`; \
|
||||
echo TAG = $$TIMESTAMP; \
|
||||
git tag $$TIMESTAMP; \
|
||||
git push origin $$TIMESTAMP;
|
||||
12
deploy/Chart.yaml
Normal file
12
deploy/Chart.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
# Version schéma helm (v2 = helm3)
|
||||
apiVersion: v2
|
||||
|
||||
# Nom de l'application déployée
|
||||
name: bot_tamiseur
|
||||
|
||||
# Version du chart : doit changer si l'application change ou si la configuration du chart change
|
||||
#version: 1
|
||||
version: "1"
|
||||
|
||||
# icon (optionnel) mais génère un warning avec "helm lint"
|
||||
icon: https://helm.sh/img/helm-logo.svg
|
||||
34
deploy/templates/deployment.yaml
Normal file
34
deploy/templates/deployment.yaml
Normal file
@@ -0,0 +1,34 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ .Release.Name }}
|
||||
spec:
|
||||
replicas: 1
|
||||
revisionHistoryLimit: 0
|
||||
strategy:
|
||||
type: {{ .Values.deployment.strategy }}
|
||||
selector:
|
||||
matchLabels:
|
||||
pod: {{ .Release.Name }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
pod: {{ .Release.Name }}
|
||||
spec:
|
||||
securityContext:
|
||||
runAsUser: 1000
|
||||
runAsGroup: 1000
|
||||
fsGroup: 1000
|
||||
containers:
|
||||
- name: {{ .Release.Name }}
|
||||
image: "{{ .Values.deployment.image.repository }}:{{ .Values.deployment.image.tag }}"
|
||||
imagePullPolicy: {{ .Values.deployment.image.pullPolicy }}
|
||||
env:
|
||||
{{ range $envName, $envValue := .Values.deployment.env }}
|
||||
- name: {{ $envName | quote}}
|
||||
value: {{ $envValue | quote}}
|
||||
{{ end }}
|
||||
{{- if .Values.deployment.resources.enable }}
|
||||
resources:
|
||||
{{- toYaml .Values.deployment.resources | nindent 12 }}
|
||||
{{- end }}
|
||||
18
deploy/values.yaml
Normal file
18
deploy/values.yaml
Normal file
@@ -0,0 +1,18 @@
|
||||
deployment:
|
||||
replica: 1
|
||||
strategy: RollingUpdate
|
||||
image:
|
||||
repository: "rgy.angels-dev.fr/prod/bot_tamiseur"
|
||||
tag: "3.0.4"
|
||||
pullPolicy: IfNotPresent
|
||||
env:
|
||||
NODE_ENV: "production"
|
||||
|
||||
## Pas de limite CPU pour éviter latence
|
||||
resources:
|
||||
limits:
|
||||
# cpu: ""
|
||||
# Memory: "500Mi"
|
||||
requests:
|
||||
Cpu: "0.1"
|
||||
Memory: "50Mi"
|
||||
11045
package-lock.json
generated
11045
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
52
package.json
52
package.json
@@ -1,14 +1,14 @@
|
||||
{
|
||||
"name": "bot_tamiseur",
|
||||
"description": "Listen to music and use fun commands with your friends!",
|
||||
"version": "3.0.3",
|
||||
"version": "3.0.4",
|
||||
"author": {
|
||||
"name": "Zachary Guénot"
|
||||
},
|
||||
"main": "src/index.ts",
|
||||
"scripts": {
|
||||
"format": "prettier --write .",
|
||||
"start": "ts-node src/index.ts",
|
||||
"start": "npx tsx src/index.ts",
|
||||
"dev": "nodemon -e ts src/index.ts",
|
||||
"build": "tsc",
|
||||
"lint": "eslint src/**/*.ts",
|
||||
@@ -18,40 +18,40 @@
|
||||
"Garder chalk à la version 4.1.2 pour éviter un bug ESM avec la version >=5.0.0"
|
||||
],
|
||||
"dependencies": {
|
||||
"@discord-player/equalizer": "^0.2.3",
|
||||
"@discord-player/extractor": "^4.5.0",
|
||||
"@discordjs/voice": "^0.17.0",
|
||||
"@discord-player/equalizer": "^7.0.0",
|
||||
"@discord-player/extractor": "^7.0.0",
|
||||
"@discordjs/voice": "^0.18.0",
|
||||
"@evan/opus": "^1.0.3",
|
||||
"axios": "^1.7.4",
|
||||
"bufferutil": "^4.0.8",
|
||||
"axios": "^1.7.9",
|
||||
"bufferutil": "^4.0.9",
|
||||
"chalk": "^4.1.2",
|
||||
"discord-player": "^6.7.1",
|
||||
"discord-player-youtubei": "^1.2.4",
|
||||
"discord.js": "^14.15.3",
|
||||
"dotenv": "^16.4.5",
|
||||
"discord-player": "^7.0.0",
|
||||
"discord-player-youtubei": "^1.3.7",
|
||||
"discord.js": "^14.17.2",
|
||||
"dotenv": "^16.4.7",
|
||||
"iconv-lite": "^0.6.3",
|
||||
"jsdom": "^24.1.1",
|
||||
"libsodium-wrappers": "^0.7.14",
|
||||
"mediaplex": "^0.0.9",
|
||||
"mongoose": "^8.5.2",
|
||||
"jsdom": "^25.0.1",
|
||||
"libsodium-wrappers": "^0.7.15",
|
||||
"mediaplex": "^1.0.0",
|
||||
"mongoose": "^8.9.3",
|
||||
"parse-torrent": "^9.1.5",
|
||||
"require-all": "^3.0.0",
|
||||
"rss-parser": "^3.13.0",
|
||||
"ts-node": "^10.9.2",
|
||||
"utf-8-validate": "^6.0.4",
|
||||
"utf-8-validate": "^6.0.5",
|
||||
"websocket": "^1.0.35"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/eslintrc": "^3.1.0",
|
||||
"@eslint/js": "^9.8.0",
|
||||
"@swc/core": "^1.7.6",
|
||||
"@types/node": "^22.1.0",
|
||||
"@eslint/eslintrc": "^3.2.0",
|
||||
"@eslint/js": "^9.17.0",
|
||||
"@swc/core": "^1.10.4",
|
||||
"@types/node": "^22.10.5",
|
||||
"@types/parse-torrent": "^5.8.7",
|
||||
"@types/websocket": "^1.0.10",
|
||||
"@typescript-eslint/eslint-plugin": "^8.0.1",
|
||||
"@typescript-eslint/parser": "^8.0.1",
|
||||
"eslint": "^9.8.0",
|
||||
"nodemon": "^3.1.4",
|
||||
"prettier": "^3.3.3"
|
||||
"@typescript-eslint/eslint-plugin": "^8.19.0",
|
||||
"@typescript-eslint/parser": "^8.19.0",
|
||||
"eslint": "^9.17.0",
|
||||
"nodemon": "^3.1.9",
|
||||
"prettier": "^3.4.2",
|
||||
"tsx": "^4.19.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ export default {
|
||||
.setColor(interaction.guild?.members.me?.displayColor || '#ffc370')
|
||||
.setTimestamp()
|
||||
.setFields(fields)
|
||||
return await interaction.channel?.send({ embeds: [embed] })
|
||||
return await interaction.followUp({ embeds: [embed] })
|
||||
})
|
||||
}
|
||||
else if (result.status === 'fail') return await interaction.followUp(failMsg(result.data as unknown as FailMsgData))
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Events, Client, ActivityType } from 'discord.js'
|
||||
import { YoutubeiExtractor } from "discord-player-youtubei"
|
||||
import { SpotifyExtractor } from '@discord-player/extractor'
|
||||
import { YoutubeiExtractor } from 'discord-player-youtubei'
|
||||
import { useMainPlayer } from 'discord-player'
|
||||
import { connect } from 'mongoose'
|
||||
import WebSocket from 'websocket'
|
||||
@@ -19,7 +20,7 @@ export default {
|
||||
console.log(chalk.blue(`[DiscordJS] Connected to Discord ! Logged in as ${client.user?.tag ?? 'unknown'}`))
|
||||
client.user?.setActivity('some bangers...', { type: ActivityType.Listening })
|
||||
|
||||
await useMainPlayer().extractors.loadDefault(ext => ext === 'SpotifyExtractor').then(() => console.log(chalk.blue('[Discord-Player] Spotify extractor loaded.'))).catch(console.error)
|
||||
await useMainPlayer().extractors.register(SpotifyExtractor, {}).then(() => console.log(chalk.blue('[Discord-Player] Spotify extractor loaded.'))).catch(console.error)
|
||||
await useMainPlayer().extractors.register(YoutubeiExtractor, {}).then(() => console.log(chalk.blue('[Discord-Player] Youtube extractor loaded.'))).catch(console.error)
|
||||
|
||||
let mongo_url = `mongodb://${process.env.MONGOOSE_USER}:${process.env.MONGOOSE_PASSWORD}@${process.env.MONGOOSE_HOST}/${process.env.MONGOOSE_DATABASE}`
|
||||
@@ -54,9 +55,17 @@ export default {
|
||||
}, 30000)
|
||||
|
||||
// TWITCH EVENTSUB
|
||||
if (process.env['TWITCH_RUNNING_' + guild.id]) return console.log(chalk.magenta(`[Twitch] {${guild.name}} Already running...`))
|
||||
console.log(chalk.magenta(`[Twitch] {${guild.name}} Not running, starting...`))
|
||||
process.env['TWITCH_RUNNING_' + guild.id] = 'true'
|
||||
|
||||
let client_id = process.env.TWITCH_APP_ID as string
|
||||
let client_secret = process.env.TWITCH_APP_SECRET as string
|
||||
|
||||
if (!client_id || !client_secret) return console.log(chalk.magenta(`[Twitch] {${guild.name}} App ID or Secret is not defined !`))
|
||||
|
||||
let dbData = guildProfile.get('guildTwitch')
|
||||
if (!dbData?.enabled) return console.log(chalk.magenta(`[Twitch] {${guild.name}} Module is disabled, please activate with \`/database edit guildTwitch.enabled True\` !`))
|
||||
|
||||
let twitch = new WebSocket.client().on('connect', async connection => {
|
||||
console.log(chalk.magenta(`[Twitch] {${guild.name}} EventSub WebSocket Connected !`))
|
||||
|
||||
@@ -102,10 +111,7 @@ export default {
|
||||
})
|
||||
}).on('connectFailed', error => console.error(chalk.magenta(`[Twitch] {${guild.name}} ` + error)))
|
||||
|
||||
let dbData = guildProfile.get('guildTwitch')
|
||||
if (!dbData?.enabled) return console.log(chalk.magenta(`[Twitch] {${guild.name}} Module is disabled for "${guild?.name}", please activate with \`/database edit guildTwitch.enabled True\` !`))
|
||||
else if (!client_id || !client_secret) return console.log(chalk.magenta(`[Twitch] {${guild.name}} App ID or Secret is not defined !`))
|
||||
else twitch.connect('wss://eventsub.wss.twitch.tv/ws')
|
||||
twitch.connect('wss://eventsub.wss.twitch.tv/ws')
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,8 @@ import 'dotenv/config'
|
||||
|
||||
// CUSTOM TYPES
|
||||
interface CConnection extends Connection {
|
||||
once: (event: string, listener: (...args: unknown[]) => void) => void
|
||||
on: (event: string, listener: (...args: unknown[]) => void) => void
|
||||
once: (event: string, listener: (...args: unknown[]) => void) => this
|
||||
on: (event: string, listener: (...args: unknown[]) => void) => this
|
||||
}
|
||||
interface Command {
|
||||
name: string
|
||||
|
||||
@@ -130,7 +130,7 @@ export async function notification (client_id: string, client_secret: string, ch
|
||||
.setImage(stream_data.thumbnail_url.replace('{width}', '1920').replace('{height}', '1080'))
|
||||
.setTimestamp()
|
||||
let hidden = hyperlink('démarre un live', 'https://www.youtube.com/watch?v=dQw4w9WgXcQ&pp=ygUJcmljayByb2xs')
|
||||
let message = await liveChannel.send({ content: `Hey ! <@${dbData.liveBroadcasterId}> ${hidden} sur **Twitch**, venez !`, embeds: [embed] })
|
||||
let message = await liveChannel.send({ content: `Hey @everyone ! <@${dbData.liveBroadcasterId}> ${hidden} sur **Twitch**, venez !`, embeds: [embed] })
|
||||
|
||||
dbData.liveMessageId = message.id
|
||||
guildProfile.set('guildTwitch', dbData)
|
||||
@@ -167,7 +167,7 @@ export async function notification (client_id: string, client_secret: string, ch
|
||||
.setAuthor({ name: `⚫ C'EST FINI, LE LIVE A DURÉ ${duration_string} ! 📼`, iconURL: user_profile_image_url })
|
||||
.setTimestamp()
|
||||
|
||||
message.edit({ content: `Re !\n<@${dbData.liveBroadcasterId}> a terminé son live sur **Twitch** !`, embeds: [embed] }).catch(console.error)
|
||||
message.edit({ content: `Re @everyone !\n<@${dbData.liveBroadcasterId}> a terminé son live sur **Twitch** !`, embeds: [embed] }).catch(console.error)
|
||||
clearInterval(liveMessageInterval)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user