feat: new server migration (prayge)

This commit is contained in:
2023-08-18 15:37:34 +02:00
parent 53603db5af
commit 06f5ebf812
22 changed files with 207 additions and 10731 deletions

54
.github/workflows/docker.yml vendored Normal file
View File

@@ -0,0 +1,54 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# GitHub recommends pinning actions to a commit SHA.
# To get a newer version, you will need to update the SHA.
# You can also reference a tag or branch, but the action may change without warning.
name: Publish Docker image
on:
push:
branches:
- main
jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Log in to Sr Izan's container registry
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
registry: containers.srizan.dev
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: containers.srizan.dev/vinci
tags: latest
- name: Build and push Docker image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Emit a webhook to the server
env:
AUTH_HEADER: ${{ secrets.WHSERVER_TOKEN }}
run: |
curl -X POST \
-H "Authorization: Bearer $AUTH_HEADER" \
https://webhooks.srizan.dev/hooks/bask

8
.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

65
.idea/codeStyles/Project.xml generated Normal file
View File

@@ -0,0 +1,65 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<HTMLCodeStyleSettings>
<option name="HTML_SPACE_INSIDE_EMPTY_TAG" value="true" />
<option name="HTML_QUOTE_STYLE" value="Single" />
<option name="HTML_ENFORCE_QUOTES" value="true" />
</HTMLCodeStyleSettings>
<JSCodeStyleSettings version="0">
<option name="FORCE_SEMICOLON_STYLE" value="true" />
<option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
<option name="USE_DOUBLE_QUOTES" value="false" />
<option name="FORCE_QUOTE_STYlE" value="true" />
<option name="ENFORCE_TRAILING_COMMA" value="Remove" />
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
<option name="SPACES_WITHIN_IMPORTS" value="true" />
</JSCodeStyleSettings>
<TypeScriptCodeStyleSettings version="0">
<option name="FORCE_SEMICOLON_STYLE" value="true" />
<option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
<option name="USE_DOUBLE_QUOTES" value="false" />
<option name="FORCE_QUOTE_STYlE" value="true" />
<option name="ENFORCE_TRAILING_COMMA" value="Remove" />
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
<option name="SPACES_WITHIN_IMPORTS" value="true" />
</TypeScriptCodeStyleSettings>
<VueCodeStyleSettings>
<option name="INTERPOLATION_NEW_LINE_AFTER_START_DELIMITER" value="false" />
<option name="INTERPOLATION_NEW_LINE_BEFORE_END_DELIMITER" value="false" />
</VueCodeStyleSettings>
<codeStyleSettings language="HTML">
<option name="SOFT_MARGINS" value="80" />
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="2" />
<option name="TAB_SIZE" value="2" />
<option name="USE_TAB_CHARACTER" value="true" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="JavaScript">
<option name="SOFT_MARGINS" value="80" />
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="2" />
<option name="TAB_SIZE" value="2" />
<option name="USE_TAB_CHARACTER" value="true" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="TypeScript">
<option name="SOFT_MARGINS" value="80" />
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="2" />
<option name="TAB_SIZE" value="2" />
<option name="USE_TAB_CHARACTER" value="true" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="Vue">
<option name="SOFT_MARGINS" value="80" />
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="2" />
<option name="USE_TAB_CHARACTER" value="true" />
</indentOptions>
</codeStyleSettings>
</code_scheme>
</component>

5
.idea/codeStyles/codeStyleConfig.xml generated Normal file
View File

@@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
</state>
</component>

7
.idea/discord.xml generated Normal file
View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DiscordProjectSettings">
<option name="show" value="PROJECT_FILES" />
<option name="description" value="" />
</component>
</project>

View File

@@ -0,0 +1,10 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
<option name="processCode" value="true" />
<option name="processLiterals" value="true" />
<option name="processComments" value="true" />
</inspection_tool>
</profile>
</component>

6
.idea/misc.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

8
.idea/modules.xml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/vinci.iml" filepath="$PROJECT_DIR$/.idea/vinci.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

9
.idea/vinci.iml generated Normal file
View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@@ -1,30 +1,32 @@
FROM node:lts
RUN echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | debconf-set-selections
RUN apt-get update && \
apt-get install -y build-essential \
wget \
python3 \
make \
gcc \
libc6-dev \
bash \
ffmpeg \
fontconfig
RUN wget http://ftp.de.debian.org/debian/pool/contrib/m/msttcorefonts/ttf-mscorefonts-installer_3.6_all.deb
RUN apt install ./ttf-mscorefonts-installer_3.6_all.deb -y
# Build stage
FROM node:lts-alpine AS build
WORKDIR /app
COPY package.json ./
RUN apk add --no-cache --virtual .gyp python3 make g++
RUN npm i
RUN npm rebuild @tensorflow/tfjs-node --build-from-source
EXPOSE 7272
COPY package.json yarn.lock ./
RUN yarn
COPY . .
RUN yarn build
RUN yarn cache clean
RUN npm run build
# Final stage
FROM node:lts-alpine AS final
CMD node ./dist/index.js
WORKDIR /app
COPY --from=build /app/dist ./dist
COPY --from=build /app/schemas ./schemas
COPY --from=build /app/util ./
COPY --from=build /app/images ./images
COPY --from=build /app/node_modules ./node_modules
COPY --from=build /app/package.json ./package.json
RUN apk add --no-cache ffmpeg msttcorefonts-installer fontconfig && \
update-ms-fonts && \
fc-cache -f
CMD ["node", "dist/index.js"]

View File

@@ -14,11 +14,11 @@ export default commandModule({
options: [],
execute: async (ctx, options) => {
await ctx.interaction.deferReply({ ephemeral: true })
const cpubrand = await axios(`http://192.168.1.44:7271/cpubrand`)
const cpucores = await axios(`http://192.168.1.44:7271/cpucores`)
const ramtotal = await axios(`http://192.168.1.44:7271/ramtotal`)
const ramfree = await axios(`http://192.168.1.44:7271/ramfree`)
const dockertotal = await axios(`http://192.168.1.44:7271/dockertotal`)
const cpubrand = await axios(`http://192.168.1.79:7271/cpubrand`)
const cpucores = await axios(`http://192.168.1.79:7271/cpucores`)
const ramtotal = await axios(`http://192.168.1.79:7271/ramtotal`)
const ramfree = await axios(`http://192.168.1.79:7271/ramfree`)
const dockertotal = await axios(`http://192.168.1.79:7271/dockertotal`)
const uptime = prettySeconds(process.uptime())
const embed = new EmbedBuilder()
.setAuthor({name: `${ctx.user.username}`, iconURL: `${ctx.user.displayAvatarURL()}`})

View File

@@ -7,8 +7,6 @@ import mongoose from 'mongoose';
import youtubenotifications from './util/youtubenotifications.js';
import { setIntervalAsync } from 'set-interval-async';
import birthdays from './util/birthdays.js';
import twitternotifications from './util/twitternotifications.js';
import webserver from './util/web/webserver.js'
import minecraftstatus from './util/minecraftstatus.js';
import * as tf from '@tensorflow/tfjs-node'
import * as nsfw from 'nsfwjs'
@@ -82,10 +80,6 @@ client.on('ready', async () => {
await youtubenotifications(client);
}, 120_000);
setIntervalAsync(async () => {
await twitternotifications(client);
}, 120_000);
setIntervalAsync(async () => {
await birthdays(client);
}, 3_600_000);
@@ -93,14 +87,8 @@ client.on('ready', async () => {
setIntervalAsync(async () => {
await minecraftstatus(client);
}, 20_000);
setIntervalAsync(async () => {
await minecraftstatus(client);
}, 20_000);
webserver()
} else {
console.log('DevMode got activated, there are no checkers or webserver in this version.')
console.log('DevMode got activated, there are no checkers in this version.')
}
});

10638
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -37,7 +37,6 @@
"@discordjs/voice": "^0.15.0",
"@napi-rs/canvas": "^0.1.30",
"@sern/handler": "^2.5.3",
"@tensorflow/tfjs-node": "4.1.0",
"axios": "^1.1.3",
"dayjs": "^1.11.6",
"discord-tictactoe": "^4.0.0",
@@ -52,7 +51,6 @@
"libsodium-wrappers": "^0.7.10",
"mongoose": "^6.5.1",
"node-fetch": "^3.3.1",
"nsfwjs": "^2.4.2",
"pretty-seconds-spanish": "^2.1.1",
"rockpaperscissors-checker": "^1.2.0",
"set-interval-async": "^3.0.2",

0
util/bonzi_temp/.gitkeep Normal file
View File

View File

@@ -1 +0,0 @@
hi

View File

@@ -1,33 +0,0 @@
import { Client, TextChannel } from 'discord.js';
import axios from 'axios';
import schema from '../schemas/twitter.js';
export default async function twitternotifications(client: Client) {
try {
const db = await schema.findOne({ user: 'elpady' });
const request = (
await axios
.get(
'https://api.twitter.com/2/tweets/search/recent?query=from%3AMaraTuring',
{
headers: {
Authorization: `Bearer ${process.env.TWITTER}`,
},
}
)
.then((res) => res.data)
).data[0].id;
const fetchTextChannel = (await (
await client.guilds.fetch(process.env.GUILDID!)
).channels.fetch(process.env.SOCIALS_CHANNEL!)) as TextChannel;
if (request === db?.id) return;
else {
db!.id = request;
await db?.save();
const message = await fetchTextChannel.send({
content: `Nuevo tweet de Mara Turing, corre a verlo! https://twitter.com/MaraTuring/status/${request}`,
});
message.react('<:Pog:1030169609178976346>');
}
} catch {}
}

View File

@@ -1,5 +1,4 @@
#!/usr/bin/node
const port = 8080
const port = 7271
const express = require('express');
const app = express();
const si = require('systeminformation');
@@ -16,9 +15,6 @@ function formatBytes(bytes, decimals = 2) {
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
}
// use the express-static middleware
app.use(express.static("public"))
app.get("/cpubrand", async function (req, res) {
const cpu = await si.cpu()
res.send(`${cpu.manufacturer} ${cpu.brand}`)

View File

@@ -1,14 +0,0 @@
const express = require('express');
const app = express();
// use the express-static middleware
app.use(express.static("public"))
// define the first route
app.get("/", function (req, res) {
res.send("<p>This is the monitoring server for the Vinci discord bot!</p><br><p>If you see this, the bot is up and running.</p>")
})
// start the server listening for requests
app.listen(process.env.PORT || 7272,
() => console.log("The webserver is listening on port " + process.env.PORT || 3000));