plex-bot.js aktualisiert
This commit is contained in:
parent
dbf1fe80ff
commit
c18e957ddc
102
plex-bot.js
102
plex-bot.js
|
@ -457,7 +457,7 @@ function generateRandomPassword() {
|
|||
const uppercaseChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
const lowercaseChars = 'abcdefghijklmnopqrstuvwxyz';
|
||||
const digits = '0123456789';
|
||||
const specialChars = '@#$!';
|
||||
const specialChars = '@$!+-*&';
|
||||
|
||||
const allChars = uppercaseChars + lowercaseChars + digits + specialChars;
|
||||
|
||||
|
@ -2226,6 +2226,9 @@ function logError(message) {
|
|||
const timestamp = new Date().toISOString();
|
||||
fs.appendFileSync('error.log', `${timestamp} - ${message}\n`);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Umgebungsvariable für die Chat-ID der Entwickler
|
||||
const DEV_CHAT_ID = parseInt(process.env.DEV_CHAT_ID, 10);
|
||||
|
||||
|
@ -2246,7 +2249,8 @@ function getDevOptionsKeyboard() {
|
|||
reply_markup: {
|
||||
inline_keyboard: [
|
||||
[{ text: '💡 Funktionswunsch', callback_data: 'dev_request' }],
|
||||
[{ text: '🐞 Bug melden', callback_data: 'dev_bug' }]
|
||||
[{ text: '🐞 Bug melden', callback_data: 'dev_bug' }],
|
||||
[{ text: '🎬 Film Report', callback_data: 'film_report' }]
|
||||
]
|
||||
}
|
||||
};
|
||||
|
@ -2292,6 +2296,15 @@ bot.on('callback_query', (query) => {
|
|||
};
|
||||
break;
|
||||
|
||||
case 'film_report':
|
||||
responseText = '🎬 *Bitte geben Sie den Film Report ein:* \n\nTitel & Fehlerbeschreibung:';
|
||||
replyMarkup = {
|
||||
reply_markup: {
|
||||
force_reply: true
|
||||
}
|
||||
};
|
||||
break;
|
||||
|
||||
default:
|
||||
// Kein Popup oder Nachricht senden, wenn die Auswahl unbekannt ist
|
||||
return;
|
||||
|
@ -2303,32 +2316,52 @@ bot.on('callback_query', (query) => {
|
|||
// Handler für die Antworten auf die Feedback-Anfrage
|
||||
bot.on('message', async (msg) => {
|
||||
if (msg.reply_to_message && (msg.reply_to_message.text.includes('Bitte geben Sie Ihren Funktionswunsch ein:') ||
|
||||
msg.reply_to_message.text.includes('Bitte beschreiben Sie den Bug, den Sie melden möchten:'))) {
|
||||
msg.reply_to_message.text.includes('Bitte beschreiben Sie den Bug, den Sie melden möchten:') ||
|
||||
msg.reply_to_message.text.includes('Bitte geben Sie den Film Report ein:'))) {
|
||||
const chatId = msg.chat.id;
|
||||
const text = msg.text;
|
||||
const userName = msg.from.first_name + (msg.from.last_name ? ` ${msg.from.last_name}` : '');
|
||||
const userId = msg.from.id;
|
||||
const messageType = msg.reply_to_message.text.includes('Funktionswunsch') ? 'Funktionswunsch' : 'Bug';
|
||||
|
||||
const devMessage = {
|
||||
id: null, // ID wird später zugewiesen
|
||||
let messageType;
|
||||
let report;
|
||||
|
||||
if (msg.reply_to_message.text.includes('Funktionswunsch')) {
|
||||
messageType = 'Funktionswunsch';
|
||||
report = { type: messageType, user: { name: userName, id: userId }, message: text };
|
||||
} else if (msg.reply_to_message.text.includes('Bug')) {
|
||||
messageType = 'Bug';
|
||||
report = { type: messageType, user: { name: userName, id: userId }, message: text };
|
||||
} else if (msg.reply_to_message.text.includes('Film Report')) {
|
||||
// Hier wird der gesamte Text für Titel und Fehlerbeschreibung verwendet
|
||||
const userMessage = text.trim(); // Benutzertext
|
||||
|
||||
messageType = 'Film Report';
|
||||
report = {
|
||||
type: messageType,
|
||||
user: {
|
||||
name: userName,
|
||||
id: userId
|
||||
},
|
||||
message: text,
|
||||
timestamp: new Date().toISOString()
|
||||
user: { name: userName, id: userId },
|
||||
message: userMessage // Der gesamte Benutzertext wird als Nachricht verwendet
|
||||
};
|
||||
}
|
||||
|
||||
// Dev Report in die Datei schreiben
|
||||
try {
|
||||
// Nur die DEV_CHAT_ID für Bug und Funktionswunsch
|
||||
if (messageType === 'Bug' || messageType === 'Funktionswunsch') {
|
||||
console.log('Sende Nachricht an Entwickler-Chat-ID:', DEV_CHAT_ID); // Debugging-Ausgabe
|
||||
await bot.sendMessage(DEV_CHAT_ID, formatDevMessage(devMessage), { parse_mode: 'Markdown' });
|
||||
await bot.sendMessage(DEV_CHAT_ID, formatDevMessage(report), { parse_mode: 'Markdown' });
|
||||
}
|
||||
// DEV_CHAT_ID und USER2_ID für Film Reports
|
||||
else if (messageType === 'Film Report') {
|
||||
console.log('Sende Nachricht an Entwickler-Chat-ID und USER2_ID:', DEV_CHAT_ID, USER2_ID); // Debugging-Ausgabe
|
||||
await bot.sendMessage(DEV_CHAT_ID, formatDevMessage(report), { parse_mode: 'Markdown' });
|
||||
await bot.sendMessage(USER2_ID, formatDevMessage(report), { parse_mode: 'Markdown' });
|
||||
}
|
||||
|
||||
console.log('Nachricht erfolgreich gesendet.');
|
||||
|
||||
// Dev Report in die JSON-Datei speichern
|
||||
saveDevReport(devMessage);
|
||||
saveDevReport(report);
|
||||
|
||||
bot.sendMessage(chatId, '✅ Ihre Nachricht wurde erfolgreich gesendet! Vielen Dank.');
|
||||
} catch (error) {
|
||||
|
@ -2356,6 +2389,8 @@ function saveDevReport(report) {
|
|||
// Starte den Bot und erstelle die Datei
|
||||
createDevReportsFile();
|
||||
|
||||
|
||||
|
||||
// Handler für den /bot-Befehl
|
||||
bot.onText(/\/bot/, (msg) => {
|
||||
const chatId = msg.chat.id;
|
||||
|
@ -5029,6 +5064,31 @@ app.post('/api/download-backup', (req, res) => {
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// API-Endpunkt zum Abrufen der Entwicklerberichte
|
||||
app.get('/api/dev-reports', (req, res) => {
|
||||
try {
|
||||
|
@ -5122,6 +5182,20 @@ function sendToTelegram(report) {
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Ende Frontend
|
||||
|
||||
/// Definition der logDebug-Funktion
|
||||
|
|
Loading…
Reference in New Issue