Compare commits
7 Commits
56ec6a1ad8
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 7a1f02ebd0 | |||
| f6bceb215c | |||
| 9914cd2bfb | |||
| fd2d5f5bff | |||
| 762bb989a2 | |||
| 4031291c38 | |||
| fca6927b08 |
@@ -1,17 +1,16 @@
|
|||||||
name: release-tag
|
name: release-tag
|
||||||
|
|
||||||
on:
|
on: push
|
||||||
push
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release-image:
|
release-image:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: catthehacker/ubuntu:act-latest
|
image: catthehacker/ubuntu:act-latest
|
||||||
# env:
|
# env:
|
||||||
# DOCKER_ORG: teacup
|
# DOCKER_ORG: teacup
|
||||||
# DOCKER_LATEST: nightly
|
# DOCKER_LATEST: nightly
|
||||||
# RUNNER_TOOL_CACHE: /toolcache
|
# RUNNER_TOOL_CACHE: /toolcache
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
@@ -28,12 +27,12 @@ jobs:
|
|||||||
registry: git.unom.io # replace it with your local IP
|
registry: git.unom.io # replace it with your local IP
|
||||||
username: ${{ vars.DOCKER_USERNAME }}
|
username: ${{ vars.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_TOKEN }}
|
password: ${{ secrets.DOCKER_TOKEN }}
|
||||||
|
|
||||||
- name: Get Meta
|
- name: Get Meta
|
||||||
id: meta
|
id: meta
|
||||||
run: |
|
run: |
|
||||||
echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}') >> $GITHUB_OUTPUT
|
echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}') >> $GITHUB_OUTPUT
|
||||||
echo REPO_VERSION=$(git describe --tags --always | sed 's/^v//') >> $GITHUB_OUTPUT
|
echo REPO_VERSION=$(git describe --tags --always | sed 's/^v//') >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v4
|
||||||
@@ -42,8 +41,8 @@ jobs:
|
|||||||
file: ./Dockerfile
|
file: ./Dockerfile
|
||||||
platforms: |
|
platforms: |
|
||||||
linux/amd64
|
linux/amd64
|
||||||
linux/arm64
|
linux/arm64
|
||||||
push: true
|
push: true
|
||||||
tags: | # replace it with your local IP and tags
|
tags: | # replace it with your local IP and tags
|
||||||
git.unom.io/moriese/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.REPO_VERSION }}
|
git.unom.io/mo/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.REPO_VERSION }}
|
||||||
git.unom.io/moriese/${{ steps.meta.outputs.REPO_NAME }}:latest
|
git.unom.io/mo/${{ steps.meta.outputs.REPO_NAME }}:latest
|
||||||
|
|||||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2024 moriese
|
Copyright (c) 2024 mo (mo@unom.io)
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
services:
|
services:
|
||||||
avocadi-bot:
|
avocadi-bot:
|
||||||
container_name: avocadi-bot
|
container_name: avocadi-bot
|
||||||
image: git.unom.io/moriese/avocadi-bot:latest
|
image: git.unom.io/mo/avocadi-bot:latest
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
volumes:
|
volumes:
|
||||||
- ./.env:/usr/src/app/.env
|
- ./.env:/usr/src/app/.env
|
||||||
|
|||||||
48
src/actions/debug/debug.service.ts
Normal file
48
src/actions/debug/debug.service.ts
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
import { type CommandsType, Commands } from "commands";
|
||||||
|
import config from "config";
|
||||||
|
import type { CacheType, ChatInputCommandInteraction, Interaction } from "discord.js";
|
||||||
|
import { checkPermission } from "permissions";
|
||||||
|
|
||||||
|
export class DebugService {
|
||||||
|
|
||||||
|
async handleInteraction(
|
||||||
|
interaction: Interaction<CacheType>
|
||||||
|
) {
|
||||||
|
if (interaction.isChatInputCommand()) {
|
||||||
|
await this.handleChatInputCommand(interaction);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
async handleChatInputCommand(interaction: ChatInputCommandInteraction<CacheType>) {
|
||||||
|
const commandName = interaction.commandName as CommandsType;
|
||||||
|
switch (commandName) {
|
||||||
|
case Commands.Enum.version:
|
||||||
|
await this.version(interaction);
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async version(interaction: ChatInputCommandInteraction<CacheType>) {
|
||||||
|
try {
|
||||||
|
console.log("version command");
|
||||||
|
if (await checkPermission(interaction.member) !== true) {
|
||||||
|
await interaction.reply({
|
||||||
|
content: "du hast keine rechte fuer diesen befehl",
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await interaction.reply({
|
||||||
|
content: "version: " + config.discord.version,
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.error("error while sending version msg:", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -18,6 +18,7 @@ import {
|
|||||||
} from "discord.js";
|
} from "discord.js";
|
||||||
import { DmService } from "actions/dm/dm.service.ts";
|
import { DmService } from "actions/dm/dm.service.ts";
|
||||||
import { Commands, type CommandsType } from "commands/index.ts";
|
import { Commands, type CommandsType } from "commands/index.ts";
|
||||||
|
import { checkPermission } from "permissions/index.ts";
|
||||||
|
|
||||||
export class GreetingService {
|
export class GreetingService {
|
||||||
dmService: DmService;
|
dmService: DmService;
|
||||||
@@ -82,7 +83,7 @@ export class GreetingService {
|
|||||||
//console.log(input);
|
//console.log(input);
|
||||||
|
|
||||||
// permission check
|
// permission check
|
||||||
if (await this.checkPermission(interaction.member) !== true) {
|
if (await checkPermission(interaction.member) !== true) {
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
content: "du hast keine rechte fuer diesen befehl",
|
content: "du hast keine rechte fuer diesen befehl",
|
||||||
ephemeral: true,
|
ephemeral: true,
|
||||||
@@ -202,7 +203,7 @@ export class GreetingService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// permission check
|
// permission check
|
||||||
if (await this.checkPermission(interaction.member) !== true) {
|
if (await checkPermission(interaction.member) !== true) {
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
content: "du hast keine rechte fuer diesen befehl",
|
content: "du hast keine rechte fuer diesen befehl",
|
||||||
ephemeral: true,
|
ephemeral: true,
|
||||||
@@ -274,7 +275,7 @@ export class GreetingService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await this.checkPermission(interaction.member) !== true) {
|
if (await checkPermission(interaction.member) !== true) {
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
content: "du hast keine rechte fuer diesen befehl",
|
content: "du hast keine rechte fuer diesen befehl",
|
||||||
ephemeral: true,
|
ephemeral: true,
|
||||||
@@ -325,17 +326,6 @@ export class GreetingService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async checkPermission(member: GuildMember | APIInteractionGuildMember | null) {
|
|
||||||
let permission = false;
|
|
||||||
if (member?.roles instanceof GuildMemberRoleManager) {
|
|
||||||
if (member.roles.cache.has(config.discord.roleAdmin) || member.roles.cache.has(config.discord.roleMod)) {
|
|
||||||
console.log("user has permission");
|
|
||||||
permission = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return permission;
|
|
||||||
}
|
|
||||||
|
|
||||||
async checkRole(member: GuildMember) {
|
async checkRole(member: GuildMember) {
|
||||||
let hasRole = false;
|
let hasRole = false;
|
||||||
if (member?.roles instanceof GuildMemberRoleManager) {
|
if (member?.roles instanceof GuildMemberRoleManager) {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export default function createEmbed() { // ({ embeds: [exampleEmbed] })
|
|||||||
.setColor(0x004400)
|
.setColor(0x004400)
|
||||||
//.setTitle("/hilfe")
|
//.setTitle("/hilfe")
|
||||||
//.setURL("")
|
//.setURL("")
|
||||||
.setAuthor({ name: "avocadi - befehle", iconURL: "https://media.discordapp.net/attachments/1321933410188656693/1323447010380222474/mo_Avocadi_Avatar_Closeup_2.png?ex=67748b93&is=67733a13&hm=f48efb3523bca5f50e79144c7b41a127c94670e693e3da3dc2e6ffe62ad8a769&=&format=webp&quality=lossless&width=1524&height=1524", url: 'https://git.unom.io/moriese/avocadi-bot' })
|
.setAuthor({ name: "avocadi - befehle", iconURL: "https://media.discordapp.net/attachments/1321933410188656693/1323447010380222474/mo_Avocadi_Avatar_Closeup_2.png?ex=67748b93&is=67733a13&hm=f48efb3523bca5f50e79144c7b41a127c94670e693e3da3dc2e6ffe62ad8a769&=&format=webp&quality=lossless&width=1524&height=1524", url: 'https://git.unom.io/mo/avocadi-bot' })
|
||||||
.setDescription(" ")
|
.setDescription(" ")
|
||||||
.addFields(
|
.addFields(
|
||||||
{ name: `/${Commands.Enum.giessen}`, value: CommandsMeta.giessen.description },
|
{ name: `/${Commands.Enum.giessen}`, value: CommandsMeta.giessen.description },
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ export class MedicationService {
|
|||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
content:
|
content:
|
||||||
"es gab einen fehler beim verarbeiten deiner anfrage :( versuch es bitte spaeter nochmal, oki? c:",
|
"es gab einen fehler beim verarbeiten deiner anfrage :( versuch es bitte spaeter nochmal, oki? c:",
|
||||||
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,9 +20,16 @@ export default class PomodoroController extends EventEmitter {
|
|||||||
oldState.channelId !== newState.channelId;
|
oldState.channelId !== newState.channelId;
|
||||||
|
|
||||||
const leftPomodoroVC = oldState.channelId != null && this.pomodoroChannels.includes(oldState.channelId) &&
|
const leftPomodoroVC = oldState.channelId != null && this.pomodoroChannels.includes(oldState.channelId) &&
|
||||||
newState.channelId !== config.discord.vchannelIdPomodoro25;
|
newState.channelId !== oldState.channelId;
|
||||||
|
|
||||||
|
if (leftPomodoroVC && this.activePomodoros.has(userId)) {
|
||||||
|
console.log("pomodoro left");
|
||||||
|
this.pomodoroService.stopPomodoro(userId);
|
||||||
|
this.activePomodoros.delete(userId);
|
||||||
|
}
|
||||||
|
|
||||||
if (joinedPomodoroVC && !this.activePomodoros.has(userId)) {
|
if (joinedPomodoroVC && !this.activePomodoros.has(userId)) {
|
||||||
|
console.log("pomodoro join");
|
||||||
const member = newState.member;
|
const member = newState.member;
|
||||||
const vchannel = newState.channel;
|
const vchannel = newState.channel;
|
||||||
if (!member || !vchannel) return;
|
if (!member || !vchannel) return;
|
||||||
@@ -30,12 +37,6 @@ export default class PomodoroController extends EventEmitter {
|
|||||||
this.activePomodoros.add(userId);
|
this.activePomodoros.add(userId);
|
||||||
this.pomodoroService.startPomodoroLoop(member, vchannel);
|
this.pomodoroService.startPomodoroLoop(member, vchannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (leftPomodoroVC && this.activePomodoros.has(userId)) {
|
|
||||||
this.pomodoroService.stopPomodoro(userId);
|
|
||||||
this.activePomodoros.delete(userId);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { SlashCommandBuilder, userMention } from "discord.js";
|
import { SlashCommandBuilder, userMention } from "discord.js";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
export const Commands = z.enum(["giessen", "medikamente", "hilfe", "support", "kofi", "disboard", "discadia", "accept", "welcome", "embed", "message", "reminder"]);
|
export const Commands = z.enum(["giessen", "medikamente", "hilfe", "support", "kofi", "disboard", "discadia", "accept", "welcome", "embed", "message", "reminder", "version"]);
|
||||||
|
|
||||||
export const CommandsMeta: Record<z.output<typeof Commands>, { description: string }> = {
|
export const CommandsMeta: Record<z.output<typeof Commands>, { description: string }> = {
|
||||||
giessen: {
|
giessen: {
|
||||||
@@ -39,6 +39,9 @@ export const CommandsMeta: Record<z.output<typeof Commands>, { description: stri
|
|||||||
},
|
},
|
||||||
reminder: {
|
reminder: {
|
||||||
description: "admin use only"
|
description: "admin use only"
|
||||||
|
},
|
||||||
|
version: {
|
||||||
|
description: "admin use only"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,6 +113,9 @@ export default function getCommands() {
|
|||||||
option.setName('input')
|
option.setName('input')
|
||||||
.setDescription('input for bot')
|
.setDescription('input for bot')
|
||||||
.setRequired(true)),
|
.setRequired(true)),
|
||||||
|
new SlashCommandBuilder()
|
||||||
|
.setName(Commands.Enum.version)
|
||||||
|
.setDescription(CommandsMeta.version.description),
|
||||||
|
|
||||||
].map((command) => command.toJSON());
|
].map((command) => command.toJSON());
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
export default {
|
export default {
|
||||||
discord: {
|
discord: {
|
||||||
version: 250508.2150,
|
version: 250602.10,
|
||||||
// avocadi
|
// avocadi
|
||||||
serverID: process.env.DISCORD_SERVER_ID || "",
|
serverID: process.env.DISCORD_SERVER_ID || "",
|
||||||
// texxt channel
|
// texxt channel
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import { ActivityService } from "actions/activity/activity.service";
|
|||||||
import { DmService } from "actions/dm/dm.service";
|
import { DmService } from "actions/dm/dm.service";
|
||||||
import { CustomMessageService } from "actions/customMessage/customMessage.service";
|
import { CustomMessageService } from "actions/customMessage/customMessage.service";
|
||||||
import { DynamicVChannelService } from "actions/dynamicVChannel/dynamicVChannel.service";
|
import { DynamicVChannelService } from "actions/dynamicVChannel/dynamicVChannel.service";
|
||||||
|
import { DebugService } from "actions/debug/debug.service";
|
||||||
import { ReactRolesService } from "actions/reactRole/reactRoles.service";
|
import { ReactRolesService } from "actions/reactRole/reactRoles.service";
|
||||||
import config from "config";
|
import config from "config";
|
||||||
|
|
||||||
@@ -36,8 +37,10 @@ export default class DiscordController extends EventEmitter {
|
|||||||
private activityService: ActivityService;
|
private activityService: ActivityService;
|
||||||
private dmService: DmService;
|
private dmService: DmService;
|
||||||
private customMessageService: CustomMessageService;
|
private customMessageService: CustomMessageService;
|
||||||
private channelListeners = new Map();
|
|
||||||
private dynamicVChannelService: DynamicVChannelService;
|
private dynamicVChannelService: DynamicVChannelService;
|
||||||
|
private debugService: DebugService;
|
||||||
|
|
||||||
|
private channelListeners = new Map();
|
||||||
private reactRolesService: ReactRolesService;
|
private reactRolesService: ReactRolesService;
|
||||||
|
|
||||||
|
|
||||||
@@ -54,6 +57,7 @@ export default class DiscordController extends EventEmitter {
|
|||||||
this.dmService = new DmService();
|
this.dmService = new DmService();
|
||||||
this.customMessageService = new CustomMessageService();
|
this.customMessageService = new CustomMessageService();
|
||||||
this.dynamicVChannelService = new DynamicVChannelService();
|
this.dynamicVChannelService = new DynamicVChannelService();
|
||||||
|
this.debugService = new DebugService();
|
||||||
this.reactRolesService = new ReactRolesService();
|
this.reactRolesService = new ReactRolesService();
|
||||||
|
|
||||||
client.on("messageReactionAdd", async (reaction, user) => {
|
client.on("messageReactionAdd", async (reaction, user) => {
|
||||||
@@ -215,6 +219,9 @@ export default class DiscordController extends EventEmitter {
|
|||||||
case Commands.Enum.reminder:
|
case Commands.Enum.reminder:
|
||||||
await this.greetingService.handleChatInputCommand(interaction);
|
await this.greetingService.handleChatInputCommand(interaction);
|
||||||
return;
|
return;
|
||||||
|
case Commands.Enum.version:
|
||||||
|
await this.debugService.handleChatInputCommand(interaction);
|
||||||
|
return;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
13
src/permissions/index.ts
Normal file
13
src/permissions/index.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import config from "config";
|
||||||
|
import { GuildMember, GuildMemberRoleManager, type APIInteractionGuildMember } from "discord.js";
|
||||||
|
|
||||||
|
export async function checkPermission(member: GuildMember | APIInteractionGuildMember | null) {
|
||||||
|
let permission = false;
|
||||||
|
if (member?.roles instanceof GuildMemberRoleManager) {
|
||||||
|
if (member.roles.cache.has(config.discord.roleAdmin) || member.roles.cache.has(config.discord.roleMod)) {
|
||||||
|
permission = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log("user permission == " + permission);
|
||||||
|
return permission;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user