Платные подписки в Telegram
Этот поток создает платные подписки для монетизации групп и каналов в Telegram.
- Когда пользователь запускает лэндинг-бота, ему отправляется описание доступных тарифов с кнопками выбора;
- После выбора тарифа пользователю предлагается выбрать способ оплаты. Для примера, данный поток интегрирован с ЮMoney;
- После выбора способа пользователь производит оплату, и ему приходят сообщения, открывающие доступ к группам/каналам, привязанным к оплаченному тарифу. Также вам приходит оповещение от админ-бота об оплате счета;
- Если у вас не настроены оповещения о входящих переводах ЮMoney или если после оплаты у пользователя не открылся доступ по какой-то причине, он может нажать кнопку «ОПЛАЧЕНО». Вам придет оповещение от админ-бота об оплате с номером счета и кнопкой «ДАТЬ ДОСТУП». Нажатие по кнопке откроет пользователю доступ по купленному тарифу;
- За сутки до истечения доступа пользователю приходит напоминание об этом с кнопкой, запускающей процесс продления;
- Если пользователь не продляет доступ, то по истечении оплаченного периода админ-бот исключает его из группы/канала, и он больше не может получить ссылку для вступления;
JSON потока#
[
{
"id": "9f3b9ed9.32299",
"type": "subflow",
"name": "Вх. перевод ЮMoney",
"info": "",
"category": "",
"in": [],
"out": [
{
"x": 680,
"y": 340,
"wires": [
{
"id": "cefafa22.d6bce8",
"port": 0
}
]
}
],
"env": [
{
"name": "URL",
"type": "str",
"value": "/yoomoney-clbck",
"ui": {
"label": {
"en-US": "URL"
},
"type": "input",
"opts": {
"types": [
"str"
]
}
}
},
{
"name": "SECRET",
"type": "str",
"value": "",
"ui": {
"label": {
"en-US": "Secret",
"ru": "Секрет"
}
}
}
],
"color": "#D8BFD8",
"icon": "font-awesome/fa-dollar"
},
{
"id": "cefafa22.d6bce8",
"type": "function",
"z": "9f3b9ed9.32299",
"name": "Проверка подлинности",
"func": "const crypto = global.get(\"require\")(\"crypto\");\nvar secret = env.get(\"SECRET\");\n\nconst params = [\"notification_type\", \"operation_id\", \"amount\", \"currency\", \"datetime\", \"sender\", \"codepro\", \"notification_secret\", \"label\"];\nconst paramVals = [];\nfor (let i=0; i<params.length; i++) {\n const param = params[i];\n if (param === \"notification_secret\") {\n paramVals.push(secret);\n } else {\n paramVals.push(msg.payload[param]);\n }\n}\nconst paramsStr = paramVals.join(\"&\");\n\nconst hash = crypto.createHash('sha1').update(paramsStr).digest(\"hex\");\n\nif (msg.payload.sha1_hash !== hash) {\n node.error(\"Неверный хэш!\", msg);\n} else {\n msg.yoomEvent = msg.payload;\n delete msg.payload;\n return msg; \n}",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 470,
"y": 340,
"wires": [
[]
]
},
{
"id": "b122747e.e510a8",
"type": "http in",
"z": "9f3b9ed9.32299",
"name": "",
"url": "${URL}",
"method": "post",
"upload": false,
"swaggerDoc": "",
"x": 210,
"y": 340,
"wires": [
[
"cefafa22.d6bce8",
"40e75a7f.3ef064"
]
]
},
{
"id": "40e75a7f.3ef064",
"type": "http response",
"z": "9f3b9ed9.32299",
"name": "",
"statusCode": "",
"headers": {
"content-type": "application/json"
},
"x": 410,
"y": 220,
"wires": []
},
{
"id": "b2e011e3.97a98",
"type": "tab",
"label": "TG Платная подписка",
"disabled": false,
"info": ""
},
{
"id": "44680096.71754",
"type": "inject",
"z": "b2e011e3.97a98",
"name": "Запустить настройку",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 200,
"y": 200,
"wires": [
[
"843d5888.dc1928"
]
]
},
{
"id": "58c2829d.46e99c",
"type": "comment",
"z": "b2e011e3.97a98",
"name": "АДМИНИСТРИРОВАНИЕ",
"info": "",
"x": 150,
"y": 80,
"wires": []
},
{
"id": "843d5888.dc1928",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "batch",
"queryType": "prepared",
"queryProp": "",
"queryText": "-- Продукты\nCREATE TABLE IF NOT EXISTS tgproducts (\n id INTEGER PRIMARY KEY AUTOINCREMENT, /* id продукта */\n name TEXT NOT NULL, /* название продукта */\n descr TEXT NOT NULL /* описание продукта и тарифов (текст первого сообщения) */\n);\n\n-- Тарифы продукта\nCREATE TABLE IF NOT EXISTS tgproduct_tariffs (\n id INTEGER PRIMARY KEY AUTOINCREMENT, /* id тарифа */\n product_id INTEGER NOT NULL, /* id продукта */\n enabled INTEGER NOT NULL, /* 1 - включен; 0 - выключен */\n name TEXT NOT NULL, /* название тарифа */\n price_rub INTEGER NOT NULL, /* цена в рос.рублях */\n pos INTEGER NOT NULL /* порядковый номер в списке кнопок */\n);\n\nCREATE INDEX IF NOT EXISTS idx_tgproudct_tariffs_product_id_enabled_pos\n ON tgproduct_tariffs (product_id, enabled, pos);\n\n-- Выдачи доступа в тарифе\nCREATE TABLE IF NOT EXISTS tgtariff_access (\n id INTEGER PRIMARY KEY AUTOINCREMENT, /* id элемента */\n tariff_id INTEGER NOT NULL, /* id тарифа, покупка которого выдает этот доступ */\n chat_id INTEGER NOT NULL, /* id tg группы или канала, куда давать доступ */\n days INTEGER NOT NULL, /* на сколько дней давать доступ */\n descr TEXT NOT NULL /* описание доступа (текст сообщения с выдачей доступа) */\n);\n\nCREATE INDEX IF NOT EXISTS idx_tgtariff_access_tariff_id\n ON tgtariff_access (tariff_id);\n\n-- Счета на оплату\nCREATE TABLE IF NOT EXISTS tginvoices (\n id TEXT PRIMARY KEY, /* id счета */\n user_id INTEGER NOT NULL, /* id tg юзера, запросившего счет */\n tariff_id INTEGER NOT NULL, /* id тарифа */\n price_rub INTEGER NOT NULL, /* цена выставленного счета в рос.рублях */\n chat_id INTEGER NOT NULL, /* id tg чата, в который был отправлен счет */\n message_id INTEGER NOT NULL, /* id tg сообщения со счетом */\n created_at INTEGER NOT NULL, /* метка времени создания счета */\n processed_at INTEGER NOT NULL /* метка времени обработки (оплаты) счета; 0 = не обработан */\n);\n\nCREATE UNIQUE INDEX IF NOT EXISTS idx_tginvoices_chat_id_message_id_tariff_id\n ON tginvoices (chat_id, message_id, tariff_id);\n\nCREATE INDEX IF NOT EXISTS idx_tginvoices_created_at\n ON tginvoices (created_at);\n\nCREATE INDEX IF NOT EXISTS idx_tginvoices_processed_at\n ON tginvoices (processed_at);\n\n-- Участники платных сообществ\nCREATE TABLE IF NOT EXISTS tgcommunity_members (\n chat_id INTEGER NOT NULL, /* id tg группы или канала с платным доступом */\n user_id INTEGER NOT NULL, /* id tg юзера участника, оплатившего доступ */\n expires_at INTEGER NOT NULL, /* метка времени окончания срока доступа */\n reminder_state INTEGER NOT NULL, /* номер отправленного напоминания об окончании */\n PRIMARY KEY (chat_id, user_id)\n);\n\nCREATE INDEX IF NOT EXISTS idx_tgcommunity_members_expires_at_reminder_state_user_id\n ON tgcommunity_members (expires_at, reminder_state, user_id);\n\n-- Ссылки для приглашения в платные сообщества\nCREATE TABLE IF NOT EXISTS tgcommunity_links (\n chat_id INTEGER PRIMARY KEY, /* id tg группы или канала с платным доступом */\n invite_link TEXT NOT NULL /* ссылка для приглашения */\n);\n\n-- Отправленные ссылки на платные сообщества (для сброса ссылок по таймеру)\nCREATE TABLE IF NOT EXISTS tglink_messages (\n chat_id INTEGER NOT NULL, /* id tg чата, в который было отправлена ссылка */\n message_id INTEGER NOT NULL, /* id tg сообщения со ссылкой */\n access_chat_id INTEGER NOT NULL, /* id tg чата, доступ к которому был выдан сообщением */\n PRIMARY KEY (chat_id, message_id)\n);\n",
"queryParamsType": "empty",
"queryParams": "",
"name": "Настр хранилищ данных",
"property": "payload",
"x": 510,
"y": 200,
"wires": [
[]
]
},
{
"id": "94524065.6e882",
"type": "inject",
"z": "b2e011e3.97a98",
"d": true,
"name": "Запустить удаление",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 200,
"y": 280,
"wires": [
[
"c087a22c.6cfae"
]
]
},
{
"id": "c087a22c.6cfae",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"d": true,
"storage": "6c999ed1.7d41f",
"exec": "batch",
"queryType": "prepared",
"queryProp": "",
"queryText": "DROP TABLE tgproducts;\nDROP TABLE tgproduct_tariffs;\nDROP TABLE tgtariff_access;\nDROP TABLE tginvoices;\nDROP TABLE tgcommunity_members;\nDROP TABLE tgcommunity_links;\nDROP TABLE tglink_messages;\n",
"queryParamsType": "empty",
"queryParams": "",
"name": "Удаление хранилищ данных",
"property": "payload",
"x": 530,
"y": 280,
"wires": [
[]
]
},
{
"id": "c4653f5e.6365",
"type": "inject",
"z": "b2e011e3.97a98",
"d": true,
"name": "Запустить очистку",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 190,
"y": 360,
"wires": [
[
"2aa65300.fcaffc"
]
]
},
{
"id": "2aa65300.fcaffc",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"d": true,
"storage": "6c999ed1.7d41f",
"exec": "batch",
"queryType": "prepared",
"queryProp": "",
"queryText": "DELETE FROM tgproducts;\nDELETE FROM tgproduct_tariffs;\nDELETE FROM tgtariff_access;\nDELETE FROM tginvoices;\nDELETE FROM tgcommunity_members;\nDELETE FROM tgcommunity_links;\nDELETE FROM tglink_messages;\n",
"queryParamsType": "empty",
"queryParams": "",
"name": "Очистка хранилищ данных",
"property": "payload",
"x": 520,
"y": 360,
"wires": [
[]
]
},
{
"id": "b5be82de.ad384",
"type": "inject",
"z": "b2e011e3.97a98",
"name": "Получить данные",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 190,
"y": 700,
"wires": [
[
"d4eb237e.bf551"
]
]
},
{
"id": "d4eb237e.bf551",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "SELECT * FROM tgcommunity_members;",
"queryParamsType": "empty",
"queryParams": "",
"name": "Получ участников",
"property": "payload",
"x": 410,
"y": 700,
"wires": [
[
"5642a40f.e87ebc"
]
]
},
{
"id": "5642a40f.e87ebc",
"type": "debug",
"z": "b2e011e3.97a98",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 655,
"y": 700,
"wires": [],
"l": false
},
{
"id": "7087eaa6.9863b4",
"type": "inject",
"z": "b2e011e3.97a98",
"name": "Получить данные",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 190,
"y": 740,
"wires": [
[
"e26ca99b.d78a68"
]
]
},
{
"id": "e26ca99b.d78a68",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "SELECT * FROM tgcommunity_links;",
"queryParamsType": "empty",
"queryParams": "",
"name": "Получ ссылки",
"property": "payload",
"x": 400,
"y": 740,
"wires": [
[
"8ad4d35.83e133"
]
]
},
{
"id": "8ad4d35.83e133",
"type": "debug",
"z": "b2e011e3.97a98",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 655,
"y": 740,
"wires": [],
"l": false
},
{
"id": "137e0352.cee3cd",
"type": "inject",
"z": "b2e011e3.97a98",
"name": "Получить данные",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 190,
"y": 780,
"wires": [
[
"a6d8e6da.240568"
]
]
},
{
"id": "a6d8e6da.240568",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "SELECT * FROM tglink_messages;",
"queryParamsType": "empty",
"queryParams": "",
"name": "Получ сообщ со ссылками",
"property": "payload",
"x": 440,
"y": 780,
"wires": [
[
"d96020d9.b3df3"
]
]
},
{
"id": "d96020d9.b3df3",
"type": "debug",
"z": "b2e011e3.97a98",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 655,
"y": 780,
"wires": [],
"l": false
},
{
"id": "846f9656.4d1ba8",
"type": "drom-tg-updates",
"z": "b2e011e3.97a98",
"name": "Обновления лэндинг-бота",
"method": "longpoll",
"property": "tgUpdate",
"client": "4497dbb.2648f24",
"x": 200,
"y": 1200,
"wires": [
[
"e58fed3c.8debb"
]
]
},
{
"id": "b80116a8.afb758",
"type": "drom-tg-switch-update",
"z": "b2e011e3.97a98",
"name": "Какое обновление?",
"tgUpdate": "tgUpdate",
"property": "tgUpdateObj",
"updates": [
"message",
"callback_query"
],
"outputs": 2,
"x": 820,
"y": 1340,
"wires": [
[
"51883c2a.a69244"
],
[
"e7c0b145.5b40d"
]
]
},
{
"id": "d6f4cdaa.c6187",
"type": "drom-tg-api-call",
"z": "b2e011e3.97a98",
"name": "Отправ/редакт сообщ",
"data": "apiData",
"dataType": "msg",
"method": "apiMethod",
"methodType": "msg",
"property": "payload",
"client": "4497dbb.2648f24",
"x": 2280,
"y": 1300,
"wires": [
[]
]
},
{
"id": "71ac86ac.699b08",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "set",
"p": "apiData.chat_id",
"pt": "msg",
"to": "tgUpdateObj.chat.id",
"tot": "msg"
},
{
"t": "set",
"p": "apiMethod",
"pt": "msg",
"to": "sendMessage",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1335,
"y": 1280,
"wires": [
[
"aba0f533.f3eb88"
]
],
"l": false
},
{
"id": "b5930060.1f264",
"type": "function",
"z": "b2e011e3.97a98",
"name": "Клавиатура",
"func": "const btns = [];\n\nfor (let tariff of msg.tariffs) {\n btns.push([{\n text: `${tariff.name} (${tariff.price_rub} ₱)`,\n \"callback_data\": \"buy:\" + tariff.id\n }])\n}\n\nmsg.apiData.reply_markup = {\n \"inline_keyboard\": btns\n};\n\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 2010,
"y": 1300,
"wires": [
[
"fa87e7e7.87ada8"
]
]
},
{
"id": "f2c4212d.7e9dc",
"type": "drom-tg-api-call",
"z": "b2e011e3.97a98",
"name": "Редакт сообщ",
"data": "apiData",
"dataType": "msg",
"method": "editMessageText",
"methodType": "str",
"property": "payload",
"client": "4497dbb.2648f24",
"x": 3300,
"y": 1580,
"wires": [
[]
]
},
{
"id": "d56324ca.3359e8",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "set",
"p": "apiData.chat_id",
"pt": "msg",
"to": "tgUpdateObj.message.chat.id",
"tot": "msg"
},
{
"t": "set",
"p": "apiData.message_id",
"pt": "msg",
"to": "tgUpdateObj.message.message_id",
"tot": "msg"
},
{
"t": "set",
"p": "apiData.parse_mode",
"pt": "msg",
"to": "HTML",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 3175,
"y": 1580,
"wires": [
[
"f2c4212d.7e9dc"
]
],
"l": false
},
{
"id": "61901c8d.0c84f4",
"type": "drom-template",
"z": "b2e011e3.97a98",
"name": "Выберите способ оплаты",
"field": "apiData.text",
"fieldType": "msg",
"syntax": "handlebars",
"htmlEscape": true,
"template": "{{product.name}}: {{tariff.name}}\nЦена: {{tariff.price_rub}} ₱\n\n<b>Выберите способ оплаты:</b>",
"x": 2880,
"y": 1420,
"wires": [
[
"991cbc5c.46a03"
]
]
},
{
"id": "991cbc5c.46a03",
"type": "function",
"z": "b2e011e3.97a98",
"name": "Клавиатура",
"func": "msg.apiData.reply_markup = {\n \"inline_keyboard\": [\n [\n {\n \"text\": \"Банк.карта/ЮMoney\",\n \"callback_data\": \"pay:\" + msg.tariff.id + \":yoom\"\n }\n ],\n [\n {\n \"text\": \"◀ Назад\",\n \"callback_data\": \"start\"\n }\n ]\n ]\n};\n\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 2930,
"y": 1460,
"wires": [
[
"d56324ca.3359e8"
]
]
},
{
"id": "e7c0b145.5b40d",
"type": "drom-switch-str",
"z": "b2e011e3.97a98",
"name": "Какие данные запроса?",
"inString": "tgUpdateObj.data",
"inStringType": "msg",
"rules": [
{
"t": "eq",
"v": "start",
"vt": "str",
"case": true
},
{
"t": "start",
"v": "buy:",
"vt": "str",
"case": true,
"extract": true
},
{
"t": "start",
"v": "pay:",
"vt": "str",
"case": true,
"extract": true
},
{
"t": "start",
"v": "paid:",
"vt": "str",
"case": true,
"extract": true
},
{
"t": "start",
"v": "getlink:",
"vt": "str",
"case": true,
"extract": true
}
],
"outputs": 5,
"property": "data",
"x": 1110,
"y": 1500,
"wires": [
[
"ef49aff1.29e13"
],
[
"5f572bb3.e56094"
],
[
"8df2e07e.82967"
],
[
"b8eb5bd6.b21858"
],
[
"711f3f00.35af8"
]
]
},
{
"id": "7742c953.7343a8",
"type": "drom-switch-str",
"z": "b2e011e3.97a98",
"name": "Какой метод оплаты?",
"inString": "data",
"inStringType": "msg",
"rules": [
{
"t": "end",
"v": ":yoom",
"vt": "str",
"case": true,
"extract": false
}
],
"outputs": 1,
"property": "invoiceId",
"x": 2420,
"y": 1580,
"wires": [
[
"4459ccfe.ef0a74"
]
]
},
{
"id": "f333cd11.eb2eb",
"type": "drom-template",
"z": "b2e011e3.97a98",
"name": "Перейти к оплате",
"field": "apiData.text",
"fieldType": "msg",
"syntax": "handlebars",
"htmlEscape": false,
"template": "📃 Счет {{invoice.id}}\n\n{{product.name}}: {{tariff.name}}\nЦена: {{invoice.price_rub}} ₱\n\nПосле оплаты Вам придет сообщение с доступом. Если в течение 5 минут после оплаты ничего не произошло, нажмите кнопку \"оплачено\".",
"x": 2910,
"y": 1560,
"wires": [
[
"d0b278d7.e12928"
]
]
},
{
"id": "d0b278d7.e12928",
"type": "function",
"z": "b2e011e3.97a98",
"name": "Клавиатура",
"func": "const receiver = msg.yoom;\nconst price = msg.invoice.price_rub;\nconst descr = `${msg.product.name}: ${msg.tariff.name}`;\nconst orderId = msg.invoice.id;\n\nmsg.apiData.reply_markup = {\n \"inline_keyboard\": [\n [\n {\n \"text\": \"🏦 Перейти к оплате\",\n \"url\": `https://yoomoney.ru/quickpay/confirm.xml?receiver=${receiver}&quickpay-form=donate&targets=${encodeURIComponent(descr.substring(0,150))}&sum=${price}&label=${orderId}&formcomment=${encodeURIComponent(descr.substring(0,50))}&short-dest=${encodeURIComponent(descr.substring(0,50))}`\n }\n ],\n [\n {\n \"text\": \"⏳ Оплачено\",\n \"callback_data\": \"paid:\"+orderId\n }\n ],\n [\n {\n \"text\": \"◀ Назад\",\n \"callback_data\": \"buy:\"+msg.tariff.id\n }\n ]\n ]\n};\n\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 2930,
"y": 1600,
"wires": [
[
"d56324ca.3359e8"
]
]
},
{
"id": "ef49aff1.29e13",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "set",
"p": "apiData.chat_id",
"pt": "msg",
"to": "tgUpdateObj.message.chat.id",
"tot": "msg"
},
{
"t": "set",
"p": "apiData.message_id",
"pt": "msg",
"to": "tgUpdateObj.message.message_id",
"tot": "msg"
},
{
"t": "set",
"p": "apiMethod",
"pt": "msg",
"to": "editMessageText",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1335,
"y": 1320,
"wires": [
[
"aba0f533.f3eb88"
]
],
"l": false
},
{
"id": "ed62e97b.581a28",
"type": "inject",
"z": "b2e011e3.97a98",
"name": "Получить все продукты",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 970,
"y": 200,
"wires": [
[
"a5080652.713058"
]
]
},
{
"id": "a5080652.713058",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "SELECT * FROM tgproducts;",
"queryParamsType": "empty",
"queryParams": "",
"name": "Получ продукты",
"property": "payload",
"x": 1650,
"y": 200,
"wires": [
[
"47886420.7dd5ec"
]
]
},
{
"id": "47886420.7dd5ec",
"type": "debug",
"z": "b2e011e3.97a98",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 1795,
"y": 200,
"wires": [],
"l": false
},
{
"id": "25a1eb8f.1e4f34",
"type": "inject",
"z": "b2e011e3.97a98",
"name": "Получить все тарифы",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 2120,
"y": 200,
"wires": [
[
"c6827749.911108"
]
]
},
{
"id": "c6827749.911108",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "SELECT * FROM tgproduct_tariffs;",
"queryParamsType": "empty",
"queryParams": "",
"name": "Получ тарифы",
"property": "payload",
"x": 2800,
"y": 200,
"wires": [
[
"67d08b0a.7efc44"
]
]
},
{
"id": "67d08b0a.7efc44",
"type": "debug",
"z": "b2e011e3.97a98",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 2935,
"y": 200,
"wires": [],
"l": false
},
{
"id": "d1a17e78.3877",
"type": "inject",
"z": "b2e011e3.97a98",
"name": "Получить данные",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 190,
"y": 640,
"wires": [
[
"12216221.c71bee"
]
]
},
{
"id": "12216221.c71bee",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "SELECT * FROM tginvoices;",
"queryParamsType": "empty",
"queryParams": "",
"name": "Получ счетов на оплату",
"property": "payload",
"x": 430,
"y": 640,
"wires": [
[
"d46d6430.05c5f8"
]
]
},
{
"id": "d46d6430.05c5f8",
"type": "debug",
"z": "b2e011e3.97a98",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 655,
"y": 640,
"wires": [],
"l": false
},
{
"id": "4223f32e.4b366c",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "INSERT INTO tgproducts (\n name,\n descr\n) VALUES (?, ?);",
"queryParamsType": "msg",
"queryParams": "sqlParams",
"name": "Добав продукт",
"property": "payload",
"x": 1640,
"y": 300,
"wires": [
[]
]
},
{
"id": "13005a0b.c38916",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "set",
"p": "sqlParams[0]",
"pt": "msg",
"to": "name",
"tot": "msg"
},
{
"t": "set",
"p": "sqlParams[1]",
"pt": "msg",
"to": "descr",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1515,
"y": 300,
"wires": [
[
"4223f32e.4b366c"
]
],
"l": false
},
{
"id": "6c133d74.5eea74",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "UPDATE tgproducts\nSET name = ?, descr = ?\nWHERE id = ?;",
"queryParamsType": "msg",
"queryParams": "sqlParams",
"name": "Изм продукт",
"property": "payload",
"x": 1630,
"y": 400,
"wires": [
[]
]
},
{
"id": "9d537de7.532c1",
"type": "inject",
"z": "b2e011e3.97a98",
"name": "Добавить продукт",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 1010,
"y": 280,
"wires": [
[
"338b08e2.1cc6d8"
]
]
},
{
"id": "338b08e2.1cc6d8",
"type": "change",
"z": "b2e011e3.97a98",
"name": "📝 Название продукта",
"rules": [
{
"t": "set",
"p": "name",
"pt": "msg",
"to": "Мой продукт",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1250,
"y": 260,
"wires": [
[
"1e3b2cfd.b79393"
]
]
},
{
"id": "d41b988a.f71b38",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "set",
"p": "sqlParams[0]",
"pt": "msg",
"to": "name",
"tot": "msg"
},
{
"t": "set",
"p": "sqlParams[1]",
"pt": "msg",
"to": "descr",
"tot": "msg"
},
{
"t": "set",
"p": "sqlParams[2]",
"pt": "msg",
"to": "id",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1515,
"y": 400,
"wires": [
[
"6c133d74.5eea74"
]
],
"l": false
},
{
"id": "776f00c9.e5686",
"type": "change",
"z": "b2e011e3.97a98",
"name": "📝 Новое название продукта",
"rules": [
{
"t": "set",
"p": "name",
"pt": "msg",
"to": "Тест продукт",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1270,
"y": 400,
"wires": [
[
"7000ea1d.d7e3d4"
]
]
},
{
"id": "ed54fdb7.7f649",
"type": "change",
"z": "b2e011e3.97a98",
"name": "🆔 id продукта для правки",
"rules": [
{
"t": "set",
"p": "id",
"pt": "msg",
"to": "1",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1260,
"y": 360,
"wires": [
[
"776f00c9.e5686"
]
]
},
{
"id": "3abc9a1e.404f86",
"type": "inject",
"z": "b2e011e3.97a98",
"name": "Изменить продукт",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 1010,
"y": 380,
"wires": [
[
"ed54fdb7.7f649"
]
]
},
{
"id": "e58fed3c.8debb",
"type": "change",
"z": "b2e011e3.97a98",
"name": "🆔 Id продукта",
"rules": [
{
"t": "set",
"p": "prodId",
"pt": "msg",
"to": "1",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 240,
"y": 1260,
"wires": [
[
"7d2d5575.66b1ac"
]
]
},
{
"id": "7d2d5575.66b1ac",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "set",
"p": "sqlParams[0]",
"pt": "msg",
"to": "prodId",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 455,
"y": 1320,
"wires": [
[
"92afdcf8.73772"
]
],
"l": false
},
{
"id": "92afdcf8.73772",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "SELECT * FROM tgproducts WHERE id=?;",
"queryParamsType": "msg",
"queryParams": "sqlParams",
"name": "Получ продукт",
"property": "product",
"x": 520,
"y": 1360,
"wires": [
[
"519304fe.058a5c"
]
]
},
{
"id": "519304fe.058a5c",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "delete",
"p": "sqlParams",
"pt": "msg"
},
{
"t": "move",
"p": "product[0]",
"pt": "msg",
"to": "product",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 595,
"y": 1320,
"wires": [
[
"b80116a8.afb758"
]
],
"l": false
},
{
"id": "62d502e7.0efd2c",
"type": "comment",
"z": "b2e011e3.97a98",
"name": "Продукты",
"info": "",
"x": 900,
"y": 140,
"wires": []
},
{
"id": "1babfc37.2eb654",
"type": "comment",
"z": "b2e011e3.97a98",
"name": "Тарифы",
"info": "",
"x": 2060,
"y": 140,
"wires": []
},
{
"id": "fa308a8c.46f588",
"type": "comment",
"z": "b2e011e3.97a98",
"name": "Хранилища данных",
"info": "",
"x": 170,
"y": 140,
"wires": []
},
{
"id": "1c739c9f.0d7003",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "INSERT INTO tgproduct_tariffs (\n product_id,\n enabled,\n name,\n price_rub,\n pos\n) VALUES (?,1,?,?,0);",
"queryParamsType": "msg",
"queryParams": "sqlParams",
"name": "Добав тариф",
"property": "payload",
"x": 2800,
"y": 340,
"wires": [
[]
]
},
{
"id": "9c7374c9.0b96a8",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "set",
"p": "sqlParams[0]",
"pt": "msg",
"to": "product_id",
"tot": "msg"
},
{
"t": "set",
"p": "sqlParams[1]",
"pt": "msg",
"to": "name",
"tot": "msg"
},
{
"t": "set",
"p": "sqlParams[2]",
"pt": "msg",
"to": "price_rub",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 2675,
"y": 340,
"wires": [
[
"1c739c9f.0d7003"
]
],
"l": false
},
{
"id": "ad1b2e5a.89f12",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "UPDATE tgproduct_tariffs\nSET name = ?,\n price_rub = ?\nWHERE id = ?;",
"queryParamsType": "msg",
"queryParams": "sqlParams",
"name": "Изм тариф",
"property": "payload",
"x": 2790,
"y": 440,
"wires": [
[]
]
},
{
"id": "f31c2784.f5aee8",
"type": "inject",
"z": "b2e011e3.97a98",
"name": "Добавить тариф",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 2160,
"y": 340,
"wires": [
[
"b68cb9d1.60b1a8"
]
]
},
{
"id": "b68cb9d1.60b1a8",
"type": "change",
"z": "b2e011e3.97a98",
"name": "📝 Данные тарифа",
"rules": [
{
"t": "set",
"p": "product_id",
"pt": "msg",
"to": "1",
"tot": "num"
},
{
"t": "set",
"p": "name",
"pt": "msg",
"to": "1 месяц",
"tot": "str"
},
{
"t": "set",
"p": "price_rub",
"pt": "msg",
"to": "900",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 2400,
"y": 340,
"wires": [
[
"9c7374c9.0b96a8"
]
]
},
{
"id": "f3b7ec06.20b7e",
"type": "change",
"z": "b2e011e3.97a98",
"name": "🆔 id тарифа для правки",
"rules": [
{
"t": "set",
"p": "id",
"pt": "msg",
"to": "1",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 2410,
"y": 400,
"wires": [
[
"bb0faad4.7ba688"
]
]
},
{
"id": "e5d13675.b58558",
"type": "inject",
"z": "b2e011e3.97a98",
"name": "Изменить тариф",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 2160,
"y": 420,
"wires": [
[
"f3b7ec06.20b7e"
]
]
},
{
"id": "b2538a32.9e2878",
"type": "inject",
"z": "b2e011e3.97a98",
"name": "Получить активные тарифы продукта",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 2170,
"y": 260,
"wires": [
[
"8ca03eb6.0d58f"
]
]
},
{
"id": "222bc91b.fbe9a6",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "SELECT * FROM tgproduct_tariffs WHERE product_id=? AND enabled=1;",
"queryParamsType": "msg",
"queryParams": "sqlParams",
"name": "Получ тарифы",
"property": "payload",
"x": 2800,
"y": 260,
"wires": [
[
"695201f2.eac3d"
]
]
},
{
"id": "695201f2.eac3d",
"type": "debug",
"z": "b2e011e3.97a98",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 2935,
"y": 260,
"wires": [],
"l": false
},
{
"id": "8ca03eb6.0d58f",
"type": "change",
"z": "b2e011e3.97a98",
"name": "🆔 id продукта",
"rules": [
{
"t": "set",
"p": "product_id",
"pt": "msg",
"to": "1",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 2440,
"y": 260,
"wires": [
[
"4613c92f.49e688"
]
]
},
{
"id": "4613c92f.49e688",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "set",
"p": "sqlParams[0]",
"pt": "msg",
"to": "product_id",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 2675,
"y": 260,
"wires": [
[
"222bc91b.fbe9a6"
]
],
"l": false
},
{
"id": "bb0faad4.7ba688",
"type": "change",
"z": "b2e011e3.97a98",
"name": "📝 Новые данные тарифа",
"rules": [
{
"t": "set",
"p": "name",
"pt": "msg",
"to": "1 месяц",
"tot": "str"
},
{
"t": "set",
"p": "price_rub",
"pt": "msg",
"to": "950",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 2420,
"y": 440,
"wires": [
[
"8b5bec24.9b467"
]
]
},
{
"id": "8b5bec24.9b467",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "set",
"p": "sqlParams[0]",
"pt": "msg",
"to": "name",
"tot": "msg"
},
{
"t": "set",
"p": "sqlParams[1]",
"pt": "msg",
"to": "price_rub",
"tot": "msg"
},
{
"t": "set",
"p": "sqlParams[2]",
"pt": "msg",
"to": "id",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 2675,
"y": 440,
"wires": [
[
"ad1b2e5a.89f12"
]
],
"l": false
},
{
"id": "70326910.0a40d8",
"type": "change",
"z": "b2e011e3.97a98",
"name": "🆔 id тарифа для отключения",
"rules": [
{
"t": "set",
"p": "id",
"pt": "msg",
"to": "1",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 2430,
"y": 520,
"wires": [
[
"8bd29b4d.bf2ed8"
]
]
},
{
"id": "d2fdcdcb.e923d",
"type": "inject",
"z": "b2e011e3.97a98",
"name": "Отключить тариф",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 2170,
"y": 520,
"wires": [
[
"70326910.0a40d8"
]
]
},
{
"id": "8bd29b4d.bf2ed8",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "set",
"p": "sqlParams[0]",
"pt": "msg",
"to": "id",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 2675,
"y": 520,
"wires": [
[
"d625b945.258bb8"
]
],
"l": false
},
{
"id": "d625b945.258bb8",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "UPDATE tgproduct_tariffs\nSET enabled = 0\nWHERE id = ?;",
"queryParamsType": "msg",
"queryParams": "sqlParams",
"name": "Изм тариф",
"property": "payload",
"x": 2790,
"y": 520,
"wires": [
[]
]
},
{
"id": "f5ed5d44.34967",
"type": "change",
"z": "b2e011e3.97a98",
"name": "🆔 id тарифа для включения",
"rules": [
{
"t": "set",
"p": "id",
"pt": "msg",
"to": "1",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 2430,
"y": 600,
"wires": [
[
"9b74a177.6aaaa"
]
]
},
{
"id": "d51ae3db.0eb16",
"type": "inject",
"z": "b2e011e3.97a98",
"name": "Включить тариф",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 2160,
"y": 600,
"wires": [
[
"f5ed5d44.34967"
]
]
},
{
"id": "9b74a177.6aaaa",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "set",
"p": "sqlParams[0]",
"pt": "msg",
"to": "id",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 2675,
"y": 600,
"wires": [
[
"c61a7711.220ad8"
]
],
"l": false
},
{
"id": "c61a7711.220ad8",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "UPDATE tgproduct_tariffs\nSET enabled = 1\nWHERE id = ?;",
"queryParamsType": "msg",
"queryParams": "sqlParams",
"name": "Изм тариф",
"property": "payload",
"x": 2790,
"y": 600,
"wires": [
[]
]
},
{
"id": "aba0f533.f3eb88",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "set",
"p": "sqlParams[0]",
"pt": "msg",
"to": "prodId",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1555,
"y": 1300,
"wires": [
[
"8c0b1df7.a219b"
]
],
"l": false
},
{
"id": "8c0b1df7.a219b",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "SELECT id, name, price_rub FROM tgproduct_tariffs WHERE product_id=? AND enabled=1 ORDER BY pos;",
"queryParamsType": "msg",
"queryParams": "sqlParams",
"name": "Получ активные тарифы",
"property": "tariffs",
"x": 1710,
"y": 1300,
"wires": [
[
"b5930060.1f264"
]
]
},
{
"id": "4859d56a.e9424c",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "SELECT id, name, price_rub FROM tgproduct_tariffs WHERE id=?;",
"queryParamsType": "msg",
"queryParams": "sqlParams",
"name": "Получ выбранный тариф",
"property": "tariff",
"x": 1650,
"y": 1460,
"wires": [
[
"ef17fcb1.8c24b"
]
]
},
{
"id": "3245d3a4.5e380c",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "set",
"p": "sqlParams[0]",
"pt": "msg",
"to": "tariffId",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1555,
"y": 1420,
"wires": [
[
"4859d56a.e9424c"
]
],
"l": false
},
{
"id": "ef17fcb1.8c24b",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "move",
"p": "tariff[0]",
"pt": "msg",
"to": "tariff",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1755,
"y": 1420,
"wires": [
[
"61901c8d.0c84f4"
]
],
"l": false
},
{
"id": "f4b61a16.c3f558",
"type": "comment",
"z": "b2e011e3.97a98",
"name": "ЛЭНДИНГ БОТ",
"info": "",
"x": 120,
"y": 1140,
"wires": []
},
{
"id": "d0f41568.8babd8",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "delete",
"p": "sqlParams",
"pt": "msg"
},
{
"t": "set",
"p": "sqlParams[0]",
"pt": "msg",
"to": "id",
"tot": "msg"
},
{
"t": "set",
"p": "sqlParams[1]",
"pt": "msg",
"to": "tgUpdateObj.message.chat.id",
"tot": "msg"
},
{
"t": "set",
"p": "sqlParams[2]",
"pt": "msg",
"to": "tariffId",
"tot": "msg"
},
{
"t": "set",
"p": "sqlParams[3]",
"pt": "msg",
"to": "tariff.price_rub",
"tot": "msg"
},
{
"t": "set",
"p": "sqlParams[4]",
"pt": "msg",
"to": "tgUpdateObj.message.chat.id",
"tot": "msg"
},
{
"t": "set",
"p": "sqlParams[5]",
"pt": "msg",
"to": "tgUpdateObj.message.message_id",
"tot": "msg"
},
{
"t": "set",
"p": "sqlParams[6]",
"pt": "msg",
"to": "",
"tot": "date"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1855,
"y": 1600,
"wires": [
[
"85ee6f9b.c66f6"
]
],
"l": false
},
{
"id": "85ee6f9b.c66f6",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "INSERT OR IGNORE INTO tginvoices (\n id, user_id, tariff_id, price_rub, chat_id, message_id, created_at, processed_at\n) VALUES (?, ?, ?, ?, ?, ?, ?, 0);\n",
"queryParamsType": "msg",
"queryParams": "sqlParams",
"name": "Добав счет",
"property": "payload",
"x": 1970,
"y": 1600,
"wires": [
[
"6b00b3c7.eae42c"
]
]
},
{
"id": "a259d2dd.8b6d",
"type": "function",
"z": "b2e011e3.97a98",
"name": "id заказа",
"func": "const enc_ts = Date.now().toString(36);\n\nlet enc_rand = \"\";\nfor (let i=0; i<10; i++) {\n enc_rand += (Math.round(Math.random()*35)).toString(36);\n}\n\nmsg.id = (enc_rand + enc_ts).toUpperCase();\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 1900,
"y": 1560,
"wires": [
[
"d0f41568.8babd8"
]
]
},
{
"id": "6b00b3c7.eae42c",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "delete",
"p": "sqlParams",
"pt": "msg"
},
{
"t": "set",
"p": "sqlParams[0]",
"pt": "msg",
"to": "tgUpdateObj.message.chat.id",
"tot": "msg"
},
{
"t": "set",
"p": "sqlParams[1]",
"pt": "msg",
"to": "tgUpdateObj.message.message_id",
"tot": "msg"
},
{
"t": "set",
"p": "sqlParams[2]",
"pt": "msg",
"to": "tariff.id",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 2135,
"y": 1560,
"wires": [
[
"bc5b0c40.fa79a"
]
],
"l": false
},
{
"id": "bc5b0c40.fa79a",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "SELECT * FROM tginvoices WHERE chat_id = ? AND message_id = ? AND tariff_id = ?;\n",
"queryParamsType": "msg",
"queryParams": "sqlParams",
"name": "Получ счет",
"property": "invoice",
"x": 2190,
"y": 1600,
"wires": [
[
"5cb19f18.a49c2"
]
]
},
{
"id": "5cb19f18.a49c2",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "move",
"p": "invoice[0]",
"pt": "msg",
"to": "invoice",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 2255,
"y": 1560,
"wires": [
[
"7742c953.7343a8"
]
],
"l": false
},
{
"id": "5f572bb3.e56094",
"type": "change",
"z": "b2e011e3.97a98",
"name": "tariffId",
"rules": [
{
"t": "move",
"p": "data",
"pt": "msg",
"to": "tariffId",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1370,
"y": 1420,
"wires": [
[
"3245d3a4.5e380c"
]
]
},
{
"id": "501a244d.e36e8c",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "delete",
"p": "sqlParams",
"pt": "msg"
},
{
"t": "set",
"p": "sqlParams[0]",
"pt": "msg",
"to": "invoiceId",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 195,
"y": 2880,
"wires": [
[
"7a165c04.3a6e84"
]
],
"l": false
},
{
"id": "7a165c04.3a6e84",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "SELECT * FROM tginvoices WHERE id = ?;\n",
"queryParamsType": "msg",
"queryParams": "sqlParams",
"name": "Получ счет",
"property": "invoice",
"x": 250,
"y": 2920,
"wires": [
[
"92137570.ac1cc8"
]
]
},
{
"id": "92137570.ac1cc8",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "move",
"p": "invoice[0]",
"pt": "msg",
"to": "invoice",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 315,
"y": 2880,
"wires": [
[
"3a961788.eb2188"
]
],
"l": false
},
{
"id": "e65ad63c.f678b8",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "delete",
"p": "sqlParams",
"pt": "msg"
},
{
"t": "set",
"p": "sqlParams[0]",
"pt": "msg",
"to": "invoice.tariff_id",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 795,
"y": 2900,
"wires": [
[
"619815a4.a636cc"
]
],
"l": false
},
{
"id": "1e3b2cfd.b79393",
"type": "drom-template",
"z": "b2e011e3.97a98",
"name": "📝 Описание продукта",
"field": "descr",
"fieldType": "msg",
"syntax": "plain",
"htmlEscape": false,
"template": "Есть несколько тарифов для получения доступа к сообществу на 1/3/6/12 месяцев.\n\n<b>Выберите Ваш тарифный план</b>",
"x": 1250,
"y": 300,
"wires": [
[
"13005a0b.c38916"
]
]
},
{
"id": "fa87e7e7.87ada8",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "set",
"p": "apiData.text",
"pt": "msg",
"to": "product.descr",
"tot": "msg"
},
{
"t": "set",
"p": "apiData.parse_mode",
"pt": "msg",
"to": "HTML",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 2135,
"y": 1300,
"wires": [
[
"d6f4cdaa.c6187"
]
],
"l": false
},
{
"id": "8df2e07e.82967",
"type": "drom-extractor",
"z": "b2e011e3.97a98",
"extractor": "int",
"occurence": "",
"occurenceType": "first",
"separator": "",
"separatorType": "reWhitespace",
"name": "tariffId",
"inText": "data",
"property": "tariffId",
"x": 1370,
"y": 1560,
"wires": [
[
"4da92fb.5f10dd"
]
]
},
{
"id": "242e33db.c5b14c",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "SELECT id, name, price_rub FROM tgproduct_tariffs WHERE id=?;",
"queryParamsType": "msg",
"queryParams": "sqlParams",
"name": "Получ выбранный тариф",
"property": "tariff",
"x": 1650,
"y": 1600,
"wires": [
[
"e02c6f81.d1914"
]
]
},
{
"id": "4da92fb.5f10dd",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "set",
"p": "sqlParams[0]",
"pt": "msg",
"to": "tariffId",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1555,
"y": 1560,
"wires": [
[
"242e33db.c5b14c"
]
],
"l": false
},
{
"id": "e02c6f81.d1914",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "move",
"p": "tariff[0]",
"pt": "msg",
"to": "tariff",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1755,
"y": 1560,
"wires": [
[
"a259d2dd.8b6d"
]
],
"l": false
},
{
"id": "5a54b357.c9768c",
"type": "subflow:9f3b9ed9.32299",
"z": "b2e011e3.97a98",
"name": "",
"env": [
{
"name": "SECRET",
"type": "cred"
},
{
"name": "secret",
"type": "cred"
}
],
"x": 180,
"y": 2520,
"wires": [
[
"e60d5c40.c4257"
]
]
},
{
"id": "ba01b23b.be604",
"type": "switch",
"z": "b2e011e3.97a98",
"name": "Есть такой счет?",
"property": "invoice",
"propertyType": "msg",
"rules": [
{
"t": "nempty"
},
{
"t": "else"
}
],
"checkall": "false",
"repair": false,
"outputs": 2,
"x": 810,
"y": 2540,
"wires": [
[
"97c102f5.e1725"
],
[
"f6310c00.4eea5"
]
],
"outputLabels": [
"Да",
"Нет"
]
},
{
"id": "6b9e882f.f4ba78",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "SELECT * FROM tginvoices WHERE id = ?;\n",
"queryParamsType": "msg",
"queryParams": "sqlParams",
"name": "Получ счет",
"property": "invoice",
"x": 570,
"y": 2540,
"wires": [
[
"ba01b23b.be604"
]
]
},
{
"id": "97c102f5.e1725",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "move",
"p": "invoice[0]",
"pt": "msg",
"to": "invoice",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 955,
"y": 2520,
"wires": [
[
"b29927aa.3dc188"
]
],
"l": false
},
{
"id": "e60d5c40.c4257",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "set",
"p": "sqlParams[0]",
"pt": "msg",
"to": "yoomEvent.label",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 455,
"y": 2540,
"wires": [
[
"6b9e882f.f4ba78"
]
],
"l": false
},
{
"id": "94172ebc.3492f",
"type": "comment",
"z": "b2e011e3.97a98",
"name": "ОПОВЕЩЕНИЯ ОТ ЮMONEY",
"info": "",
"x": 170,
"y": 2460,
"wires": []
},
{
"id": "6090edd5.435624",
"type": "drom-tg-api-call",
"z": "b2e011e3.97a98",
"name": "Отправка сообщ админу",
"data": "apiData",
"dataType": "msg",
"method": "sendMessage",
"methodType": "str",
"property": "payload",
"client": "55c122b.68894dc",
"x": 3150,
"y": 2440,
"wires": [
[]
]
},
{
"id": "e88f45d6.df2d18",
"type": "change",
"z": "b2e011e3.97a98",
"name": "🆔 Id админа",
"rules": [
{
"t": "set",
"p": "apiData.chat_id",
"pt": "msg",
"to": "123",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 3060,
"y": 2400,
"wires": [
[
"e56a64db.05a768"
]
]
},
{
"id": "e56a64db.05a768",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "set",
"p": "apiData.parse_mode",
"pt": "msg",
"to": "HTML",
"tot": "str"
},
{
"t": "set",
"p": "apiData.disable_web_page_preview",
"pt": "msg",
"to": "true",
"tot": "bool"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 2995,
"y": 2440,
"wires": [
[
"6090edd5.435624"
]
],
"l": false
},
{
"id": "bf3d9cff.5e782",
"type": "drom-template",
"z": "b2e011e3.97a98",
"name": "Пришел перевод",
"field": "apiData.text",
"fieldType": "msg",
"syntax": "handlebars",
"htmlEscape": true,
"template": "📃 Пришел перевод для счета {{invoice.id}}\n\nId операции: {{yoomEvent.operation_id}}\nСумма списания: {{yoomEvent.withdraw_amount}} <b>{{note}}</b>",
"x": 1770,
"y": 2540,
"wires": [
[
"8a33358a.2744c8"
]
]
},
{
"id": "b29927aa.3dc188",
"type": "switch",
"z": "b2e011e3.97a98",
"name": "Сколько оплачено?",
"property": "yoomEvent.withdraw_amount",
"propertyType": "msg",
"rules": [
{
"t": "gte",
"v": "invoice.price_rub",
"vt": "msg"
},
{
"t": "else"
}
],
"checkall": "false",
"repair": false,
"outputs": 2,
"x": 1240,
"y": 2520,
"wires": [
[
"aa2c6e7c.4ce1b",
"8d57a7f3.39f958"
],
[
"91490f43.e4578"
]
],
"outputLabels": [
"Ровно как в счете",
"Меньше чем в счет"
]
},
{
"id": "91490f43.e4578",
"type": "drom-template",
"z": "b2e011e3.97a98",
"name": "Предупреждение",
"field": "note",
"fieldType": "msg",
"syntax": "handlebars",
"htmlEscape": true,
"template": "❌ Должно быть {{invoice.price_rub}}",
"x": 1510,
"y": 2600,
"wires": [
[
"bf3d9cff.5e782"
]
]
},
{
"id": "f6310c00.4eea5",
"type": "drom-template",
"z": "b2e011e3.97a98",
"name": "Пришел перевод не для оплаты счета",
"field": "apiData.text",
"fieldType": "msg",
"syntax": "handlebars",
"htmlEscape": true,
"template": "👛 Пришел перевод не для оплаты счета\n\nId операции: {{yoomEvent.operation_id}}\nСумма: {{yoomEvent.withdraw_amount}}",
"x": 1100,
"y": 2620,
"wires": [
[
"8a33358a.2744c8"
]
]
},
{
"id": "aa2c6e7c.4ce1b",
"type": "drom-template",
"z": "b2e011e3.97a98",
"name": "Ок",
"field": "note",
"fieldType": "msg",
"syntax": "handlebars",
"htmlEscape": true,
"template": "✔",
"x": 1470,
"y": 2540,
"wires": [
[
"bf3d9cff.5e782"
]
]
},
{
"id": "dbaa7387.84f7",
"type": "change",
"z": "b2e011e3.97a98",
"d": true,
"name": "Данные оповещения",
"rules": [
{
"t": "set",
"p": "yoomEvent.withdraw_amount",
"pt": "msg",
"to": "900",
"tot": "num"
},
{
"t": "set",
"p": "yoomEvent.label",
"pt": "msg",
"to": "НОМЕРСЧЕТА",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 220,
"y": 2660,
"wires": [
[
"e60d5c40.c4257"
]
]
},
{
"id": "b8eb5bd6.b21858",
"type": "change",
"z": "b2e011e3.97a98",
"name": "invoiceId",
"rules": [
{
"t": "move",
"p": "data",
"pt": "msg",
"to": "invoiceId",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1380,
"y": 1700,
"wires": [
[
"f8d335ac.478948",
"a0b5f8c7.a13418"
]
]
},
{
"id": "f8d335ac.478948",
"type": "drom-template",
"z": "b2e011e3.97a98",
"name": "Оплачено",
"field": "apiData.text",
"fieldType": "msg",
"syntax": "handlebars",
"htmlEscape": false,
"template": "⁉ Пользователь сообщает, что оплатил счет, но доступ не получил. Счет {{invoiceId}}\n\n",
"x": 1650,
"y": 1800,
"wires": [
[
"31cbc126.2cc61e"
]
]
},
{
"id": "31cbc126.2cc61e",
"type": "function",
"z": "b2e011e3.97a98",
"name": "Клавиатура",
"func": "msg.apiData.reply_markup = {\n \"inline_keyboard\": [\n [\n {\n \"text\": \"✅ Дать доступ\",\n \"callback_data\": \"confirm:\"+msg.invoiceId\n }\n ]\n ]\n};\n\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 1650,
"y": 1840,
"wires": [
[
"1df49dca.549432"
]
]
},
{
"id": "a0b5f8c7.a13418",
"type": "drom-template",
"z": "b2e011e3.97a98",
"name": "Админ оповещен",
"field": "apiData.text",
"fieldType": "msg",
"syntax": "handlebars",
"htmlEscape": false,
"template": "Администратору отправлено сообщение об оплате. Через некоторое время Вам придет сообщение с доступом.",
"x": 2910,
"y": 1700,
"wires": [
[
"7185c180.f4528"
]
]
},
{
"id": "7185c180.f4528",
"type": "function",
"z": "b2e011e3.97a98",
"name": "Клавиатура",
"func": "msg.apiData.reply_markup = {\n \"inline_keyboard\": [\n [\n {\n \"text\": \"◀ Назад\",\n \"callback_data\": \"start\"\n }\n ]\n ]\n};\n\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 2930,
"y": 1740,
"wires": [
[
"d56324ca.3359e8"
]
]
},
{
"id": "39a42c84.ab9b64",
"type": "comment",
"z": "b2e011e3.97a98",
"name": "АДМИН БОТ",
"info": "",
"x": 110,
"y": 2180,
"wires": []
},
{
"id": "a0466bee.fcded8",
"type": "drom-tg-updates",
"z": "b2e011e3.97a98",
"name": "Обновления админ-бота",
"method": "longpoll",
"property": "tgUpdate",
"client": "55c122b.68894dc",
"x": 190,
"y": 2240,
"wires": [
[
"18455f8c.870b3"
]
]
},
{
"id": "18455f8c.870b3",
"type": "drom-tg-switch-update",
"z": "b2e011e3.97a98",
"name": "Какое обновление?",
"tgUpdate": "tgUpdate",
"property": "tgUpdateObj",
"updates": [
"callback_query",
"message"
],
"outputs": 2,
"x": 520,
"y": 2240,
"wires": [
[
"364a54a.2a34eac"
],
[
"537a5eb8.6cea8"
]
]
},
{
"id": "364a54a.2a34eac",
"type": "drom-switch-str",
"z": "b2e011e3.97a98",
"name": "Какие данные запроса?",
"inString": "tgUpdateObj.data",
"inStringType": "msg",
"rules": [
{
"t": "start",
"v": "confirm:",
"vt": "str",
"case": true,
"extract": true
}
],
"outputs": 1,
"property": "data",
"x": 830,
"y": 2180,
"wires": [
[
"d4513804.72ac58",
"15edb299.f5c14d"
]
]
},
{
"id": "d4513804.72ac58",
"type": "change",
"z": "b2e011e3.97a98",
"name": "invoiceId",
"rules": [
{
"t": "set",
"p": "invoiceId",
"pt": "msg",
"to": "data",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1080,
"y": 2200,
"wires": [
[
"8670060c.b09f08"
]
]
},
{
"id": "8d57a7f3.39f958",
"type": "change",
"z": "b2e011e3.97a98",
"name": "invoiceId",
"rules": [
{
"t": "set",
"p": "invoiceId",
"pt": "msg",
"to": "invoice.id",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1480,
"y": 2480,
"wires": [
[
"65a0c624.c41a28"
]
]
},
{
"id": "f0edcd8c.39b19",
"type": "comment",
"z": "b2e011e3.97a98",
"name": "ВЫДАЧА ДОСТУПА",
"info": "",
"x": 130,
"y": 2820,
"wires": []
},
{
"id": "8aa82272.426ab",
"type": "link in",
"z": "b2e011e3.97a98",
"name": "ВЫДАЧА ДОСТУПА",
"links": [
"8670060c.b09f08",
"65a0c624.c41a28"
],
"x": 95,
"y": 2880,
"wires": [
[
"501a244d.e36e8c"
]
]
},
{
"id": "8670060c.b09f08",
"type": "link out",
"z": "b2e011e3.97a98",
"name": "ВЫДАЧА ДОСТУПА",
"links": [
"8aa82272.426ab"
],
"x": 1215,
"y": 2200,
"wires": []
},
{
"id": "65a0c624.c41a28",
"type": "link out",
"z": "b2e011e3.97a98",
"name": "ВЫДАЧА ДОСТУПА",
"links": [
"8aa82272.426ab"
],
"x": 1700,
"y": 2480,
"wires": [],
"l": true
},
{
"id": "3a961788.eb2188",
"type": "switch",
"z": "b2e011e3.97a98",
"name": "Еще не был обработан?",
"property": "invoice.processed_at",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "0",
"vt": "num"
}
],
"checkall": "false",
"repair": false,
"outputs": 1,
"x": 530,
"y": 2900,
"wires": [
[
"e65ad63c.f678b8"
]
],
"outputLabels": [
"Не был"
]
},
{
"id": "1fb66bc0.9059c4",
"type": "link in",
"z": "b2e011e3.97a98",
"name": "СООБЩЕНИЕ АДМИНУ",
"links": [
"8a33358a.2744c8",
"1df49dca.549432"
],
"x": 2895,
"y": 2400,
"wires": [
[
"e88f45d6.df2d18"
]
]
},
{
"id": "8a33358a.2744c8",
"type": "link out",
"z": "b2e011e3.97a98",
"name": "СООБЩЕНИЕ АДМИНУ",
"links": [
"1fb66bc0.9059c4"
],
"x": 2110,
"y": 2620,
"wires": [],
"l": true
},
{
"id": "15edb299.f5c14d",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "set",
"p": "apiData.callback_query_id",
"pt": "msg",
"to": "tgUpdateObj.id",
"tot": "msg"
},
{
"t": "set",
"p": "apiData.text",
"pt": "msg",
"to": "Готово!",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1035,
"y": 2140,
"wires": [
[
"1a0a621b.c7034e"
]
],
"l": false
},
{
"id": "1a0a621b.c7034e",
"type": "drom-tg-api-call",
"z": "b2e011e3.97a98",
"name": "Оповещение \"Готово!\"",
"data": "apiData",
"dataType": "msg",
"method": "answerCallbackQuery",
"methodType": "str",
"property": "payload",
"client": "55c122b.68894dc",
"x": 1190,
"y": 2140,
"wires": [
[]
]
},
{
"id": "1516f940.cad847",
"type": "comment",
"z": "b2e011e3.97a98",
"name": "СООБЩЕНИЕ АДМИНУ",
"info": "",
"x": 2950,
"y": 2340,
"wires": []
},
{
"id": "2f15a8f3.3bc808",
"type": "inject",
"z": "b2e011e3.97a98",
"name": "Получить все доступы",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 3300,
"y": 200,
"wires": [
[
"24887815.410198"
]
]
},
{
"id": "24887815.410198",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "SELECT * FROM tgtariff_access;",
"queryParamsType": "empty",
"queryParams": "",
"name": "Получ доступы",
"property": "payload",
"x": 3980,
"y": 200,
"wires": [
[
"cb79f981.fcdf48"
]
]
},
{
"id": "cb79f981.fcdf48",
"type": "debug",
"z": "b2e011e3.97a98",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 4115,
"y": 200,
"wires": [],
"l": false
},
{
"id": "7d87ac.cf2ba854",
"type": "comment",
"z": "b2e011e3.97a98",
"name": "Тарифы: доступы",
"info": "",
"x": 3270,
"y": 140,
"wires": []
},
{
"id": "86b4c71.123e238",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "INSERT INTO tgtariff_access (\n tariff_id,\n chat_id,\n days,\n descr\n) VALUES (?,?,?,?);",
"queryParamsType": "msg",
"queryParams": "sqlParams",
"name": "Добав доступ",
"property": "payload",
"x": 3980,
"y": 340,
"wires": [
[
"c6c0b7a4.de2c88"
]
]
},
{
"id": "62a152d6.0c98ac",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "set",
"p": "sqlParams[0]",
"pt": "msg",
"to": "tariff_id",
"tot": "msg"
},
{
"t": "set",
"p": "sqlParams[1]",
"pt": "msg",
"to": "chat_id",
"tot": "msg"
},
{
"t": "set",
"p": "sqlParams[2]",
"pt": "msg",
"to": "days",
"tot": "msg"
},
{
"t": "set",
"p": "sqlParams[3]",
"pt": "msg",
"to": "descr",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 3855,
"y": 340,
"wires": [
[
"86b4c71.123e238"
]
],
"l": false
},
{
"id": "6ee97e08.d7c22",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "UPDATE tgtariff_access\nSET chat_id = ?,\n days = ?,\n descr = ?\nWHERE id = ?;",
"queryParamsType": "msg",
"queryParams": "sqlParams",
"name": "Изм доступ",
"property": "payload",
"x": 3970,
"y": 440,
"wires": [
[
"c6c0b7a4.de2c88"
]
]
},
{
"id": "a6fc3555.c14328",
"type": "inject",
"z": "b2e011e3.97a98",
"name": "Добавить доступ",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 3340,
"y": 340,
"wires": [
[
"d1347c32.71721"
]
]
},
{
"id": "d1347c32.71721",
"type": "change",
"z": "b2e011e3.97a98",
"name": "📝 Данные доступа",
"rules": [
{
"t": "set",
"p": "tariff_id",
"pt": "msg",
"to": "1",
"tot": "num"
},
{
"t": "set",
"p": "chat_id",
"pt": "msg",
"to": "-12345",
"tot": "num"
},
{
"t": "set",
"p": "days",
"pt": "msg",
"to": "30",
"tot": "num"
},
{
"t": "set",
"p": "descr",
"pt": "msg",
"to": "Доступ к тестовому сообществу на 30 дней",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 3580,
"y": 340,
"wires": [
[
"62a152d6.0c98ac"
]
]
},
{
"id": "794d9c1d.928fb4",
"type": "change",
"z": "b2e011e3.97a98",
"name": "🆔 id доступа для правки",
"rules": [
{
"t": "set",
"p": "id",
"pt": "msg",
"to": "1",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 3600,
"y": 400,
"wires": [
[
"828ba9cf.eb2158"
]
]
},
{
"id": "2442b919.51d766",
"type": "inject",
"z": "b2e011e3.97a98",
"name": "Изменить доступ",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 3350,
"y": 420,
"wires": [
[
"794d9c1d.928fb4"
]
]
},
{
"id": "828ba9cf.eb2158",
"type": "change",
"z": "b2e011e3.97a98",
"name": "📝 Новые данные доступа",
"rules": [
{
"t": "set",
"p": "chat_id",
"pt": "msg",
"to": "-12345",
"tot": "num"
},
{
"t": "set",
"p": "days",
"pt": "msg",
"to": "30",
"tot": "num"
},
{
"t": "set",
"p": "descr",
"pt": "msg",
"to": "Доступ к тестовому сообществу на 30 дней",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 3600,
"y": 440,
"wires": [
[
"bfd48cb8.fe01a"
]
]
},
{
"id": "bfd48cb8.fe01a",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "set",
"p": "sqlParams[0]",
"pt": "msg",
"to": "chat_id",
"tot": "msg"
},
{
"t": "set",
"p": "sqlParams[1]",
"pt": "msg",
"to": "days",
"tot": "msg"
},
{
"t": "set",
"p": "sqlParams[2]",
"pt": "msg",
"to": "descr",
"tot": "msg"
},
{
"t": "set",
"p": "sqlParams[3]",
"pt": "msg",
"to": "id",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 3855,
"y": 440,
"wires": [
[
"6ee97e08.d7c22"
]
],
"l": false
},
{
"id": "119aecc6.f21783",
"type": "inject",
"z": "b2e011e3.97a98",
"name": "Получить доступы тарифа",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 3320,
"y": 260,
"wires": [
[
"94334f3b.50337"
]
]
},
{
"id": "94334f3b.50337",
"type": "change",
"z": "b2e011e3.97a98",
"name": "🆔 id тарифа",
"rules": [
{
"t": "set",
"p": "tariff_id",
"pt": "msg",
"to": "1",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 3560,
"y": 260,
"wires": [
[
"7f5fe1f6.6ca21"
]
]
},
{
"id": "7f5fe1f6.6ca21",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "set",
"p": "sqlParams[0]",
"pt": "msg",
"to": "tariff_id",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 3855,
"y": 260,
"wires": [
[
"5fa0cd6a.388b44"
]
],
"l": false
},
{
"id": "5fa0cd6a.388b44",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "SELECT * FROM tgtariff_access WHERE tariff_id=?;",
"queryParamsType": "msg",
"queryParams": "sqlParams",
"name": "Получ доступы",
"property": "payload",
"x": 3980,
"y": 260,
"wires": [
[
"77c5ceae.fe1ee"
]
]
},
{
"id": "77c5ceae.fe1ee",
"type": "debug",
"z": "b2e011e3.97a98",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 4115,
"y": 260,
"wires": [],
"l": false
},
{
"id": "51883c2a.a69244",
"type": "switch",
"z": "b2e011e3.97a98",
"name": "/start?",
"property": "tgUpdateObj.text",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "/start",
"vt": "str"
}
],
"checkall": "false",
"repair": false,
"outputs": 1,
"x": 1050,
"y": 1280,
"wires": [
[
"71ac86ac.699b08"
]
],
"outputLabels": [
"Да"
]
},
{
"id": "619815a4.a636cc",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "SELECT * FROM tgtariff_access WHERE tariff_id=?;",
"queryParamsType": "msg",
"queryParams": "sqlParams",
"name": "Получ доступы для тарифа",
"property": "payload",
"x": 960,
"y": 2900,
"wires": [
[
"8674541c.420b98"
]
]
},
{
"id": "88f0a533.cde0b8",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "SELECT * FROM tgcommunity_members WHERE chat_id = ? AND user_id = ?;",
"queryParamsType": "msg",
"queryParams": "sqlParams",
"name": "Получ участника",
"property": "member",
"x": 1610,
"y": 2880,
"wires": [
[
"99f3225d.54952"
]
]
},
{
"id": "b355f7cc.7412b8",
"type": "split",
"z": "b2e011e3.97a98",
"name": "",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"x": 1290,
"y": 2900,
"wires": [
[
"8bfb7c8d.43802"
]
]
},
{
"id": "fd38e1ba.80904",
"type": "join",
"z": "b2e011e3.97a98",
"name": "",
"mode": "auto",
"build": "string",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": "false",
"timeout": "",
"count": "",
"reduceRight": false,
"x": 3010,
"y": 2920,
"wires": [
[
"222bf8fd.6060c8",
"71d90feb.ecaaf"
]
]
},
{
"id": "71d90feb.ecaaf",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "delete",
"p": "sqlParams",
"pt": "msg"
},
{
"t": "set",
"p": "sqlParams[0]",
"pt": "msg",
"to": "",
"tot": "date"
},
{
"t": "set",
"p": "sqlParams[1]",
"pt": "msg",
"to": "invoice.id",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 3195,
"y": 2960,
"wires": [
[
"286c3e15.a7f992"
]
],
"l": false
},
{
"id": "286c3e15.a7f992",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "UPDATE tginvoices\nSET processed_at = ?\nWHERE id = ?;",
"queryParamsType": "msg",
"queryParams": "sqlParams",
"name": "Счет обработан",
"property": "payload",
"x": 3330,
"y": 2960,
"wires": [
[]
]
},
{
"id": "b11e778b.2871c8",
"type": "drom-template",
"z": "b2e011e3.97a98",
"name": "Счет оплачен",
"field": "apiData.text",
"fieldType": "msg",
"syntax": "handlebars",
"htmlEscape": false,
"template": "📃 Счет {{invoice.id}}\n\n✅ Оплачен и обработан\n\n💡 Чтобы купить еще, используйте команду /start",
"x": 3320,
"y": 2880,
"wires": [
[
"c97f0eb4.cc119"
]
]
},
{
"id": "222bf8fd.6060c8",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "delete",
"p": "apiData",
"pt": "msg"
},
{
"t": "set",
"p": "apiData.chat_id",
"pt": "msg",
"to": "invoice.chat_id",
"tot": "msg"
},
{
"t": "set",
"p": "apiData.message_id",
"pt": "msg",
"to": "invoice.message_id",
"tot": "msg"
},
{
"t": "set",
"p": "apiData.parse_mode",
"pt": "msg",
"to": "HTML",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 3195,
"y": 2880,
"wires": [
[
"b11e778b.2871c8"
]
],
"l": false
},
{
"id": "c97f0eb4.cc119",
"type": "drom-tg-api-call",
"z": "b2e011e3.97a98",
"name": "Редакт сообщ",
"data": "apiData",
"dataType": "msg",
"method": "editMessageText",
"methodType": "str",
"property": "payload",
"client": "4497dbb.2648f24",
"x": 3540,
"y": 2880,
"wires": [
[]
]
},
{
"id": "8bfb7c8d.43802",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "move",
"p": "payload",
"pt": "msg",
"to": "access",
"tot": "msg"
},
{
"t": "set",
"p": "access.msecs",
"pt": "msg",
"to": "access.days * 86400000",
"tot": "jsonata"
},
{
"t": "delete",
"p": "sqlParams",
"pt": "msg"
},
{
"t": "set",
"p": "sqlParams[0]",
"pt": "msg",
"to": "access.chat_id",
"tot": "msg"
},
{
"t": "set",
"p": "sqlParams[1]",
"pt": "msg",
"to": "invoice.user_id",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1435,
"y": 2900,
"wires": [
[
"88f0a533.cde0b8"
]
],
"l": false
},
{
"id": "99f3225d.54952",
"type": "switch",
"z": "b2e011e3.97a98",
"name": "Уже есть?",
"property": "member",
"propertyType": "msg",
"rules": [
{
"t": "nempty"
},
{
"t": "else"
}
],
"checkall": "false",
"repair": false,
"outputs": 2,
"x": 1630,
"y": 2940,
"wires": [
[
"c2225f64.41809"
],
[
"7a5dabd.13c7654"
]
],
"outputLabels": [
"Да",
"Нет"
]
},
{
"id": "c2225f64.41809",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "set",
"p": "member",
"pt": "msg",
"to": "member[0]",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1795,
"y": 2900,
"wires": [
[
"ec47b345.10bad"
]
],
"l": false
},
{
"id": "ec47b345.10bad",
"type": "change",
"z": "b2e011e3.97a98",
"name": "Время окончания доступа",
"rules": [
{
"t": "set",
"p": "new_exp_at",
"pt": "msg",
"to": "",
"tot": "date"
},
{
"t": "set",
"p": "new_exp_at",
"pt": "msg",
"to": "$max([new_exp_at,member.expires_at]) + access.msecs",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1960,
"y": 2900,
"wires": [
[
"50f153c2.62f64c"
]
]
},
{
"id": "7a5dabd.13c7654",
"type": "change",
"z": "b2e011e3.97a98",
"name": "Время окончания доступа",
"rules": [
{
"t": "set",
"p": "new_exp_at",
"pt": "msg",
"to": "",
"tot": "date"
},
{
"t": "set",
"p": "new_exp_at",
"pt": "msg",
"to": "new_exp_at + access.msecs",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1960,
"y": 2980,
"wires": [
[
"50f153c2.62f64c"
]
]
},
{
"id": "5e5e8cb1.c889f4",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "INSERT INTO tgcommunity_members (\n chat_id,\n user_id,\n expires_at,\n reminder_state\n) VALUES(?,?,?,0)\nON CONFLICT (chat_id, user_id) DO UPDATE SET expires_at=excluded.expires_at, reminder_state=excluded.reminder_state;\n",
"queryParamsType": "msg",
"queryParams": "sqlParams",
"name": "Добав/обнов участника",
"property": "payload",
"x": 2350,
"y": 2940,
"wires": [
[
"19faa44f.74130c"
]
]
},
{
"id": "50f153c2.62f64c",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "delete",
"p": "sqlParams",
"pt": "msg"
},
{
"t": "set",
"p": "sqlParams[0]",
"pt": "msg",
"to": "access.chat_id",
"tot": "msg"
},
{
"t": "set",
"p": "sqlParams[1]",
"pt": "msg",
"to": "invoice.user_id",
"tot": "msg"
},
{
"t": "set",
"p": "sqlParams[2]",
"pt": "msg",
"to": "new_exp_at",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 2155,
"y": 2940,
"wires": [
[
"5e5e8cb1.c889f4"
]
],
"l": false
},
{
"id": "19faa44f.74130c",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "delete",
"p": "apiData",
"pt": "msg"
},
{
"t": "set",
"p": "apiData.chat_id",
"pt": "msg",
"to": "invoice.chat_id",
"tot": "msg"
},
{
"t": "set",
"p": "apiData.text",
"pt": "msg",
"to": "access.descr",
"tot": "msg"
},
{
"t": "set",
"p": "apiData.parse_mode",
"pt": "msg",
"to": "HTML",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 2555,
"y": 2920,
"wires": [
[
"984ca45e.7072f8"
]
],
"l": false
},
{
"id": "1e419db4.e3a2b2",
"type": "drom-tg-api-call",
"z": "b2e011e3.97a98",
"name": "Отправ сообщение с доступом",
"data": "apiData",
"dataType": "msg",
"method": "sendMessage",
"methodType": "str",
"property": "payload",
"client": "4497dbb.2648f24",
"x": 2670,
"y": 2960,
"wires": [
[
"fd38e1ba.80904"
]
]
},
{
"id": "984ca45e.7072f8",
"type": "function",
"z": "b2e011e3.97a98",
"name": "Клавиатура",
"func": "msg.apiData.reply_markup = {\n \"inline_keyboard\": [\n [\n {\n \"text\": \"🔒 Получить доступ\",\n \"callback_data\": \"getlink:\"+msg.access.chat_id\n }\n ]\n ]\n};\n\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 2670,
"y": 2920,
"wires": [
[
"1e419db4.e3a2b2"
]
]
},
{
"id": "8674541c.420b98",
"type": "switch",
"z": "b2e011e3.97a98",
"name": "Есть доступы?",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "nempty"
},
{
"t": "else"
}
],
"checkall": "false",
"repair": false,
"outputs": 2,
"x": 1000,
"y": 2960,
"wires": [
[
"b355f7cc.7412b8"
],
[
"bbcd01a8.df324"
]
],
"outputLabels": [
"Да",
""
]
},
{
"id": "4a473185.a9992",
"type": "link in",
"z": "b2e011e3.97a98",
"name": "",
"links": [
"bbcd01a8.df324"
],
"x": 3065,
"y": 3040,
"wires": [
[
"71d90feb.ecaaf",
"222bf8fd.6060c8"
]
]
},
{
"id": "bbcd01a8.df324",
"type": "link out",
"z": "b2e011e3.97a98",
"name": "",
"links": [
"4a473185.a9992"
],
"x": 1235,
"y": 3020,
"wires": []
},
{
"id": "1df49dca.549432",
"type": "link out",
"z": "b2e011e3.97a98",
"name": "СООБЩЕНИЕ АДМИНУ",
"links": [
"1fb66bc0.9059c4"
],
"x": 1950,
"y": 1820,
"wires": [],
"l": true
},
{
"id": "711f3f00.35af8",
"type": "change",
"z": "b2e011e3.97a98",
"name": "chatId",
"rules": [
{
"t": "move",
"p": "data",
"pt": "msg",
"to": "chatId",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1370,
"y": 1980,
"wires": [
[
"7e17f86e.167b98"
]
]
},
{
"id": "8a266c1b.322c2",
"type": "comment",
"z": "b2e011e3.97a98",
"name": "ИНИЦИАЛИЗАЦИЯ ССЫЛОК",
"info": "",
"x": 170,
"y": 3100,
"wires": []
},
{
"id": "e6c4b3b4.c266f",
"type": "link in",
"z": "b2e011e3.97a98",
"name": "ИНИЦИАЛИЗАЦИЯ ССЫЛОК",
"links": [
"c6c0b7a4.de2c88"
],
"x": 95,
"y": 3160,
"wires": [
[
"de5fb702.ea4508"
]
]
},
{
"id": "c6c0b7a4.de2c88",
"type": "link out",
"z": "b2e011e3.97a98",
"name": "ИНИЦИАЛИЗАЦИЯ ССЫЛОК",
"links": [
"e6c4b3b4.c266f"
],
"x": 4250,
"y": 380,
"wires": [],
"l": true
},
{
"id": "de5fb702.ea4508",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "SELECT DISTINCT chat_id AS id FROM tgtariff_access;\n",
"queryParamsType": "empty",
"queryParams": "",
"name": "Получ все сообщества",
"property": "payload",
"x": 290,
"y": 3160,
"wires": [
[
"a44c7da5.0fe6c"
]
]
},
{
"id": "b578e2a1.41048",
"type": "inject",
"z": "b2e011e3.97a98",
"d": true,
"name": "Инициализировать",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 190,
"y": 3240,
"wires": [
[
"de5fb702.ea4508"
]
]
},
{
"id": "a44c7da5.0fe6c",
"type": "split",
"z": "b2e011e3.97a98",
"name": "",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"x": 530,
"y": 3160,
"wires": [
[
"3b531ce.6934fe4"
]
]
},
{
"id": "ad7fce72.28832",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "set",
"p": "apiData.chat_id",
"pt": "msg",
"to": "chatId",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1155,
"y": 3160,
"wires": [
[
"edaa4a47.1e6988"
]
],
"l": false
},
{
"id": "edaa4a47.1e6988",
"type": "drom-tg-api-call",
"z": "b2e011e3.97a98",
"name": "Генерация ссылки",
"data": "apiData",
"dataType": "msg",
"method": "exportChatInviteLink",
"methodType": "str",
"property": "newLink",
"client": "55c122b.68894dc",
"x": 1290,
"y": 3160,
"wires": [
[
"1795763b.9667da"
]
]
},
{
"id": "3b531ce.6934fe4",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "move",
"p": "payload.id",
"pt": "msg",
"to": "chatId",
"tot": "msg"
},
{
"t": "delete",
"p": "sqlParams",
"pt": "msg"
},
{
"t": "set",
"p": "sqlParams[0]",
"pt": "msg",
"to": "chatId",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 675,
"y": 3160,
"wires": [
[
"67051067.0e82d"
]
],
"l": false
},
{
"id": "67051067.0e82d",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "SELECT * FROM tgcommunity_links WHERE chat_id = ?;\n",
"queryParamsType": "msg",
"queryParams": "sqlParams",
"name": "Получ ссылку",
"property": "links",
"x": 820,
"y": 3160,
"wires": [
[
"79ed14f1.fee51c"
]
]
},
{
"id": "79ed14f1.fee51c",
"type": "switch",
"z": "b2e011e3.97a98",
"name": "Нет ссылки?",
"property": "links",
"propertyType": "msg",
"rules": [
{
"t": "empty"
}
],
"checkall": "false",
"repair": false,
"outputs": 1,
"x": 1010,
"y": 3160,
"wires": [
[
"ad7fce72.28832"
]
],
"outputLabels": [
"Нет ссылки"
]
},
{
"id": "71fcfab4.eea8f4",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "INSERT INTO tgcommunity_links (\n chat_id,\n invite_link\n) VALUES(?,?);\n",
"queryParamsType": "msg",
"queryParams": "sqlParams",
"name": "Добав ссылку",
"property": "links",
"x": 1580,
"y": 3160,
"wires": [
[]
]
},
{
"id": "1795763b.9667da",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "delete",
"p": "sqlParams",
"pt": "msg"
},
{
"t": "set",
"p": "sqlParams[0]",
"pt": "msg",
"to": "chatId",
"tot": "msg"
},
{
"t": "set",
"p": "sqlParams[1]",
"pt": "msg",
"to": "newLink",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1455,
"y": 3160,
"wires": [
[
"71fcfab4.eea8f4"
]
],
"l": false
},
{
"id": "493a5e7c.46876",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "SELECT * FROM tgcommunity_members WHERE chat_id=? AND user_id=?;",
"queryParamsType": "msg",
"queryParams": "sqlParams",
"name": "Получ участника",
"property": "member",
"x": 1690,
"y": 1980,
"wires": [
[
"800c7a24.a1f8b8"
]
]
},
{
"id": "7e17f86e.167b98",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "set",
"p": "sqlParams[0]",
"pt": "msg",
"to": "chatId",
"tot": "msg"
},
{
"t": "set",
"p": "sqlParams[1]",
"pt": "msg",
"to": "tgUpdateObj.from.id",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1555,
"y": 1980,
"wires": [
[
"493a5e7c.46876"
]
],
"l": false
},
{
"id": "346cc69.d39d13a",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "move",
"p": "member[0]",
"pt": "msg",
"to": "member",
"tot": "msg"
},
{
"t": "set",
"p": "time",
"pt": "msg",
"to": "",
"tot": "date"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 2095,
"y": 1940,
"wires": [
[
"dfa17276.e055f"
]
],
"l": false
},
{
"id": "dfa17276.e055f",
"type": "switch",
"z": "b2e011e3.97a98",
"name": "Доступ истек?",
"property": "member.expires_at",
"propertyType": "msg",
"rules": [
{
"t": "lte",
"v": "time",
"vt": "msg"
},
{
"t": "else"
}
],
"checkall": "false",
"repair": false,
"outputs": 2,
"x": 2240,
"y": 1940,
"wires": [
[
"82093669.3f6f48"
],
[
"2b935fbf.72447"
]
],
"outputLabels": [
"Да",
"Нет"
]
},
{
"id": "82093669.3f6f48",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "set",
"p": "apiData.callback_query_id",
"pt": "msg",
"to": "tgUpdateObj.id",
"tot": "msg"
},
{
"t": "set",
"p": "apiData.text",
"pt": "msg",
"to": "⚠ Доступ истек! Необходимо продление.",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 2415,
"y": 1900,
"wires": [
[
"21c5a890.4ed428"
]
],
"l": false
},
{
"id": "21c5a890.4ed428",
"type": "drom-tg-api-call",
"z": "b2e011e3.97a98",
"name": "Оповещение \"Доступ истек\"",
"data": "apiData",
"dataType": "msg",
"method": "answerCallbackQuery",
"methodType": "str",
"property": "payload",
"client": "4497dbb.2648f24",
"x": 2580,
"y": 1900,
"wires": [
[]
]
},
{
"id": "de836731.da2d18",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "delete",
"p": "apiData",
"pt": "msg"
},
{
"t": "set",
"p": "apiData.callback_query_id",
"pt": "msg",
"to": "tgUpdateObj.id",
"tot": "msg"
},
{
"t": "set",
"p": "apiData.text",
"pt": "msg",
"to": "🔓 Доступ открыт",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 3375,
"y": 2000,
"wires": [
[
"2c8f47d7.660b38"
]
],
"l": false
},
{
"id": "2c8f47d7.660b38",
"type": "drom-tg-api-call",
"z": "b2e011e3.97a98",
"name": "Оповещение \"Доступ открыт\"",
"data": "apiData",
"dataType": "msg",
"method": "answerCallbackQuery",
"methodType": "str",
"property": "payload",
"client": "4497dbb.2648f24",
"x": 3550,
"y": 2000,
"wires": [
[]
]
},
{
"id": "194b3ae5.e95cb5",
"type": "drom-tg-api-call",
"z": "b2e011e3.97a98",
"name": "Редакт клавиатуру",
"data": "apiData",
"dataType": "msg",
"method": "editMessageReplyMarkup",
"methodType": "str",
"property": "payload",
"client": "4497dbb.2648f24",
"x": 3170,
"y": 2020,
"wires": [
[
"de836731.da2d18"
]
]
},
{
"id": "1c0f19d4.9c85f6",
"type": "function",
"z": "b2e011e3.97a98",
"name": "Клавиатура",
"func": "msg.apiData.reply_markup = {\n \"inline_keyboard\": [\n [\n {\n \"text\": \"🚪 Войти\",\n \"url\": msg.links[0].invite_link\n }\n ]\n ]\n};\n\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 3190,
"y": 1980,
"wires": [
[
"194b3ae5.e95cb5"
]
]
},
{
"id": "1da7b0d5.57fdaf",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "delete",
"p": "apiData",
"pt": "msg"
},
{
"t": "set",
"p": "apiData.chat_id",
"pt": "msg",
"to": "tgUpdateObj.message.chat.id",
"tot": "msg"
},
{
"t": "set",
"p": "apiData.message_id",
"pt": "msg",
"to": "tgUpdateObj.message.message_id",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 3075,
"y": 1980,
"wires": [
[
"1c0f19d4.9c85f6"
]
],
"l": false
},
{
"id": "2b935fbf.72447",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "delete",
"p": "sqlParams",
"pt": "msg"
},
{
"t": "set",
"p": "sqlParams[0]",
"pt": "msg",
"to": "chatId",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 2415,
"y": 2000,
"wires": [
[
"8e22c6c5.232798"
]
],
"l": false
},
{
"id": "8e22c6c5.232798",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "SELECT * FROM tgcommunity_links WHERE chat_id = ?;\n",
"queryParamsType": "msg",
"queryParams": "sqlParams",
"name": "Получ ссылку",
"property": "links",
"x": 2540,
"y": 2000,
"wires": [
[
"3eb30d95.59e892"
]
]
},
{
"id": "3eb30d95.59e892",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "delete",
"p": "sqlParams",
"pt": "msg"
},
{
"t": "set",
"p": "sqlParams[0]",
"pt": "msg",
"to": "tgUpdateObj.message.chat.id",
"tot": "msg"
},
{
"t": "set",
"p": "sqlParams[1]",
"pt": "msg",
"to": "tgUpdateObj.message.message_id",
"tot": "msg"
},
{
"t": "set",
"p": "sqlParams[2]",
"pt": "msg",
"to": "chatId",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 2715,
"y": 2000,
"wires": [
[
"e1583f13.d87f5"
]
],
"l": false
},
{
"id": "e1583f13.d87f5",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "INSERT OR IGNORE INTO tglink_messages (\n chat_id, message_id, access_chat_id\n) VALUES (?, ?, ?);\n",
"queryParamsType": "msg",
"queryParams": "sqlParams",
"name": "Запомнить сообщение",
"property": "payload",
"x": 2870,
"y": 2000,
"wires": [
[
"1da7b0d5.57fdaf"
]
]
},
{
"id": "b53f636c.3585c",
"type": "inject",
"z": "b2e011e3.97a98",
"name": "каждые 20 мин",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "1200",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 210,
"y": 3440,
"wires": [
[
"2fc35d94.7a4482"
]
]
},
{
"id": "565e8a78.108d84",
"type": "comment",
"z": "b2e011e3.97a98",
"name": "СБРОС ОТПРАВЛЕННЫХ ССЫЛОК",
"info": "",
"x": 190,
"y": 3380,
"wires": []
},
{
"id": "2fc35d94.7a4482",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "SELECT * FROM tglink_messages;",
"queryParamsType": "empty",
"queryParams": "",
"name": "Получ сообщения",
"property": "payload",
"x": 450,
"y": 3440,
"wires": [
[
"fbd7bc31.b5f9c",
"8f6d5011.eefe1"
]
]
},
{
"id": "fbd7bc31.b5f9c",
"type": "change",
"z": "b2e011e3.97a98",
"name": "Иды сообществ",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "[$distinct(payload.access_chat_id)]",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 700,
"y": 3620,
"wires": [
[
"c8a69bab.ca8e58"
]
]
},
{
"id": "8f6d5011.eefe1",
"type": "split",
"z": "b2e011e3.97a98",
"name": "",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"x": 690,
"y": 3400,
"wires": [
[
"56ec6ef9.2e6a9"
]
]
},
{
"id": "90c68fb5.6601d",
"type": "comment",
"z": "b2e011e3.97a98",
"name": "Возврат кнопок обратно на \"получить доступ\"",
"info": "",
"x": 800,
"y": 3360,
"wires": []
},
{
"id": "5050b3fc.21162c",
"type": "comment",
"z": "b2e011e3.97a98",
"name": "Сброс отправленных ранее ссылок",
"info": "",
"x": 760,
"y": 3580,
"wires": []
},
{
"id": "c8a69bab.ca8e58",
"type": "split",
"z": "b2e011e3.97a98",
"name": "",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"x": 930,
"y": 3620,
"wires": [
[
"7f9fd73c.0b6058"
]
]
},
{
"id": "f7e4d6b0.4964d8",
"type": "drom-tg-api-call",
"z": "b2e011e3.97a98",
"name": "Редакт клавиатуру",
"data": "apiData",
"dataType": "msg",
"method": "editMessageReplyMarkup",
"methodType": "str",
"property": "apiRes",
"client": "4497dbb.2648f24",
"x": 950,
"y": 3440,
"wires": [
[
"b8626a1d.614248"
]
]
},
{
"id": "dd4a06a9.945988",
"type": "function",
"z": "b2e011e3.97a98",
"name": "Клавиатура",
"func": "msg.apiData.reply_markup = {\n \"inline_keyboard\": [\n [\n {\n \"text\": \"🔒 Получить доступ\",\n \"callback_data\": \"getlink:\"+msg.payload.access_chat_id\n }\n ]\n ]\n};\n\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 970,
"y": 3400,
"wires": [
[
"f7e4d6b0.4964d8"
]
]
},
{
"id": "56ec6ef9.2e6a9",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "delete",
"p": "apiData",
"pt": "msg"
},
{
"t": "set",
"p": "apiData.chat_id",
"pt": "msg",
"to": "payload.chat_id",
"tot": "msg"
},
{
"t": "set",
"p": "apiData.message_id",
"pt": "msg",
"to": "payload.message_id",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 855,
"y": 3400,
"wires": [
[
"dd4a06a9.945988"
]
],
"l": false
},
{
"id": "6f9f2df4.c25824",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "DELETE FROM tglink_messages WHERE chat_id=? AND message_id=?;\n",
"queryParamsType": "msg",
"queryParams": "sqlParams",
"name": "Удалить сообщение",
"property": "sqlRes",
"x": 1300,
"y": 3420,
"wires": [
[]
]
},
{
"id": "b8626a1d.614248",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "delete",
"p": "sqlParams",
"pt": "msg"
},
{
"t": "set",
"p": "sqlParams[0]",
"pt": "msg",
"to": "payload.chat_id",
"tot": "msg"
},
{
"t": "set",
"p": "sqlParams[1]",
"pt": "msg",
"to": "payload.message_id",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1155,
"y": 3420,
"wires": [
[
"6f9f2df4.c25824"
]
],
"l": false
},
{
"id": "7f9fd73c.0b6058",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "delete",
"p": "apiData",
"pt": "msg"
},
{
"t": "set",
"p": "apiData.chat_id",
"pt": "msg",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1115,
"y": 3620,
"wires": [
[
"5ca2102f.61d14"
]
],
"l": false
},
{
"id": "5ca2102f.61d14",
"type": "drom-tg-api-call",
"z": "b2e011e3.97a98",
"name": "Генерация ссылки",
"data": "apiData",
"dataType": "msg",
"method": "exportChatInviteLink",
"methodType": "str",
"property": "newLink",
"client": "55c122b.68894dc",
"x": 1250,
"y": 3620,
"wires": [
[
"6d03e837.200e58"
]
]
},
{
"id": "2ae74a14.8a51c6",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "UPDATE tgcommunity_links\nSET invite_link=?\nWHERE chat_id=?;\n",
"queryParamsType": "msg",
"queryParams": "sqlParams",
"name": "Обнов ссылку",
"property": "sqlRes",
"x": 1540,
"y": 3620,
"wires": [
[]
]
},
{
"id": "6d03e837.200e58",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "delete",
"p": "sqlParams",
"pt": "msg"
},
{
"t": "set",
"p": "sqlParams[0]",
"pt": "msg",
"to": "newLink",
"tot": "msg"
},
{
"t": "set",
"p": "sqlParams[1]",
"pt": "msg",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1415,
"y": 3620,
"wires": [
[
"2ae74a14.8a51c6"
]
],
"l": false
},
{
"id": "537a5eb8.6cea8",
"type": "switch",
"z": "b2e011e3.97a98",
"name": "Вступление?",
"property": "tgUpdateObj.new_chat_members",
"propertyType": "msg",
"rules": [
{
"t": "istype",
"v": "array",
"vt": "array"
}
],
"checkall": "false",
"repair": false,
"outputs": 1,
"x": 800,
"y": 2320,
"wires": [
[
"63595398.20f49c"
]
],
"outputLabels": [
"Да"
]
},
{
"id": "63595398.20f49c",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "tgUpdateObj.new_chat_members",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1035,
"y": 2320,
"wires": [
[
"1c0d26c7.a4de49"
]
],
"l": false
},
{
"id": "300e17f6.741bb8",
"type": "comment",
"z": "b2e011e3.97a98",
"name": "Кик вступлений без доступа",
"info": "",
"x": 1140,
"y": 2280,
"wires": []
},
{
"id": "1c0d26c7.a4de49",
"type": "split",
"z": "b2e011e3.97a98",
"name": "",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"x": 1150,
"y": 2320,
"wires": [
[
"a3651e22.10ad2"
]
]
},
{
"id": "800c7a24.a1f8b8",
"type": "switch",
"z": "b2e011e3.97a98",
"name": "Есть участник?",
"property": "member",
"propertyType": "msg",
"rules": [
{
"t": "nempty"
},
{
"t": "else"
}
],
"checkall": "false",
"repair": false,
"outputs": 2,
"x": 1920,
"y": 1980,
"wires": [
[
"346cc69.d39d13a"
],
[
"ce054ef5.9be27"
]
],
"outputLabels": [
"Да",
"Нет"
]
},
{
"id": "ce054ef5.9be27",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "set",
"p": "apiData.callback_query_id",
"pt": "msg",
"to": "tgUpdateObj.id",
"tot": "msg"
},
{
"t": "set",
"p": "apiData.text",
"pt": "msg",
"to": "⚠ Нет доступа!",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 2095,
"y": 2060,
"wires": [
[
"9b8ce1d0.e1f1f"
]
],
"l": false
},
{
"id": "9b8ce1d0.e1f1f",
"type": "drom-tg-api-call",
"z": "b2e011e3.97a98",
"name": "Оповещение \"Нет доступа\"",
"data": "apiData",
"dataType": "msg",
"method": "answerCallbackQuery",
"methodType": "str",
"property": "payload",
"client": "4497dbb.2648f24",
"x": 2260,
"y": 2060,
"wires": [
[]
]
},
{
"id": "246d849d.a3523c",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "SELECT * FROM tgcommunity_members WHERE chat_id=? AND user_id=?;",
"queryParamsType": "msg",
"queryParams": "sqlParams",
"name": "Получ участника",
"property": "member",
"x": 1450,
"y": 2320,
"wires": [
[
"b7786861.29ea78"
]
]
},
{
"id": "a3651e22.10ad2",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "set",
"p": "newMember",
"pt": "msg",
"to": "payload",
"tot": "msg"
},
{
"t": "delete",
"p": "sqlParams",
"pt": "msg"
},
{
"t": "set",
"p": "sqlParams[0]",
"pt": "msg",
"to": "tgUpdateObj.chat.id",
"tot": "msg"
},
{
"t": "set",
"p": "sqlParams[1]",
"pt": "msg",
"to": "payload.id",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1315,
"y": 2320,
"wires": [
[
"246d849d.a3523c"
]
],
"l": false
},
{
"id": "b7786861.29ea78",
"type": "switch",
"z": "b2e011e3.97a98",
"name": "Есть участник?",
"property": "member",
"propertyType": "msg",
"rules": [
{
"t": "nempty"
},
{
"t": "else"
}
],
"checkall": "false",
"repair": false,
"outputs": 2,
"x": 1680,
"y": 2320,
"wires": [
[
"cd88d1b3.5dd2d"
],
[
"2767ae8e.2316f2"
]
],
"outputLabels": [
"Да",
"Нет"
]
},
{
"id": "cd88d1b3.5dd2d",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "move",
"p": "member[0]",
"pt": "msg",
"to": "member",
"tot": "msg"
},
{
"t": "set",
"p": "time",
"pt": "msg",
"to": "",
"tot": "date"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1855,
"y": 2280,
"wires": [
[
"60e3a434.c55dac"
]
],
"l": false
},
{
"id": "60e3a434.c55dac",
"type": "switch",
"z": "b2e011e3.97a98",
"name": "Доступ истек?",
"property": "member.expires_at",
"propertyType": "msg",
"rules": [
{
"t": "lte",
"v": "time",
"vt": "msg"
}
],
"checkall": "false",
"repair": false,
"outputs": 1,
"x": 2000,
"y": 2280,
"wires": [
[
"2767ae8e.2316f2"
]
],
"outputLabels": [
"Да"
]
},
{
"id": "2767ae8e.2316f2",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "delete",
"p": "apiData",
"pt": "msg"
},
{
"t": "set",
"p": "apiData.chat_id",
"pt": "msg",
"to": "tgUpdateObj.chat.id",
"tot": "msg"
},
{
"t": "set",
"p": "apiData.user_id",
"pt": "msg",
"to": "newMember.id",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 2155,
"y": 2320,
"wires": [
[
"500c6e74.a95cd"
]
],
"l": false
},
{
"id": "500c6e74.a95cd",
"type": "drom-tg-api-call",
"z": "b2e011e3.97a98",
"name": "Кик участника",
"data": "apiData",
"dataType": "msg",
"method": "kickChatMember",
"methodType": "str",
"property": "payload",
"client": "55c122b.68894dc",
"x": 2280,
"y": 2320,
"wires": [
[]
]
},
{
"id": "ebedca33.ff3448",
"type": "inject",
"z": "b2e011e3.97a98",
"name": "каждые 30 мин",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "1800",
"crontab": "",
"once": true,
"onceDelay": "30",
"topic": "",
"payload": "",
"payloadType": "date",
"x": 210,
"y": 3800,
"wires": [
[
"6d4cff81.7efc8"
]
]
},
{
"id": "371b2152.40cd0e",
"type": "comment",
"z": "b2e011e3.97a98",
"name": "НАПОМИНАНИЯ ЗА СУТКИ ДО ИСТЕЧЕНИЯ ДОСТУПА",
"info": "",
"x": 250,
"y": 3740,
"wires": []
},
{
"id": "79126cab.1cfa24",
"type": "inject",
"z": "b2e011e3.97a98",
"name": "каждые 30 мин",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "1800",
"crontab": "",
"once": true,
"onceDelay": "90",
"topic": "",
"payload": "",
"payloadType": "date",
"x": 210,
"y": 3980,
"wires": [
[
"46eb239d.5ebb5c"
]
]
},
{
"id": "694ac227.d3092c",
"type": "comment",
"z": "b2e011e3.97a98",
"name": "КИК ПО ИСТЕЧЕНИЮ ДОСТУПА",
"info": "",
"x": 180,
"y": 3920,
"wires": []
},
{
"id": "2aac6bb6.622ff4",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "SELECT DISTINCT user_id FROM tgcommunity_members WHERE expires_at < ? AND reminder_state < 1;",
"queryParamsType": "msg",
"queryParams": "sqlParams",
"name": "Получ участников",
"property": "payload",
"x": 550,
"y": 3800,
"wires": [
[
"e4d404ed.145a98"
]
]
},
{
"id": "6d4cff81.7efc8",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "set",
"p": "time24h",
"pt": "msg",
"to": "payload+86400000",
"tot": "jsonata"
},
{
"t": "set",
"p": "sqlParams[0]",
"pt": "msg",
"to": "time24h",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 415,
"y": 3800,
"wires": [
[
"2aac6bb6.622ff4"
]
],
"l": false
},
{
"id": "e4d404ed.145a98",
"type": "split",
"z": "b2e011e3.97a98",
"name": "",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"x": 830,
"y": 3800,
"wires": [
[
"ac59f94c.4b7bc8"
]
]
},
{
"id": "ac59f94c.4b7bc8",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "set",
"p": "userId",
"pt": "msg",
"to": "payload.user_id",
"tot": "msg"
},
{
"t": "delete",
"p": "apiData",
"pt": "msg"
},
{
"t": "set",
"p": "apiData.chat_id",
"pt": "msg",
"to": "userId",
"tot": "msg"
},
{
"t": "set",
"p": "apiData.parse_mode",
"pt": "msg",
"to": "HTML",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1015,
"y": 3780,
"wires": [
[
"b7670e15.1f406"
]
],
"l": false
},
{
"id": "f29051e2.f11cb",
"type": "drom-tg-api-call",
"z": "b2e011e3.97a98",
"name": "Отправ напоминание",
"data": "apiData",
"dataType": "msg",
"method": "sendMessage",
"methodType": "str",
"property": "payload",
"client": "4497dbb.2648f24",
"x": 1320,
"y": 3820,
"wires": [
[
"2707d3c5.839d1c"
]
]
},
{
"id": "b7670e15.1f406",
"type": "drom-template",
"z": "b2e011e3.97a98",
"name": "Завтра истекает",
"field": "apiData.text",
"fieldType": "msg",
"syntax": "handlebars",
"htmlEscape": false,
"template": "Завтра истекает Ваш доступ. Нажмите <b>НАЧАТЬ</b> для продления.",
"x": 1150,
"y": 3780,
"wires": [
[
"b8a5acca.87305"
]
]
},
{
"id": "b8a5acca.87305",
"type": "function",
"z": "b2e011e3.97a98",
"name": "Клавиатура",
"func": "msg.apiData.reply_markup = {\n \"inline_keyboard\": [\n [\n {\n \"text\": \"НАЧАТЬ\",\n \"callback_data\": \"start\"\n }\n ]\n ]\n};\n\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 1350,
"y": 3780,
"wires": [
[
"f29051e2.f11cb"
]
]
},
{
"id": "e7cc0214.7e3b3",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "UPDATE tgcommunity_members\nSET reminder_state = 1\nWHERE user_id = ? AND expires_at < ? AND reminder_state < 1;",
"queryParamsType": "msg",
"queryParams": "sqlParams",
"name": "Обнов участника",
"property": "payload",
"x": 1710,
"y": 3800,
"wires": [
[]
]
},
{
"id": "2707d3c5.839d1c",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "delete",
"p": "sqlParams",
"pt": "msg"
},
{
"t": "set",
"p": "sqlParams[0]",
"pt": "msg",
"to": "userId",
"tot": "msg"
},
{
"t": "set",
"p": "sqlParams[1]",
"pt": "msg",
"to": "time24h",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1575,
"y": 3800,
"wires": [
[
"e7cc0214.7e3b3"
]
],
"l": false
},
{
"id": "62df6554.c44e2c",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "SELECT * FROM tgcommunity_members WHERE expires_at < ? AND reminder_state < 2;",
"queryParamsType": "msg",
"queryParams": "sqlParams",
"name": "Получ участников",
"property": "payload",
"x": 550,
"y": 3980,
"wires": [
[
"da15c5fc.690ca8"
]
]
},
{
"id": "46eb239d.5ebb5c",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "set",
"p": "timeNow",
"pt": "msg",
"to": "payload",
"tot": "msg"
},
{
"t": "set",
"p": "sqlParams[0]",
"pt": "msg",
"to": "timeNow",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 415,
"y": 3980,
"wires": [
[
"62df6554.c44e2c"
]
],
"l": false
},
{
"id": "da15c5fc.690ca8",
"type": "split",
"z": "b2e011e3.97a98",
"name": "",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"x": 830,
"y": 3980,
"wires": [
[
"ccfc98a0.376478"
]
]
},
{
"id": "ccfc98a0.376478",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "set",
"p": "member",
"pt": "msg",
"to": "payload",
"tot": "msg"
},
{
"t": "delete",
"p": "apiData",
"pt": "msg"
},
{
"t": "set",
"p": "apiData.chat_id",
"pt": "msg",
"to": "member.chat_id",
"tot": "msg"
},
{
"t": "set",
"p": "apiData.user_id",
"pt": "msg",
"to": "member.user_id",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1015,
"y": 3980,
"wires": [
[
"f3408fb3.85663"
]
],
"l": false
},
{
"id": "f3408fb3.85663",
"type": "drom-tg-api-call",
"z": "b2e011e3.97a98",
"name": "Кик участника",
"data": "apiData",
"dataType": "msg",
"method": "kickChatMember",
"methodType": "str",
"property": "payload",
"client": "55c122b.68894dc",
"x": 1140,
"y": 3980,
"wires": [
[
"8d4b8194.64a71"
]
]
},
{
"id": "44d60aea.bef6f4",
"type": "drom-data-query",
"z": "b2e011e3.97a98",
"storage": "6c999ed1.7d41f",
"exec": "single",
"queryType": "prepared",
"queryProp": "",
"queryText": "UPDATE tgcommunity_members\nSET reminder_state = 2\nWHERE chat_id = ? AND user_id = ?;",
"queryParamsType": "msg",
"queryParams": "sqlParams",
"name": "Обнов участника",
"property": "payload",
"x": 1430,
"y": 3980,
"wires": [
[]
]
},
{
"id": "8d4b8194.64a71",
"type": "change",
"z": "b2e011e3.97a98",
"name": "",
"rules": [
{
"t": "delete",
"p": "sqlParams",
"pt": "msg"
},
{
"t": "set",
"p": "sqlParams[0]",
"pt": "msg",
"to": "member.chat_id",
"tot": "msg"
},
{
"t": "set",
"p": "sqlParams[1]",
"pt": "msg",
"to": "member.user_id",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1295,
"y": 3980,
"wires": [
[
"44d60aea.bef6f4"
]
],
"l": false
},
{
"id": "e618861.5c48378",
"type": "comment",
"z": "b2e011e3.97a98",
"name": "Просмотр данных",
"info": "",
"x": 170,
"y": 580,
"wires": []
},
{
"id": "fa7fe85c.69daf8",
"type": "inject",
"z": "b2e011e3.97a98",
"d": true,
"name": "Тест оповещения",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 200,
"y": 2620,
"wires": [
[
"dbaa7387.84f7"
]
]
},
{
"id": "4459ccfe.ef0a74",
"type": "change",
"z": "b2e011e3.97a98",
"name": "👛 Номер кошелька",
"rules": [
{
"t": "set",
"p": "yoom",
"pt": "msg",
"to": "410010000000001",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 2660,
"y": 1580,
"wires": [
[
"f333cd11.eb2eb"
]
]
},
{
"id": "a88158fd.a097d8",
"type": "comment",
"z": "b2e011e3.97a98",
"name": "Перейти к оплате",
"info": "",
"x": 1410,
"y": 1520,
"wires": []
},
{
"id": "d2c70afe.5bd7a8",
"type": "comment",
"z": "b2e011e3.97a98",
"name": "Оплачено",
"info": "",
"x": 1380,
"y": 1660,
"wires": []
},
{
"id": "c2af8448.bd9c78",
"type": "comment",
"z": "b2e011e3.97a98",
"name": "start - выбор тарифа",
"info": "",
"x": 1420,
"y": 1240,
"wires": []
},
{
"id": "fe3062.9c493fa",
"type": "comment",
"z": "b2e011e3.97a98",
"name": "Выбор способа оплаты",
"info": "",
"x": 1430,
"y": 1380,
"wires": []
},
{
"id": "173d0319.7d23bd",
"type": "comment",
"z": "b2e011e3.97a98",
"name": "Получение доступа",
"info": "",
"x": 1410,
"y": 1940,
"wires": []
},
{
"id": "ac41d955.b868b8",
"type": "comment",
"z": "b2e011e3.97a98",
"name": "Дать доступ",
"info": "",
"x": 1090,
"y": 2100,
"wires": []
},
{
"id": "7000ea1d.d7e3d4",
"type": "drom-template",
"z": "b2e011e3.97a98",
"name": "📝 Новое описание продукта",
"field": "descr",
"fieldType": "msg",
"syntax": "plain",
"htmlEscape": false,
"template": "Есть несколько тарифов для получения доступа к сообществу на 1/3/6/12 месяцев.\n\n<b>Выберите Ваш тарифный план</b>",
"x": 1270,
"y": 440,
"wires": [
[
"d41b988a.f71b38"
]
]
},
{
"id": "6c999ed1.7d41f",
"type": "drom-data-config",
"name": "",
"dbType": "sqlite",
"sqliteFile": "my-data.sqlite"
},
{
"id": "4497dbb.2648f24",
"type": "drom-tg-api-config",
"name": "Лэндинг Бот"
},
{
"id": "55c122b.68894dc",
"type": "drom-tg-api-config",
"name": "Админ Бот"
}
]
Настройка#
- Скопируйте JSON потока и импортируйте в ваш Ботодром - у вас появится новая вкладка "TG Платная подписка"
- Откройте боковую панель узлов конфигурации и настройте конфиг-узлы:
- Лэндинг Бот - Введите токен вашего Telegram бота, через которого пользователи будут покупать тарифы и получать доступ к группе/каналу. Инструкции по регистрации нового бота и получению его токена вы можете найти на боковой панели справки, в документации к узлу
drom-tg-api-config
. - Админ Бот - Введите токен вашего Telegram бота, который будет присылать вам оповещения и выгонять из сообщества тех, у кого закончился срок доступа.
- Файл my-data.sqlite - Для хранения данных используется файл
my-data.sqlite
. При желании можно выбрать другой файл.
- Лэндинг Бот - Введите токен вашего Telegram бота, через которого пользователи будут покупать тарифы и получать доступ к группе/каналу. Инструкции по регистрации нового бота и получению его токена вы можете найти на боковой панели справки, в документации к узлу
- Нажмите Развернуть.
- Убедитесь, что Админ Бот состоит в сообществах, где будет платный доступ, а также, что у него установлены права администратора с возможностью добавлять и удалять участников.
- В верхней части потока найдите секцию "Администрирование". Там в секции "Хранилища данных" нажмите кнопку узла "Запустить настройку", чтобы настроить хранилище данных для платных подписок.
- Используйте секцию "Продукты" для настройки продуктов. Продукт - это группа тарифов, которая будет предлагаться пользователям лэндинг-ботом.
- Добавление продукта:
- В узле "📝 Название продукта" введите название - оно используется при выставлении счета на оплату.
- В узле "📝 Описание продукта" введите описание тарифов - оно будет показано пользователю после нажатия "НАЧАТЬ" в лэндинг-боте.
- Нажмите Развернуть.
- Нажмите кнопку, запускающую узел "Добавить продукт".
- Получение данных обо всех добавленных продуктах и их
id
:- Запустите узел "Получить все продукты" - он выведет на боковую панель отладки данные обо всех продуктах.
- Изменение продукта:
- В узле "🆔 id продукта для правки" введите
id
продукта, чьи данные вы хотите изменить. - В узлах "📝 Новое название продукта" и "📝 Новое описание продукта" введите название и описание, которые будут установлены для продукта.
- Нажмите Развернуть.
- Нажмите кнопку, запускающую узел "Изменить продукт".
- В узле "🆔 id продукта для правки" введите
- Добавление продукта:
- Используйте секцию "Тарифы" для настройки тарифов. Тариф - это то, что лэндинг-бот будет предлагать пользователю купить.
- Добавление тарифа:
- В узле "📝 Данные тарифа" введите
id
продукта, для которого будет добавлен тариф, а также название и цену. - Нажмите Развернуть.
- Нажмите кнопку, запускающую узел "Добавить тариф".
- В узле "📝 Данные тарифа" введите
- Получение данных обо всех добавленных тарифах и их
id
:- Запустите узел "Получить все тарифы" - он выведет на боковую панель отладки данные обо всех тарифах.
- Получение данных только о включенных тарифах для определенного продукта:
- В узле "🆔 id продукта" введите
id
продукта, чьи тарифы вы хотите получить. - Запустите узел "Получить активные тарифы продукта" - он выведет на боковую панель отладки данные об активных тарифах для указанного продукта.
- В узле "🆔 id продукта" введите
- Изменение тарифа:
- В узле "🆔 id тарифа для правки" введите
id
тарифа, чьи данные вы хотите изменить. - В узле "📝 Новые данные тарифа" введите название и цену, которые будут установлены для тарифа.
- Нажмите Развернуть.
- Нажмите кнопку, запускающую узел "Изменить тариф".
- В узле "🆔 id тарифа для правки" введите
- Отключение тарифа:
- В узле "🆔 id тарифа для отключения" введите
id
тарифа, который вы хотите отключить. - Нажмите Развернуть.
- Нажмите кнопку, запускающую узел "Отключить тариф".
- В узле "🆔 id тарифа для отключения" введите
- Включение тарифа:
- В узле "🆔 id тарифа для включения" введите
id
тарифа, который вы хотите включить обратно. - Нажмите Развернуть.
- Нажмите кнопку, запускающую узел "Включить тариф".
- В узле "🆔 id тарифа для включения" введите
- Добавление тарифа:
- Используйте секцию "Тарифы: доступы" для настройки доступов, выдаваемых пользователю при покупке тарифа.
- Добавление доступа:
- В узле "📝 Данные доступа" введите
id
тарифа, для которого будет добавлен доступ, а такжеid
Telegram-сообщества, куда будет выдан доступ, количество дней доступа и описание доступа, которое будет отправлено лэндинг-ботом пользователю. Чтобы узнатьid
Telegram-сообщества, воспользуйтесь ботом для получения ID. - Нажмите Развернуть.
- Нажмите кнопку, запускающую узел "Добавить доступ".
- В узле "📝 Данные доступа" введите
- Получение данных обо всех добавленных доступах и их
id
:- Запустите узел "Получить все доступы" - он выведет на боковую панель отладки данные обо всех доступах.
- Получение данных о доступах только для определенного тарифа:
- В узле "🆔 id тарифа" введите
id
тарифа, чьи доступы вы хотите получить. - Запустите узел "Получить доступы тарифа" - он выведет на боковую панель отладки данные о доступах для указанного тарифа.
- В узле "🆔 id тарифа" введите
- Изменение доступа:
- В узле "🆔 id доступа для правки" введите
id
доступа, чьи данные вы хотите изменить. - В узле "📝 Новые данные доступа" введите
id
Telegram-сообщества, количество дней и описание, которые будут установлены для доступа. - Нажмите Развернуть.
- Нажмите кнопку, запускающую узел "Изменить тариф".
- В узле "🆔 id доступа для правки" введите
- Добавление доступа:
- В секции "ЛЭНДИНГ БОТ" найдите узел "🆔 Id продукта" под узлом "Обновления лэндинг-бота" и введите в его настройках
id
продукта, который вы добавили. - В той же секции найдите узел "👛 Номер кошелька" в ветке "Перейти к оплате" и введите в его настройках номер вашего кошелька в ЮMoney.
- В секции "СООБЩЕНИЕ АДМИНУ" найдите узел "🆔 Id админа" и введите в его настройках ваш
id
в Telegram. Чтобы узнать вашid
в Telegram, воспользуйтесь ботом для получения ID. - Чтобы выдавать доступ пользователям не вручную, а автоматически сразу после оплаты, настройте обработчик оповещений о входящих переводах ЮMoney. Для этого найдите узел "Вх.перевод ЮMoney" в секции "ОПОВЕЩЕНИЯ ОТ ЮMONEY" и выполните настройку по этой инструкции (шаги 2-11).
- Нажмите Развернуть.
- Готово! Откройте лэндинг-бот и попробуйте получить доступ к вашему сообществу по подписке.