Setting up a Telegram bot
Sooo…
First, you need to have a Unit already set up and running smoothly.
How to connect a Unit to a Telegram bot and control drying remotely:
- In Telegram, find @BotFather (https://t.me/BotFather), message it, and send /newbot, come up with a name for the bot in English, and then follow the instructions — basically a mini quest — after which you’ll get the HTTP API we need;
- Go into KIAUH and install the bot;
- Now you need to add to the bot config so you can control it. To do that, open the config file in an editor (depending on the system, the config may be in different folders)
nano /home/…../printer_data/config/telegram.conf
In the bot_token line, paste the API you got earlier from BotFather, and at this stage save the config file.
Then restart the bot and apply the config changes with: sudo systemctl restart moonraker-telegram-bot ;
4. Open our bot, which will accept commands from us to control the dryer, and send the /start command, but in response you’ll get an error like… Unauthorized access detected with chat id: 12345qwerty (at this stage we specifically need the chat id);
5. Open the Telegram bot config file from step 3 again and put the id from our bot’s message into the chat_id line. You also need to remove the timelapse section and save the config file, then restart the service (the command is in step 3).
After all these steps, the bot will send a message and should hopefully let you control the dryer using the configured macros ![]()
🇷🇺 Оригинал
Настройка телеграм бота
Итаааак…
Предварительно требуется настроенный и спокойно работающий Unit
Как подключить Unit к телеграмм боту и управлять сушкой удаленно:
- Ищем в телеграмме @BotFather (https://t.me/BotFather) стучимся к нему и пишем /newbot, придумываем название бота на Английском языке и следует инструкция, которую нужно пройти, почти квест, пройдя который мы получим нужный нам HTTP API;
- Заходим в KIAUH и устанавливаем бота;
- Теперь, нужно дополнить конфиг бота, для того что бы управлять им, для этого открываем в редакторе файл конфигурации (в зависимости от системы конфиг может находиться в различных папках)
nano /home/…../printer_data/config/telegram.conf
В строку bot_token вписываем ранее полученный API от Бота-отца и на данном этапе сохраняем файл конфига.
Далее для перезапуска бота и применения изменений в конфиге вводим: sudo systemctl restart moonraker-telegram-bot ; - Заходим в нашего бота, который будет принимать от нас команды для управления сушилкой и пишем команду /start, но в ответ получим ошибку вида… Unauthorized access detected with chat id: 12345qwerty (на этом этапе нам нужен именно chat id);
- Снова открываем файл конфигурации телеграмм бота из п.3 и вносим в строку chat_id id из сообщения нашего бота, также необходимо убрать секцию таймлапса и сохранить файл конфига, далее перезагрузить службу (команда в п.3)
После проделанных манипуляций бот напишет сообщение и возможно будет управлять сушилкой при помощи настроенных макросов