Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

iobroker.telegram-menu

Package Overview
Dependencies
Maintainers
2
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iobroker.telegram-menu - npm Package Compare versions

Comparing version 0.7.1 to 0.7.2

15

admin/js/emit.js

@@ -29,2 +29,3 @@ /*global $,newSelectInstanceRow */

function getAllTelegramInstances(socket, _this) {
console.log("getAllTelegramInstances");
const id = [];

@@ -40,9 +41,10 @@ try {

for (let i = 0; i < doc.rows.length; i++) {
console.log(doc.rows[i]);
if (
doc.rows[i].value &&
doc.rows[i].value.common &&
doc.rows[i].value.common.titleLang &&
doc.rows[i].value.common.titleLang.en &&
doc.rows[i].value.common.titleLang.en == "Telegram"
// doc.rows[i].value.common.title == "Telegram"
(doc.rows[i].value &&
doc.rows[i].value.common &&
doc.rows[i].value.common.titleLang &&
doc.rows[i].value.common.titleLang.en &&
doc.rows[i].value.common.titleLang.en == "Telegram") ||
doc.rows[i].value.common.title == "Telegram"
) {

@@ -56,2 +58,3 @@ id.push(doc.rows[i].id.replace(/^system\.adapter\./, ""));

});
console.log("Instancen: " + id);
}

@@ -58,0 +61,0 @@ }

6

admin/js/global.js
/*global $, */
/*eslint no-unused-vars: ["error", { "varsIgnorePattern": "isInputFieldEmpty|countOccurrences|deleteDoubleEntrysInArray|"}]*/
/*eslint no-unused-vars: ["error", { "varsIgnorePattern": "isInputFieldEmpty|countOccurrences|deleteDoubleEntrysInArray|replaceAll|isInputFieldEmty|sortArray"}]*/
/**

@@ -60,1 +60,5 @@ * Counts how often an element is present in the array

}
function replaceAll(text, searchValue, replaceValue) {
return text.replace(new RegExp(searchValue, "g"), replaceValue);
}

@@ -538,2 +538,3 @@ /*global deleteDoubleEntrysInArray,sortArray,newUserBtn,getUsersFromTelegram ,navElement, userSelectionTelegram ,actionElement,createSelectTrigger,newTableRow_Action,newTableRow_Action,newTrInAction,userActivCheckbox,$, groupUserInput*/

texts = valuesToArray($this, "p[data-name='text']");
console.log(texts);
}

@@ -609,3 +610,4 @@ if (action == "pic") {

.each(function () {
val.push($(this).html().trim() != "-" ? $(this).html() : "");
// #63 - Bugfix
val.push($(this).html().trim() != "-" ? $(this).html().replaceAll('"', "'") : "");
});

@@ -612,0 +614,0 @@ return val;

{
"common": {
"name": "telegram-menu",
"version": "0.7.1",
"version": "0.7.2",
"news": {
"0.7.2": {
"en": "submenu Number fixed\ntext is lost when editing #63\nconvert milliseconds value to a local time specification\nsetstate and get result of another state with text adjusted",
"de": "unterpositionen Anzahl fest\ntext wird beim editieren von #63 verloren\nmillisekunden-wert in eine lokale zeitvorgabe umwandeln\nsetstate und erhalten ergebnis eines anderen staates mit text angepasst",
"ru": "подменю Номер фиксированный\nтекст теряется при редактировании #63\nконвертировать миллисекундное значение в местную спецификацию времени\nsetstate и получить результат другого государства с текстом скорректирован",
"pt": "submenu Número fixo\ntexto é perdido ao editar #63\nconverter valor de milissegundos para uma especificação de tempo local\nsetstate e obter resultado de outro estado com texto ajustado",
"nl": "submenu Nummer gerepareerd\nsms is verloren als editing 63\nverbergt milliseconden waarde voor een plaatselijke tijd specifiek\nvertaling:",
"fr": "sous-menu Nombre fixe\ntexte est perdu lors de l'édition #63\nconvertir la valeur millisecondes à une spécification locale\nsetstate and get result of another state with text adjusted",
"it": "sottomenu Numero fisso\ntesto si perde quando si modifica #63\nconvertire il valore di millisecondi in una specifica dell'ora locale\nsetstate e ottenere il risultato di un altro stato con testo regolato",
"es": "submenú Número fijo\ntexto se pierde cuando se edita #63\nconvertir el valor de milisegundos a una especificación de tiempo local\nsetstate y obtener resultado de otro estado con texto ajustado",
"pl": "submenu liczba stała\ntekst został utracony podczas edycji #63\nwartość zwrotu milisekund do specyfikacji czasu lokalnego\nzbiór i dostaniemy rezultat innego stanu z tekstem dostosowywanym",
"uk": "субмену Номер фіксований\nтекст втрачено при редагування #63\nконвертувати значення мілісекундів в локальну специфікацію часу\nsetstate і отримати результат іншої держави з текстом",
"zh-cn": "分项 固定人数\n编辑第63号\n当地时间的具体化肥价值\na. 一国和另一国由于经调整案文"
},
"0.7.1": {

@@ -83,15 +96,2 @@ "en": "bugfix, Error read UserListTypeError: Cannot read properties of undefined",

"zh-cn": "a. 固定状态,向男子发出错误的通知"
},
"0.6.6": {
"en": "add info-big.png",
"de": "info-big.png",
"ru": "добавить info-big.png",
"pt": "adicionar info-big.png",
"nl": "voeg info-big toe",
"fr": "ajouter info-big.png",
"it": "aggiungere info-big.png",
"es": "añadir info-big.png",
"pl": "info-big.png",
"uk": "javascript licenses api веб-сайт go1.13.8",
"zh-cn": "增 编"
}

@@ -98,0 +98,0 @@ },

@@ -32,4 +32,5 @@ const sendToTelegram = require("./telegram").sendToTelegram;

const startindex = textToSend.indexOf("change{");
const match = textToSend.substring(startindex + "change".length + 1, textToSend.indexOf("}", startindex));
let match = textToSend.substring(startindex + "change".length + 1, textToSend.indexOf("}", startindex));
let objChangeValue;
match = match.replaceAll("'", '"');
if (Utils.isJSON("{" + match + "}")) objChangeValue = JSON.parse("{" + match + "}");

@@ -104,25 +105,29 @@ else {

const promises = enums.map(async (id) => {
const value = await _this.getForeignStateAsync(id);
if (value && value.val) {
_this.log.debug("Value " + JSON.stringify(value.val));
_this.log.debug("text " + JSON.stringify(text));
let newtext = text;
let name;
if (text.includes("{common.name}")) {
_this.log.debug("test ");
name = await _this.getForeignObjectAsync(id);
_this.log.debug("Name " + JSON.stringify(name));
// _this.log.debug("Name " + JSON.stringify(await _this.getForeignObjectAsync(id)));
if (name && name.common.name)
newtext = newtext.replace("{common.name}", name.common.name);
try {
const value = await _this.getForeignStateAsync(id);
if (value && value.val) {
_this.log.debug("Value " + JSON.stringify(value.val));
_this.log.debug("text " + JSON.stringify(text));
let newtext = text;
let name;
if (text.includes("{common.name}")) {
_this.log.debug("test ");
name = await _this.getForeignObjectAsync(id);
_this.log.debug("Name " + JSON.stringify(name));
// _this.log.debug("Name " + JSON.stringify(await _this.getForeignObjectAsync(id)));
if (name && name.common.name)
newtext = newtext.replace("{common.name}", name.common.name);
}
if (text.includes("&amp;&amp;")) text2Send += newtext.replace("&amp;&amp;", value.val);
else {
text2Send += newtext;
text2Send += " " + value.val;
}
}
if (text.includes("&amp;&amp;")) text2Send += newtext.replace("&amp;&amp;", value.val);
else {
text2Send += newtext;
text2Send += " " + value.val;
}
if (newline == "true") text2Send += "\n";
else text2Send += " ";
_this.log.debug("text2send " + JSON.stringify(text2Send));
} catch (e) {
_this.log.error("Error idBySelector: " + JSON.stringify(e));
}
if (newline == "true") text2Send += "\n";
else text2Send += " ";
_this.log.debug("text2send " + JSON.stringify(text2Send));
});

@@ -129,0 +134,0 @@ Promise.all(promises)

@@ -17,6 +17,6 @@ const sendToTelegram = require("./telegram").sendToTelegram;

function getstate(_this, part, userToSend, telegramInstance, one_time_keyboard, resize_keyboard, userListWithChatID) {
try {
let text = "";
let i = 1;
part.getData.forEach(async (element) => {
let text = "";
let i = 1;
part.getData.forEach(async (element) => {
try {
_this.log.debug("Get Value ID " + JSON.stringify(element.id));

@@ -53,2 +53,13 @@ const specificatorSelektor = "functions=";

let textToSend = element.text.toString();
if (textToSend.includes("{time}")) {
const time = new Date(value.val);
const timeString = time.toLocaleDateString("de-DE", {
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
hour12: false,
});
textToSend = textToSend.replace("{time}", timeString);
val = "";
}
if (textToSend.includes("math:")) {

@@ -90,7 +101,7 @@ const result = calcValue(_this, textToSend, val);

}
});
} catch (error) {
_this.log.error("Error Getdata: " + JSON.stringify(error));
}
} catch (error) {
_this.log.error("Error Getdata: " + JSON.stringify(error));
}
});
}
module.exports = { getstate };

@@ -0,1 +1,3 @@

const sendToTelegram = require("./telegram").sendToTelegram;
/**

@@ -10,3 +12,13 @@ * Sets the state

*/
function setstate(_this, part, userToSend, valueFromSubmenu, SubmenuValuePriority) {
function setstate(
_this,
part,
userToSend,
valueFromSubmenu,
SubmenuValuePriority,
telegramInstance,
resize_keyboard,
one_time_keyboard,
userListWithChatID,
) {
try {

@@ -26,3 +38,3 @@ const setStateIds = [];

} else if (returnText.includes("ack:false")) {
_this.log.debug("Set sck: " + JSON.stringify(false));
_this.log.debug("Set ack: " + JSON.stringify(false));
ack = false;

@@ -32,3 +44,3 @@ returnText = element.returnText.replace("ack:false", "").trim();

if (!returnText.includes('{"id":"')) {
if (!returnText.includes("{'id':'")) {
setStateIds.push({

@@ -43,3 +55,19 @@ id: element.id,

try {
const returnObj = JSON.parse(returnText);
_this.log.debug("Returntext " + JSON.stringify(returnText));
returnText = returnText.replaceAll("'", '"');
const textToSend = returnText.slice(0, returnText.indexOf("{"));
const returnObj = JSON.parse(
returnText.slice(returnText.indexOf("{"), returnText.indexOf("}") + 1),
);
sendToTelegram(
_this,
userToSend,
textToSend,
undefined,
telegramInstance,
one_time_keyboard,
resize_keyboard,
userListWithChatID,
);
_this.log.debug("JSON parse: " + JSON.stringify(returnObj));
setStateIds.push({

@@ -46,0 +74,0 @@ id: returnObj.id,

@@ -25,5 +25,14 @@ const setstate = require("./setstate").setstate;

) {
const splittetText = part.split(`"`)[1].split(":");
const callbackData = splittetText[1];
let device2Switch = splittetText[2];
_this.log.debug("Part: " + JSON.stringify(part));
let splittetText = [];
let callbackData = "";
let device2Switch = "";
if (part.includes('"')) {
splittetText = part.split(`"`)[1].split(":");
} else {
splittetText = part.split(":");
}
device2Switch = splittetText[2];
callbackData = splittetText[1];
_this.log.debug("callbackData: " + JSON.stringify(callbackData));

@@ -63,3 +72,13 @@ _this.log.debug("splittet Data of callbackData " + JSON.stringify(splittetText[1]));

}
const result = setstate(_this, groupData[device2Switch], userToSend, val, true);
const result = setstate(
_this,
groupData[device2Switch],
userToSend,
val,
true,
undefined,
undefined,
undefined,
undefined,
);
if (Array.isArray(result)) returnIDToListenTo = result;

@@ -76,3 +95,13 @@ return [null, null, null, returnIDToListenTo];

}
const result = setstate(_this, groupData[device2Switch], userToSend, val, true);
const result = setstate(
_this,
groupData[device2Switch],
userToSend,
val,
true,
undefined,
undefined,
undefined,
undefined,
);
if (Array.isArray(result)) returnIDToListenTo = result;

@@ -115,3 +144,13 @@ return [null, null, null, returnIDToListenTo];

const result = setstate(_this, groupData[device2Switch], userToSend, value, true);
const result = setstate(
_this,
groupData[device2Switch],
userToSend,
value,
true,
undefined,
undefined,
undefined,
undefined,
);
if (Array.isArray(result)) returnIDToListenTo = result;

@@ -147,6 +186,6 @@ return [null, null, null, returnIDToListenTo];

} else index = i;
//FIXME - index eine position nach hinten geschoben
menu.push({
text: `${index}${unit}`,
callback_data: `submenu:${callbackData}:${index}:${device2Switch}`,
callback_data: `submenu:${callbackData}:${device2Switch}:${index}`,
});

@@ -166,8 +205,20 @@ rowEntrys++;

} else if (part.includes(`submenu:${callbackData}`)) {
const value = parseInt(part.split(":")[2]);
device2Switch = part.split(":")[3];
_this.log.debug("CallbackData" + JSON.stringify(callbackData));
//FIXME - value und device2Switch vertauscht
const value = parseInt(part.split(":")[3]);
device2Switch = part.split(":")[2];
_this.log.debug(
JSON.stringify({ device2Switch: device2Switch, data: groupData, user: userToSend, value: value }),
);
const result = setstate(_this, groupData[device2Switch], userToSend, value, true);
const result = setstate(
_this,
groupData[device2Switch],
userToSend,
value,
true,
undefined,
undefined,
undefined,
undefined,
);
if (Array.isArray(result)) returnIDToListenTo = result;

@@ -174,0 +225,0 @@ return [null, null, null, returnIDToListenTo];

@@ -49,3 +49,3 @@ "use strict";

let instanceTelegram = this.config.instance;
if (instanceTelegram.length == 0) instanceTelegram = "telegram.0";
if (!instanceTelegram || instanceTelegram.length == 0) instanceTelegram = "telegram.0";
const telegramID = `${instanceTelegram}.communicate.request`;

@@ -198,3 +198,15 @@ const datapoint = `${instanceTelegram}.info.connection`;

if (processData(this, groupData, calledValue, userToSend, group)) {
if (
processData(
this,
groupData,
calledValue,
userToSend,
group,
instanceTelegram,
resize_keyboard,
one_time_keyboard,
userListWithChatID,
)
) {
dataFound = true;

@@ -296,3 +308,13 @@ break;

*/
function processData(_this, groupData, calledValue, userToSend = "", groupWithUser) {
function processData(
_this,
groupData,
calledValue,
userToSend = "",
groupWithUser,
instanceTelegram,
resize_keyboard,
one_time_keyboard,
userListWithChatID,
) {
if (groupData[calledValue] && userToSend && groupWithUser && userActiveCheckbox[groupWithUser]) {

@@ -305,3 +327,12 @@ const part = groupData[calledValue];

if (JSON.stringify(part.nav).includes("menu")) {
callSubMenu(_this, JSON.stringify(part.nav), groupData, userToSend);
callSubMenu(
_this,
JSON.stringify(part.nav),
groupData,
userToSend,
instanceTelegram,
resize_keyboard,
one_time_keyboard,
userListWithChatID,
);
return true;

@@ -327,3 +358,13 @@ } else {

else if (part.switch) {
setStateIdsToListenTo = setstate(_this, part, userToSend, 0, false);
setStateIdsToListenTo = setstate(
_this,
part,
userToSend,
0,
false,
instanceTelegram,
resize_keyboard,
one_time_keyboard,
userListWithChatID,
);

@@ -381,18 +422,22 @@ _this.log.debug("SubmenuData3" + JSON.stringify(setStateIdsToListenTo));

const timeout = _this.setTimeout(async () => {
_this.log.debug("Send Pic to Telegram");
sendToTelegram(
_this,
userToSend,
path,
undefined,
instanceTelegram,
resize_keyboard,
one_time_keyboard,
userListWithChatID,
);
try {
_this.log.debug("Send Pic to Telegram");
sendToTelegram(
_this,
userToSend,
path,
undefined,
instanceTelegram,
resize_keyboard,
one_time_keyboard,
userListWithChatID,
);
let timeoutToClear = {};
timeoutToClear = timeouts.filter((item) => item.key == timeoutKey);
clearTimeout(timeoutToClear.timeout);
timeouts = timeouts.filter((item) => item.key !== timeoutKey);
let timeoutToClear = {};
timeoutToClear = timeouts.filter((item) => item.key == timeoutKey);
clearTimeout(timeoutToClear.timeout);
timeouts = timeouts.filter((item) => item.key !== timeoutKey);
} catch (e) {
_this.log.error("Error: " + JSON.stringify(e));
}
}, parseInt(element.delay));

@@ -411,3 +456,13 @@ _this.log.debug("Timeout add");

} else if (calledValue.startsWith("menu") || calledValue.startsWith("submenu")) {
callSubMenu(_this, calledValue, groupData, userToSend);
_this.log.debug("Call Submenu");
callSubMenu(
_this,
calledValue,
groupData,
userToSend,
instanceTelegram,
resize_keyboard,
one_time_keyboard,
userListWithChatID,
);
return true;

@@ -425,3 +480,12 @@ } else {

*/
function callSubMenu(_this, part, groupData, userToSend) {
function callSubMenu(
_this,
part,
groupData,
userToSend,
instanceTelegram,
resize_keyboard,
one_time_keyboard,
userListWithChatID,
) {
const subMenuData = subMenu(

@@ -428,0 +492,0 @@ _this,

{
"name": "iobroker.telegram-menu",
"version": "0.7.1",
"version": "0.7.2",
"description": "Easily create Telegram Menus",

@@ -5,0 +5,0 @@ "author": {

@@ -36,2 +36,9 @@ ![Logo](admin/telegram-menu.png)

-->
### 0.7.2 (2023-10-15)
- submenu Number fixed
- text is lost when editing #63
- convert milliseconds value to a local time specification
- setstate and get result of another state with text adjusted
### 0.7.1 (2023-10-02)

@@ -38,0 +45,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc