This commit is contained in:
Matthieu Pignolet 2024-06-05 21:17:18 +04:00
parent 1fc983ac97
commit 39ee647d01
16 changed files with 428 additions and 3194 deletions

1
.gitignore vendored
View file

@ -0,0 +1 @@
.env

View file

@ -14,7 +14,7 @@ COPY . .
RUN cargo build --release --bin server RUN cargo build --release --bin server
# We do not need the Rust toolchain to run the binary! # We do not need the Rust toolchain to run the binary!
FROM debian:buster-slim AS runtime FROM debian AS runtime
WORKDIR /app WORKDIR /app
RUN apt-get update && apt-get install -y ca-certificates libssl-dev RUN apt-get update && apt-get install -y ca-certificates libssl-dev
COPY --from=builder /app/target/release/server /usr/local/bin/server COPY --from=builder /app/target/release/server /usr/local/bin/server

View file

@ -1,19 +0,0 @@
FROM node as builder
# Create app directory
WORKDIR /usr/src/app
# Install app dependencies
COPY package*.json ./
RUN npm i
COPY . .
RUN npm run build || true
FROM node:slim
# Create app directory
WORKDIR /usr/src/app
# Install app dependencies
COPY package*.json ./
RUN npm i --omit=dev --production
COPY --from=builder /usr/src/app/dist ./dist
CMD [ "node", "dist/index.mjs" ]

View file

@ -1,59 +0,0 @@
gateway:
token: # You need to fill this!
intents: 3276799
shard: 0
shard_total: 1
rest:
discord:
token: # You need to fill this!
server:
listening_adress: 0.0.0.0:8090
ratelimiter_address: localhost # You need to change this to your ratelimit server address!
ratelimiter_port: 8092
webhook:
discord:
public_key: # You need to fill this
server:
listening_adress: 0.0.0.0:8091
cache:
toggles:
- channels_cache
- guilds_cache
- guild_schedules_cache
- stage_instances_cache
- integrations_cache
- members_cache
- bans_cache
- reactions_cache
- messages_cache
- threads_cache
- invites_cache
- roles_cache
- automoderation_cache
- voice_states_cache
ratelimiter:
server:
listening_adress: 0.0.0.0:8092
# Prometheus monitoring configuration
monitoring:
enabled: false
address: 0.0.0.0
port: 9000
# Nats broker configuration
nats:
host: nats
redis:
url: redis://redis
#opentelemetry:
# metrics:
# endpoint: http://otelcol:4317
# traces:
# endpoint: http://otelcol:4317

View file

@ -1,42 +0,0 @@
{
"name": "@discordnova/nova-quickstart",
"version": "1.0.0",
"description": "Simple example of a nova deployment",
"main": "dist/index.js",
"repository": "https://github.com/discordnova/nova-quickstart",
"author": "MatthieuCoder",
"type": "module",
"license": "Apache-2.0",
"dependencies": {
"@discordnova/nova-cli": "0.0.5",
"@discordnova/nova-js": "0.0.5",
"source-map-support": "^0.5.21",
"tslib": "^2.4.1",
"undici": "^5.15.0"
},
"devDependencies": {
"@types/node": "^18.11.18",
"discord-api-types": "^0.37.25",
"typescript": "^5.0.0-dev.20230120",
"xo": "^0.53.1"
},
"scripts": {
"build": "tsc",
"lint": "xo",
"lint:fix": "xo --fix",
"start": "tsc && node dist/index.mjs",
"nova": "nova",
"preprocess": "tsc && node dist/preprocess.mjs"
},
"xo": {
"rules": {
"import/extensions": "off",
"unicorn/prefer-top-level-await": "off",
"no-constructor-return": "off",
"unicorn/no-array-reduce": "off",
"import/no-unassigned-import": "off",
"n/file-extension-in-import": "off"
},
"prettier": true
}
}

View file

@ -1,89 +0,0 @@
import "source-map-support";
import {
GatewayMessageCreateDispatch,
RESTPostAPIChannelMessageJSONBody,
Routes,
} from "discord-api-types/v10";
import { Client } from "@discordnova/nova-js/src/lib/client.js";
import { request } from "undici";
// `autofeur_db` service
export const DB = process.env.DB || "http://localhost:3000";
// nats broker for connecting to nova
export const NATS = process.env.NATS || "192.168.0.17:4222";
// rest endpoint for connecting to nova
export const REST = process.env.REST || "http://192.168.0.17:8090/api";
/**
* Completes a grapheme using the `autofeur_db` service.
* @param grapheme Grapheme to complete
* @returns Completed grapheme
*/
export const completeWord = (grapheme: string) => {
let resp = request(`${DB}?grapheme=${encodeURIComponent(grapheme)}`);
return resp.then((x) => {
if (x.statusCode === 200) {
return x.body.text();
}
});
};
/**
* Cleans a sentence for usage with this program, strips unwanted chars
* @param sentence Raw discord sentence
* @returns The last word without any specials characters
*/
const cutWord = (sentence: string) => {
let lastWord = sentence
.split(" ")
.slice(-1)[0]
.replaceAll(/(\s)?([^\x41-\x5A\s^\x61-\x7A^\xC0-\xFF])/g, "");
return lastWord;
};
/**
* Nova client for receiving events
*/
const emitter = new Client({
transport: {
additionalEvents: [],
nats: {
servers: [NATS],
},
queue: "autofeur_nova",
},
rest: {
api: REST,
},
});
/**
* Handle the message creation event
*/
emitter.on(
"messageCreate",
async (message: GatewayMessageCreateDispatch["d"]) => {
// we shall not repond to bots
if (message.author.bot) return;
if (Math.random() > 0.7) {
try {
// Get the completed word found by the db.
let response = await completeWord(cutWord(message.content));
// Ignore if there is no completion
if (response || response === "") {
// Respond to the message.
await emitter.rest.post(Routes.channelMessages(message.channel_id), {
body: {
content: response,
message_reference: { message_id: message.id },
} as RESTPostAPIChannelMessageJSONBody,
});
}
} catch (e) {}
}
}
);
// Start the service (listening for events.)
(async () => await emitter.start())();

View file

@ -1,15 +0,0 @@
{
"compilerOptions": {
"outDir": "dist",
"downlevelIteration": true,
"module": "es2022",
"target": "ES6",
"sourceMap": true,
"lib": ["ES2022"],
"moduleResolution": "NodeNext",
"skipLibCheck": true,
"incremental": true
},
"exclude": ["node_modules"]
}

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
FROM python:3.7.3-slim FROM python:slim
COPY requirements.txt / COPY requirements.txt /
RUN apt-get update && apt-get install -y build-essential RUN apt-get update && apt-get install -y build-essential
RUN pip3 install -r /requirements.txt RUN pip3 install -r /requirements.txt

View file

@ -1,3 +1,3 @@
config/ config/
dist/ dist/
node_modules/ node_modules/

View file

@ -2,4 +2,4 @@ bin/
node_modules/ node_modules/
dist/ dist/
config/* config/*
!config/default.example.yml !config/default.example.yml

10
discordjs/Dockerfile Normal file
View file

@ -0,0 +1,10 @@
FROM node as builder
# Create app directory
WORKDIR /usr/src/app
# Install app dependencies
COPY package*.json ./
RUN npm i
COPY . .
CMD [ "node", "src/index.mjs" ]

327
discordjs/package-lock.json generated Normal file
View file

@ -0,0 +1,327 @@
{
"name": "discordjs",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "discordjs",
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"discord.js": "^14.15.3",
"undici": "^6.18.2"
}
},
"node_modules/@discordjs/builders": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-1.8.2.tgz",
"integrity": "sha512-6wvG3QaCjtMu0xnle4SoOIeFB4y6fKMN6WZfy3BMKJdQQtPLik8KGzDwBVL/+wTtcE/ZlFjgEk74GublyEVZ7g==",
"license": "Apache-2.0",
"dependencies": {
"@discordjs/formatters": "^0.4.0",
"@discordjs/util": "^1.1.0",
"@sapphire/shapeshift": "^3.9.7",
"discord-api-types": "0.37.83",
"fast-deep-equal": "^3.1.3",
"ts-mixer": "^6.0.4",
"tslib": "^2.6.2"
},
"engines": {
"node": ">=16.11.0"
},
"funding": {
"url": "https://github.com/discordjs/discord.js?sponsor"
}
},
"node_modules/@discordjs/collection": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-1.5.3.tgz",
"integrity": "sha512-SVb428OMd3WO1paV3rm6tSjM4wC+Kecaa1EUGX7vc6/fddvw/6lg90z4QtCqm21zvVe92vMMDt9+DkIvjXImQQ==",
"license": "Apache-2.0",
"engines": {
"node": ">=16.11.0"
}
},
"node_modules/@discordjs/formatters": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/@discordjs/formatters/-/formatters-0.4.0.tgz",
"integrity": "sha512-fJ06TLC1NiruF35470q3Nr1bi95BdvKFAF+T5bNfZJ4bNdqZ3VZ+Ttg6SThqTxm6qumSG3choxLBHMC69WXNXQ==",
"license": "Apache-2.0",
"dependencies": {
"discord-api-types": "0.37.83"
},
"engines": {
"node": ">=16.11.0"
},
"funding": {
"url": "https://github.com/discordjs/discord.js?sponsor"
}
},
"node_modules/@discordjs/rest": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-2.3.0.tgz",
"integrity": "sha512-C1kAJK8aSYRv3ZwMG8cvrrW4GN0g5eMdP8AuN8ODH5DyOCbHgJspze1my3xHOAgwLJdKUbWNVyAeJ9cEdduqIg==",
"license": "Apache-2.0",
"dependencies": {
"@discordjs/collection": "^2.1.0",
"@discordjs/util": "^1.1.0",
"@sapphire/async-queue": "^1.5.2",
"@sapphire/snowflake": "^3.5.3",
"@vladfrangu/async_event_emitter": "^2.2.4",
"discord-api-types": "0.37.83",
"magic-bytes.js": "^1.10.0",
"tslib": "^2.6.2",
"undici": "6.13.0"
},
"engines": {
"node": ">=16.11.0"
},
"funding": {
"url": "https://github.com/discordjs/discord.js?sponsor"
}
},
"node_modules/@discordjs/rest/node_modules/@discordjs/collection": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-2.1.0.tgz",
"integrity": "sha512-mLcTACtXUuVgutoznkh6hS3UFqYirDYAg5Dc1m8xn6OvPjetnUlf/xjtqnnc47OwWdaoCQnHmHh9KofhD6uRqw==",
"license": "Apache-2.0",
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/discordjs/discord.js?sponsor"
}
},
"node_modules/@discordjs/rest/node_modules/undici": {
"version": "6.13.0",
"resolved": "https://registry.npmjs.org/undici/-/undici-6.13.0.tgz",
"integrity": "sha512-Q2rtqmZWrbP8nePMq7mOJIN98M0fYvSgV89vwl/BQRT4mDOeY2GXZngfGpcBBhtky3woM7G24wZV3Q304Bv6cw==",
"license": "MIT",
"engines": {
"node": ">=18.0"
}
},
"node_modules/@discordjs/util": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@discordjs/util/-/util-1.1.0.tgz",
"integrity": "sha512-IndcI5hzlNZ7GS96RV3Xw1R2kaDuXEp7tRIy/KlhidpN/BQ1qh1NZt3377dMLTa44xDUNKT7hnXkA/oUAzD/lg==",
"license": "Apache-2.0",
"engines": {
"node": ">=16.11.0"
},
"funding": {
"url": "https://github.com/discordjs/discord.js?sponsor"
}
},
"node_modules/@discordjs/ws": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@discordjs/ws/-/ws-1.1.1.tgz",
"integrity": "sha512-PZ+vLpxGCRtmr2RMkqh8Zp+BenUaJqlS6xhgWKEZcgC/vfHLEzpHtKkB0sl3nZWpwtcKk6YWy+pU3okL2I97FA==",
"license": "Apache-2.0",
"dependencies": {
"@discordjs/collection": "^2.1.0",
"@discordjs/rest": "^2.3.0",
"@discordjs/util": "^1.1.0",
"@sapphire/async-queue": "^1.5.2",
"@types/ws": "^8.5.10",
"@vladfrangu/async_event_emitter": "^2.2.4",
"discord-api-types": "0.37.83",
"tslib": "^2.6.2",
"ws": "^8.16.0"
},
"engines": {
"node": ">=16.11.0"
},
"funding": {
"url": "https://github.com/discordjs/discord.js?sponsor"
}
},
"node_modules/@discordjs/ws/node_modules/@discordjs/collection": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-2.1.0.tgz",
"integrity": "sha512-mLcTACtXUuVgutoznkh6hS3UFqYirDYAg5Dc1m8xn6OvPjetnUlf/xjtqnnc47OwWdaoCQnHmHh9KofhD6uRqw==",
"license": "Apache-2.0",
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/discordjs/discord.js?sponsor"
}
},
"node_modules/@sapphire/async-queue": {
"version": "1.5.2",
"resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.5.2.tgz",
"integrity": "sha512-7X7FFAA4DngXUl95+hYbUF19bp1LGiffjJtu7ygrZrbdCSsdDDBaSjB7Akw0ZbOu6k0xpXyljnJ6/RZUvLfRdg==",
"license": "MIT",
"engines": {
"node": ">=v14.0.0",
"npm": ">=7.0.0"
}
},
"node_modules/@sapphire/shapeshift": {
"version": "3.9.7",
"resolved": "https://registry.npmjs.org/@sapphire/shapeshift/-/shapeshift-3.9.7.tgz",
"integrity": "sha512-4It2mxPSr4OGn4HSQWGmhFMsNFGfFVhWeRPCRwbH972Ek2pzfGRZtb0pJ4Ze6oIzcyh2jw7nUDa6qGlWofgd9g==",
"license": "MIT",
"dependencies": {
"fast-deep-equal": "^3.1.3",
"lodash": "^4.17.21"
},
"engines": {
"node": ">=v16"
}
},
"node_modules/@sapphire/snowflake": {
"version": "3.5.3",
"resolved": "https://registry.npmjs.org/@sapphire/snowflake/-/snowflake-3.5.3.tgz",
"integrity": "sha512-jjmJywLAFoWeBi1W7994zZyiNWPIiqRRNAmSERxyg93xRGzNYvGjlZ0gR6x0F4gPRi2+0O6S71kOZYyr3cxaIQ==",
"license": "MIT",
"engines": {
"node": ">=v14.0.0",
"npm": ">=7.0.0"
}
},
"node_modules/@types/node": {
"version": "20.14.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.2.tgz",
"integrity": "sha512-xyu6WAMVwv6AKFLB+e/7ySZVr/0zLCzOa7rSpq6jNwpqOrUbcACDWC+53d4n2QHOnDou0fbIsg8wZu/sxrnI4Q==",
"license": "MIT",
"dependencies": {
"undici-types": "~5.26.4"
}
},
"node_modules/@types/ws": {
"version": "8.5.10",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.10.tgz",
"integrity": "sha512-vmQSUcfalpIq0R9q7uTo2lXs6eGIpt9wtnLdMv9LVpIjCA/+ufZRozlVoVelIYixx1ugCBKDhn89vnsEGOCx9A==",
"license": "MIT",
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@vladfrangu/async_event_emitter": {
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/@vladfrangu/async_event_emitter/-/async_event_emitter-2.2.4.tgz",
"integrity": "sha512-ButUPz9E9cXMLgvAW8aLAKKJJsPu1dY1/l/E8xzLFuysowXygs6GBcyunK9rnGC4zTsnIc2mQo71rGw9U+Ykug==",
"license": "MIT",
"engines": {
"node": ">=v14.0.0",
"npm": ">=7.0.0"
}
},
"node_modules/discord-api-types": {
"version": "0.37.83",
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.83.tgz",
"integrity": "sha512-urGGYeWtWNYMKnYlZnOnDHm8fVRffQs3U0SpE8RHeiuLKb/u92APS8HoQnPTFbnXmY1vVnXjXO4dOxcAn3J+DA==",
"license": "MIT"
},
"node_modules/discord.js": {
"version": "14.15.3",
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.15.3.tgz",
"integrity": "sha512-/UJDQO10VuU6wQPglA4kz2bw2ngeeSbogiIPx/TsnctfzV/tNf+q+i1HlgtX1OGpeOBpJH9erZQNO5oRM2uAtQ==",
"license": "Apache-2.0",
"dependencies": {
"@discordjs/builders": "^1.8.2",
"@discordjs/collection": "1.5.3",
"@discordjs/formatters": "^0.4.0",
"@discordjs/rest": "^2.3.0",
"@discordjs/util": "^1.1.0",
"@discordjs/ws": "^1.1.1",
"@sapphire/snowflake": "3.5.3",
"discord-api-types": "0.37.83",
"fast-deep-equal": "3.1.3",
"lodash.snakecase": "4.1.1",
"tslib": "2.6.2",
"undici": "6.13.0"
},
"engines": {
"node": ">=16.11.0"
},
"funding": {
"url": "https://github.com/discordjs/discord.js?sponsor"
}
},
"node_modules/discord.js/node_modules/undici": {
"version": "6.13.0",
"resolved": "https://registry.npmjs.org/undici/-/undici-6.13.0.tgz",
"integrity": "sha512-Q2rtqmZWrbP8nePMq7mOJIN98M0fYvSgV89vwl/BQRT4mDOeY2GXZngfGpcBBhtky3woM7G24wZV3Q304Bv6cw==",
"license": "MIT",
"engines": {
"node": ">=18.0"
}
},
"node_modules/fast-deep-equal": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
"license": "MIT"
},
"node_modules/lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
"license": "MIT"
},
"node_modules/lodash.snakecase": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/lodash.snakecase/-/lodash.snakecase-4.1.1.tgz",
"integrity": "sha512-QZ1d4xoBHYUeuouhEq3lk3Uq7ldgyFXGBhg04+oRLnIz8o9T65Eh+8YdroUwn846zchkA9yDsDl5CVVaV2nqYw==",
"license": "MIT"
},
"node_modules/magic-bytes.js": {
"version": "1.10.0",
"resolved": "https://registry.npmjs.org/magic-bytes.js/-/magic-bytes.js-1.10.0.tgz",
"integrity": "sha512-/k20Lg2q8LE5xiaaSkMXk4sfvI+9EGEykFS4b0CHHGWqDYU0bGUFSwchNOMA56D7TCs9GwVTkqe9als1/ns8UQ==",
"license": "MIT"
},
"node_modules/ts-mixer": {
"version": "6.0.4",
"resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-6.0.4.tgz",
"integrity": "sha512-ufKpbmrugz5Aou4wcr5Wc1UUFWOLhq+Fm6qa6P0w0K5Qw2yhaUoiWszhCVuNQyNwrlGiscHOmqYoAox1PtvgjA==",
"license": "MIT"
},
"node_modules/tslib": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",
"integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==",
"license": "0BSD"
},
"node_modules/undici": {
"version": "6.18.2",
"resolved": "https://registry.npmjs.org/undici/-/undici-6.18.2.tgz",
"integrity": "sha512-o/MQLTwRm9IVhOqhZ0NQ9oXax1ygPjw6Vs+Vq/4QRjbOAC3B1GCHy7TYxxbExKlb7bzDRzt9vBWU6BDz0RFfYg==",
"license": "MIT",
"engines": {
"node": ">=18.17"
}
},
"node_modules/undici-types": {
"version": "5.26.5",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
"license": "MIT"
},
"node_modules/ws": {
"version": "8.17.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.17.0.tgz",
"integrity": "sha512-uJq6108EgZMAl20KagGkzCKfMEjxmKvZHG7Tlq0Z6nOky7YF7aq4mOx6xK8TJ/i1LeK4Qus7INktacctDgY8Ow==",
"license": "MIT",
"engines": {
"node": ">=10.0.0"
},
"peerDependencies": {
"bufferutil": "^4.0.1",
"utf-8-validate": ">=5.0.2"
},
"peerDependenciesMeta": {
"bufferutil": {
"optional": true
},
"utf-8-validate": {
"optional": true
}
}
}
}
}

16
discordjs/package.json Normal file
View file

@ -0,0 +1,16 @@
{
"name": "discordjs",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"type": "module",
"license": "ISC",
"description": "",
"dependencies": {
"discord.js": "^14.15.3",
"undici": "^6.18.2"
}
}

57
discordjs/src/index.mjs Normal file
View file

@ -0,0 +1,57 @@
// Require the necessary discord.js classes
import { Client, GatewayIntentBits } from 'discord.js';
import { request } from "undici";
// Create a new client instance
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildMessages] });
// `autofeur_db` service
export const DB = process.env.DB || "http://localhost:3000";
/**
* Completes a grapheme using the `autofeur_db` service.
* @param grapheme Grapheme to complete
* @returns Completed grapheme
*/
export const completeWord = (grapheme) => {
let resp = request(`${DB}?grapheme=${encodeURIComponent(grapheme)}`);
return resp.then((x) => {
if (x.statusCode === 200) {
return x.body.text();
}
});
};
/**
* Cleans a sentence for usage with this program, strips unwanted chars
* @param sentence Raw discord sentence
* @returns The last word without any specials characters
*/
const cutWord = (sentence) => {
let lastWord = sentence
.split(" ")
.slice(-1)[0]
.replaceAll(/(\s)?([^\x41-\x5A\s^\x61-\x7A^\xC0-\xFF])/g, "");
return lastWord;
};
client.on("messageCreate", async (message) => {
// we shall not repond to bots
if (message.author.bot) return;
if (Math.random() > 0.6) {
try {
// Get the completed word found by the db.
let response = await completeWord(cutWord(message.content));
// Ignore if there is no completion
if (response || response === "") {
message.reply(response);
}
} catch (e) {
console.log(e);
}
}
})
client.login(process.env.TOKEN);

View file

@ -1,25 +1,25 @@
version: "3.3"
services: services:
autofeur_nova: discordjs_bot:
build: autofeur_nova build: discordjs
restart: always restart: always
env_file: .env
depends_on: depends_on:
- autofeur_db - autofeur_db
- nats
environment: environment:
- NATS=nats
- REST=http://rest:8090/api
- DB=http://autofeur_db:3000/ - DB=http://autofeur_db:3000/
autofeur_db: autofeur_db:
build: autofeur_db build: autofeur_db
restart: always restart: always
ports:
- 3000:3000
depends_on: depends_on:
- deep_phonemizer - deep_phonemizer
environment: environment:
- PHONEMIZER=http://deep_phonemizer:8000/ - PHONEMIZER=http://deep_phonemizer:8000/
volumes: volumes:
- ./autofeur_db/assets/db.bin:/app/assets/db.bin - ./autofeur_db/assets/db.bin:/app/assets/db.bin
deep_phonemizer: deep_phonemizer:
build: deep_phonemizer build: deep_phonemizer
restart: always restart: always
@ -27,54 +27,10 @@ services:
- 8000:8000 - 8000:8000
volumes: volumes:
- ./deep_phonemizer/assets/model.pt:/app/assets/model.pt - ./deep_phonemizer/assets/model.pt:/app/assets/model.pt
nats: deploy:
image: nats resources:
restart: always reservations:
devices:
redis: - driver: nvidia
image: redis count: 1
restart: always capabilities: [gpu]
cache:
image: ghcr.io/discordnova/nova/cache
restart: always
volumes:
- ./autofeur_nova/config/default.yml:/config/default.yml
depends_on:
- nats
- redis
gateway0:
image: ghcr.io/discordnova/nova/gateway
restart: always
environment:
- NOVA__GATEWAY__SHARD=0
volumes:
- ./autofeur_nova/config/default.yml:/config/default.yml
depends_on:
- nats
rest:
image: ghcr.io/discordnova/nova/rest
restart: always
volumes:
- ./autofeur_nova/config/default.yml:/config/default.yml
depends_on:
- ratelimiter
webhook:
image: ghcr.io/discordnova/nova/webhook
restart: always
volumes:
- ./autofeur_nova/config/default.yml:/config/default.yml
depends_on:
- nats
ratelimiter:
image: ghcr.io/discordnova/nova/ratelimit
restart: always
volumes:
- ./autofeur_nova/config/default.yml:/config/default.yml
depends_on:
- nats
- redis