Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
04353bbba0 | |||
82cb07811c | |||
98408bed1d | |||
c206dfa424 | |||
611e101483 | |||
38c244a1fa | |||
91e28fe84f | |||
dc6f15e606 | |||
cd2e2fb54c |
13
.env
13
.env
@ -1,4 +1,9 @@
|
||||
EMAIL_USER= "Mailadresse (Postausgang)"
|
||||
EMAIL_PASS= "Passwort (Postausgang)"
|
||||
BOT_TOKEN= "Telegram Bot Token"
|
||||
EMAIL_RECIPIENT= "Mail Empfänger Adresse"
|
||||
EMAIL_USER= "Mailadresse (Postausgang)"
|
||||
EMAIL_PASS= "Passwort (Postausgang)"
|
||||
BOT_TOKEN= "Telegram Bot Token"
|
||||
EMAIL_RECIPIENT= "Mail Empfänger Adresse"
|
||||
ADMIN_ID= "Telegran ID"
|
||||
WEBSITE_1_NAME= "Webseite 1"
|
||||
WEBSITE_1_URL=https://example.org
|
||||
WEBSITE_2_NAME= "Webseite 2"
|
||||
WEBSITE_2_URL=https://example.org
|
1702
package-lock.json
generated
Normal file
1702
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
24
package.json
Normal file
24
package.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "support_bot",
|
||||
"version": "1.0.0",
|
||||
"description": "Telegram Support Bot",
|
||||
"main": "support_bot.js",
|
||||
"keywords": [
|
||||
"telegram",
|
||||
"support",
|
||||
"bot"
|
||||
],
|
||||
"author": "M_Viper",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"axios": "^1.6.5",
|
||||
"dotenv": "^16.3.1",
|
||||
"fluent-ffmpeg": "^2.1.2",
|
||||
"fs": "^0.0.1-security",
|
||||
"js-yaml": "^4.1.0",
|
||||
"multer": "^1.4.5-lts.1",
|
||||
"node-telegram-bot-api": "^0.63.0",
|
||||
"nodemailer": "^6.9.8",
|
||||
"validator": "^13.11.0"
|
||||
}
|
||||
}
|
70
setup.sh
Normal file
70
setup.sh
Normal file
@ -0,0 +1,70 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Überprüfen, ob Node.js installiert ist
|
||||
if ! command -v node &> /dev/null; then
|
||||
echo "Node.js ist nicht installiert. Installiere Node.js automatisch..."
|
||||
|
||||
# Automatische Installation von Node.js, abhängig vom Linux-System
|
||||
if command -v apt &> /dev/null; then
|
||||
sudo apt update
|
||||
sudo apt install -y nodejs
|
||||
elif command -v yum &> /dev/null; then
|
||||
sudo yum install -y nodejs
|
||||
else
|
||||
echo "Automatische Installation von Node.js wird nicht unterstützt. Bitte installieren Sie Node.js manuell und führen Sie das Skript erneut aus."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Überprüfen, ob npm installiert ist
|
||||
if ! command -v npm &> /dev/null; then
|
||||
echo "npm ist nicht installiert. Installiere npm automatisch..."
|
||||
sudo apt install -y npm # Oder passen Sie dies an Ihr System an
|
||||
fi
|
||||
|
||||
# Laden Sie die Umgebungsvariablen aus der .env-Datei
|
||||
source .env
|
||||
|
||||
# Erstellen Sie ein neues Node.js-Projekt mit npm init und verwenden Sie Umgebungsvariablen
|
||||
echo -e "Creating a new Node.js project..."
|
||||
echo -e "Project name: $PROJECT_NAME"
|
||||
echo -e "Version: 1.0.0"
|
||||
echo -e "Description: Node.js project"
|
||||
echo -e "Entry point: support_bot.js" # Hier Dateinamen anpassen
|
||||
echo -e "Test command: "
|
||||
echo -e "Git repository: https://git.viper.ipv64.net/M_Viper/telegram_server_monitoring"
|
||||
echo -e "Keywords: "
|
||||
echo -e "Author: M_Viper"
|
||||
echo -e "License: ISC"
|
||||
|
||||
# npm init -y sollte ohne sudo ausgeführt werden, um Probleme mit Dateiberechtigungen zu vermeiden
|
||||
sudo npm init -y
|
||||
|
||||
# Installieren Sie die benötigten Pakete, einschließlich node-telegram-bot-api
|
||||
sudo npm install
|
||||
sudo npm install ping
|
||||
sudo npm install node-telegram-bot-api
|
||||
sudo npm install js-yaml
|
||||
sudo npm install moment
|
||||
sudo npm install yaml # Änderung: 'yaml' anstelle von 'yml'
|
||||
sudo npm install dotenv
|
||||
sudo npm install fs
|
||||
sudo npm install request
|
||||
sudo npm install nodemailer
|
||||
sudo npm install axios
|
||||
|
||||
# Installieren Sie pm2, wenn es noch nicht installiert ist
|
||||
if ! command -v pm2 &> /dev/null; then
|
||||
sudo npm install -g pm2
|
||||
fi
|
||||
|
||||
# Erstellen Sie ein Startskript für den Bot
|
||||
echo -e "Creating start script..."
|
||||
echo -e "#!/bin/bash\n\npm2 start support_bot.js" > start_bot.sh # Hier Dateinamen anpassen
|
||||
chmod +x start_bot.sh
|
||||
|
||||
# Erstellen Sie ein Autostart-Skript für den Bot
|
||||
echo -e "Creating autostart script..."
|
||||
echo -e "[Unit]\nDescription=Telegram Support Bot\n\n[Service]\nExecStart=$(pwd)/start_bot.sh\n\n[Install]\nWantedBy=default.target" > telegram_bot.service
|
||||
sudo mv telegram_bot.service /etc/systemd/system/
|
||||
sudo systemctl enable telegram_bot
|
3
start_bot.sh
Normal file
3
start_bot.sh
Normal file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
pm2 start support_bot.js
|
409
support_bot.js
409
support_bot.js
@ -3,6 +3,7 @@ const nodemailer = require('nodemailer');
|
||||
const fs = require('fs').promises;
|
||||
const yaml = require('js-yaml');
|
||||
const path = require('path');
|
||||
const axios = require('axios');
|
||||
require('dotenv').config();
|
||||
|
||||
const emailConfig = {
|
||||
@ -12,10 +13,13 @@ const emailConfig = {
|
||||
};
|
||||
|
||||
const botToken = process.env.BOT_TOKEN;
|
||||
const adminChatId = process.env.ADMIN_CHAT_ID;
|
||||
|
||||
const allowedAdminIds = adminChatId.split(',');
|
||||
|
||||
const botInfo = {
|
||||
name: 'Telegram Support Bot',
|
||||
version: '1.0.0',
|
||||
version: '1.0.7',
|
||||
author: 'M_Viper',
|
||||
license: 'ISC',
|
||||
};
|
||||
@ -24,7 +28,83 @@ const bot = new TelegramBot(botToken, { polling: true });
|
||||
|
||||
const ticketCreationStatus = new Map();
|
||||
|
||||
const logoPath = path.join(__dirname, 'logo.png'); // Setze den korrekten Pfad zu deinem Logo
|
||||
const logoPath = path.join(__dirname, 'logo.png');
|
||||
|
||||
function sendErrorNotification(error) {
|
||||
try {
|
||||
const adminChatId = 5507179337;
|
||||
|
||||
bot.sendMessage(adminChatId, `Es ist ein Fehler aufgetreten:\n${error}`)
|
||||
.catch((adminError) => {
|
||||
console.error('Fehler beim Senden der Fehlermeldung an den Administrator:', adminError);
|
||||
});
|
||||
} catch (sendErrorNotificationError) {
|
||||
console.error('Fehler beim Senden der Fehlermeldung:', sendErrorNotificationError);
|
||||
}
|
||||
}
|
||||
|
||||
async function checkBotStatus(msg) {
|
||||
try {
|
||||
console.log('Received message:', msg);
|
||||
|
||||
// Überprüfe, ob der Befehl /status ausgeführt wurde
|
||||
const isStatusCommand = msg && msg.text && msg.text.toLowerCase() === '/status';
|
||||
|
||||
console.log('Is /status command?', isStatusCommand);
|
||||
|
||||
const isBotOnline = true; // Hier sollte deine Logik stehen, um den Bot-Status zu überprüfen.
|
||||
const statusMessage = isBotOnline ? 'Der Bot ist online.' : 'Der Bot ist offline.';
|
||||
|
||||
if (isStatusCommand) {
|
||||
bot.sendMessage(msg.chat.id, statusMessage);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Fehler beim Überprüfen des Bot-Status:', error);
|
||||
sendErrorNotification(error);
|
||||
|
||||
if (msg && msg.text && msg.text.toLowerCase() === '/status') {
|
||||
bot.sendMessage(msg.chat.id, 'Fehler beim Überprüfen des Bot-Status.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* bot.onText(/\/status/, checkBotStatus);
|
||||
|
||||
async function checkWebsiteStatus() {
|
||||
const adminChatId = process.env.ADMIN_CHAT_ID;
|
||||
|
||||
const websites = [
|
||||
{
|
||||
name: process.env.WEBSITE_1_NAME,
|
||||
url: process.env.WEBSITE_1_URL,
|
||||
},
|
||||
{
|
||||
name: process.env.WEBSITE_2_NAME,
|
||||
url: process.env.WEBSITE_2_URL,
|
||||
},
|
||||
];
|
||||
|
||||
for (const website of websites) {
|
||||
try {
|
||||
const response = await axios.get(website.url);
|
||||
const statusMessage = `✅ <b>${website.name}</b> ist <i>online</i>.`;
|
||||
if (!website.online) {
|
||||
website.online = true;
|
||||
bot.sendMessage(adminChatId, statusMessage, { parse_mode: 'HTML' });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Fehler beim Zugriff auf ${website.name}:`, error);
|
||||
const errorMessage = `❌ <b>${website.name}</b> ist <i>offline</i>. Fehler: ${error.message}`;
|
||||
if (website.online !== false) {
|
||||
website.online = false;
|
||||
sendErrorNotification(errorMessage);
|
||||
bot.sendMessage(adminChatId, errorMessage, { parse_mode: 'HTML' });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setInterval(checkWebsiteStatus, 3600000); */
|
||||
|
||||
async function loadFromYaml(filePath) {
|
||||
try {
|
||||
@ -32,35 +112,60 @@ async function loadFromYaml(filePath) {
|
||||
return yaml.load(fileContents);
|
||||
} catch (error) {
|
||||
console.error(`Fehler beim Laden der YAML-Datei für ${path.basename(filePath)}:`, error);
|
||||
sendErrorNotification(error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
async function loadLinks() {
|
||||
const linksDataPath = path.join(__dirname, 'links.yml');
|
||||
return await loadFromYaml(linksDataPath);
|
||||
try {
|
||||
const linksDataPath = path.join(__dirname, 'links.yml');
|
||||
return await loadFromYaml(linksDataPath);
|
||||
} catch (error) {
|
||||
console.error('Fehler beim Laden der Links:', error);
|
||||
sendErrorNotification(error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
async function loadTeam() {
|
||||
const teamDataPath = path.join(__dirname, 'team.json');
|
||||
return await loadFromYaml(teamDataPath);
|
||||
try {
|
||||
const teamDataPath = path.join(__dirname, 'team.json');
|
||||
return await loadFromYaml(teamDataPath);
|
||||
} catch (error) {
|
||||
console.error('Fehler beim Laden des Teams:', error);
|
||||
sendErrorNotification(error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
async function loadFragen() {
|
||||
const fragenDataPath = path.join(__dirname, 'fragen.yml');
|
||||
return await loadFromYaml(fragenDataPath);
|
||||
try {
|
||||
const fragenDataPath = path.join(__dirname, 'fragen.yml');
|
||||
return await loadFromYaml(fragenDataPath);
|
||||
} catch (error) {
|
||||
console.error('Fehler beim Laden der Fragen:', error);
|
||||
sendErrorNotification(error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
function sendWelcomeMessage(chatId) {
|
||||
const welcomeMessage = `
|
||||
**Willkommen beim Support!**
|
||||
function sendWelcomeMessage(chatId, isStatusCommand = false) {
|
||||
const excludedCommands = ['/status', '/info', '/help', '/menu'];
|
||||
|
||||
Herzlich willkommen! Wir schätzen es, dass Sie sich für unseren Support entschieden haben. Unser oberstes Ziel ist es, Ihnen bestmöglich zu helfen und Ihre Anliegen so schnell wie möglich zu klären. Wenn Sie Unterstützung benötigen, haben Sie verschiedene Möglichkeiten:
|
||||
if (!isStatusCommand && !excludedCommands.includes('/' + chatId)) {
|
||||
const welcomeMessage = `
|
||||
Herzlich willkommen beim Support!
|
||||
|
||||
- Um unser Menü anzuzeigen, geben Sie einfach "/menu" ein.
|
||||
- Sollte Ihre Frage nicht beantwortet werden, können Sie ganz einfach ein Ticket erstellen, um spezifische Unterstützung zu erhalten.
|
||||
Wir freuen uns, dass Sie sich für unseren Support entschieden haben. Unser vorrangiges Ziel ist es, Ihnen bestmöglich zu helfen und Ihre Anliegen so schnell wie möglich zu klären. Falls Sie Unterstützung benötigen, bieten wir Ihnen verschiedene Optionen:
|
||||
|
||||
Wir stehen Ihnen zur Verfügung und sind hier, um Ihre Anfragen zu bearbeiten. Bitte geben Sie uns so viele Details wie möglich, damit wir Ihnen effektiv helfen können.
|
||||
👉 Um unser Menü anzuzeigen, tippen Sie einfach "/menu" ein.
|
||||
|
||||
👉 Sollte Ihre Frage nicht beantwortet werden, können Sie unkompliziert ein Ticket erstellen, um spezifische Unterstützung zu erhalten.
|
||||
|
||||
Für weitere Hilfe steht Ihnen unser "/help"-Befehl zur Verfügung.
|
||||
|
||||
Wir sind jederzeit für Sie da und bearbeiten gerne Ihre Anfragen. Bitte teilen Sie uns so viele Details wie möglich mit, damit wir Ihnen effektiv helfen können.
|
||||
|
||||
Vielen Dank für Ihr Vertrauen.
|
||||
|
||||
@ -68,109 +173,157 @@ Herzliche Grüße,
|
||||
Das Support-Team
|
||||
`;
|
||||
|
||||
bot.sendMessage(chatId, welcomeMessage, { parse_mode: 'Markdown' });
|
||||
bot.sendMessage(chatId, welcomeMessage, { parse_mode: 'Markdown' });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function handleStatusCommand(msg) {
|
||||
const chatId = msg.chat.id;
|
||||
const userId = msg.from.id;
|
||||
|
||||
if (allowedAdminIds.includes(userId.toString())) {
|
||||
bot.sendMessage(chatId, 'Aktueller Bot- und Webseitenstatus wird abgerufen...');
|
||||
|
||||
checkBotStatus(chatId);
|
||||
checkWebsiteStatus(chatId);
|
||||
} else {
|
||||
bot.sendMessage(chatId, 'Du hast keine Berechtigung, diesen Befehl zu verwenden.');
|
||||
}
|
||||
}
|
||||
|
||||
bot.onText(/\/status/, handleStatusCommand);
|
||||
|
||||
async function initializeBot() {
|
||||
const linksData = await loadLinks();
|
||||
const teamData = await loadTeam();
|
||||
const fragenData = await loadFragen();
|
||||
try {
|
||||
const linksData = await loadLinks();
|
||||
const teamData = await loadTeam();
|
||||
const fragenData = await loadFragen();
|
||||
|
||||
// Hinzugefügter Abschnitt für den /info-Befehl
|
||||
bot.onText(/\/info/, (msg) => {
|
||||
const chatId = msg.chat.id;
|
||||
console.log('Info-Befehl empfangen:', msg.text);
|
||||
showBotInfo(chatId);
|
||||
});
|
||||
bot.onText(/\/info/, (msg) => {
|
||||
const chatId = msg.chat.id;
|
||||
console.log('Info-Befehl empfangen:', msg.text);
|
||||
showBotInfo(chatId);
|
||||
});
|
||||
|
||||
// Hinzugefügter Abschnitt für den /logo-Befehl
|
||||
bot.onText(/\/logo/, (msg) => {
|
||||
const chatId = msg.chat.id;
|
||||
bot.sendPhoto(chatId, logoPath, { caption: 'Hier ist unser Logo!' })
|
||||
.then(() => {
|
||||
console.log('Logo erfolgreich gesendet.');
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Fehler beim Senden des Logos:', error);
|
||||
});
|
||||
});
|
||||
bot.on('message', async (msg) => {
|
||||
const chatId = msg.chat.id;
|
||||
|
||||
bot.on('message', async (msg) => {
|
||||
const chatId = msg.chat.id;
|
||||
if (msg.text && msg.text.toLowerCase() === '/help') {
|
||||
const helpMessage = `
|
||||
🤖 ${botInfo.name} - Hilfe 🤖
|
||||
|
||||
if (msg.text === '/menu') {
|
||||
handleMainMenu(msg, chatId, linksData, fragenData);
|
||||
return;
|
||||
}
|
||||
Verfügbare Befehle:
|
||||
|
||||
if (msg.text && msg.text.toLowerCase() === '/info') {
|
||||
// /info wird nun auch über onText abgefangen
|
||||
return;
|
||||
}
|
||||
1. /menu - Zeigt das Hauptmenü an.
|
||||
2. /help - Zeigt diese Hilfe an.
|
||||
3. /info - Zeigt Informationen zum Bot an.
|
||||
|
||||
if (ticketCreationStatus.has(chatId)) {
|
||||
handleTicketCreation(msg, chatId, linksData);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
sendWelcomeMessage(chatId);
|
||||
});
|
||||
🎫 Ticket erstellen: 🎫
|
||||
👉 Erstellt ein Support-Ticket.
|
||||
|
||||
🔗 Links: 🔗
|
||||
👉 Zeigt Links zu verschiedenen Kategorien an.
|
||||
|
||||
❓ Fragen: ❓
|
||||
👉 Zeigt häufig gestellte Fragen (FAQs) an.
|
||||
|
||||
👮 Team: 👮
|
||||
👉 Zeigt Informationen zum Support-Team an.
|
||||
|
||||
‼️ Hinweis: Weitere Funktionen werden folgen ‼️
|
||||
`;
|
||||
|
||||
bot.on('callback_query', (callbackQuery) => {
|
||||
const chatId = callbackQuery.message.chat.id;
|
||||
const action = callbackQuery.data;
|
||||
bot.sendMessage(chatId, helpMessage)
|
||||
.catch((error) => {
|
||||
console.error('Fehler beim Senden der Hilfe:', error);
|
||||
});
|
||||
|
||||
if (action === 'create_ticket') {
|
||||
ticketCreationStatus.set(chatId, { step: 'waiting_for_name' });
|
||||
bot.sendMessage(chatId, 'Um ein Ticket zu erstellen, gib bitte deinen Namen ein:')
|
||||
.catch((error) => {
|
||||
console.error('Fehler beim Senden der Aufforderung für den Namen:', error);
|
||||
});
|
||||
} else if (action === 'links') {
|
||||
showLinksMenu(chatId, linksData);
|
||||
} else if (action.startsWith('links_')) {
|
||||
const category = action.replace('links_', '');
|
||||
showLinksInCategory(chatId, category, linksData);
|
||||
} else if (action === 'team') {
|
||||
showTeam(chatId, teamData);
|
||||
} else if (action === 'fragen') {
|
||||
handleFragen(chatId, fragenData);
|
||||
} else if (action.startsWith('fragen_')) {
|
||||
const category = action.replace('fragen_', '');
|
||||
showFragenInCategory(chatId, category, fragenData);
|
||||
} else if (action.startsWith('frage_')) {
|
||||
const questionId = action.replace('frage_', '');
|
||||
showFrageAnswer(chatId, questionId, fragenData);
|
||||
} else {
|
||||
handleMainMenu(callbackQuery.message, chatId, linksData, fragenData);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
bot.startPolling();
|
||||
// Logging Bot Information
|
||||
console.log(`
|
||||
*Bot Information:*
|
||||
- *Name:* ${escapeMarkdown(botInfo.name)}
|
||||
- *Version:* ${escapeMarkdown(botInfo.version)}
|
||||
- *Author:* ${escapeMarkdown(botInfo.author)}
|
||||
- *License:* ${escapeMarkdown(botInfo.license)}
|
||||
Bot ist gestartet und bereit.
|
||||
`);
|
||||
if (msg.text === '/menu') {
|
||||
handleMainMenu(msg, chatId, linksData, fragenData);
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg.text && msg.text.toLowerCase() === '/info') {
|
||||
// Code für den Befehl /info
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg.text && msg.text.toLowerCase() === '/status') {
|
||||
// Code für den Befehl /status
|
||||
return;
|
||||
}
|
||||
|
||||
if (ticketCreationStatus.has(chatId)) {
|
||||
handleTicketCreation(msg, chatId, linksData);
|
||||
return;
|
||||
}
|
||||
|
||||
sendWelcomeMessage(chatId);
|
||||
});
|
||||
|
||||
bot.on('callback_query', (callbackQuery) => {
|
||||
const chatId = callbackQuery.message.chat.id;
|
||||
const action = callbackQuery.data;
|
||||
|
||||
if (action === 'create_ticket') {
|
||||
ticketCreationStatus.set(chatId, { step: 'waiting_for_name' });
|
||||
bot.sendMessage(chatId, 'Um ein Ticket zu erstellen, gib bitte deinen Namen ein:')
|
||||
.catch((error) => {
|
||||
console.error('Fehler beim Senden der Aufforderung für den Namen:', error);
|
||||
});
|
||||
} else if (action === 'links') {
|
||||
showLinksMenu(chatId, linksData);
|
||||
} else if (action.startsWith('links_')) {
|
||||
const category = action.replace('links_', '');
|
||||
showLinksInCategory(chatId, category, linksData);
|
||||
} else if (action === 'team') {
|
||||
showTeam(chatId, teamData);
|
||||
} else if (action === 'fragen') {
|
||||
handleFragen(chatId, fragenData);
|
||||
} else if (action.startsWith('fragen_')) {
|
||||
const category = action.replace('fragen_', '');
|
||||
showFragenInCategory(chatId, category, fragenData);
|
||||
} else if (action.startsWith('frage_')) {
|
||||
const questionId = action.replace('frage_', '');
|
||||
showFrageAnswer(chatId, questionId, fragenData);
|
||||
} else {
|
||||
handleMainMenu(callbackQuery.message, chatId, linksData, fragenData);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
console.log(`
|
||||
*Bot Information:*
|
||||
- *Name:* ${escapeMarkdown(botInfo.name)}
|
||||
- *Version:* ${escapeMarkdown(botInfo.version)}
|
||||
- *Author:* ${escapeMarkdown(botInfo.author)}
|
||||
- *License:* ${escapeMarkdown(botInfo.license)}
|
||||
Bot ist gestartet und bereit.
|
||||
`);
|
||||
} catch (error) {
|
||||
console.error('Fehler beim Initialisieren des Bots:', error);
|
||||
sendErrorNotification(error);
|
||||
}
|
||||
}
|
||||
|
||||
function showBotInfo(chatId) {
|
||||
// Sende zuerst das Logo
|
||||
bot.sendPhoto(chatId, logoPath, { caption: '*Der Bot wurde am 08.01.2024 erstellt' })
|
||||
bot.sendPhoto(chatId, logoPath, { caption: '*Der Bot wurde am 08.01.2024 erstellt*' })
|
||||
.then(() => {
|
||||
// Dann sende die Bot-Informationen
|
||||
const botInfoMessage = `
|
||||
*Bot Information:*
|
||||
- *Name:* ${escapeMarkdown(botInfo.name)}
|
||||
- *Author:* ${escapeMarkdown(botInfo.author)}
|
||||
- *License:* ${escapeMarkdown(botInfo.license)}
|
||||
`;
|
||||
🤖Bot Information:
|
||||
- *Name:* ${escapeMarkdown(botInfo.name)}
|
||||
- *Author:* ${escapeMarkdown(botInfo.author)}
|
||||
- *License:* ${escapeMarkdown(botInfo.license)}
|
||||
`;
|
||||
|
||||
return bot.sendMessage(chatId, botInfoMessage, { parse_mode: 'Markdown' });
|
||||
bot.sendMessage(chatId, botInfoMessage, { parse_mode: 'Markdown' });
|
||||
})
|
||||
.then(() => {
|
||||
console.log('Bot-Informationen erfolgreich gesendet.');
|
||||
@ -181,7 +334,6 @@ function showBotInfo(chatId) {
|
||||
}
|
||||
|
||||
function escapeMarkdown(text) {
|
||||
// Funktion zum Hinzufügen von Escape-Zeichen für Markdown-Sonderzeichen
|
||||
return text.replace(/[_*[\]()~`>#+-=|{}.!]/g, '\\$&');
|
||||
}
|
||||
|
||||
@ -225,7 +377,7 @@ function showLinksInCategory(chatId, category, linksData) {
|
||||
}
|
||||
|
||||
function showTeam(chatId, teamData) {
|
||||
let teamMessage = 'Unser Team:\n\n';
|
||||
let teamMessage = '*Unser Team:*\n\n';
|
||||
|
||||
teamData.forEach((member) => {
|
||||
teamMessage += `*Name:* ${member.name}\n*Position:* ${member.position}\n*zuständig:* ${member.zustaendig}\n*Profil:* [Profil](${member.profil})\n\n`;
|
||||
@ -304,33 +456,30 @@ async function handleTicketCreation(msg, chatId, linksData) {
|
||||
const userId = msg.from.id;
|
||||
const userStatus = ticketCreationStatus.get(chatId);
|
||||
|
||||
switch (userStatus.step) {
|
||||
case 'waiting_for_name':
|
||||
userStatus.step = 'waiting_for_email';
|
||||
userStatus.name = msg.text;
|
||||
bot.sendMessage(chatId, 'Danke! Bitte gib nun deine E-Mail-Adresse ein:')
|
||||
.catch((error) => {
|
||||
console.error('Fehler beim Senden der Aufforderung für den Namen:', error);
|
||||
});
|
||||
break;
|
||||
case 'waiting_for_email':
|
||||
userStatus.step = 'waiting_for_message';
|
||||
userStatus.email = msg.text;
|
||||
bot.sendMessage(chatId, 'Vielen Dank! Bitte schreibe jetzt deine Nachricht:')
|
||||
.catch((error) => {
|
||||
console.error('Fehler beim Senden der Aufforderung für die E-Mail:', error);
|
||||
});
|
||||
break;
|
||||
case 'waiting_for_message':
|
||||
userStatus.message = msg.text;
|
||||
sendTicketEmail(chatId, userStatus);
|
||||
ticketCreationStatus.delete(chatId);
|
||||
bot.sendMessage(chatId, 'Vielen Dank! Dein Ticket wurde erstellt. Wir melden uns bald bei dir.')
|
||||
.catch((error) => {
|
||||
console.error('Fehler beim Senden der Bestätigungsnachricht für das Ticket:', error);
|
||||
});
|
||||
handleMainMenu(msg, chatId, linksData);
|
||||
break;
|
||||
try {
|
||||
switch (userStatus.step) {
|
||||
case 'waiting_for_name':
|
||||
userStatus.step = 'waiting_for_email';
|
||||
userStatus.name = msg.text;
|
||||
bot.sendMessage(chatId, 'Danke! Bitte gib nun deine E-Mail-Adresse ein:');
|
||||
break;
|
||||
case 'waiting_for_email':
|
||||
userStatus.step = 'waiting_for_message';
|
||||
userStatus.email = msg.text;
|
||||
bot.sendMessage(chatId, 'Vielen Dank! Bitte schreibe jetzt deine Nachricht:');
|
||||
break;
|
||||
case 'waiting_for_message':
|
||||
userStatus.message = msg.text;
|
||||
sendTicketEmail(chatId, userStatus);
|
||||
ticketCreationStatus.delete(chatId);
|
||||
bot.sendMessage(chatId, 'Vielen Dank! Dein Ticket wurde erstellt. Wir melden uns bald bei dir.');
|
||||
handleMainMenu(msg, chatId, linksData);
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Fehler beim Ticket-Erstellen:', error);
|
||||
sendErrorNotification(error);
|
||||
bot.sendMessage(chatId, 'Es ist ein Fehler beim Erstellen des Tickets aufgetreten. Bitte versuche es später erneut.');
|
||||
}
|
||||
}
|
||||
|
||||
@ -356,7 +505,7 @@ function sendTicketEmail(chatId, ticketInfo) {
|
||||
const mailOptions = {
|
||||
from: `"${ticketInfo.name}" <${emailConfig.user}>`,
|
||||
to: emailConfig.recipient,
|
||||
subject: 'Supportanfrage',
|
||||
subject: 'Telegram Supportanfrage',
|
||||
text: `Name: ${ticketInfo.name}\nE-Mail: ${ticketInfo.email}\nNachricht: ${ticketInfo.message}`,
|
||||
};
|
||||
|
||||
@ -377,4 +526,4 @@ function sendTicketEmail(chatId, ticketInfo) {
|
||||
});
|
||||
}
|
||||
|
||||
initializeBot();
|
||||
initializeBot();
|
||||
|
52
team.json
52
team.json
@ -1,27 +1,27 @@
|
||||
[
|
||||
{
|
||||
"name": "Name",
|
||||
"position": "Administrator",
|
||||
"zustaendig": "Hosting & DEV - Support",
|
||||
"profil": "https://example.com"
|
||||
},
|
||||
{
|
||||
"name": "Florian",
|
||||
"position": "Moderator",
|
||||
"zustaendig": "Support ",
|
||||
"profil": "https://example.com"
|
||||
},
|
||||
{
|
||||
"name": "Name",
|
||||
"position": "Moderator",
|
||||
"zustaendig": "Support ",
|
||||
"profil": "https://example.com"
|
||||
},
|
||||
{
|
||||
"name": "Name",
|
||||
"position": "Discord Moderator",
|
||||
"zustaendig": "Discord",
|
||||
"profil": "https://example.com"
|
||||
}
|
||||
]
|
||||
[
|
||||
{
|
||||
"name": "Name",
|
||||
"position": "Administrator",
|
||||
"zustaendig": "Hosting & DEV - Support",
|
||||
"profil": "https://example.com"
|
||||
},
|
||||
{
|
||||
"name": "Name",
|
||||
"position": "Moderator",
|
||||
"zustaendig": "Support ",
|
||||
"profil": "https://example.com"
|
||||
},
|
||||
{
|
||||
"name": "Name",
|
||||
"position": "Moderator",
|
||||
"zustaendig": "Support ",
|
||||
"profil": "https://example.com"
|
||||
},
|
||||
{
|
||||
"name": "Name",
|
||||
"position": "Discord Moderator",
|
||||
"zustaendig": "Discord",
|
||||
"profil": "https://example.com"
|
||||
}
|
||||
]
|
||||
|
Reference in New Issue
Block a user