Библиотеки

Библиотека для связи вашей интеграции с Senler

https://github.com/SenlerBot/senler-integration-bot

npm i senler-integration-bot



import IntegrationConnect from "senler-integration-bot/IntegrationConnect";

const integrationConnect = new IntegrationConnect();
 
 //получение настроек от Senler
   integrationConnect.route('setData', (message) => {
        let settings = message.request.payload;
        if ('private' in settings) {
            console.log(JSON.parse(settings.private));
        }
        if ('public' in settings) {
            console.log(JSON.parse(settings.public))
        }
        message.responce.success = true;
        message.send();//отправить ответ
    });

 //запись настроек в Senler
    integrationConnect.route('getData', (message) => {
        message['responce'] = {
            payload: {},
            success: true
        };
        
        message.responce.payload['public'] =  JSON.parse(localStorage.getItem('tasksP'));
        message.responce.payload['private'] = JSON.parse(localStorage.getItem('tasks'));
        message.responce.payload['command_title'] = 'Бот шлет сообщение с подписчиком';

        message.send();//отправить ответ
    });

Last updated