Skip to content

Commit

Permalink
Merge branch 'master' into bun
Browse files Browse the repository at this point in the history
  • Loading branch information
holzmaster committed Jan 19, 2024
2 parents dbeb428 + 9418739 commit 710e0d8
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 167 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ jobs:

steps:
- name: Deploy CSZ Bot
uses: appleboy/ssh-action@55dabf81b49d4120609345970c91507e2d734799
uses: appleboy/ssh-action@8f949198563a347a01c65ffc60399aef2b59d4ab
env:
DOCKER_BUILDKIT: 1
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.SSH_PORT }}
envs: DOCKER_BUILDKIT
script: /home/csc/deploy.sh
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ FROM oven/bun:latest as dependency-base
libpixman-1-dev libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev \
&& apt-get clean -yqqq

COPY package.json bun.lockb /app/

FROM dependency-base as runtime-dependencies
RUN NODE_ENV=production bun install
RUN --mount=type=bind,source=package.json,target=package.json \
--mount=type=bind,source=bun.lockb,target=bun.lockb \
NODE_ENV=production bun install

FROM node:21-slim
WORKDIR /app
Expand Down
Binary file modified bun.lockb
Binary file not shown.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@
"@discordjs/voice": "^0.16.1",
"@resvg/resvg-js": "^2.6.0",
"canvas": "^2.11.2",
"chrono-node": "^2.7.3",
"croner": "^7.0.5",
"chrono-node": "^2.7.4",
"croner": "^8.0.0",
"discord.js": "^14.14.1",
"get-audio-duration": "^4.0.1",
"graphviz-wasm": "^3.0.1",
"instagram-url-direct": "^1.0.13",
"jsdom": "^23.0.1",
"libsodium-wrappers": "^0.7.13",
"minimist": "^1.2.8",
"moment": "^2.29.4",
"pino": "^8.16.2",
"sequelize": "^6.35.1",
"moment": "^2.30.1",
"pino": "^8.17.2",
"sequelize": "^6.35.2",
"splid-js": "^1.1.1",
"sqlite3": "~5.1.6"
},
Expand All @@ -48,11 +48,11 @@
"@ffprobe-installer/ffprobe": "^2.1.2",
"@types/jsdom": "^21.1.6",
"@types/minimist": "^1.2.5",
"@types/node": "^20.10.4",
"@types/node": "^20.10.6",
"@types/node-cron": "^3.0.11",
"@types/sqlite3": "^3.1.11",
"concurrently": "^8.2.2",
"pino-pretty": "^10.2.3",
"pino-pretty": "^10.3.1",
"typescript": "^5.3.3"
},
"engines": {
Expand Down
15 changes: 11 additions & 4 deletions src/commands/ehre.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,19 @@ export const ehreReactionHandler = {
const replyChannelHasSlowMode =
replyChannel.isTextBased() &&
(replyChannel as TextChannel).rateLimitPerUser > 0;
const replyChannelHasOverwrite =
replyChannel.isTextBased() &&
(replyChannel as TextChannel).permissionOverwrites.cache
.get(context.roles.default.id)
?.deny?.has("SendMessages");

if (!replyChannelHasSlowMode) {
await reactionEvent.message.reply(
`${invoker} hat ${ehrenbruder} geährt`,
);
if (replyChannelHasSlowMode || replyChannelHasOverwrite) {
return;
}

await reactionEvent.message.reply(
`${invoker} hat ${ehrenbruder} geährt`,
);
},
};

Expand Down
139 changes: 0 additions & 139 deletions src/commands/special/linkEnhancer.ts

This file was deleted.

16 changes: 9 additions & 7 deletions src/commands/splid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,23 +334,25 @@ export class SplidGroupCommand implements ApplicationCommand {
return;
}

function getPrintableDisplayName(splidAccount: SplidMember) {
function getDisplayName(splidAccount: SplidMember) {
const discordUser = linkedAccounts.get(splidAccount.globalId);
return discordUser ? userMention(discordUser) : splidAccount.name;
}

const getBalance = (splidAccount: SplidMember): string => {
// TODO: How do we get the balance? It seems that splid computes this on the client side?
const balance = accountBalances[splidAccount.globalId] ?? 0;
return createNumberFormatter("EUR").format(balance);
const getBalance = (splidAccount: SplidMember): number => {
return accountBalances[splidAccount.globalId] ?? 0;
};

const descriptionPrefix = group.longDescription
? `${group.longDescription}\n\n`
: "";

const description = memberData
.map(n => `${getPrintableDisplayName(n)}: \`${getBalance(n)}\``)
const formatter = createNumberFormatter("EUR");
const format = formatter.format.bind(formatter);

const description = [...memberData]
.sort((a, b) => getBalance(b) - getBalance(a))
.map(n => `${getDisplayName(n)}: \`${format(getBalance(n))}\``)
.join("\n");

await command.editReply({
Expand Down
2 changes: 0 additions & 2 deletions src/handler/commandHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ import { WoisCommand } from "../commands/woisvote.js";
import { ApplicationCommandCreationResponse } from "../types.js";
import { AoCCommand } from "../commands/aoc.js";
import { BanListCommand } from "../commands/banlist.js";
import { LinkEnhancer } from "../commands/special/linkEnhancer.js";
import { Vote2Command } from "../commands/vote2.js";

const config = getConfig();
Expand Down Expand Up @@ -126,7 +125,6 @@ export const commands: readonly Command[] = [
new EhreCommand(),
new AoCCommand(),
new BanListCommand(),
new LinkEnhancer(),
new Vote2Command(),
];
export const interactions: readonly UserInteraction[] = [
Expand Down
22 changes: 18 additions & 4 deletions src/storage/model/AustrianTranslation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,24 @@ export default class AustrianTranslation extends Model {
): Promise<AustrianTranslation | null> {
return AustrianTranslation.findOne({
where: {
austrian: {
// we want like to be case-insensitive, we don't need a placeholder
[Op.like]: austrian.trim().toLowerCase(),
},
[Op.or]: [
{
// we want like to be case-insensitive, we don't need a placeholder
// We might have translations with punctuations in it, so we simply try to match the whole string against it
austrian: {
[Op.like]: austrian.trim().toLowerCase(),
},
},
{
// If we couldn't find a translation with the punctuations in it, we remove the special chars
austrian: {
[Op.like]: austrian
.trim()
.toLowerCase()
.replace(/[^\w\s]/gu, ""),
},
},
],
},
});
}
Expand Down

0 comments on commit 710e0d8

Please sign in to comment.