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([
|
bot.setMyCommands([
|
||||||
{ command: '/chatid', description: 'Zeigt deine Chat ID' },
|
{ 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;
|
const chatId = msg.chat.id;
|
||||||
|
|
||||||
switch (msg.text) {
|
switch (msg.text) {
|
||||||
case '/chatid':
|
case '/chatid':
|
||||||
bot.sendMessage(chatId, 'Deine Chat ID ist: ' + chatId);
|
bot.sendMessage(chatId, 'Deine Chat ID ist: ' + chatId);
|
||||||
break;
|
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:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user