From d81b8aebf2368572799beb4a445022efbeefe93c Mon Sep 17 00:00:00 2001 From: Till-JS <101404291+Till-JS@users.noreply.github.com> Date: Sat, 14 Feb 2026 11:26:58 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=92=20refactor(bots):=20remove=20!logi?= =?UTF-8?q?n=20command=20and=20enforce=20OIDC-only=20auth?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove !login and !logout commands from all 16+ Matrix bots - Remove login/logout references from all help/welcome messages - Disable password login in Synapse (password_config.enabled: false) - System is now OIDC-only via Mana Core authentication Users must authenticate via "Sign in with Mana Core" in Element. Existing bot access tokens remain valid. Co-Authored-By: Claude Opus 4.5 --- docker/matrix/homeserver.yaml | 6 +- .../src/bot/matrix.service.ts | 51 -------- .../matrix-chat-bot/src/bot/matrix.service.ts | 57 +++----- .../src/config/configuration.ts | 5 +- .../src/bot/matrix.service.ts | 122 ++++++------------ .../src/config/configuration.ts | 16 +-- .../src/bot/matrix.service.ts | 121 +++++------------ .../src/config/configuration.ts | 4 +- .../src/config/configuration.ts | 5 - .../src/bot/matrix.service.ts | 47 +------ .../src/config/configuration.ts | 7 - .../src/bot/matrix.service.ts | 43 ------ .../src/config/configuration.ts | 1 - .../src/bot/matrix.service.ts | 68 +++------- .../src/config/configuration.ts | 4 +- .../src/bot/matrix.service.ts | 47 +------ .../src/config/configuration.ts | 7 - .../src/bot/matrix.service.ts | 47 +------ .../src/config/configuration.ts | 7 - .../src/bot/matrix.service.ts | 36 ------ .../src/bot/matrix.service.ts | 47 +------ .../src/config/configuration.ts | 7 - .../src/bot/matrix.service.ts | 47 +------ .../src/config/configuration.ts | 7 - .../src/bot/matrix.service.ts | 47 +------ .../src/config/configuration.ts | 7 - .../matrix-todo-bot/src/bot/matrix.service.ts | 30 ----- .../src/config/configuration.ts | 2 - .../src/bot/matrix.service.ts | 43 ------ .../src/config/configuration.ts | 6 +- 30 files changed, 158 insertions(+), 786 deletions(-) diff --git a/docker/matrix/homeserver.yaml b/docker/matrix/homeserver.yaml index 76a2fb240..59af0b2e5 100644 --- a/docker/matrix/homeserver.yaml +++ b/docker/matrix/homeserver.yaml @@ -74,10 +74,10 @@ url_preview_ip_range_blacklist: enable_registration: false enable_registration_without_verification: false -# Password config +# Password config (disabled - all users authenticate via OIDC/SSO) password_config: - enabled: true - localdb_enabled: true + enabled: false + localdb_enabled: false pepper: "${SYNAPSE_PASSWORD_PEPPER:-change-me-pepper}" # Session lifetime (must be >= refresh_token_lifetime) diff --git a/services/matrix-calendar-bot/src/bot/matrix.service.ts b/services/matrix-calendar-bot/src/bot/matrix.service.ts index 51357db8d..dd7e7a477 100644 --- a/services/matrix-calendar-bot/src/bot/matrix.service.ts +++ b/services/matrix-calendar-bot/src/bot/matrix.service.ts @@ -234,14 +234,6 @@ export class MatrixService extends BaseMatrixService { await this.handlePinHelp(roomId, event); break; - case 'login': - await this.handleLogin(roomId, event, userId, args); - break; - - case 'logout': - await this.handleLogout(roomId, event, userId); - break; - case 'language': case 'sprache': case 'lang': @@ -570,49 +562,6 @@ export class MatrixService extends BaseMatrixService { await this.sendReply(roomId, event, response); } - private async handleLogin(roomId: string, event: MatrixRoomEvent, userId: string, args: string) { - const parts = args.trim().split(/\s+/); - if (parts.length < 2) { - await this.sendReply( - roomId, - event, - '❌ Bitte gib Email und Passwort an.\n\nBeispiel: `!login email@example.com passwort`' - ); - return; - } - - const [email, password] = parts; - const result = await this.sessionService.login(userId, email, password); - - if (!result.success) { - await this.sendReply(roomId, event, `❌ Login fehlgeschlagen: ${result.error}`); - return; - } - - const token = await this.sessionService.getToken(userId); - if (token) { - const balance = await this.creditService.getBalance(token); - await this.sendReply( - roomId, - event, - `✅ Erfolgreich angemeldet als **${email}**\n⚡ Credits: ${balance.balance.toFixed(2)}` - ); - } else { - await this.sendReply(roomId, event, `✅ Erfolgreich angemeldet als **${email}**`); - } - } - - private async handleLogout(roomId: string, event: MatrixRoomEvent, userId: string) { - const session = await this.sessionService.getSession(userId); - if (!session) { - await this.sendReply(roomId, event, '❌ Du bist nicht angemeldet.'); - return; - } - - this.sessionService.logout(userId); - await this.sendReply(roomId, event, '✅ Erfolgreich abgemeldet.'); - } - private async handlePinHelp(roomId: string, event: MatrixRoomEvent) { try { // Send help message diff --git a/services/matrix-chat-bot/src/bot/matrix.service.ts b/services/matrix-chat-bot/src/bot/matrix.service.ts index 536d2aaeb..6a3337f71 100644 --- a/services/matrix-chat-bot/src/bot/matrix.service.ts +++ b/services/matrix-chat-bot/src/bot/matrix.service.ts @@ -13,6 +13,7 @@ import { TranscriptionService, CreditService, CreditErrorCode, + LOGIN_MESSAGES, } from '@manacore/bot-services'; import { HELP_MESSAGE, BRANCH_ICONS } from '../config/configuration'; @@ -138,14 +139,6 @@ export class MatrixService extends BaseMatrixService { response = HELP_MESSAGE; break; - case 'login': - response = await this.handleLogin(sender, args); - break; - - case 'logout': - response = await this.handleLogout(sender); - break; - case 'status': response = await this.handleStatus(sender); break; @@ -239,26 +232,6 @@ export class MatrixService extends BaseMatrixService { await this.sendReply(roomId, event, response); } - // Auth handlers - private async handleLogin(sender: string, args: string[]): Promise { - if (args.length < 2) { - return 'Verwendung: `!login email passwort`'; - } - - const [email, password] = args; - const result = await this.sessionService.login(sender, email, password); - - if (result.success) { - return `Erfolgreich angemeldet als **${email}**`; - } - return `Anmeldung fehlgeschlagen: ${result.error}`; - } - - private async handleLogout(sender: string): Promise { - await this.sessionService.logout(sender); - return 'Erfolgreich abgemeldet.'; - } - private async handleStatus(sender: string): Promise { const isLoggedIn = await this.sessionService.isLoggedIn(sender); const email = await this.sessionService.getEmail(sender); @@ -281,7 +254,7 @@ export class MatrixService extends BaseMatrixService { } if (!isLoggedIn) { - return `🤖 **Bot Status**\n\n❌ Nicht angemeldet.\n\nNutze \`!login email passwort\` zum Anmelden.`; + return `🤖 **Bot Status**\n\n❌ Nicht angemeldet.\n\n${LOGIN_MESSAGES.chat}`; } const statusMessage = this.creditService.formatStatusMessage( @@ -301,7 +274,7 @@ export class MatrixService extends BaseMatrixService { const token = await this.sessionService.getToken(sender); if (!token) { - return 'Bitte zuerst anmelden mit `!login email passwort`'; + return LOGIN_MESSAGES.chat; } // Get models to find default @@ -345,7 +318,7 @@ export class MatrixService extends BaseMatrixService { private async handleNewConversation(sender: string, title: string): Promise { const token = await this.sessionService.getToken(sender); if (!token) { - return 'Bitte zuerst anmelden mit `!login email passwort`'; + return LOGIN_MESSAGES.chat; } // Get models to find default @@ -376,7 +349,7 @@ export class MatrixService extends BaseMatrixService { private async handleListConversations(sender: string): Promise { const token = await this.sessionService.getToken(sender); if (!token) { - return 'Bitte zuerst anmelden mit `!login email passwort`'; + return LOGIN_MESSAGES.chat; } const result = await this.chatService.getConversations(token); @@ -417,7 +390,7 @@ export class MatrixService extends BaseMatrixService { private async handleSelectConversation(sender: string, numberStr: string): Promise { const token = await this.sessionService.getToken(sender); if (!token) { - return 'Bitte zuerst anmelden mit `!login email passwort`'; + return LOGIN_MESSAGES.chat; } if (!numberStr) { @@ -475,7 +448,7 @@ Nutze \`!senden [nachricht]\` um zu chatten oder \`!verlauf\` fuer den Nachricht const token = await this.sessionService.getToken(sender); if (!token) { - return 'Bitte zuerst anmelden mit `!login email passwort`'; + return LOGIN_MESSAGES.chat; } const conversationId = await this.getCurrentConversation(sender); @@ -540,7 +513,7 @@ Nutze \`!senden [nachricht]\` um zu chatten oder \`!verlauf\` fuer den Nachricht private async handleShowHistory(sender: string, numberStr?: string): Promise { const token = await this.sessionService.getToken(sender); if (!token) { - return 'Bitte zuerst anmelden mit `!login email passwort`'; + return LOGIN_MESSAGES.chat; } let conversationId = await this.getCurrentConversation(sender); @@ -591,7 +564,7 @@ Nutze \`!senden [nachricht]\` um zu chatten oder \`!verlauf\` fuer den Nachricht ): Promise { const token = await this.sessionService.getToken(sender); if (!token) { - return 'Bitte zuerst anmelden mit `!login email passwort`'; + return LOGIN_MESSAGES.chat; } if (!numberStr || !title) { @@ -619,7 +592,7 @@ Nutze \`!senden [nachricht]\` um zu chatten oder \`!verlauf\` fuer den Nachricht private async handleArchive(sender: string, numberStr: string): Promise { const token = await this.sessionService.getToken(sender); if (!token) { - return 'Bitte zuerst anmelden mit `!login email passwort`'; + return LOGIN_MESSAGES.chat; } if (!numberStr) { @@ -647,7 +620,7 @@ Nutze \`!senden [nachricht]\` um zu chatten oder \`!verlauf\` fuer den Nachricht private async handleListArchived(sender: string): Promise { const token = await this.sessionService.getToken(sender); if (!token) { - return 'Bitte zuerst anmelden mit `!login email passwort`'; + return LOGIN_MESSAGES.chat; } const result = await this.chatService.getArchivedConversations(token); @@ -678,7 +651,7 @@ Nutze \`!senden [nachricht]\` um zu chatten oder \`!verlauf\` fuer den Nachricht private async handleUnarchive(sender: string, numberStr: string): Promise { const token = await this.sessionService.getToken(sender); if (!token) { - return 'Bitte zuerst anmelden mit `!login email passwort`'; + return LOGIN_MESSAGES.chat; } if (!numberStr) { @@ -706,7 +679,7 @@ Nutze \`!senden [nachricht]\` um zu chatten oder \`!verlauf\` fuer den Nachricht private async handlePin(sender: string, numberStr: string): Promise { const token = await this.sessionService.getToken(sender); if (!token) { - return 'Bitte zuerst anmelden mit `!login email passwort`'; + return LOGIN_MESSAGES.chat; } if (!numberStr) { @@ -734,7 +707,7 @@ Nutze \`!senden [nachricht]\` um zu chatten oder \`!verlauf\` fuer den Nachricht private async handleUnpin(sender: string, numberStr: string): Promise { const token = await this.sessionService.getToken(sender); if (!token) { - return 'Bitte zuerst anmelden mit `!login email passwort`'; + return LOGIN_MESSAGES.chat; } if (!numberStr) { @@ -762,7 +735,7 @@ Nutze \`!senden [nachricht]\` um zu chatten oder \`!verlauf\` fuer den Nachricht private async handleDelete(sender: string, numberStr: string): Promise { const token = await this.sessionService.getToken(sender); if (!token) { - return 'Bitte zuerst anmelden mit `!login email passwort`'; + return LOGIN_MESSAGES.chat; } if (!numberStr) { diff --git a/services/matrix-chat-bot/src/config/configuration.ts b/services/matrix-chat-bot/src/config/configuration.ts index 9fb45d600..e205883b9 100644 --- a/services/matrix-chat-bot/src/config/configuration.ts +++ b/services/matrix-chat-bot/src/config/configuration.ts @@ -17,9 +17,7 @@ export default () => ({ export const HELP_MESSAGE = `**AI Chat Bot - Hilfe** -**Authentifizierung:** -- \`!login email passwort\` - Anmelden -- \`!logout\` - Abmelden +**Status:** - \`!status\` - Bot-Status anzeigen **Schnell-Chat:** @@ -48,7 +46,6 @@ export const HELP_MESSAGE = `**AI Chat Bot - Hilfe** **Beispiele:** \`\`\` -!login max@example.com meinpasswort !chat Was ist die Hauptstadt von Frankreich? !neu Programmierung !senden Erklaere mir Python Listen diff --git a/services/matrix-clock-bot/src/bot/matrix.service.ts b/services/matrix-clock-bot/src/bot/matrix.service.ts index d1fd1cd77..38d812c0e 100644 --- a/services/matrix-clock-bot/src/bot/matrix.service.ts +++ b/services/matrix-clock-bot/src/bot/matrix.service.ts @@ -15,6 +15,7 @@ import { I18nService, Language, LANGUAGE_NAMES, + LOGIN_MESSAGES, } from '@manacore/bot-services'; import { HELP_TEXT, WELCOME_TEXT } from '../config/configuration'; @@ -168,14 +169,6 @@ export class MatrixService extends BaseMatrixService { await this.sendReply(roomId, event, HELP_TEXT); break; - case 'login': - await this.handleLogin(roomId, event, userId, args); - break; - - case 'logout': - await this.handleLogout(roomId, event, userId); - break; - case 'timer': await this.handleTimerCommand(roomId, event, userId, args); break; @@ -263,11 +256,8 @@ export class MatrixService extends BaseMatrixService { const label = args.replace(/[\d\s]*[hms]+/gi, '').trim() || null; try { - const token = await this.getToken(userId); - if (!token) { - await this.sendReply(roomId, event, 'Keine Authentifizierung. Bitte zuerst `!login`.'); - return; - } + const token = await this.requireLogin(roomId, event, userId); + if (!token) return; // Create and start timer const timer = await this.clockService.createTimer(durationSeconds, label, token); @@ -287,11 +277,8 @@ export class MatrixService extends BaseMatrixService { private async handleStopCommand(roomId: string, event: MatrixRoomEvent, userId: string) { try { - const token = await this.getToken(userId); - if (!token) { - await this.sendReply(roomId, event, 'Keine Authentifizierung.'); - return; - } + const token = await this.requireLogin(roomId, event, userId); + if (!token) return; const runningTimer = await this.clockService.getRunningTimer(token); if (!runningTimer) { @@ -324,11 +311,8 @@ export class MatrixService extends BaseMatrixService { private async handleResumeCommand(roomId: string, event: MatrixRoomEvent, userId: string) { try { - const token = await this.getToken(userId); - if (!token) { - await this.sendReply(roomId, event, 'Keine Authentifizierung.'); - return; - } + const token = await this.requireLogin(roomId, event, userId); + if (!token) return; const pausedTimer = await this.clockService.getRunningTimer(token); if (!pausedTimer || pausedTimer.status !== 'paused') { @@ -348,11 +332,8 @@ export class MatrixService extends BaseMatrixService { private async handleResetCommand(roomId: string, event: MatrixRoomEvent, userId: string) { try { - const token = await this.getToken(userId); - if (!token) { - await this.sendReply(roomId, event, 'Keine Authentifizierung.'); - return; - } + const token = await this.requireLogin(roomId, event, userId); + if (!token) return; const activeTimer = await this.clockService.getRunningTimer(token); if (!activeTimer) { @@ -368,37 +349,6 @@ export class MatrixService extends BaseMatrixService { } } - private async handleLogin(roomId: string, event: MatrixRoomEvent, userId: string, args: string) { - const parts = args.split(' '); - if (parts.length < 2 || !parts[0] || !parts[1]) { - await this.sendReply(roomId, event, 'Verwendung: `!login email passwort`'); - return; - } - const [email, password] = parts; - const result = await this.sessionService.login(userId, email, password); - - if (result.success) { - const token = await this.sessionService.getToken(userId); - if (token) { - const balance = await this.creditService.getBalance(token); - await this.sendReply( - roomId, - event, - `✅ Erfolgreich angemeldet als **${email}**\n⚡ Credits: ${balance.balance.toFixed(2)}` - ); - } else { - await this.sendReply(roomId, event, `✅ Erfolgreich angemeldet als **${email}**`); - } - } else { - await this.sendReply(roomId, event, `❌ Anmeldung fehlgeschlagen: ${result.error}`); - } - } - - private async handleLogout(roomId: string, event: MatrixRoomEvent, userId: string) { - await this.sessionService.logout(userId); - await this.sendReply(roomId, event, '👋 Erfolgreich abgemeldet.'); - } - private async handleStatusCommand(roomId: string, event: MatrixRoomEvent, userId: string) { // Auth-Status zuerst const loggedIn = await this.sessionService.isLoggedIn(userId); @@ -412,8 +362,7 @@ export class MatrixService extends BaseMatrixService { response += `👤 Angemeldet als: ${session.email}\n`; response += `⚡ Credits: ${balance.balance.toFixed(2)}\n\n`; } else { - response += `❌ Nicht angemeldet\n`; - response += `Nutze \`!login email passwort\` zum Anmelden.\n\n`; + response += `⚠️ Nicht verbunden - bitte in Element neu einloggen via "Mit Mana Core anmelden"\n\n`; } // Timer-Status @@ -445,11 +394,8 @@ export class MatrixService extends BaseMatrixService { private async handleTimersCommand(roomId: string, event: MatrixRoomEvent, userId: string) { try { - const token = await this.getToken(userId); - if (!token) { - await this.sendReply(roomId, event, 'Keine Authentifizierung.'); - return; - } + const token = await this.requireLogin(roomId, event, userId); + if (!token) return; const timers = await this.clockService.getTimers(token); if (timers.length === 0) { @@ -501,11 +447,8 @@ export class MatrixService extends BaseMatrixService { const label = args.replace(/[\d:]+\s*(uhr\s*\d*)?/gi, '').trim() || null; try { - const token = await this.getToken(userId); - if (!token) { - await this.sendReply(roomId, event, 'Keine Authentifizierung.'); - return; - } + const token = await this.requireLogin(roomId, event, userId); + if (!token) return; await this.clockService.createAlarm(time, label, token); let response = `**Alarm gestellt!**\n\nZeit: ${time.substring(0, 5)} Uhr`; @@ -520,11 +463,8 @@ export class MatrixService extends BaseMatrixService { private async handleAlarmsCommand(roomId: string, event: MatrixRoomEvent, userId: string) { try { - const token = await this.getToken(userId); - if (!token) { - await this.sendReply(roomId, event, 'Keine Authentifizierung.'); - return; - } + const token = await this.requireLogin(roomId, event, userId); + if (!token) return; const alarms = await this.clockService.getAlarms(token); if (alarms.length === 0) { @@ -603,11 +543,8 @@ export class MatrixService extends BaseMatrixService { return; } - const token = await this.getToken(userId); - if (!token) { - await this.sendReply(roomId, event, 'Keine Authentifizierung.'); - return; - } + const token = await this.requireLogin(roomId, event, userId); + if (!token) return; const best = results[0]; await this.clockService.addWorldClock(best.timezone, best.city, token); @@ -620,11 +557,8 @@ export class MatrixService extends BaseMatrixService { private async handleWorldClocksCommand(roomId: string, event: MatrixRoomEvent, userId: string) { try { - const token = await this.getToken(userId); - if (!token) { - await this.sendReply(roomId, event, 'Keine Authentifizierung.'); - return; - } + const token = await this.requireLogin(roomId, event, userId); + if (!token) return; const clocks = await this.clockService.getWorldClocks(token); if (clocks.length === 0) { @@ -711,6 +645,22 @@ export class MatrixService extends BaseMatrixService { return this.demoToken || null; } + /** + * Require login - returns token or sends login prompt and returns null + */ + private async requireLogin( + roomId: string, + event: MatrixRoomEvent, + userId: string + ): Promise { + const token = await this.getToken(userId); + if (!token) { + await this.sendReply(roomId, event, LOGIN_MESSAGES.clock); + return null; + } + return token; + } + private async handleLanguage( roomId: string, event: MatrixRoomEvent, diff --git a/services/matrix-clock-bot/src/config/configuration.ts b/services/matrix-clock-bot/src/config/configuration.ts index c1a692e60..cf15600eb 100644 --- a/services/matrix-clock-bot/src/config/configuration.ts +++ b/services/matrix-clock-bot/src/config/configuration.ts @@ -16,9 +16,7 @@ export default () => ({ export const HELP_TEXT = `**Clock Bot - Zeiterfassung per Chat** -**Account:** -- \`!login email passwort\` - Anmelden -- \`!logout\` - Abmelden +**Status:** - \`!status\` - Account & Timer Status **Timer (Stoppuhr):** @@ -49,16 +47,14 @@ Sende eine Sprachnotiz wie "Timer 25 Minuten" oder "Wecker um 7 Uhr" - "stop" - Timer stoppen - "status" - Status anzeigen`; -export const WELCOME_TEXT = `**Clock Bot - Zeiterfassung** +export const WELCOME_TEXT = `🕐 **Clock Bot - Zeiterfassung** -Starte mit: -- \`!timer 25m\` - 25-Minuten Timer +**Schnellstart:** +- \`!timer 25m\` - 25-Minuten Timer starten - \`!alarm 07:30\` - Wecker stellen -- \`!zeit\` - Aktuelle Zeit +- \`!status\` - Status anzeigen -Oder sende eine Sprachnotiz! - -\`!help\` fur alle Befehle.`; +\`!help\` für alle Befehle.`; // Natural language patterns for time parsing export const TIME_PATTERNS = { diff --git a/services/matrix-contacts-bot/src/bot/matrix.service.ts b/services/matrix-contacts-bot/src/bot/matrix.service.ts index 3295286db..3211ee688 100644 --- a/services/matrix-contacts-bot/src/bot/matrix.service.ts +++ b/services/matrix-contacts-bot/src/bot/matrix.service.ts @@ -16,6 +16,7 @@ import { I18nService, Language, LANGUAGE_NAMES, + LOGIN_MESSAGES, } from '@manacore/bot-services'; import { HELP_MESSAGE } from '../config/configuration'; @@ -183,15 +184,6 @@ Sag "hilfe" fur alle Befehle!`; await this.handleToggleArchive(roomId, event, sender, args); break; - case 'login': - await this.handleLogin(roomId, event, sender, args); - break; - - case 'logout': - await this.sessionService.logout(sender); - await this.sendReply(roomId, event, 'Du wurdest abgemeldet.'); - break; - case 'status': await this.handleStatus(roomId, event, sender); break; @@ -216,11 +208,8 @@ Sag "hilfe" fur alle Befehle!`; } private async handleListContacts(roomId: string, event: MatrixRoomEvent, sender: string) { - const token = await this.sessionService.getToken(sender); - if (!token) { - await this.sendReply(roomId, event, `Du bist nicht angemeldet. Nutze \`!login\` zuerst.`); - return; - } + const token = await this.requireLogin(roomId, event, sender); + if (!token) return; try { const result = await this.contactsService.getContacts(token, { limit: 20 }); @@ -267,11 +256,8 @@ Sag "hilfe" fur alle Befehle!`; sender: string, searchTerm: string ) { - const token = await this.sessionService.getToken(sender); - if (!token) { - await this.sendReply(roomId, event, `Du bist nicht angemeldet. Nutze \`!login\` zuerst.`); - return; - } + const token = await this.requireLogin(roomId, event, sender); + if (!token) return; if (!searchTerm.trim()) { await this.sendReply( @@ -314,11 +300,8 @@ Sag "hilfe" fur alle Befehle!`; } private async handleFavorites(roomId: string, event: MatrixRoomEvent, sender: string) { - const token = await this.sessionService.getToken(sender); - if (!token) { - await this.sendReply(roomId, event, `Du bist nicht angemeldet. Nutze \`!login\` zuerst.`); - return; - } + const token = await this.requireLogin(roomId, event, sender); + if (!token) return; try { const result = await this.contactsService.getContacts(token, { isFavorite: true, limit: 20 }); @@ -357,11 +340,8 @@ Sag "hilfe" fur alle Befehle!`; sender: string, args: string[] ) { - const token = await this.sessionService.getToken(sender); - if (!token) { - await this.sendReply(roomId, event, `Du bist nicht angemeldet. Nutze \`!login\` zuerst.`); - return; - } + const token = await this.requireLogin(roomId, event, sender); + if (!token) return; if (args.length < 1) { await this.sendReply( @@ -429,11 +409,8 @@ Sag "hilfe" fur alle Befehle!`; sender: string, args: string[] ) { - const token = await this.sessionService.getToken(sender); - if (!token) { - await this.sendReply(roomId, event, `Du bist nicht angemeldet. Nutze \`!login\` zuerst.`); - return; - } + const token = await this.requireLogin(roomId, event, sender); + if (!token) return; // Validate credits const validation = await this.creditService.validateCredits(token, CONTACT_CREATE_CREDITS); @@ -484,11 +461,8 @@ Sag "hilfe" fur alle Befehle!`; sender: string, args: string[] ) { - const token = await this.sessionService.getToken(sender); - if (!token) { - await this.sendReply(roomId, event, `Du bist nicht angemeldet. Nutze \`!login\` zuerst.`); - return; - } + const token = await this.requireLogin(roomId, event, sender); + if (!token) return; if (args.length < 3) { await this.sendReply( @@ -579,11 +553,8 @@ Sag "hilfe" fur alle Befehle!`; sender: string, args: string[] ) { - const token = await this.sessionService.getToken(sender); - if (!token) { - await this.sendReply(roomId, event, `Du bist nicht angemeldet. Nutze \`!login\` zuerst.`); - return; - } + const token = await this.requireLogin(roomId, event, sender); + if (!token) return; if (args.length < 1) { await this.sendReply( @@ -623,11 +594,8 @@ Sag "hilfe" fur alle Befehle!`; sender: string, args: string[] ) { - const token = await this.sessionService.getToken(sender); - if (!token) { - await this.sendReply(roomId, event, `Du bist nicht angemeldet. Nutze \`!login\` zuerst.`); - return; - } + const token = await this.requireLogin(roomId, event, sender); + if (!token) return; if (args.length < 1) { await this.sendReply( @@ -667,11 +635,8 @@ Sag "hilfe" fur alle Befehle!`; sender: string, args: string[] ) { - const token = await this.sessionService.getToken(sender); - if (!token) { - await this.sendReply(roomId, event, `Du bist nicht angemeldet. Nutze \`!login\` zuerst.`); - return; - } + const token = await this.requireLogin(roomId, event, sender); + if (!token) return; if (args.length < 1) { await this.sendReply( @@ -705,46 +670,20 @@ Sag "hilfe" fur alle Befehle!`; } } - private async handleLogin( + /** + * Require login - returns token or sends login prompt and returns null + */ + private async requireLogin( roomId: string, event: MatrixRoomEvent, - sender: string, - args: string[] - ) { - if (args.length < 2) { - await this.sendReply( - roomId, - event, - `**Verwendung:** \`!login email passwort\`\n\nBeispiel: \`!login nutzer@example.com meinpasswort\`` - ); - return; - } - - const [email, password] = args; - - await this.sendReply(roomId, event, 'Anmeldung lauft...'); - - const result = await this.sessionService.login(sender, email, password); - - if (result.success) { - const token = await this.sessionService.getToken(sender); - if (token) { - const balance = await this.creditService.getBalance(token); - await this.sendReply( - roomId, - event, - `✅ Erfolgreich angemeldet als **${email}**\n⚡ Credits: ${balance.balance.toFixed(2)}\n\nNutze \`!kontakte\` um deine Kontakte zu sehen.` - ); - } else { - await this.sendReply( - roomId, - event, - `✅ Erfolgreich angemeldet!\n\nNutze \`!kontakte\` um deine Kontakte zu sehen.` - ); - } - } else { - await this.sendReply(roomId, event, `❌ Anmeldung fehlgeschlagen: ${result.error}`); + userId: string + ): Promise { + const token = await this.sessionService.getToken(userId); + if (!token) { + await this.sendReply(roomId, event, LOGIN_MESSAGES.contacts); + return null; } + return token; } private async handleStatus(roomId: string, event: MatrixRoomEvent, sender: string) { diff --git a/services/matrix-contacts-bot/src/config/configuration.ts b/services/matrix-contacts-bot/src/config/configuration.ts index 056f1e0fc..923d1e000 100644 --- a/services/matrix-contacts-bot/src/config/configuration.ts +++ b/services/matrix-contacts-bot/src/config/configuration.ts @@ -23,7 +23,7 @@ export const HELP_MESSAGE = `**Contacts Bot - Kontaktverwaltung** - \`!favoriten\` - Favoriten anzeigen - \`!kontakt [nr]\` - Kontakt-Details -**Kontakte verwalten:** (Login erforderlich) +**Kontakte verwalten:** - \`!neu Vorname Nachname\` - Neuen Kontakt erstellen - \`!edit [nr] [feld] [wert]\` - Kontakt bearbeiten - \`!loeschen [nr]\` - Kontakt loschen @@ -42,7 +42,5 @@ export const HELP_MESSAGE = `**Contacts Bot - Kontaktverwaltung** \`!edit 1 phone +49 123 456789\` **Sonstiges:** -- \`!login email passwort\` - Anmelden -- \`!logout\` - Abmelden - \`!status\` - Bot-Status - \`!help\` - Diese Hilfe`; diff --git a/services/matrix-mana-bot/src/config/configuration.ts b/services/matrix-mana-bot/src/config/configuration.ts index 17d12db76..8d7dc4686 100644 --- a/services/matrix-mana-bot/src/config/configuration.ts +++ b/services/matrix-mana-bot/src/config/configuration.ts @@ -37,11 +37,6 @@ export default () => ({ // Help text for the unified bot export const HELP_TEXT = `**🤖 Mana - Dein Assistent** -**👤 Account** -• \`!login email passwort\` - Anmelden -• \`!logout\` - Abmelden -• \`!status\` - Account & Bot Status - **AI & Chat** Schreib einfach eine Nachricht - ich antworte! • \`!model [name]\` - KI-Modell wechseln diff --git a/services/matrix-manadeck-bot/src/bot/matrix.service.ts b/services/matrix-manadeck-bot/src/bot/matrix.service.ts index a2422790e..164f8d57a 100644 --- a/services/matrix-manadeck-bot/src/bot/matrix.service.ts +++ b/services/matrix-manadeck-bot/src/bot/matrix.service.ts @@ -9,7 +9,12 @@ import { COMMON_KEYWORDS, } from '@manacore/matrix-bot-common'; import { ManadeckService, Deck, Card } from '../manadeck/manadeck.service'; -import { SessionService, TranscriptionService, CreditService } from '@manacore/bot-services'; +import { + SessionService, + TranscriptionService, + CreditService, + LOGIN_MESSAGES, +} from '@manacore/bot-services'; import { HELP_MESSAGE } from '../config/configuration'; const DECK_CREATE_CREDITS = 0.1; @@ -106,15 +111,6 @@ export class MatrixService extends BaseMatrixService { await this.sendHtml(roomId, HELP_MESSAGE); break; - case 'login': - await this.handleLogin(roomId, sender, args); - break; - - case 'logout': - await this.sessionService.logout(sender); - await this.sendHtml(roomId, '

Erfolgreich abgemeldet.

'); - break; - case 'status': await this.handleStatus(roomId, sender); break; @@ -211,40 +207,11 @@ export class MatrixService extends BaseMatrixService { private async requireAuth(sender: string): Promise { const token = await this.sessionService.getToken(sender); if (!token) { - throw new Error('Nicht angemeldet. Nutze !login email passwort'); + throw new Error(LOGIN_MESSAGES.manadeck); } return token; } - // Auth handlers - private async handleLogin(roomId: string, sender: string, args: string[]) { - if (args.length < 2) { - await this.sendHtml(roomId, '

Verwendung: !login email passwort

'); - return; - } - - const [email, password] = args; - const result = await this.sessionService.login(sender, email, password); - - if (result.success) { - const token = await this.sessionService.getToken(sender); - if (token) { - const balance = await this.creditService.getBalance(token); - await this.sendHtml( - roomId, - `

✅ Erfolgreich angemeldet als ${email}
⚡ Credits: ${balance.balance.toFixed(2)}

` - ); - } else { - await this.sendHtml( - roomId, - `

✅ Erfolgreich angemeldet als ${email}

` - ); - } - } else { - await this.sendHtml(roomId, `

❌ Login fehlgeschlagen: ${result.error}

`); - } - } - private async handleStatus(roomId: string, sender: string) { const backendOk = await this.manadeckService.checkHealth(); const loggedIn = await this.sessionService.isLoggedIn(sender); diff --git a/services/matrix-manadeck-bot/src/config/configuration.ts b/services/matrix-manadeck-bot/src/config/configuration.ts index b7f7a59a3..c79d94bb3 100644 --- a/services/matrix-manadeck-bot/src/config/configuration.ts +++ b/services/matrix-manadeck-bot/src/config/configuration.ts @@ -17,13 +17,6 @@ export default () => ({ export const HELP_MESSAGE = `

ManaDeck Bot - Befehle

-

Authentifizierung

-
    -
  • !login email passwort - Anmelden
  • -
  • !logout - Abmelden
  • -
  • !status - Bot-Status anzeigen
  • -
-

Decks verwalten

  • !decks - Alle Decks auflisten
  • diff --git a/services/matrix-nutriphi-bot/src/bot/matrix.service.ts b/services/matrix-nutriphi-bot/src/bot/matrix.service.ts index aa71b1446..2916a85f0 100644 --- a/services/matrix-nutriphi-bot/src/bot/matrix.service.ts +++ b/services/matrix-nutriphi-bot/src/bot/matrix.service.ts @@ -241,15 +241,6 @@ Sag "hilfe" fur alle Befehle!`; await this.sendHelp(roomId); break; - case 'login': - await this.handleLogin(roomId, sender, args); - break; - - case 'logout': - await this.sessionService.logout(sender); - await this.sendMessage(roomId, 'Du wurdest abgemeldet.'); - break; - case 'analyze': await this.handleAnalyze(roomId, sender, argString); break; @@ -298,40 +289,6 @@ Sag "hilfe" fur alle Befehle!`; await this.sendMessage(roomId, HELP_MESSAGE); } - private async handleLogin(roomId: string, sender: string, args: string[]) { - if (args.length < 2) { - await this.sendMessage( - roomId, - `**Verwendung:** \`!login email passwort\`\n\nBeispiel: \`!login nutzer@example.com meinpasswort\`` - ); - return; - } - - const [email, password] = args; - - await this.sendMessage(roomId, 'Anmeldung lauft...'); - - const result = await this.sessionService.login(sender, email, password); - - if (result.success) { - const token = await this.sessionService.getToken(sender); - if (token) { - const balance = await this.creditService.getBalance(token); - await this.sendMessage( - roomId, - `✅ Erfolgreich angemeldet als **${email}**\n⚡ Credits: ${balance.balance.toFixed(2)}\n\nDu kannst jetzt Fotos analysieren und deine Ernahrung tracken.` - ); - } else { - await this.sendMessage( - roomId, - `✅ Erfolgreich angemeldet!\n\nDu kannst jetzt Fotos analysieren und deine Ernahrung tracken.` - ); - } - } else { - await this.sendMessage(roomId, `Anmeldung fehlgeschlagen: ${result.error}`); - } - } - private async handleAnalyze(roomId: string, sender: string, description: string) { const token = await this.requireLogin(roomId, sender); if (!token) return; diff --git a/services/matrix-nutriphi-bot/src/config/configuration.ts b/services/matrix-nutriphi-bot/src/config/configuration.ts index 526f99e62..e40b2d2a8 100644 --- a/services/matrix-nutriphi-bot/src/config/configuration.ts +++ b/services/matrix-nutriphi-bot/src/config/configuration.ts @@ -27,7 +27,6 @@ export const HELP_MESSAGE = `**NutriPhi Bot - KI-Ernahrungsassistent** **Befehle:** - \`!help\` - Diese Hilfe anzeigen -- \`!login email passwort\` - Bei NutriPhi anmelden - \`!analyze beschreibung\` - Text analysieren - \`!today\` / \`heute\` - Tages-Zusammenfassung - \`!week\` / \`woche\` - Wochen-Statistik diff --git a/services/matrix-picture-bot/src/bot/matrix.service.ts b/services/matrix-picture-bot/src/bot/matrix.service.ts index 63d5e4a35..d97670baf 100644 --- a/services/matrix-picture-bot/src/bot/matrix.service.ts +++ b/services/matrix-picture-bot/src/bot/matrix.service.ts @@ -8,7 +8,12 @@ import { COMMON_KEYWORDS, } from '@manacore/matrix-bot-common'; import { PictureService } from '../picture/picture.service'; -import { SessionService, TranscriptionService, CreditService } from '@manacore/bot-services'; +import { + SessionService, + TranscriptionService, + CreditService, + LOGIN_MESSAGES, +} from '@manacore/bot-services'; import { HELP_MESSAGE } from '../config/configuration'; // Credit cost for image generation @@ -158,15 +163,6 @@ Sag "hilfe" fur alle Befehle!`; await this.handleCredits(roomId, sender); break; - case 'login': - await this.handleLogin(roomId, sender, args); - break; - - case 'logout': - await this.sessionService.logout(sender); - await this.sendMessage(roomId, 'Du wurdest abgemeldet.'); - break; - case 'status': await this.handleStatus(roomId, sender); break; @@ -402,11 +398,8 @@ Sag "hilfe" fur alle Befehle!`; } private async handleHistory(roomId: string, sender: string) { - const token = await this.sessionService.getToken(sender); - if (!token) { - await this.sendMessage(roomId, `Du bist nicht angemeldet. Nutze \`!login\` zuerst.`); - return; - } + const token = await this.requireLogin(roomId, sender); + if (!token) return; try { const images = await this.pictureService.getImages(token, 10); @@ -434,11 +427,8 @@ Sag "hilfe" fur alle Befehle!`; } private async handleDelete(roomId: string, sender: string, args: string[]) { - const token = await this.sessionService.getToken(sender); - if (!token) { - await this.sendMessage(roomId, `Du bist nicht angemeldet. Nutze \`!login\` zuerst.`); - return; - } + const token = await this.requireLogin(roomId, sender); + if (!token) return; if (args.length < 1) { await this.sendMessage( @@ -472,11 +462,8 @@ Sag "hilfe" fur alle Befehle!`; } private async handleCredits(roomId: string, sender: string) { - const token = await this.sessionService.getToken(sender); - if (!token) { - await this.sendMessage(roomId, `Du bist nicht angemeldet. Nutze \`!login\` zuerst.`); - return; - } + const token = await this.requireLogin(roomId, sender); + if (!token) return; try { const balance = await this.creditService.getBalance(token); @@ -510,29 +497,16 @@ Sag "hilfe" fur alle Befehle!`; await this.sendMessage(roomId, HELP_MESSAGE); } - private async handleLogin(roomId: string, sender: string, args: string[]) { - if (args.length < 2) { - await this.sendMessage( - roomId, - `**Verwendung:** \`!login email passwort\`\n\nBeispiel: \`!login nutzer@example.com meinpasswort\`` - ); - return; - } - - const [email, password] = args; - - await this.sendMessage(roomId, 'Anmeldung lauft...'); - - const result = await this.sessionService.login(sender, email, password); - - if (result.success) { - await this.sendMessage( - roomId, - `Erfolgreich angemeldet!\n\nDu kannst jetzt Bilder generieren mit \`!generate [prompt]\`` - ); - } else { - await this.sendMessage(roomId, `Anmeldung fehlgeschlagen: ${result.error}`); + /** + * Require login - returns token or sends login prompt and returns null + */ + private async requireLogin(roomId: string, userId: string): Promise { + const token = await this.sessionService.getToken(userId); + if (!token) { + await this.sendMessage(roomId, LOGIN_MESSAGES.picture); + return null; } + return token; } private async handleStatus(roomId: string, sender: string) { diff --git a/services/matrix-picture-bot/src/config/configuration.ts b/services/matrix-picture-bot/src/config/configuration.ts index d1ad99a13..1bc93e877 100644 --- a/services/matrix-picture-bot/src/config/configuration.ts +++ b/services/matrix-picture-bot/src/config/configuration.ts @@ -33,9 +33,7 @@ export const HELP_MESSAGE = `**Picture Bot - AI-Bildgenerierung** \`!generate A beautiful sunset over mountains --width 1280 --height 720\` \`!bild Ein niedlicher Hund im Park --steps 40\` -**Bilder verwalten:** (Login erforderlich) -- \`!login email passwort\` - Anmelden -- \`!logout\` - Abmelden +**Bilder verwalten:** - \`!history\` - Letzte Bilder anzeigen - \`!delete [nr]\` - Bild loschen diff --git a/services/matrix-planta-bot/src/bot/matrix.service.ts b/services/matrix-planta-bot/src/bot/matrix.service.ts index 2f33e4e9a..7d691034b 100644 --- a/services/matrix-planta-bot/src/bot/matrix.service.ts +++ b/services/matrix-planta-bot/src/bot/matrix.service.ts @@ -9,7 +9,12 @@ import { COMMON_KEYWORDS, } from '@manacore/matrix-bot-common'; import { PlantaService, Plant } from '../planta/planta.service'; -import { SessionService, TranscriptionService, CreditService } from '@manacore/bot-services'; +import { + SessionService, + TranscriptionService, + CreditService, + LOGIN_MESSAGES, +} from '@manacore/bot-services'; import { HELP_MESSAGE } from '../config/configuration'; @Injectable() @@ -118,15 +123,6 @@ export class MatrixService extends BaseMatrixService { await this.sendMessage(roomId, HELP_MESSAGE); break; - case 'login': - await this.handleLogin(roomId, sender, args); - break; - - case 'logout': - await this.sessionService.logout(sender); - await this.sendMessage(roomId, '

    Erfolgreich abgemeldet.

    '); - break; - case 'status': await this.handleStatus(roomId, sender); break; @@ -198,40 +194,11 @@ export class MatrixService extends BaseMatrixService { private async requireAuth(sender: string): Promise { const token = await this.sessionService.getToken(sender); if (!token) { - throw new Error('Nicht angemeldet. Nutze !login email passwort'); + throw new Error(LOGIN_MESSAGES.planta); } return token; } - // Auth handlers - private async handleLogin(roomId: string, sender: string, args: string[]) { - if (args.length < 2) { - await this.sendMessage(roomId, '

    Verwendung: !login email passwort

    '); - return; - } - - const [email, password] = args; - const result = await this.sessionService.login(sender, email, password); - - if (result.success) { - const token = await this.sessionService.getToken(sender); - if (token) { - const balance = await this.creditService.getBalance(token); - await this.sendMessage( - roomId, - `

    ✅ Erfolgreich angemeldet als ${email}
    ⚡ Credits: ${balance.balance.toFixed(2)}

    ` - ); - } else { - await this.sendMessage( - roomId, - `

    ✅ Erfolgreich angemeldet als ${email}

    ` - ); - } - } else { - await this.sendMessage(roomId, `

    ❌ Login fehlgeschlagen: ${result.error}

    `); - } - } - private async handleStatus(roomId: string, sender: string) { const backendOk = await this.plantaService.checkHealth(); const loggedIn = await this.sessionService.isLoggedIn(sender); diff --git a/services/matrix-planta-bot/src/config/configuration.ts b/services/matrix-planta-bot/src/config/configuration.ts index 0d1add6be..b7d7d7388 100644 --- a/services/matrix-planta-bot/src/config/configuration.ts +++ b/services/matrix-planta-bot/src/config/configuration.ts @@ -17,13 +17,6 @@ export default () => ({ export const HELP_MESSAGE = `

    Planta Bot - Befehle

    -

    Authentifizierung

    -
      -
    • !login email passwort - Anmelden
    • -
    • !logout - Abmelden
    • -
    • !status - Bot-Status anzeigen
    • -
    -

    Pflanzen verwalten

    • !pflanzen - Alle Pflanzen auflisten
    • diff --git a/services/matrix-presi-bot/src/bot/matrix.service.ts b/services/matrix-presi-bot/src/bot/matrix.service.ts index 3bf33aabe..1ac9dbf00 100644 --- a/services/matrix-presi-bot/src/bot/matrix.service.ts +++ b/services/matrix-presi-bot/src/bot/matrix.service.ts @@ -9,7 +9,12 @@ import { COMMON_KEYWORDS, } from '@manacore/matrix-bot-common'; import { PresiService, Deck, Theme, SlideContent } from '../presi/presi.service'; -import { SessionService, TranscriptionService, CreditService } from '@manacore/bot-services'; +import { + SessionService, + TranscriptionService, + CreditService, + LOGIN_MESSAGES, +} from '@manacore/bot-services'; import { HELP_MESSAGE } from '../config/configuration'; @Injectable() @@ -99,15 +104,6 @@ export class MatrixService extends BaseMatrixService { await this.sendMessage(roomId, HELP_MESSAGE); break; - case 'login': - await this.handleLogin(roomId, sender, args); - break; - - case 'logout': - await this.sessionService.logout(sender); - await this.sendMessage(roomId, '

      Erfolgreich abgemeldet.

      '); - break; - case 'status': await this.handleStatus(roomId, sender); break; @@ -189,40 +185,11 @@ export class MatrixService extends BaseMatrixService { private async requireAuth(sender: string): Promise { const token = await this.sessionService.getToken(sender); if (!token) { - throw new Error('Nicht angemeldet. Nutze !login email passwort'); + throw new Error(LOGIN_MESSAGES.presi); } return token; } - // Auth handlers - private async handleLogin(roomId: string, sender: string, args: string[]) { - if (args.length < 2) { - await this.sendMessage(roomId, '

      Verwendung: !login email passwort

      '); - return; - } - - const [email, password] = args; - const result = await this.sessionService.login(sender, email, password); - - if (result.success) { - const token = await this.sessionService.getToken(sender); - if (token) { - const balance = await this.creditService.getBalance(token); - await this.sendMessage( - roomId, - `

      ✅ Erfolgreich angemeldet als ${email}
      ⚡ Credits: ${balance.balance.toFixed(2)}

      ` - ); - } else { - await this.sendMessage( - roomId, - `

      ✅ Erfolgreich angemeldet als ${email}

      ` - ); - } - } else { - await this.sendMessage(roomId, `

      Login fehlgeschlagen: ${result.error}

      `); - } - } - private async handleStatus(roomId: string, sender: string) { const backendOk = await this.presiService.checkHealth(); const loggedIn = await this.sessionService.isLoggedIn(sender); diff --git a/services/matrix-presi-bot/src/config/configuration.ts b/services/matrix-presi-bot/src/config/configuration.ts index 4bf83c3b9..c9743f849 100644 --- a/services/matrix-presi-bot/src/config/configuration.ts +++ b/services/matrix-presi-bot/src/config/configuration.ts @@ -17,13 +17,6 @@ export default () => ({ export const HELP_MESSAGE = `

      Presi Bot - Befehle

      -

      Authentifizierung

      -
        -
      • !login email passwort - Anmelden
      • -
      • !logout - Abmelden
      • -
      • !status - Bot-Status anzeigen
      • -
      -

      Praesentationen

      • !presis - Alle Praesentationen auflisten
      • diff --git a/services/matrix-project-doc-bot/src/bot/matrix.service.ts b/services/matrix-project-doc-bot/src/bot/matrix.service.ts index f9a33bce8..f06d38e9f 100644 --- a/services/matrix-project-doc-bot/src/bot/matrix.service.ts +++ b/services/matrix-project-doc-bot/src/bot/matrix.service.ts @@ -121,12 +121,6 @@ export class MatrixService extends BaseMatrixService { case 'start': await this.sendHelp(roomId); break; - case 'login': - await this.handleLogin(roomId, sender, argString); - break; - case 'logout': - await this.handleLogout(roomId, sender); - break; case 'auth': case 'account': await this.handleAuthStatus(roomId, sender); @@ -200,36 +194,6 @@ ${styles} await this.sendMessage(roomId, helpText); } - private async handleLogin(roomId: string, sender: string, args: string) { - const parts = args.split(' '); - if (parts.length < 2 || !parts[0] || !parts[1]) { - await this.sendMessage(roomId, 'Verwendung: `!login email passwort`'); - return; - } - const [email, password] = parts; - const result = await this.sessionService.login(sender, email, password); - - if (result.success) { - const token = await this.sessionService.getToken(sender); - if (token) { - const balance = await this.creditService.getBalance(token); - await this.sendMessage( - roomId, - `✅ Erfolgreich angemeldet als **${email}**\n⚡ Credits: ${balance.balance.toFixed(2)}` - ); - } else { - await this.sendMessage(roomId, `✅ Erfolgreich angemeldet als **${email}**`); - } - } else { - await this.sendMessage(roomId, `❌ Anmeldung fehlgeschlagen: ${result.error}`); - } - } - - private async handleLogout(roomId: string, sender: string) { - await this.sessionService.logout(sender); - await this.sendMessage(roomId, '👋 Erfolgreich abgemeldet.'); - } - private async handleAuthStatus(roomId: string, sender: string) { const loggedIn = await this.sessionService.isLoggedIn(sender); const session = await this.sessionService.getSession(sender); diff --git a/services/matrix-questions-bot/src/bot/matrix.service.ts b/services/matrix-questions-bot/src/bot/matrix.service.ts index e34fbf46a..85b2b28be 100644 --- a/services/matrix-questions-bot/src/bot/matrix.service.ts +++ b/services/matrix-questions-bot/src/bot/matrix.service.ts @@ -9,7 +9,12 @@ import { COMMON_KEYWORDS, } from '@manacore/matrix-bot-common'; import { QuestionsService, Question, Collection, Answer } from '../questions/questions.service'; -import { SessionService, TranscriptionService, CreditService } from '@manacore/bot-services'; +import { + SessionService, + TranscriptionService, + CreditService, + LOGIN_MESSAGES, +} from '@manacore/bot-services'; import { HELP_MESSAGE } from '../config/configuration'; const QUESTION_CREATE_CREDITS = 0.02; @@ -82,15 +87,6 @@ export class MatrixService extends BaseMatrixService { await this.sendMessage(roomId, HELP_MESSAGE); break; - case 'login': - await this.handleLogin(roomId, sender, args); - break; - - case 'logout': - this.sessionService.logout(sender); - await this.sendMessage(roomId, '

        Erfolgreich abgemeldet.

        '); - break; - case 'status': await this.handleStatus(roomId, sender); break; @@ -212,40 +208,11 @@ export class MatrixService extends BaseMatrixService { private async requireAuth(sender: string): Promise { const token = await this.sessionService.getToken(sender); if (!token) { - throw new Error('Nicht angemeldet. Nutze !login email passwort'); + throw new Error(LOGIN_MESSAGES.questions); } return token; } - // Auth handlers - private async handleLogin(roomId: string, sender: string, args: string[]) { - if (args.length < 2) { - await this.sendMessage(roomId, '

        Verwendung: !login email passwort

        '); - return; - } - - const [email, password] = args; - const result = await this.sessionService.login(sender, email, password); - - if (result.success) { - const token = await this.sessionService.getToken(sender); - if (token) { - const balance = await this.creditService.getBalance(token); - await this.sendMessage( - roomId, - `

        ✅ Erfolgreich angemeldet als ${email}
        ⚡ Credits: ${balance.balance.toFixed(2)}

        ` - ); - } else { - await this.sendMessage( - roomId, - `

        ✅ Erfolgreich angemeldet als ${email}

        ` - ); - } - } else { - await this.sendMessage(roomId, `

        ❌ Login fehlgeschlagen: ${result.error}

        `); - } - } - private async handleStatus(roomId: string, sender: string) { const backendOk = await this.questionsService.checkHealth(); const loggedIn = await this.sessionService.isLoggedIn(sender); diff --git a/services/matrix-questions-bot/src/config/configuration.ts b/services/matrix-questions-bot/src/config/configuration.ts index ed552305e..0d94c5156 100644 --- a/services/matrix-questions-bot/src/config/configuration.ts +++ b/services/matrix-questions-bot/src/config/configuration.ts @@ -17,13 +17,6 @@ export default () => ({ export const HELP_MESSAGE = `

        Questions Bot - Befehle

        -

        Authentifizierung

        -
          -
        • !login email passwort - Anmelden
        • -
        • !logout - Abmelden
        • -
        • !status - Bot-Status anzeigen
        • -
        -

        Fragen

        • !fragen - Alle Fragen auflisten
        • diff --git a/services/matrix-skilltree-bot/src/bot/matrix.service.ts b/services/matrix-skilltree-bot/src/bot/matrix.service.ts index e2df84c0a..b2bf29023 100644 --- a/services/matrix-skilltree-bot/src/bot/matrix.service.ts +++ b/services/matrix-skilltree-bot/src/bot/matrix.service.ts @@ -9,7 +9,12 @@ import { COMMON_KEYWORDS, } from '@manacore/matrix-bot-common'; import { SkilltreeService, Skill, SkillBranch } from '../skilltree/skilltree.service'; -import { SessionService, TranscriptionService, CreditService } from '@manacore/bot-services'; +import { + SessionService, + TranscriptionService, + CreditService, + LOGIN_MESSAGES, +} from '@manacore/bot-services'; import { HELP_MESSAGE } from '../config/configuration'; @Injectable() @@ -98,15 +103,6 @@ export class MatrixService extends BaseMatrixService { await this.sendMessage(roomId, HELP_MESSAGE); break; - case 'login': - await this.handleLogin(roomId, sender, args); - break; - - case 'logout': - await this.sessionService.logout(sender); - await this.sendMessage(roomId, '

          Erfolgreich abgemeldet.

          '); - break; - case 'status': await this.handleStatus(roomId, sender); break; @@ -192,40 +188,11 @@ export class MatrixService extends BaseMatrixService { private async requireAuth(sender: string): Promise { const token = await this.sessionService.getToken(sender); if (!token) { - throw new Error('Nicht angemeldet. Nutze !login email passwort'); + throw new Error(LOGIN_MESSAGES.skilltree); } return token; } - // Auth handlers - private async handleLogin(roomId: string, sender: string, args: string[]) { - if (args.length < 2) { - await this.sendMessage(roomId, '

          Verwendung: !login email passwort

          '); - return; - } - - const [email, password] = args; - const result = await this.sessionService.login(sender, email, password); - - if (result.success) { - const token = await this.sessionService.getToken(sender); - if (token) { - const balance = await this.creditService.getBalance(token); - await this.sendMessage( - roomId, - `

          ✅ Erfolgreich angemeldet als ${email}
          ⚡ Credits: ${balance.balance.toFixed(2)}

          ` - ); - } else { - await this.sendMessage( - roomId, - `

          ✅ Erfolgreich angemeldet als ${email}

          ` - ); - } - } else { - await this.sendMessage(roomId, `

          Login fehlgeschlagen: ${result.error}

          `); - } - } - private async handleStatus(roomId: string, sender: string) { const backendOk = await this.skilltreeService.checkHealth(); const loggedIn = await this.sessionService.isLoggedIn(sender); diff --git a/services/matrix-skilltree-bot/src/config/configuration.ts b/services/matrix-skilltree-bot/src/config/configuration.ts index 2fa699563..8badcfb4f 100644 --- a/services/matrix-skilltree-bot/src/config/configuration.ts +++ b/services/matrix-skilltree-bot/src/config/configuration.ts @@ -17,13 +17,6 @@ export default () => ({ export const HELP_MESSAGE = `

          Skilltree Bot - Befehle

          -

          Authentifizierung

          -
            -
          • !login email passwort - Anmelden
          • -
          • !logout - Abmelden
          • -
          • !status - Bot-Status anzeigen
          • -
          -

          Skills

          • !skills - Alle Skills auflisten
          • diff --git a/services/matrix-storage-bot/src/bot/matrix.service.ts b/services/matrix-storage-bot/src/bot/matrix.service.ts index bbfb171ef..b76a07e01 100644 --- a/services/matrix-storage-bot/src/bot/matrix.service.ts +++ b/services/matrix-storage-bot/src/bot/matrix.service.ts @@ -15,7 +15,12 @@ import { ShareLink, TrashItem, } from '../storage/storage.service'; -import { SessionService, TranscriptionService, CreditService } from '@manacore/bot-services'; +import { + SessionService, + TranscriptionService, + CreditService, + LOGIN_MESSAGES, +} from '@manacore/bot-services'; import { HELP_MESSAGE } from '../config/configuration'; @Injectable() @@ -85,15 +90,6 @@ export class MatrixService extends BaseMatrixService { await this.sendMessage(roomId, HELP_MESSAGE); break; - case 'login': - await this.handleLogin(roomId, sender, args); - break; - - case 'logout': - await this.sessionService.logout(sender); - await this.sendMessage(roomId, '

            Erfolgreich abgemeldet.

            '); - break; - case 'status': await this.handleStatus(roomId, sender); break; @@ -240,40 +236,11 @@ export class MatrixService extends BaseMatrixService { private async requireAuth(sender: string): Promise { const token = await this.sessionService.getToken(sender); if (!token) { - throw new Error('Nicht angemeldet. Nutze !login email passwort'); + throw new Error(LOGIN_MESSAGES.storage); } return token; } - // Auth handlers - private async handleLogin(roomId: string, sender: string, args: string[]) { - if (args.length < 2) { - await this.sendMessage(roomId, '

            Verwendung: !login email passwort

            '); - return; - } - - const [email, password] = args; - const result = await this.sessionService.login(sender, email, password); - - if (result.success) { - const token = await this.sessionService.getToken(sender); - if (token) { - const balance = await this.creditService.getBalance(token); - await this.sendMessage( - roomId, - `

            ✅ Erfolgreich angemeldet als ${email}
            ⚡ Credits: ${balance.balance.toFixed(2)}

            ` - ); - } else { - await this.sendMessage( - roomId, - `

            ✅ Erfolgreich angemeldet als ${email}

            ` - ); - } - } else { - await this.sendMessage(roomId, `

            Login fehlgeschlagen: ${result.error}

            `); - } - } - private async handleStatus(roomId: string, sender: string) { const backendOk = await this.storageService.checkHealth(); const loggedIn = await this.sessionService.isLoggedIn(sender); diff --git a/services/matrix-storage-bot/src/config/configuration.ts b/services/matrix-storage-bot/src/config/configuration.ts index 54c77870e..c4b797bea 100644 --- a/services/matrix-storage-bot/src/config/configuration.ts +++ b/services/matrix-storage-bot/src/config/configuration.ts @@ -17,13 +17,6 @@ export default () => ({ export const HELP_MESSAGE = `

            Storage Bot - Befehle

            -

            Authentifizierung

            -
              -
            • !login email passwort - Anmelden
            • -
            • !logout - Abmelden
            • -
            • !status - Bot-Status anzeigen
            • -
            -

            Dateien

            • !dateien - Dateien im Root auflisten
            • diff --git a/services/matrix-todo-bot/src/bot/matrix.service.ts b/services/matrix-todo-bot/src/bot/matrix.service.ts index 00d343dd2..ca477f18a 100644 --- a/services/matrix-todo-bot/src/bot/matrix.service.ts +++ b/services/matrix-todo-bot/src/bot/matrix.service.ts @@ -419,14 +419,6 @@ export class MatrixService await this.sendReply(roomId, event, HELP_TEXT); break; - case 'login': - await this.handleLogin(roomId, event, userId, args); - break; - - case 'logout': - await this.handleLogout(roomId, event, userId); - break; - case 'add': case 'neu': case 'neue': @@ -846,28 +838,6 @@ export class MatrixService } } - private async handleLogin(roomId: string, event: MatrixRoomEvent, userId: string, args: string) { - const parts = args.trim().split(/\s+/); - if (parts.length < 2) { - await this.sendReply(roomId, event, 'Verwendung: `login email passwort`'); - return; - } - - const [email, password] = parts; - const result = await this.sessionService.login(userId, email, password); - - if (result.success) { - await this.sendReply(roomId, event, `Erfolgreich angemeldet als **${email}**`); - } else { - await this.sendReply(roomId, event, `Anmeldung fehlgeschlagen: ${result.error}`); - } - } - - private async handleLogout(roomId: string, event: MatrixRoomEvent, userId: string) { - this.sessionService.logout(userId); - await this.sendReply(roomId, event, 'Erfolgreich abgemeldet.'); - } - private async handlePinHelp(roomId: string, event: MatrixRoomEvent) { try { // Send help message diff --git a/services/matrix-todo-bot/src/config/configuration.ts b/services/matrix-todo-bot/src/config/configuration.ts index f1aecb973..e3b9a600f 100644 --- a/services/matrix-todo-bot/src/config/configuration.ts +++ b/services/matrix-todo-bot/src/config/configuration.ts @@ -38,8 +38,6 @@ export const HELP_TEXT = `🎯 **Todo Bot - Hilfe** **Sonstiges:** • \`status\` - Verbindungsstatus prüfen • \`hilfe\` - Diese Hilfe anzeigen -• \`login email passwort\` - Anmelden für Synchronisation -• \`logout\` - Abmelden **Tipp:** Alle Befehle funktionieren auch mit \`!\` davor (z.B. \`!neu\`)`; diff --git a/services/matrix-zitare-bot/src/bot/matrix.service.ts b/services/matrix-zitare-bot/src/bot/matrix.service.ts index 496d6ed24..0d9e9aa7f 100644 --- a/services/matrix-zitare-bot/src/bot/matrix.service.ts +++ b/services/matrix-zitare-bot/src/bot/matrix.service.ts @@ -198,15 +198,6 @@ Sag "hilfe" fuer alle Befehle!`; await this.handleCategoryQuote(roomId, sender, 'motivation'); break; - case 'login': - await this.handleLogin(roomId, sender, args); - break; - - case 'logout': - await this.sessionService.logout(sender); - await this.sendMessage(roomId, 'Du wurdest abgemeldet.'); - break; - case 'favorit': case 'fav': await this.handleAddFavorite(roomId, sender); @@ -353,40 +344,6 @@ Sag "hilfe" fuer alle Befehle!`; await this.sendMessage(roomId, text); } - private async handleLogin(roomId: string, sender: string, args: string[]) { - if (args.length < 2) { - await this.sendMessage( - roomId, - `**Verwendung:** \`!login email passwort\`\n\nBeispiel: \`!login nutzer@example.com meinpasswort\`` - ); - return; - } - - const [email, password] = args; - - await this.sendMessage(roomId, 'Anmeldung laeuft...'); - - const result = await this.sessionService.login(sender, email, password); - - if (result.success) { - const token = await this.sessionService.getToken(sender); - if (token) { - const balance = await this.creditService.getBalance(token); - await this.sendMessage( - roomId, - `✅ Erfolgreich angemeldet!\n⚡ Credits: ${balance.balance.toFixed(2)}\n\nDu kannst jetzt Favoriten speichern und Listen verwalten.` - ); - } else { - await this.sendMessage( - roomId, - `Erfolgreich angemeldet!\n\nDu kannst jetzt Favoriten speichern und Listen verwalten.` - ); - } - } else { - await this.sendMessage(roomId, `Anmeldung fehlgeschlagen: ${result.error}`); - } - } - private async handleAddFavorite(roomId: string, sender: string) { const token = await this.requireLogin(roomId, sender); if (!token) return; diff --git a/services/matrix-zitare-bot/src/config/configuration.ts b/services/matrix-zitare-bot/src/config/configuration.ts index c609f934e..a8981439b 100644 --- a/services/matrix-zitare-bot/src/config/configuration.ts +++ b/services/matrix-zitare-bot/src/config/configuration.ts @@ -27,13 +27,11 @@ export const HELP_MESSAGE = `**Zitare Bot - Taegliche Inspiration** - \`!kategorie [name]\` - Zitate nach Kategorie - \`!kategorien\` - Alle Kategorien -**Favoriten:** (Login erforderlich) -- \`!login email passwort\` - Anmelden -- \`!logout\` - Abmelden +**Favoriten:** - \`!favorit\` - Letztes Zitat speichern - \`!favoriten\` - Alle Favoriten anzeigen -**Listen:** (Login erforderlich) +**Listen:** - \`!listen\` - Alle Listen anzeigen - \`!liste [name]\` - Neue Liste erstellen - \`!addliste [nr] [zitat-nr]\` - Zitat zur Liste hinzufuegen