🔒 refactor(bots): remove !login command and enforce OIDC-only auth

- 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 <noreply@anthropic.com>
This commit is contained in:
Till-JS 2026-02-14 11:26:58 +01:00
parent c698318c91
commit d81b8aebf2
30 changed files with 158 additions and 786 deletions

View file

@ -74,10 +74,10 @@ url_preview_ip_range_blacklist:
enable_registration: false enable_registration: false
enable_registration_without_verification: false enable_registration_without_verification: false
# Password config # Password config (disabled - all users authenticate via OIDC/SSO)
password_config: password_config:
enabled: true enabled: false
localdb_enabled: true localdb_enabled: false
pepper: "${SYNAPSE_PASSWORD_PEPPER:-change-me-pepper}" pepper: "${SYNAPSE_PASSWORD_PEPPER:-change-me-pepper}"
# Session lifetime (must be >= refresh_token_lifetime) # Session lifetime (must be >= refresh_token_lifetime)

View file

@ -234,14 +234,6 @@ export class MatrixService extends BaseMatrixService {
await this.handlePinHelp(roomId, event); await this.handlePinHelp(roomId, event);
break; break;
case 'login':
await this.handleLogin(roomId, event, userId, args);
break;
case 'logout':
await this.handleLogout(roomId, event, userId);
break;
case 'language': case 'language':
case 'sprache': case 'sprache':
case 'lang': case 'lang':
@ -570,49 +562,6 @@ export class MatrixService extends BaseMatrixService {
await this.sendReply(roomId, event, response); 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) { private async handlePinHelp(roomId: string, event: MatrixRoomEvent) {
try { try {
// Send help message // Send help message

View file

@ -13,6 +13,7 @@ import {
TranscriptionService, TranscriptionService,
CreditService, CreditService,
CreditErrorCode, CreditErrorCode,
LOGIN_MESSAGES,
} from '@manacore/bot-services'; } from '@manacore/bot-services';
import { HELP_MESSAGE, BRANCH_ICONS } from '../config/configuration'; import { HELP_MESSAGE, BRANCH_ICONS } from '../config/configuration';
@ -138,14 +139,6 @@ export class MatrixService extends BaseMatrixService {
response = HELP_MESSAGE; response = HELP_MESSAGE;
break; break;
case 'login':
response = await this.handleLogin(sender, args);
break;
case 'logout':
response = await this.handleLogout(sender);
break;
case 'status': case 'status':
response = await this.handleStatus(sender); response = await this.handleStatus(sender);
break; break;
@ -239,26 +232,6 @@ export class MatrixService extends BaseMatrixService {
await this.sendReply(roomId, event, response); await this.sendReply(roomId, event, response);
} }
// Auth handlers
private async handleLogin(sender: string, args: string[]): Promise<string> {
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<string> {
await this.sessionService.logout(sender);
return 'Erfolgreich abgemeldet.';
}
private async handleStatus(sender: string): Promise<string> { private async handleStatus(sender: string): Promise<string> {
const isLoggedIn = await this.sessionService.isLoggedIn(sender); const isLoggedIn = await this.sessionService.isLoggedIn(sender);
const email = await this.sessionService.getEmail(sender); const email = await this.sessionService.getEmail(sender);
@ -281,7 +254,7 @@ export class MatrixService extends BaseMatrixService {
} }
if (!isLoggedIn) { 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( const statusMessage = this.creditService.formatStatusMessage(
@ -301,7 +274,7 @@ export class MatrixService extends BaseMatrixService {
const token = await this.sessionService.getToken(sender); const token = await this.sessionService.getToken(sender);
if (!token) { if (!token) {
return 'Bitte zuerst anmelden mit `!login email passwort`'; return LOGIN_MESSAGES.chat;
} }
// Get models to find default // Get models to find default
@ -345,7 +318,7 @@ export class MatrixService extends BaseMatrixService {
private async handleNewConversation(sender: string, title: string): Promise<string> { private async handleNewConversation(sender: string, title: string): Promise<string> {
const token = await this.sessionService.getToken(sender); const token = await this.sessionService.getToken(sender);
if (!token) { if (!token) {
return 'Bitte zuerst anmelden mit `!login email passwort`'; return LOGIN_MESSAGES.chat;
} }
// Get models to find default // Get models to find default
@ -376,7 +349,7 @@ export class MatrixService extends BaseMatrixService {
private async handleListConversations(sender: string): Promise<string> { private async handleListConversations(sender: string): Promise<string> {
const token = await this.sessionService.getToken(sender); const token = await this.sessionService.getToken(sender);
if (!token) { if (!token) {
return 'Bitte zuerst anmelden mit `!login email passwort`'; return LOGIN_MESSAGES.chat;
} }
const result = await this.chatService.getConversations(token); const result = await this.chatService.getConversations(token);
@ -417,7 +390,7 @@ export class MatrixService extends BaseMatrixService {
private async handleSelectConversation(sender: string, numberStr: string): Promise<string> { private async handleSelectConversation(sender: string, numberStr: string): Promise<string> {
const token = await this.sessionService.getToken(sender); const token = await this.sessionService.getToken(sender);
if (!token) { if (!token) {
return 'Bitte zuerst anmelden mit `!login email passwort`'; return LOGIN_MESSAGES.chat;
} }
if (!numberStr) { if (!numberStr) {
@ -475,7 +448,7 @@ Nutze \`!senden [nachricht]\` um zu chatten oder \`!verlauf\` fuer den Nachricht
const token = await this.sessionService.getToken(sender); const token = await this.sessionService.getToken(sender);
if (!token) { if (!token) {
return 'Bitte zuerst anmelden mit `!login email passwort`'; return LOGIN_MESSAGES.chat;
} }
const conversationId = await this.getCurrentConversation(sender); 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<string> { private async handleShowHistory(sender: string, numberStr?: string): Promise<string> {
const token = await this.sessionService.getToken(sender); const token = await this.sessionService.getToken(sender);
if (!token) { if (!token) {
return 'Bitte zuerst anmelden mit `!login email passwort`'; return LOGIN_MESSAGES.chat;
} }
let conversationId = await this.getCurrentConversation(sender); let conversationId = await this.getCurrentConversation(sender);
@ -591,7 +564,7 @@ Nutze \`!senden [nachricht]\` um zu chatten oder \`!verlauf\` fuer den Nachricht
): Promise<string> { ): Promise<string> {
const token = await this.sessionService.getToken(sender); const token = await this.sessionService.getToken(sender);
if (!token) { if (!token) {
return 'Bitte zuerst anmelden mit `!login email passwort`'; return LOGIN_MESSAGES.chat;
} }
if (!numberStr || !title) { 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<string> { private async handleArchive(sender: string, numberStr: string): Promise<string> {
const token = await this.sessionService.getToken(sender); const token = await this.sessionService.getToken(sender);
if (!token) { if (!token) {
return 'Bitte zuerst anmelden mit `!login email passwort`'; return LOGIN_MESSAGES.chat;
} }
if (!numberStr) { if (!numberStr) {
@ -647,7 +620,7 @@ Nutze \`!senden [nachricht]\` um zu chatten oder \`!verlauf\` fuer den Nachricht
private async handleListArchived(sender: string): Promise<string> { private async handleListArchived(sender: string): Promise<string> {
const token = await this.sessionService.getToken(sender); const token = await this.sessionService.getToken(sender);
if (!token) { if (!token) {
return 'Bitte zuerst anmelden mit `!login email passwort`'; return LOGIN_MESSAGES.chat;
} }
const result = await this.chatService.getArchivedConversations(token); 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<string> { private async handleUnarchive(sender: string, numberStr: string): Promise<string> {
const token = await this.sessionService.getToken(sender); const token = await this.sessionService.getToken(sender);
if (!token) { if (!token) {
return 'Bitte zuerst anmelden mit `!login email passwort`'; return LOGIN_MESSAGES.chat;
} }
if (!numberStr) { 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<string> { private async handlePin(sender: string, numberStr: string): Promise<string> {
const token = await this.sessionService.getToken(sender); const token = await this.sessionService.getToken(sender);
if (!token) { if (!token) {
return 'Bitte zuerst anmelden mit `!login email passwort`'; return LOGIN_MESSAGES.chat;
} }
if (!numberStr) { 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<string> { private async handleUnpin(sender: string, numberStr: string): Promise<string> {
const token = await this.sessionService.getToken(sender); const token = await this.sessionService.getToken(sender);
if (!token) { if (!token) {
return 'Bitte zuerst anmelden mit `!login email passwort`'; return LOGIN_MESSAGES.chat;
} }
if (!numberStr) { 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<string> { private async handleDelete(sender: string, numberStr: string): Promise<string> {
const token = await this.sessionService.getToken(sender); const token = await this.sessionService.getToken(sender);
if (!token) { if (!token) {
return 'Bitte zuerst anmelden mit `!login email passwort`'; return LOGIN_MESSAGES.chat;
} }
if (!numberStr) { if (!numberStr) {

View file

@ -17,9 +17,7 @@ export default () => ({
export const HELP_MESSAGE = `**AI Chat Bot - Hilfe** export const HELP_MESSAGE = `**AI Chat Bot - Hilfe**
**Authentifizierung:** **Status:**
- \`!login email passwort\` - Anmelden
- \`!logout\` - Abmelden
- \`!status\` - Bot-Status anzeigen - \`!status\` - Bot-Status anzeigen
**Schnell-Chat:** **Schnell-Chat:**
@ -48,7 +46,6 @@ export const HELP_MESSAGE = `**AI Chat Bot - Hilfe**
**Beispiele:** **Beispiele:**
\`\`\` \`\`\`
!login max@example.com meinpasswort
!chat Was ist die Hauptstadt von Frankreich? !chat Was ist die Hauptstadt von Frankreich?
!neu Programmierung !neu Programmierung
!senden Erklaere mir Python Listen !senden Erklaere mir Python Listen

View file

@ -15,6 +15,7 @@ import {
I18nService, I18nService,
Language, Language,
LANGUAGE_NAMES, LANGUAGE_NAMES,
LOGIN_MESSAGES,
} from '@manacore/bot-services'; } from '@manacore/bot-services';
import { HELP_TEXT, WELCOME_TEXT } from '../config/configuration'; import { HELP_TEXT, WELCOME_TEXT } from '../config/configuration';
@ -168,14 +169,6 @@ export class MatrixService extends BaseMatrixService {
await this.sendReply(roomId, event, HELP_TEXT); await this.sendReply(roomId, event, HELP_TEXT);
break; break;
case 'login':
await this.handleLogin(roomId, event, userId, args);
break;
case 'logout':
await this.handleLogout(roomId, event, userId);
break;
case 'timer': case 'timer':
await this.handleTimerCommand(roomId, event, userId, args); await this.handleTimerCommand(roomId, event, userId, args);
break; break;
@ -263,11 +256,8 @@ export class MatrixService extends BaseMatrixService {
const label = args.replace(/[\d\s]*[hms]+/gi, '').trim() || null; const label = args.replace(/[\d\s]*[hms]+/gi, '').trim() || null;
try { try {
const token = await this.getToken(userId); const token = await this.requireLogin(roomId, event, userId);
if (!token) { if (!token) return;
await this.sendReply(roomId, event, 'Keine Authentifizierung. Bitte zuerst `!login`.');
return;
}
// Create and start timer // Create and start timer
const timer = await this.clockService.createTimer(durationSeconds, label, token); 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) { private async handleStopCommand(roomId: string, event: MatrixRoomEvent, userId: string) {
try { try {
const token = await this.getToken(userId); const token = await this.requireLogin(roomId, event, userId);
if (!token) { if (!token) return;
await this.sendReply(roomId, event, 'Keine Authentifizierung.');
return;
}
const runningTimer = await this.clockService.getRunningTimer(token); const runningTimer = await this.clockService.getRunningTimer(token);
if (!runningTimer) { if (!runningTimer) {
@ -324,11 +311,8 @@ export class MatrixService extends BaseMatrixService {
private async handleResumeCommand(roomId: string, event: MatrixRoomEvent, userId: string) { private async handleResumeCommand(roomId: string, event: MatrixRoomEvent, userId: string) {
try { try {
const token = await this.getToken(userId); const token = await this.requireLogin(roomId, event, userId);
if (!token) { if (!token) return;
await this.sendReply(roomId, event, 'Keine Authentifizierung.');
return;
}
const pausedTimer = await this.clockService.getRunningTimer(token); const pausedTimer = await this.clockService.getRunningTimer(token);
if (!pausedTimer || pausedTimer.status !== 'paused') { if (!pausedTimer || pausedTimer.status !== 'paused') {
@ -348,11 +332,8 @@ export class MatrixService extends BaseMatrixService {
private async handleResetCommand(roomId: string, event: MatrixRoomEvent, userId: string) { private async handleResetCommand(roomId: string, event: MatrixRoomEvent, userId: string) {
try { try {
const token = await this.getToken(userId); const token = await this.requireLogin(roomId, event, userId);
if (!token) { if (!token) return;
await this.sendReply(roomId, event, 'Keine Authentifizierung.');
return;
}
const activeTimer = await this.clockService.getRunningTimer(token); const activeTimer = await this.clockService.getRunningTimer(token);
if (!activeTimer) { 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) { private async handleStatusCommand(roomId: string, event: MatrixRoomEvent, userId: string) {
// Auth-Status zuerst // Auth-Status zuerst
const loggedIn = await this.sessionService.isLoggedIn(userId); const loggedIn = await this.sessionService.isLoggedIn(userId);
@ -412,8 +362,7 @@ export class MatrixService extends BaseMatrixService {
response += `👤 Angemeldet als: ${session.email}\n`; response += `👤 Angemeldet als: ${session.email}\n`;
response += `⚡ Credits: ${balance.balance.toFixed(2)}\n\n`; response += `⚡ Credits: ${balance.balance.toFixed(2)}\n\n`;
} else { } else {
response += `❌ Nicht angemeldet\n`; response += `⚠️ Nicht verbunden - bitte in Element neu einloggen via "Mit Mana Core anmelden"\n\n`;
response += `Nutze \`!login email passwort\` zum Anmelden.\n\n`;
} }
// Timer-Status // Timer-Status
@ -445,11 +394,8 @@ export class MatrixService extends BaseMatrixService {
private async handleTimersCommand(roomId: string, event: MatrixRoomEvent, userId: string) { private async handleTimersCommand(roomId: string, event: MatrixRoomEvent, userId: string) {
try { try {
const token = await this.getToken(userId); const token = await this.requireLogin(roomId, event, userId);
if (!token) { if (!token) return;
await this.sendReply(roomId, event, 'Keine Authentifizierung.');
return;
}
const timers = await this.clockService.getTimers(token); const timers = await this.clockService.getTimers(token);
if (timers.length === 0) { 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; const label = args.replace(/[\d:]+\s*(uhr\s*\d*)?/gi, '').trim() || null;
try { try {
const token = await this.getToken(userId); const token = await this.requireLogin(roomId, event, userId);
if (!token) { if (!token) return;
await this.sendReply(roomId, event, 'Keine Authentifizierung.');
return;
}
await this.clockService.createAlarm(time, label, token); await this.clockService.createAlarm(time, label, token);
let response = `**Alarm gestellt!**\n\nZeit: ${time.substring(0, 5)} Uhr`; 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) { private async handleAlarmsCommand(roomId: string, event: MatrixRoomEvent, userId: string) {
try { try {
const token = await this.getToken(userId); const token = await this.requireLogin(roomId, event, userId);
if (!token) { if (!token) return;
await this.sendReply(roomId, event, 'Keine Authentifizierung.');
return;
}
const alarms = await this.clockService.getAlarms(token); const alarms = await this.clockService.getAlarms(token);
if (alarms.length === 0) { if (alarms.length === 0) {
@ -603,11 +543,8 @@ export class MatrixService extends BaseMatrixService {
return; return;
} }
const token = await this.getToken(userId); const token = await this.requireLogin(roomId, event, userId);
if (!token) { if (!token) return;
await this.sendReply(roomId, event, 'Keine Authentifizierung.');
return;
}
const best = results[0]; const best = results[0];
await this.clockService.addWorldClock(best.timezone, best.city, token); 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) { private async handleWorldClocksCommand(roomId: string, event: MatrixRoomEvent, userId: string) {
try { try {
const token = await this.getToken(userId); const token = await this.requireLogin(roomId, event, userId);
if (!token) { if (!token) return;
await this.sendReply(roomId, event, 'Keine Authentifizierung.');
return;
}
const clocks = await this.clockService.getWorldClocks(token); const clocks = await this.clockService.getWorldClocks(token);
if (clocks.length === 0) { if (clocks.length === 0) {
@ -711,6 +645,22 @@ export class MatrixService extends BaseMatrixService {
return this.demoToken || null; 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<string | null> {
const token = await this.getToken(userId);
if (!token) {
await this.sendReply(roomId, event, LOGIN_MESSAGES.clock);
return null;
}
return token;
}
private async handleLanguage( private async handleLanguage(
roomId: string, roomId: string,
event: MatrixRoomEvent, event: MatrixRoomEvent,

View file

@ -16,9 +16,7 @@ export default () => ({
export const HELP_TEXT = `**Clock Bot - Zeiterfassung per Chat** export const HELP_TEXT = `**Clock Bot - Zeiterfassung per Chat**
**Account:** **Status:**
- \`!login email passwort\` - Anmelden
- \`!logout\` - Abmelden
- \`!status\` - Account & Timer Status - \`!status\` - Account & Timer Status
**Timer (Stoppuhr):** **Timer (Stoppuhr):**
@ -49,16 +47,14 @@ Sende eine Sprachnotiz wie "Timer 25 Minuten" oder "Wecker um 7 Uhr"
- "stop" - Timer stoppen - "stop" - Timer stoppen
- "status" - Status anzeigen`; - "status" - Status anzeigen`;
export const WELCOME_TEXT = `**Clock Bot - Zeiterfassung** export const WELCOME_TEXT = `🕐 **Clock Bot - Zeiterfassung**
Starte mit: **Schnellstart:**
- \`!timer 25m\` - 25-Minuten Timer - \`!timer 25m\` - 25-Minuten Timer starten
- \`!alarm 07:30\` - Wecker stellen - \`!alarm 07:30\` - Wecker stellen
- \`!zeit\` - Aktuelle Zeit - \`!status\` - Status anzeigen
Oder sende eine Sprachnotiz! \`!help\` für alle Befehle.`;
\`!help\` fur alle Befehle.`;
// Natural language patterns for time parsing // Natural language patterns for time parsing
export const TIME_PATTERNS = { export const TIME_PATTERNS = {

View file

@ -16,6 +16,7 @@ import {
I18nService, I18nService,
Language, Language,
LANGUAGE_NAMES, LANGUAGE_NAMES,
LOGIN_MESSAGES,
} from '@manacore/bot-services'; } from '@manacore/bot-services';
import { HELP_MESSAGE } from '../config/configuration'; import { HELP_MESSAGE } from '../config/configuration';
@ -183,15 +184,6 @@ Sag "hilfe" fur alle Befehle!`;
await this.handleToggleArchive(roomId, event, sender, args); await this.handleToggleArchive(roomId, event, sender, args);
break; 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': case 'status':
await this.handleStatus(roomId, event, sender); await this.handleStatus(roomId, event, sender);
break; break;
@ -216,11 +208,8 @@ Sag "hilfe" fur alle Befehle!`;
} }
private async handleListContacts(roomId: string, event: MatrixRoomEvent, sender: string) { private async handleListContacts(roomId: string, event: MatrixRoomEvent, sender: string) {
const token = await this.sessionService.getToken(sender); const token = await this.requireLogin(roomId, event, sender);
if (!token) { if (!token) return;
await this.sendReply(roomId, event, `Du bist nicht angemeldet. Nutze \`!login\` zuerst.`);
return;
}
try { try {
const result = await this.contactsService.getContacts(token, { limit: 20 }); const result = await this.contactsService.getContacts(token, { limit: 20 });
@ -267,11 +256,8 @@ Sag "hilfe" fur alle Befehle!`;
sender: string, sender: string,
searchTerm: string searchTerm: string
) { ) {
const token = await this.sessionService.getToken(sender); const token = await this.requireLogin(roomId, event, sender);
if (!token) { if (!token) return;
await this.sendReply(roomId, event, `Du bist nicht angemeldet. Nutze \`!login\` zuerst.`);
return;
}
if (!searchTerm.trim()) { if (!searchTerm.trim()) {
await this.sendReply( await this.sendReply(
@ -314,11 +300,8 @@ Sag "hilfe" fur alle Befehle!`;
} }
private async handleFavorites(roomId: string, event: MatrixRoomEvent, sender: string) { private async handleFavorites(roomId: string, event: MatrixRoomEvent, sender: string) {
const token = await this.sessionService.getToken(sender); const token = await this.requireLogin(roomId, event, sender);
if (!token) { if (!token) return;
await this.sendReply(roomId, event, `Du bist nicht angemeldet. Nutze \`!login\` zuerst.`);
return;
}
try { try {
const result = await this.contactsService.getContacts(token, { isFavorite: true, limit: 20 }); const result = await this.contactsService.getContacts(token, { isFavorite: true, limit: 20 });
@ -357,11 +340,8 @@ Sag "hilfe" fur alle Befehle!`;
sender: string, sender: string,
args: string[] args: string[]
) { ) {
const token = await this.sessionService.getToken(sender); const token = await this.requireLogin(roomId, event, sender);
if (!token) { if (!token) return;
await this.sendReply(roomId, event, `Du bist nicht angemeldet. Nutze \`!login\` zuerst.`);
return;
}
if (args.length < 1) { if (args.length < 1) {
await this.sendReply( await this.sendReply(
@ -429,11 +409,8 @@ Sag "hilfe" fur alle Befehle!`;
sender: string, sender: string,
args: string[] args: string[]
) { ) {
const token = await this.sessionService.getToken(sender); const token = await this.requireLogin(roomId, event, sender);
if (!token) { if (!token) return;
await this.sendReply(roomId, event, `Du bist nicht angemeldet. Nutze \`!login\` zuerst.`);
return;
}
// Validate credits // Validate credits
const validation = await this.creditService.validateCredits(token, CONTACT_CREATE_CREDITS); const validation = await this.creditService.validateCredits(token, CONTACT_CREATE_CREDITS);
@ -484,11 +461,8 @@ Sag "hilfe" fur alle Befehle!`;
sender: string, sender: string,
args: string[] args: string[]
) { ) {
const token = await this.sessionService.getToken(sender); const token = await this.requireLogin(roomId, event, sender);
if (!token) { if (!token) return;
await this.sendReply(roomId, event, `Du bist nicht angemeldet. Nutze \`!login\` zuerst.`);
return;
}
if (args.length < 3) { if (args.length < 3) {
await this.sendReply( await this.sendReply(
@ -579,11 +553,8 @@ Sag "hilfe" fur alle Befehle!`;
sender: string, sender: string,
args: string[] args: string[]
) { ) {
const token = await this.sessionService.getToken(sender); const token = await this.requireLogin(roomId, event, sender);
if (!token) { if (!token) return;
await this.sendReply(roomId, event, `Du bist nicht angemeldet. Nutze \`!login\` zuerst.`);
return;
}
if (args.length < 1) { if (args.length < 1) {
await this.sendReply( await this.sendReply(
@ -623,11 +594,8 @@ Sag "hilfe" fur alle Befehle!`;
sender: string, sender: string,
args: string[] args: string[]
) { ) {
const token = await this.sessionService.getToken(sender); const token = await this.requireLogin(roomId, event, sender);
if (!token) { if (!token) return;
await this.sendReply(roomId, event, `Du bist nicht angemeldet. Nutze \`!login\` zuerst.`);
return;
}
if (args.length < 1) { if (args.length < 1) {
await this.sendReply( await this.sendReply(
@ -667,11 +635,8 @@ Sag "hilfe" fur alle Befehle!`;
sender: string, sender: string,
args: string[] args: string[]
) { ) {
const token = await this.sessionService.getToken(sender); const token = await this.requireLogin(roomId, event, sender);
if (!token) { if (!token) return;
await this.sendReply(roomId, event, `Du bist nicht angemeldet. Nutze \`!login\` zuerst.`);
return;
}
if (args.length < 1) { if (args.length < 1) {
await this.sendReply( 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, roomId: string,
event: MatrixRoomEvent, event: MatrixRoomEvent,
sender: string, userId: string
args: string[] ): Promise<string | null> {
) { const token = await this.sessionService.getToken(userId);
if (args.length < 2) { if (!token) {
await this.sendReply( await this.sendReply(roomId, event, LOGIN_MESSAGES.contacts);
roomId, return null;
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}`);
} }
return token;
} }
private async handleStatus(roomId: string, event: MatrixRoomEvent, sender: string) { private async handleStatus(roomId: string, event: MatrixRoomEvent, sender: string) {

View file

@ -23,7 +23,7 @@ export const HELP_MESSAGE = `**Contacts Bot - Kontaktverwaltung**
- \`!favoriten\` - Favoriten anzeigen - \`!favoriten\` - Favoriten anzeigen
- \`!kontakt [nr]\` - Kontakt-Details - \`!kontakt [nr]\` - Kontakt-Details
**Kontakte verwalten:** (Login erforderlich) **Kontakte verwalten:**
- \`!neu Vorname Nachname\` - Neuen Kontakt erstellen - \`!neu Vorname Nachname\` - Neuen Kontakt erstellen
- \`!edit [nr] [feld] [wert]\` - Kontakt bearbeiten - \`!edit [nr] [feld] [wert]\` - Kontakt bearbeiten
- \`!loeschen [nr]\` - Kontakt loschen - \`!loeschen [nr]\` - Kontakt loschen
@ -42,7 +42,5 @@ export const HELP_MESSAGE = `**Contacts Bot - Kontaktverwaltung**
\`!edit 1 phone +49 123 456789\` \`!edit 1 phone +49 123 456789\`
**Sonstiges:** **Sonstiges:**
- \`!login email passwort\` - Anmelden
- \`!logout\` - Abmelden
- \`!status\` - Bot-Status - \`!status\` - Bot-Status
- \`!help\` - Diese Hilfe`; - \`!help\` - Diese Hilfe`;

View file

@ -37,11 +37,6 @@ export default () => ({
// Help text for the unified bot // Help text for the unified bot
export const HELP_TEXT = `**🤖 Mana - Dein Assistent** export const HELP_TEXT = `**🤖 Mana - Dein Assistent**
**👤 Account**
\`!login email passwort\` - Anmelden
\`!logout\` - Abmelden
\`!status\` - Account & Bot Status
**AI & Chat** **AI & Chat**
Schreib einfach eine Nachricht - ich antworte! Schreib einfach eine Nachricht - ich antworte!
\`!model [name]\` - KI-Modell wechseln \`!model [name]\` - KI-Modell wechseln

View file

@ -9,7 +9,12 @@ import {
COMMON_KEYWORDS, COMMON_KEYWORDS,
} from '@manacore/matrix-bot-common'; } from '@manacore/matrix-bot-common';
import { ManadeckService, Deck, Card } from '../manadeck/manadeck.service'; 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'; import { HELP_MESSAGE } from '../config/configuration';
const DECK_CREATE_CREDITS = 0.1; const DECK_CREATE_CREDITS = 0.1;
@ -106,15 +111,6 @@ export class MatrixService extends BaseMatrixService {
await this.sendHtml(roomId, HELP_MESSAGE); await this.sendHtml(roomId, HELP_MESSAGE);
break; break;
case 'login':
await this.handleLogin(roomId, sender, args);
break;
case 'logout':
await this.sessionService.logout(sender);
await this.sendHtml(roomId, '<p>Erfolgreich abgemeldet.</p>');
break;
case 'status': case 'status':
await this.handleStatus(roomId, sender); await this.handleStatus(roomId, sender);
break; break;
@ -211,40 +207,11 @@ export class MatrixService extends BaseMatrixService {
private async requireAuth(sender: string): Promise<string> { private async requireAuth(sender: string): Promise<string> {
const token = await this.sessionService.getToken(sender); const token = await this.sessionService.getToken(sender);
if (!token) { if (!token) {
throw new Error('Nicht angemeldet. Nutze <code>!login email passwort</code>'); throw new Error(LOGIN_MESSAGES.manadeck);
} }
return token; return token;
} }
// Auth handlers
private async handleLogin(roomId: string, sender: string, args: string[]) {
if (args.length < 2) {
await this.sendHtml(roomId, '<p>Verwendung: <code>!login email passwort</code></p>');
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,
`<p>✅ Erfolgreich angemeldet als <strong>${email}</strong><br/>⚡ Credits: ${balance.balance.toFixed(2)}</p>`
);
} else {
await this.sendHtml(
roomId,
`<p>✅ Erfolgreich angemeldet als <strong>${email}</strong></p>`
);
}
} else {
await this.sendHtml(roomId, `<p>❌ Login fehlgeschlagen: ${result.error}</p>`);
}
}
private async handleStatus(roomId: string, sender: string) { private async handleStatus(roomId: string, sender: string) {
const backendOk = await this.manadeckService.checkHealth(); const backendOk = await this.manadeckService.checkHealth();
const loggedIn = await this.sessionService.isLoggedIn(sender); const loggedIn = await this.sessionService.isLoggedIn(sender);

View file

@ -17,13 +17,6 @@ export default () => ({
export const HELP_MESSAGE = `<h2>ManaDeck Bot - Befehle</h2> export const HELP_MESSAGE = `<h2>ManaDeck Bot - Befehle</h2>
<h3>Authentifizierung</h3>
<ul>
<li><code>!login email passwort</code> - Anmelden</li>
<li><code>!logout</code> - Abmelden</li>
<li><code>!status</code> - Bot-Status anzeigen</li>
</ul>
<h3>Decks verwalten</h3> <h3>Decks verwalten</h3>
<ul> <ul>
<li><code>!decks</code> - Alle Decks auflisten</li> <li><code>!decks</code> - Alle Decks auflisten</li>

View file

@ -241,15 +241,6 @@ Sag "hilfe" fur alle Befehle!`;
await this.sendHelp(roomId); await this.sendHelp(roomId);
break; 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': case 'analyze':
await this.handleAnalyze(roomId, sender, argString); await this.handleAnalyze(roomId, sender, argString);
break; break;
@ -298,40 +289,6 @@ Sag "hilfe" fur alle Befehle!`;
await this.sendMessage(roomId, HELP_MESSAGE); 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) { private async handleAnalyze(roomId: string, sender: string, description: string) {
const token = await this.requireLogin(roomId, sender); const token = await this.requireLogin(roomId, sender);
if (!token) return; if (!token) return;

View file

@ -27,7 +27,6 @@ export const HELP_MESSAGE = `**NutriPhi Bot - KI-Ernahrungsassistent**
**Befehle:** **Befehle:**
- \`!help\` - Diese Hilfe anzeigen - \`!help\` - Diese Hilfe anzeigen
- \`!login email passwort\` - Bei NutriPhi anmelden
- \`!analyze beschreibung\` - Text analysieren - \`!analyze beschreibung\` - Text analysieren
- \`!today\` / \`heute\` - Tages-Zusammenfassung - \`!today\` / \`heute\` - Tages-Zusammenfassung
- \`!week\` / \`woche\` - Wochen-Statistik - \`!week\` / \`woche\` - Wochen-Statistik

View file

@ -8,7 +8,12 @@ import {
COMMON_KEYWORDS, COMMON_KEYWORDS,
} from '@manacore/matrix-bot-common'; } from '@manacore/matrix-bot-common';
import { PictureService } from '../picture/picture.service'; 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'; import { HELP_MESSAGE } from '../config/configuration';
// Credit cost for image generation // Credit cost for image generation
@ -158,15 +163,6 @@ Sag "hilfe" fur alle Befehle!`;
await this.handleCredits(roomId, sender); await this.handleCredits(roomId, sender);
break; 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': case 'status':
await this.handleStatus(roomId, sender); await this.handleStatus(roomId, sender);
break; break;
@ -402,11 +398,8 @@ Sag "hilfe" fur alle Befehle!`;
} }
private async handleHistory(roomId: string, sender: string) { private async handleHistory(roomId: string, sender: string) {
const token = await this.sessionService.getToken(sender); const token = await this.requireLogin(roomId, sender);
if (!token) { if (!token) return;
await this.sendMessage(roomId, `Du bist nicht angemeldet. Nutze \`!login\` zuerst.`);
return;
}
try { try {
const images = await this.pictureService.getImages(token, 10); 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[]) { private async handleDelete(roomId: string, sender: string, args: string[]) {
const token = await this.sessionService.getToken(sender); const token = await this.requireLogin(roomId, sender);
if (!token) { if (!token) return;
await this.sendMessage(roomId, `Du bist nicht angemeldet. Nutze \`!login\` zuerst.`);
return;
}
if (args.length < 1) { if (args.length < 1) {
await this.sendMessage( await this.sendMessage(
@ -472,11 +462,8 @@ Sag "hilfe" fur alle Befehle!`;
} }
private async handleCredits(roomId: string, sender: string) { private async handleCredits(roomId: string, sender: string) {
const token = await this.sessionService.getToken(sender); const token = await this.requireLogin(roomId, sender);
if (!token) { if (!token) return;
await this.sendMessage(roomId, `Du bist nicht angemeldet. Nutze \`!login\` zuerst.`);
return;
}
try { try {
const balance = await this.creditService.getBalance(token); const balance = await this.creditService.getBalance(token);
@ -510,29 +497,16 @@ Sag "hilfe" fur alle Befehle!`;
await this.sendMessage(roomId, HELP_MESSAGE); await this.sendMessage(roomId, HELP_MESSAGE);
} }
private async handleLogin(roomId: string, sender: string, args: string[]) { /**
if (args.length < 2) { * Require login - returns token or sends login prompt and returns null
await this.sendMessage( */
roomId, private async requireLogin(roomId: string, userId: string): Promise<string | null> {
`**Verwendung:** \`!login email passwort\`\n\nBeispiel: \`!login nutzer@example.com meinpasswort\`` const token = await this.sessionService.getToken(userId);
); if (!token) {
return; await this.sendMessage(roomId, LOGIN_MESSAGES.picture);
} return null;
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}`);
} }
return token;
} }
private async handleStatus(roomId: string, sender: string) { private async handleStatus(roomId: string, sender: string) {

View file

@ -33,9 +33,7 @@ export const HELP_MESSAGE = `**Picture Bot - AI-Bildgenerierung**
\`!generate A beautiful sunset over mountains --width 1280 --height 720\` \`!generate A beautiful sunset over mountains --width 1280 --height 720\`
\`!bild Ein niedlicher Hund im Park --steps 40\` \`!bild Ein niedlicher Hund im Park --steps 40\`
**Bilder verwalten:** (Login erforderlich) **Bilder verwalten:**
- \`!login email passwort\` - Anmelden
- \`!logout\` - Abmelden
- \`!history\` - Letzte Bilder anzeigen - \`!history\` - Letzte Bilder anzeigen
- \`!delete [nr]\` - Bild loschen - \`!delete [nr]\` - Bild loschen

View file

@ -9,7 +9,12 @@ import {
COMMON_KEYWORDS, COMMON_KEYWORDS,
} from '@manacore/matrix-bot-common'; } from '@manacore/matrix-bot-common';
import { PlantaService, Plant } from '../planta/planta.service'; 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'; import { HELP_MESSAGE } from '../config/configuration';
@Injectable() @Injectable()
@ -118,15 +123,6 @@ export class MatrixService extends BaseMatrixService {
await this.sendMessage(roomId, HELP_MESSAGE); await this.sendMessage(roomId, HELP_MESSAGE);
break; break;
case 'login':
await this.handleLogin(roomId, sender, args);
break;
case 'logout':
await this.sessionService.logout(sender);
await this.sendMessage(roomId, '<p>Erfolgreich abgemeldet.</p>');
break;
case 'status': case 'status':
await this.handleStatus(roomId, sender); await this.handleStatus(roomId, sender);
break; break;
@ -198,40 +194,11 @@ export class MatrixService extends BaseMatrixService {
private async requireAuth(sender: string): Promise<string> { private async requireAuth(sender: string): Promise<string> {
const token = await this.sessionService.getToken(sender); const token = await this.sessionService.getToken(sender);
if (!token) { if (!token) {
throw new Error('Nicht angemeldet. Nutze <code>!login email passwort</code>'); throw new Error(LOGIN_MESSAGES.planta);
} }
return token; return token;
} }
// Auth handlers
private async handleLogin(roomId: string, sender: string, args: string[]) {
if (args.length < 2) {
await this.sendMessage(roomId, '<p>Verwendung: <code>!login email passwort</code></p>');
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,
`<p>✅ Erfolgreich angemeldet als <strong>${email}</strong><br/>⚡ Credits: ${balance.balance.toFixed(2)}</p>`
);
} else {
await this.sendMessage(
roomId,
`<p>✅ Erfolgreich angemeldet als <strong>${email}</strong></p>`
);
}
} else {
await this.sendMessage(roomId, `<p>❌ Login fehlgeschlagen: ${result.error}</p>`);
}
}
private async handleStatus(roomId: string, sender: string) { private async handleStatus(roomId: string, sender: string) {
const backendOk = await this.plantaService.checkHealth(); const backendOk = await this.plantaService.checkHealth();
const loggedIn = await this.sessionService.isLoggedIn(sender); const loggedIn = await this.sessionService.isLoggedIn(sender);

View file

@ -17,13 +17,6 @@ export default () => ({
export const HELP_MESSAGE = `<h2>Planta Bot - Befehle</h2> export const HELP_MESSAGE = `<h2>Planta Bot - Befehle</h2>
<h3>Authentifizierung</h3>
<ul>
<li><code>!login email passwort</code> - Anmelden</li>
<li><code>!logout</code> - Abmelden</li>
<li><code>!status</code> - Bot-Status anzeigen</li>
</ul>
<h3>Pflanzen verwalten</h3> <h3>Pflanzen verwalten</h3>
<ul> <ul>
<li><code>!pflanzen</code> - Alle Pflanzen auflisten</li> <li><code>!pflanzen</code> - Alle Pflanzen auflisten</li>

View file

@ -9,7 +9,12 @@ import {
COMMON_KEYWORDS, COMMON_KEYWORDS,
} from '@manacore/matrix-bot-common'; } from '@manacore/matrix-bot-common';
import { PresiService, Deck, Theme, SlideContent } from '../presi/presi.service'; 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'; import { HELP_MESSAGE } from '../config/configuration';
@Injectable() @Injectable()
@ -99,15 +104,6 @@ export class MatrixService extends BaseMatrixService {
await this.sendMessage(roomId, HELP_MESSAGE); await this.sendMessage(roomId, HELP_MESSAGE);
break; break;
case 'login':
await this.handleLogin(roomId, sender, args);
break;
case 'logout':
await this.sessionService.logout(sender);
await this.sendMessage(roomId, '<p>Erfolgreich abgemeldet.</p>');
break;
case 'status': case 'status':
await this.handleStatus(roomId, sender); await this.handleStatus(roomId, sender);
break; break;
@ -189,40 +185,11 @@ export class MatrixService extends BaseMatrixService {
private async requireAuth(sender: string): Promise<string> { private async requireAuth(sender: string): Promise<string> {
const token = await this.sessionService.getToken(sender); const token = await this.sessionService.getToken(sender);
if (!token) { if (!token) {
throw new Error('Nicht angemeldet. Nutze <code>!login email passwort</code>'); throw new Error(LOGIN_MESSAGES.presi);
} }
return token; return token;
} }
// Auth handlers
private async handleLogin(roomId: string, sender: string, args: string[]) {
if (args.length < 2) {
await this.sendMessage(roomId, '<p>Verwendung: <code>!login email passwort</code></p>');
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,
`<p>✅ Erfolgreich angemeldet als <strong>${email}</strong><br/>⚡ Credits: ${balance.balance.toFixed(2)}</p>`
);
} else {
await this.sendMessage(
roomId,
`<p>✅ Erfolgreich angemeldet als <strong>${email}</strong></p>`
);
}
} else {
await this.sendMessage(roomId, `<p>Login fehlgeschlagen: ${result.error}</p>`);
}
}
private async handleStatus(roomId: string, sender: string) { private async handleStatus(roomId: string, sender: string) {
const backendOk = await this.presiService.checkHealth(); const backendOk = await this.presiService.checkHealth();
const loggedIn = await this.sessionService.isLoggedIn(sender); const loggedIn = await this.sessionService.isLoggedIn(sender);

View file

@ -17,13 +17,6 @@ export default () => ({
export const HELP_MESSAGE = `<h2>Presi Bot - Befehle</h2> export const HELP_MESSAGE = `<h2>Presi Bot - Befehle</h2>
<h3>Authentifizierung</h3>
<ul>
<li><code>!login email passwort</code> - Anmelden</li>
<li><code>!logout</code> - Abmelden</li>
<li><code>!status</code> - Bot-Status anzeigen</li>
</ul>
<h3>Praesentationen</h3> <h3>Praesentationen</h3>
<ul> <ul>
<li><code>!presis</code> - Alle Praesentationen auflisten</li> <li><code>!presis</code> - Alle Praesentationen auflisten</li>

View file

@ -121,12 +121,6 @@ export class MatrixService extends BaseMatrixService {
case 'start': case 'start':
await this.sendHelp(roomId); await this.sendHelp(roomId);
break; break;
case 'login':
await this.handleLogin(roomId, sender, argString);
break;
case 'logout':
await this.handleLogout(roomId, sender);
break;
case 'auth': case 'auth':
case 'account': case 'account':
await this.handleAuthStatus(roomId, sender); await this.handleAuthStatus(roomId, sender);
@ -200,36 +194,6 @@ ${styles}
await this.sendMessage(roomId, helpText); 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) { private async handleAuthStatus(roomId: string, sender: string) {
const loggedIn = await this.sessionService.isLoggedIn(sender); const loggedIn = await this.sessionService.isLoggedIn(sender);
const session = await this.sessionService.getSession(sender); const session = await this.sessionService.getSession(sender);

View file

@ -9,7 +9,12 @@ import {
COMMON_KEYWORDS, COMMON_KEYWORDS,
} from '@manacore/matrix-bot-common'; } from '@manacore/matrix-bot-common';
import { QuestionsService, Question, Collection, Answer } from '../questions/questions.service'; 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'; import { HELP_MESSAGE } from '../config/configuration';
const QUESTION_CREATE_CREDITS = 0.02; const QUESTION_CREATE_CREDITS = 0.02;
@ -82,15 +87,6 @@ export class MatrixService extends BaseMatrixService {
await this.sendMessage(roomId, HELP_MESSAGE); await this.sendMessage(roomId, HELP_MESSAGE);
break; break;
case 'login':
await this.handleLogin(roomId, sender, args);
break;
case 'logout':
this.sessionService.logout(sender);
await this.sendMessage(roomId, '<p>Erfolgreich abgemeldet.</p>');
break;
case 'status': case 'status':
await this.handleStatus(roomId, sender); await this.handleStatus(roomId, sender);
break; break;
@ -212,40 +208,11 @@ export class MatrixService extends BaseMatrixService {
private async requireAuth(sender: string): Promise<string> { private async requireAuth(sender: string): Promise<string> {
const token = await this.sessionService.getToken(sender); const token = await this.sessionService.getToken(sender);
if (!token) { if (!token) {
throw new Error('Nicht angemeldet. Nutze <code>!login email passwort</code>'); throw new Error(LOGIN_MESSAGES.questions);
} }
return token; return token;
} }
// Auth handlers
private async handleLogin(roomId: string, sender: string, args: string[]) {
if (args.length < 2) {
await this.sendMessage(roomId, '<p>Verwendung: <code>!login email passwort</code></p>');
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,
`<p>✅ Erfolgreich angemeldet als <strong>${email}</strong><br/>⚡ Credits: ${balance.balance.toFixed(2)}</p>`
);
} else {
await this.sendMessage(
roomId,
`<p>✅ Erfolgreich angemeldet als <strong>${email}</strong></p>`
);
}
} else {
await this.sendMessage(roomId, `<p>❌ Login fehlgeschlagen: ${result.error}</p>`);
}
}
private async handleStatus(roomId: string, sender: string) { private async handleStatus(roomId: string, sender: string) {
const backendOk = await this.questionsService.checkHealth(); const backendOk = await this.questionsService.checkHealth();
const loggedIn = await this.sessionService.isLoggedIn(sender); const loggedIn = await this.sessionService.isLoggedIn(sender);

View file

@ -17,13 +17,6 @@ export default () => ({
export const HELP_MESSAGE = `<h2>Questions Bot - Befehle</h2> export const HELP_MESSAGE = `<h2>Questions Bot - Befehle</h2>
<h3>Authentifizierung</h3>
<ul>
<li><code>!login email passwort</code> - Anmelden</li>
<li><code>!logout</code> - Abmelden</li>
<li><code>!status</code> - Bot-Status anzeigen</li>
</ul>
<h3>Fragen</h3> <h3>Fragen</h3>
<ul> <ul>
<li><code>!fragen</code> - Alle Fragen auflisten</li> <li><code>!fragen</code> - Alle Fragen auflisten</li>

View file

@ -9,7 +9,12 @@ import {
COMMON_KEYWORDS, COMMON_KEYWORDS,
} from '@manacore/matrix-bot-common'; } from '@manacore/matrix-bot-common';
import { SkilltreeService, Skill, SkillBranch } from '../skilltree/skilltree.service'; 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'; import { HELP_MESSAGE } from '../config/configuration';
@Injectable() @Injectable()
@ -98,15 +103,6 @@ export class MatrixService extends BaseMatrixService {
await this.sendMessage(roomId, HELP_MESSAGE); await this.sendMessage(roomId, HELP_MESSAGE);
break; break;
case 'login':
await this.handleLogin(roomId, sender, args);
break;
case 'logout':
await this.sessionService.logout(sender);
await this.sendMessage(roomId, '<p>Erfolgreich abgemeldet.</p>');
break;
case 'status': case 'status':
await this.handleStatus(roomId, sender); await this.handleStatus(roomId, sender);
break; break;
@ -192,40 +188,11 @@ export class MatrixService extends BaseMatrixService {
private async requireAuth(sender: string): Promise<string> { private async requireAuth(sender: string): Promise<string> {
const token = await this.sessionService.getToken(sender); const token = await this.sessionService.getToken(sender);
if (!token) { if (!token) {
throw new Error('Nicht angemeldet. Nutze <code>!login email passwort</code>'); throw new Error(LOGIN_MESSAGES.skilltree);
} }
return token; return token;
} }
// Auth handlers
private async handleLogin(roomId: string, sender: string, args: string[]) {
if (args.length < 2) {
await this.sendMessage(roomId, '<p>Verwendung: <code>!login email passwort</code></p>');
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,
`<p>✅ Erfolgreich angemeldet als <strong>${email}</strong><br/>⚡ Credits: ${balance.balance.toFixed(2)}</p>`
);
} else {
await this.sendMessage(
roomId,
`<p>✅ Erfolgreich angemeldet als <strong>${email}</strong></p>`
);
}
} else {
await this.sendMessage(roomId, `<p>Login fehlgeschlagen: ${result.error}</p>`);
}
}
private async handleStatus(roomId: string, sender: string) { private async handleStatus(roomId: string, sender: string) {
const backendOk = await this.skilltreeService.checkHealth(); const backendOk = await this.skilltreeService.checkHealth();
const loggedIn = await this.sessionService.isLoggedIn(sender); const loggedIn = await this.sessionService.isLoggedIn(sender);

View file

@ -17,13 +17,6 @@ export default () => ({
export const HELP_MESSAGE = `<h2>Skilltree Bot - Befehle</h2> export const HELP_MESSAGE = `<h2>Skilltree Bot - Befehle</h2>
<h3>Authentifizierung</h3>
<ul>
<li><code>!login email passwort</code> - Anmelden</li>
<li><code>!logout</code> - Abmelden</li>
<li><code>!status</code> - Bot-Status anzeigen</li>
</ul>
<h3>Skills</h3> <h3>Skills</h3>
<ul> <ul>
<li><code>!skills</code> - Alle Skills auflisten</li> <li><code>!skills</code> - Alle Skills auflisten</li>

View file

@ -15,7 +15,12 @@ import {
ShareLink, ShareLink,
TrashItem, TrashItem,
} from '../storage/storage.service'; } 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'; import { HELP_MESSAGE } from '../config/configuration';
@Injectable() @Injectable()
@ -85,15 +90,6 @@ export class MatrixService extends BaseMatrixService {
await this.sendMessage(roomId, HELP_MESSAGE); await this.sendMessage(roomId, HELP_MESSAGE);
break; break;
case 'login':
await this.handleLogin(roomId, sender, args);
break;
case 'logout':
await this.sessionService.logout(sender);
await this.sendMessage(roomId, '<p>Erfolgreich abgemeldet.</p>');
break;
case 'status': case 'status':
await this.handleStatus(roomId, sender); await this.handleStatus(roomId, sender);
break; break;
@ -240,40 +236,11 @@ export class MatrixService extends BaseMatrixService {
private async requireAuth(sender: string): Promise<string> { private async requireAuth(sender: string): Promise<string> {
const token = await this.sessionService.getToken(sender); const token = await this.sessionService.getToken(sender);
if (!token) { if (!token) {
throw new Error('Nicht angemeldet. Nutze <code>!login email passwort</code>'); throw new Error(LOGIN_MESSAGES.storage);
} }
return token; return token;
} }
// Auth handlers
private async handleLogin(roomId: string, sender: string, args: string[]) {
if (args.length < 2) {
await this.sendMessage(roomId, '<p>Verwendung: <code>!login email passwort</code></p>');
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,
`<p>✅ Erfolgreich angemeldet als <strong>${email}</strong><br/>⚡ Credits: ${balance.balance.toFixed(2)}</p>`
);
} else {
await this.sendMessage(
roomId,
`<p>✅ Erfolgreich angemeldet als <strong>${email}</strong></p>`
);
}
} else {
await this.sendMessage(roomId, `<p>Login fehlgeschlagen: ${result.error}</p>`);
}
}
private async handleStatus(roomId: string, sender: string) { private async handleStatus(roomId: string, sender: string) {
const backendOk = await this.storageService.checkHealth(); const backendOk = await this.storageService.checkHealth();
const loggedIn = await this.sessionService.isLoggedIn(sender); const loggedIn = await this.sessionService.isLoggedIn(sender);

View file

@ -17,13 +17,6 @@ export default () => ({
export const HELP_MESSAGE = `<h2>Storage Bot - Befehle</h2> export const HELP_MESSAGE = `<h2>Storage Bot - Befehle</h2>
<h3>Authentifizierung</h3>
<ul>
<li><code>!login email passwort</code> - Anmelden</li>
<li><code>!logout</code> - Abmelden</li>
<li><code>!status</code> - Bot-Status anzeigen</li>
</ul>
<h3>Dateien</h3> <h3>Dateien</h3>
<ul> <ul>
<li><code>!dateien</code> - Dateien im Root auflisten</li> <li><code>!dateien</code> - Dateien im Root auflisten</li>

View file

@ -419,14 +419,6 @@ export class MatrixService
await this.sendReply(roomId, event, HELP_TEXT); await this.sendReply(roomId, event, HELP_TEXT);
break; break;
case 'login':
await this.handleLogin(roomId, event, userId, args);
break;
case 'logout':
await this.handleLogout(roomId, event, userId);
break;
case 'add': case 'add':
case 'neu': case 'neu':
case 'neue': 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) { private async handlePinHelp(roomId: string, event: MatrixRoomEvent) {
try { try {
// Send help message // Send help message

View file

@ -38,8 +38,6 @@ export const HELP_TEXT = `🎯 **Todo Bot - Hilfe**
**Sonstiges:** **Sonstiges:**
\`status\` - Verbindungsstatus prüfen \`status\` - Verbindungsstatus prüfen
\`hilfe\` - Diese Hilfe anzeigen \`hilfe\` - Diese Hilfe anzeigen
\`login email passwort\` - Anmelden für Synchronisation
\`logout\` - Abmelden
**Tipp:** Alle Befehle funktionieren auch mit \`!\` davor (z.B. \`!neu\`)`; **Tipp:** Alle Befehle funktionieren auch mit \`!\` davor (z.B. \`!neu\`)`;

View file

@ -198,15 +198,6 @@ Sag "hilfe" fuer alle Befehle!`;
await this.handleCategoryQuote(roomId, sender, 'motivation'); await this.handleCategoryQuote(roomId, sender, 'motivation');
break; 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 'favorit':
case 'fav': case 'fav':
await this.handleAddFavorite(roomId, sender); await this.handleAddFavorite(roomId, sender);
@ -353,40 +344,6 @@ Sag "hilfe" fuer alle Befehle!`;
await this.sendMessage(roomId, text); 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) { private async handleAddFavorite(roomId: string, sender: string) {
const token = await this.requireLogin(roomId, sender); const token = await this.requireLogin(roomId, sender);
if (!token) return; if (!token) return;

View file

@ -27,13 +27,11 @@ export const HELP_MESSAGE = `**Zitare Bot - Taegliche Inspiration**
- \`!kategorie [name]\` - Zitate nach Kategorie - \`!kategorie [name]\` - Zitate nach Kategorie
- \`!kategorien\` - Alle Kategorien - \`!kategorien\` - Alle Kategorien
**Favoriten:** (Login erforderlich) **Favoriten:**
- \`!login email passwort\` - Anmelden
- \`!logout\` - Abmelden
- \`!favorit\` - Letztes Zitat speichern - \`!favorit\` - Letztes Zitat speichern
- \`!favoriten\` - Alle Favoriten anzeigen - \`!favoriten\` - Alle Favoriten anzeigen
**Listen:** (Login erforderlich) **Listen:**
- \`!listen\` - Alle Listen anzeigen - \`!listen\` - Alle Listen anzeigen
- \`!liste [name]\` - Neue Liste erstellen - \`!liste [name]\` - Neue Liste erstellen
- \`!addliste [nr] [zitat-nr]\` - Zitat zur Liste hinzufuegen - \`!addliste [nr] [zitat-nr]\` - Zitat zur Liste hinzufuegen