feat(telegram): drucker list command

This commit is contained in:
Stefan080106
2023-04-16 21:01:59 +02:00
parent 8897fb6321
commit 80881c29f3

View File

@@ -18,15 +18,25 @@ const bot = new TelegramBot(token, { polling: true });
bot.setMyCommands([
{ command: '/chatid', description: 'Zeigt deine Chat ID' },
{ command: '/druckerliste', description: 'Zeigt alle Drucker' },
])
bot.on('message', (msg) => {
bot.on('message', async (msg) => {
const chatId = msg.chat.id;
switch (msg.text) {
case '/chatid':
bot.sendMessage(chatId, 'Deine Chat ID ist: ' + chatId);
break;
case '/druckerliste':
let message = ""
const printers = await pdfLib.getPrinters()
printers.forEach((printer) => {
message += printer.deviceId + "\n"
});
bot.sendMessage(chatId, 'Drucker Liste:\n' + message);
default:
}