iobroker.telegram-menu
Advanced tools
Comparing version 0.9.0 to 0.9.2
{ | ||
"common": { | ||
"name": "telegram-menu", | ||
"version": "0.9.0", | ||
"version": "0.9.2", | ||
"news": { | ||
"0.9.2": { | ||
"en": "fixed error when the Adapter starts\nDrag & Drop in Action Card", | ||
"de": "fester Fehler beim Start des Adapters\nDrag & Drop in Aktionskarte", | ||
"ru": "исправлена ошибка при запуске адаптера\nПеретащите и упадайте в Action Card", | ||
"pt": "erro fixo quando o adaptador começa\nArrastar e soltar no cartão de ação", | ||
"nl": "als de Adapter begint\nDrag Drop in Action Card", | ||
"fr": "erreur fixe lorsque l'adaptateur démarre\nDrag & Drop in Action Card", | ||
"it": "errore fisso quando l'adattatore inizia\nDrag & Drop in Action Card", | ||
"es": "error fijo cuando el Adaptador comienza\nArrastre y suelte la tarjeta de acción", | ||
"pl": "uruchomiony błąd, gdy Adapter rozpoczyna się od startu\nDrag & Drop, Action Card (ang.)", | ||
"uk": "виправлена помилка при запуску адаптера\nПеретягніть та вставте в дію картку", | ||
"zh-cn": "当Adapter开始时,固定错误\nDrag & Drop Action Card" | ||
}, | ||
"0.9.1": { | ||
"en": "fixed error when the Adapter starts\nDrag & Drop in Action Card", | ||
"de": "fester Fehler beim Start des Adapters\nDrag & Drop in Aktionskarte", | ||
"ru": "исправлена ошибка при запуске адаптера\nПеретащите и упадайте в Action Card", | ||
"pt": "erro fixo quando o adaptador começa\nArrastar e soltar no cartão de ação", | ||
"nl": "als de Adapter begint\nDrag Drop in Action Card", | ||
"fr": "erreur fixe lorsque l'adaptateur démarre\nDrag & Drop in Action Card", | ||
"it": "errore fisso quando l'adattatore inizia\nDrag & Drop in Action Card", | ||
"es": "error fijo cuando el Adaptador comienza\nArrastre y suelte la tarjeta de acción", | ||
"pl": "uruchomiony błąd, gdy Adapter rozpoczyna się od startu\nDrag & Drop, Action Card (ang.)", | ||
"uk": "виправлена помилка при запуску адаптера\nПеретягніть та вставте в дію картку", | ||
"zh-cn": "当Adapter开始时,固定错误\nDrag & Drop Action Card" | ||
}, | ||
"0.9.0": { | ||
@@ -70,28 +96,2 @@ "en": "#75 fixed add new row in Action and edit it", | ||
"zh-cn": "a. 国家间的圆桌会议价值\n固定名称\n固定呼吁附属于附属男子\n转换成目标类型的数值" | ||
}, | ||
"0.8.3": { | ||
"en": "fix, step smaller than 1 in submenu number and percent\ngloabl fixes in submenu", | ||
"de": "fix, schritt kleiner als 1 in untermenünummer und prozent\ngloabl fixes in submenu", | ||
"ru": "исправить, шаг меньше 1 в подменю номер и процент\ngloabl исправляет в подменю", | ||
"pt": "corrigir, passo menor que 1 no número submenu e por cento\ngloabl correções em submenu", | ||
"nl": "vertaling:\ngloabel in submenu", | ||
"fr": "fixer, faire plus petit que 1 dans le numéro de sous-menu et pour cent\ngloabl corrige dans le sous-menu", | ||
"it": "correzione, passo più piccolo di 1 in numero submenu e per cento\nguaabl fissa in submenu", | ||
"es": "fijado, paso más pequeño que 1 en submenú número y porcentaje\ngloabl fijados en submenu", | ||
"pl": "metoda ta jest mniejsza niż 1 w liczbie submenu i 1%\nustalenie w podmenu", | ||
"uk": "фіксація, крок менше 1 в субмену кількість і відсотків\nглобл закріплює в підменю", | ||
"zh-cn": "fix 小于1级和4%\n分项abl f" | ||
}, | ||
"0.8.2": { | ||
"en": "fix {status:...}", | ||
"de": "fix {status.}:", | ||
"ru": "исправить {status.}:", | ||
"pt": "correção", | ||
"nl": "maak status", | ||
"fr": "correction {status.}:", | ||
"it": "correggere {status.}:", | ||
"es": "arréglalo", | ||
"pl": "refix {status.}", | ||
"uk": "фіксація {status.}:", | ||
"zh-cn": "fixstatus:]" | ||
} | ||
@@ -98,0 +98,0 @@ }, |
383
main.js
@@ -62,5 +62,5 @@ "use strict"; | ||
const checkboxNoEntryFound = checkbox["checkboxNoValueFound"]; | ||
// @ts-ignore | ||
const listofMenus = this.config.menus; | ||
// @ts-ignore | ||
let listofMenus = []; | ||
if (this.config.usersInGroup) listofMenus = Object.keys(this.config.usersInGroup); | ||
const startsides = this.config.startsides; | ||
@@ -84,130 +84,68 @@ // @ts-ignore | ||
this.getForeignObject(datapoint, async (err, obj) => { | ||
if (err || obj == null) { | ||
this.log.error(JSON.stringify(err)); | ||
this.log.error(`The State ${datapoint} was not found!`); | ||
} else { | ||
// Datenpunkt wurde gefunden | ||
try { | ||
telegramState = await this.getForeignStateAsync(datapoint); | ||
} catch (e) { | ||
this.log.error("Error getForeignState: " + JSON.stringify(e.message)); | ||
this.log.error(JSON.stringify(e.stack)); | ||
} | ||
telegramAktiv = telegramState?.val; | ||
if (!telegramAktiv) { | ||
this.log.info("Telegram was found, but is not runnig. Please start!"); | ||
} | ||
if (telegramAktiv) { | ||
this.log.info("Telegram was found"); | ||
this.setState("info.connection", true, true); | ||
// @ts-ignore | ||
const data = this.config.data; | ||
const nav = data["nav"]; | ||
const action = data["action"]; | ||
this.log.debug("Groups With Users: " + JSON.stringify(groupsWithUsers)); | ||
this.log.debug("Navigation " + JSON.stringify(nav)); | ||
this.log.debug("Action " + JSON.stringify(action)); | ||
try { | ||
if (err || obj == null) { | ||
this.log.error(JSON.stringify(err)); | ||
this.log.error(`The State ${datapoint} was not found!`); | ||
} else { | ||
// Datenpunkt wurde gefunden | ||
try { | ||
for (const name in nav) { | ||
const value = await editArrayButtons(nav[name], this); | ||
if (value) menuData.data[name] = await generateNewObjectStructure(_this, value); | ||
this.log.debug("New Structure: " + JSON.stringify(menuData.data[name])); | ||
const returnValue = generateActions(_this, action[name], menuData.data[name]); | ||
menuData.data[name] = returnValue?.obj; | ||
subscribeForeignStateIds = returnValue?.ids; | ||
this.log.debug("SubscribeForeignStates: " + JSON.stringify(subscribeForeignStateIds)); | ||
if (subscribeForeignStateIds && subscribeForeignStateIds?.length > 0) { | ||
_subscribeForeignStatesAsync(subscribeForeignStateIds, _this); | ||
} else this.log.debug("Nothing to Subscribe!"); | ||
this.log.debug("Menu: " + JSON.stringify(name)); | ||
this.log.debug("Array Buttons: " + JSON.stringify(value)); | ||
this.log.debug("Gen. Actions: " + JSON.stringify(menuData.data[name])); | ||
} | ||
} catch (err) { | ||
this.log.error("Error generateNav: " + JSON.stringify(err.message)); | ||
this.log.error(JSON.stringify(err.stack)); | ||
telegramState = await this.getForeignStateAsync(datapoint); | ||
} catch (e) { | ||
this.log.error("Error getForeignState: " + JSON.stringify(e.message)); | ||
this.log.error(JSON.stringify(e.stack)); | ||
} | ||
telegramAktiv = telegramState?.val; | ||
if (!telegramAktiv) { | ||
this.log.info("Telegram was found, but is not runnig. Please start!"); | ||
} | ||
if (telegramAktiv) { | ||
this.log.info("Telegram was found"); | ||
this.setState("info.connection", true, true); | ||
this.log.debug("Checkbox " + JSON.stringify(checkbox)); | ||
// @ts-ignore | ||
const data = this.config.data; | ||
const nav = data["nav"]; | ||
const action = data["action"]; | ||
this.log.debug("Groups With Users: " + JSON.stringify(groupsWithUsers)); | ||
this.log.debug("Navigation " + JSON.stringify(nav)); | ||
this.log.debug("Action " + JSON.stringify(action)); | ||
try { | ||
for (const name in nav) { | ||
const value = await editArrayButtons(nav[name], this); | ||
if (value) menuData.data[name] = await generateNewObjectStructure(_this, value); | ||
this.log.debug("New Structure: " + JSON.stringify(menuData.data[name])); | ||
const returnValue = generateActions(_this, action[name], menuData.data[name]); | ||
menuData.data[name] = returnValue?.obj; | ||
subscribeForeignStateIds = returnValue?.ids; | ||
this.log.debug("SubscribeForeignStates: " + JSON.stringify(subscribeForeignStateIds)); | ||
if (subscribeForeignStateIds && subscribeForeignStateIds?.length > 0) { | ||
_subscribeForeignStatesAsync(subscribeForeignStateIds, _this); | ||
} else this.log.debug("Nothing to Subscribe!"); | ||
this.log.debug("Menu: " + JSON.stringify(name)); | ||
this.log.debug("Array Buttons: " + JSON.stringify(value)); | ||
this.log.debug("Gen. Actions: " + JSON.stringify(menuData.data[name])); | ||
} | ||
} catch (err) { | ||
this.log.error("Error generateNav: " + JSON.stringify(err.message)); | ||
this.log.error(JSON.stringify(err.stack)); | ||
} | ||
try { | ||
this.log.debug("MenuList: " + JSON.stringify(listofMenus)); | ||
listofMenus.forEach((menu) => { | ||
this.log.debug("Menu: " + JSON.stringify(menu)); | ||
const startside = [startsides[menu]].toString(); | ||
if (userActiveCheckbox[menu] && startside != "-") { | ||
this.log.debug("Startseite: " + JSON.stringify(startside)); | ||
groupsWithUsers[menu].forEach((user) => { | ||
backMenuFunc(this, startside, null, user); | ||
this.log.debug("User List " + JSON.stringify(userListWithChatID)); | ||
this.log.debug("Checkbox " + JSON.stringify(checkbox)); | ||
sendToTelegram( | ||
_this, | ||
user, | ||
menuData.data[menu][startside].text, | ||
menuData.data[menu][startside].nav, | ||
instanceTelegram, | ||
resize_keyboard, | ||
one_time_keyboard, | ||
userListWithChatID, | ||
); | ||
}); | ||
} else this.log.debug("Menu inactive or is Submenu. " + JSON.stringify({ active: userActiveCheckbox[menu], startside: startside })); | ||
}); | ||
} catch (error) { | ||
this.log.error("Error read UserList" + JSON.stringify(error.message)); | ||
this.log.error(JSON.stringify(error.stack)); | ||
} | ||
} | ||
this.on("stateChange", async (id, state) => { | ||
try { | ||
let userToSend; | ||
if (telegramAktiv && state?.ack) { | ||
if (state && typeof state.val === "string" && state.val != "" && id == telegramID) { | ||
const value = state.val; | ||
const chatID = await this.getForeignStateAsync(`${instanceTelegram}.communicate.requestChatId`); | ||
try { | ||
this.log.debug("MenuList: " + JSON.stringify(listofMenus)); | ||
listofMenus.forEach((menu) => { | ||
this.log.debug("Menu: " + JSON.stringify(menu)); | ||
const startside = [startsides[menu]].toString(); | ||
if (userActiveCheckbox[menu] && startside != "-") { | ||
this.log.debug("Startseite: " + JSON.stringify(startside)); | ||
groupsWithUsers[menu].forEach((user) => { | ||
backMenuFunc(this, startside, null, user); | ||
this.log.debug("User List " + JSON.stringify(userListWithChatID)); | ||
if (chatID) { | ||
this.log.debug("ChatID to use: " + JSON.stringify(chatID.val)); | ||
userListWithChatID.forEach((element) => { | ||
this.log.debug("User and ChatID: " + JSON.stringify(element)); | ||
if (element.chatID == chatID.val) userToSend = element.name; | ||
this.log.debug("User " + JSON.stringify(userToSend)); | ||
}); | ||
} else { | ||
this.log.debug("ChatID not found"); | ||
} | ||
const calledValue = value.slice(value.indexOf("]") + 1, value.length); | ||
this.log.debug( | ||
JSON.stringify({ | ||
Value: value, | ||
User: userToSend, | ||
Todo: calledValue, | ||
groups: groupsWithUsers, | ||
}), | ||
); | ||
const menus = []; | ||
for (const key in groupsWithUsers) { | ||
this.log.debug("Groups " + JSON.stringify(key)); | ||
if (groupsWithUsers[key].includes(userToSend)) { | ||
menus.push(key); | ||
} | ||
} | ||
this.log.debug("Groups with searched User " + JSON.stringify(menus)); | ||
let dataFound = false; | ||
for (const menu of menus) { | ||
const groupData = menuData.data[menu]; | ||
this.log.debug("Nav: " + JSON.stringify(groupData)); | ||
this.log.debug("Menu: " + JSON.stringify(menuData.data)); | ||
this.log.debug("Group: " + JSON.stringify(menu)); | ||
if ( | ||
await processData( | ||
this, | ||
groupData, | ||
calledValue, | ||
userToSend, | ||
menu, | ||
sendToTelegram( | ||
_this, | ||
user, | ||
menuData.data[menu][startside].text, | ||
menuData.data[menu][startside].nav, | ||
instanceTelegram, | ||
@@ -217,52 +155,61 @@ resize_keyboard, | ||
userListWithChatID, | ||
menuData.data, | ||
menus, | ||
) | ||
) { | ||
dataFound = true; | ||
break; | ||
} else continue; | ||
} | ||
if (!dataFound && checkboxNoEntryFound) { | ||
sendToTelegram(this, userToSend, textNoEntryFound, undefined, instanceTelegram, resize_keyboard, one_time_keyboard, userListWithChatID); | ||
} | ||
); | ||
}); | ||
} else this.log.debug("Menu inactive or is Submenu. " + JSON.stringify({ active: userActiveCheckbox[menu], startside: startside })); | ||
}); | ||
} catch (error) { | ||
this.log.error("Error read UserList" + JSON.stringify(error.message)); | ||
this.log.error(JSON.stringify(error.stack)); | ||
} | ||
} | ||
this.on("stateChange", async (id, state) => { | ||
try { | ||
let userToSend; | ||
if (telegramAktiv && state?.ack) { | ||
if (state && typeof state.val === "string" && state.val != "" && id == telegramID) { | ||
const value = state.val; | ||
const chatID = await this.getForeignStateAsync(`${instanceTelegram}.communicate.requestChatId`); | ||
// Auf Setstate reagieren und Wert schicken | ||
} else if (state && setStateIdsToListenTo && setStateIdsToListenTo.find((element) => element.id == id)) { | ||
this.log.debug("State, which is listen to was changed " + JSON.stringify(id)); | ||
setStateIdsToListenTo.forEach((element, key) => { | ||
if (element.id == id) { | ||
this.log.debug("Send Value " + JSON.stringify(element)); | ||
if (element.confirm != "false") { | ||
this.log.debug("User " + JSON.stringify(element.userToSend)); | ||
if (chatID) { | ||
this.log.debug("ChatID to use: " + JSON.stringify(chatID.val)); | ||
userListWithChatID.forEach((element) => { | ||
this.log.debug("User and ChatID: " + JSON.stringify(element)); | ||
if (element.chatID == chatID.val) userToSend = element.name; | ||
this.log.debug("User " + JSON.stringify(userToSend)); | ||
}); | ||
} else { | ||
this.log.debug("ChatID not found"); | ||
} | ||
let textToSend = ""; | ||
textToSend = element.returnText; | ||
// Wenn eine Rückkgabe des Value an den User nicht gewünscht ist soll value durch einen leeren String ersetzt werden | ||
let value = ""; | ||
// Change set value in another Value, like true => on, false => off | ||
let result = {}; | ||
let valueChange = ""; | ||
if (textToSend.toString().includes("change{")) { | ||
result = exchangeValue(textToSend, state.val, this); | ||
if (result) { | ||
textToSend = result["textToSend"]; | ||
valueChange = result["valueChange"]; | ||
} | ||
} | ||
if (textToSend?.toString().includes("{novalue}")) { | ||
value = ""; | ||
textToSend = textToSend.replace("{novalue}", ""); | ||
} else if (state.val || state.val == false) value = state.val?.toString(); | ||
const calledValue = value.slice(value.indexOf("]") + 1, value.length); | ||
this.log.debug( | ||
JSON.stringify({ | ||
Value: value, | ||
User: userToSend, | ||
Todo: calledValue, | ||
groups: groupsWithUsers, | ||
}), | ||
); | ||
const menus = []; | ||
for (const key in groupsWithUsers) { | ||
this.log.debug("Groups " + JSON.stringify(key)); | ||
if (groupsWithUsers[key].includes(userToSend)) { | ||
menus.push(key); | ||
} | ||
} | ||
this.log.debug("Groups with searched User " + JSON.stringify(menus)); | ||
let dataFound = false; | ||
for (const menu of menus) { | ||
const groupData = menuData.data[menu]; | ||
this.log.debug("Nav: " + JSON.stringify(groupData)); | ||
this.log.debug("Menu: " + JSON.stringify(menuData.data)); | ||
this.log.debug("Group: " + JSON.stringify(menu)); | ||
valueChange ? (value = valueChange) : value; | ||
textToSend.toString().indexOf("&&") != -1 | ||
? (textToSend = textToSend.replace("&&", value)) | ||
: (textToSend += " " + value); | ||
this.log.debug("Send Set to Telegram"); | ||
sendToTelegram( | ||
if ( | ||
await processData( | ||
this, | ||
element.userToSend, | ||
textToSend, | ||
undefined, | ||
groupData, | ||
calledValue, | ||
userToSend, | ||
menu, | ||
instanceTelegram, | ||
@@ -272,25 +219,83 @@ resize_keyboard, | ||
userListWithChatID, | ||
); | ||
// Die Elemente auf die Reagiert wurde entfernen | ||
setStateIdsToListenTo.splice(key, 1); | ||
menuData.data, | ||
menus, | ||
) | ||
) { | ||
dataFound = true; | ||
break; | ||
} else continue; | ||
} | ||
if (!dataFound && checkboxNoEntryFound) { | ||
sendToTelegram(this, userToSend, textNoEntryFound, undefined, instanceTelegram, resize_keyboard, one_time_keyboard, userListWithChatID); | ||
} | ||
// Auf Setstate reagieren und Wert schicken | ||
} else if (state && setStateIdsToListenTo && setStateIdsToListenTo.find((element) => element.id == id)) { | ||
this.log.debug("State, which is listen to was changed " + JSON.stringify(id)); | ||
setStateIdsToListenTo.forEach((element, key) => { | ||
if (element.id == id) { | ||
this.log.debug("Send Value " + JSON.stringify(element)); | ||
if (element.confirm != "false") { | ||
this.log.debug("User " + JSON.stringify(element.userToSend)); | ||
let textToSend = ""; | ||
textToSend = element.returnText; | ||
// Wenn eine Rückkgabe des Value an den User nicht gewünscht ist soll value durch einen leeren String ersetzt werden | ||
let value = ""; | ||
// Change set value in another Value, like true => on, false => off | ||
let result = {}; | ||
let valueChange = ""; | ||
if (textToSend.toString().includes("change{")) { | ||
result = exchangeValue(textToSend, state.val, this); | ||
if (result) { | ||
textToSend = result["textToSend"]; | ||
valueChange = result["valueChange"]; | ||
} | ||
} | ||
if (textToSend?.toString().includes("{novalue}")) { | ||
value = ""; | ||
textToSend = textToSend.replace("{novalue}", ""); | ||
} else if (state.val || state.val == false) value = state.val?.toString(); | ||
valueChange ? (value = valueChange) : value; | ||
textToSend.toString().indexOf("&&") != -1 | ||
? (textToSend = textToSend.replace("&&", value)) | ||
: (textToSend += " " + value); | ||
this.log.debug("Send Set to Telegram"); | ||
sendToTelegram( | ||
this, | ||
element.userToSend, | ||
textToSend, | ||
undefined, | ||
instanceTelegram, | ||
resize_keyboard, | ||
one_time_keyboard, | ||
userListWithChatID, | ||
); | ||
// Die Elemente auf die Reagiert wurde entfernen | ||
setStateIdsToListenTo.splice(key, 1); | ||
} | ||
} | ||
} | ||
}); | ||
}); | ||
} | ||
} | ||
} | ||
if (state && id == `${instanceTelegram}.info.connection`) { | ||
if (!state.val) { | ||
telegramAktiv = false; | ||
this.setState("info.connection", false, true); | ||
} else { | ||
this.setState("info.connection", true, true); | ||
telegramAktiv = true; | ||
if (state && id == `${instanceTelegram}.info.connection`) { | ||
if (!state.val) { | ||
telegramAktiv = false; | ||
this.setState("info.connection", false, true); | ||
} else { | ||
this.setState("info.connection", true, true); | ||
telegramAktiv = true; | ||
} | ||
} | ||
} catch (e) { | ||
this.log.error("Error StateChange " + JSON.stringify(e.message)); | ||
this.log.error(JSON.stringify(e.stack)); | ||
} | ||
} catch (e) { | ||
this.log.error("Error StateChange " + JSON.stringify(e.message)); | ||
this.log.error(JSON.stringify(e.stack)); | ||
} | ||
}); | ||
}); | ||
} | ||
} catch (e) { | ||
this.log.error("Error onReady: " + JSON.stringify(e.message)); | ||
this.log.error(JSON.stringify(e.stack)); | ||
} | ||
@@ -297,0 +302,0 @@ }); |
{ | ||
"name": "iobroker.telegram-menu", | ||
"version": "0.9.0", | ||
"version": "0.9.2", | ||
"description": "Easily create Telegram Menus", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -36,3 +36,7 @@ ![Logo](admin/telegram-menu.png) | ||
--> | ||
### 0.9.2 (2023-11-26) | ||
- fixed error when the Adapter starts | ||
- Drag & Drop in Action Card | ||
### 0.9.0 (2023-11-26) | ||
@@ -39,0 +43,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13205809
253
4559