feat(telegram): drucker list command
This commit is contained in:
12
index.js
12
index.js
@@ -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:
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user