iobroker.telegram-menu 0.4.2 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -33,6 +33,20 @@ You can create different groups with separate menus, and then assign users to th
33
33
  Placeholder for the next version (at the beginning of the line):
34
34
  ### **WORK IN PROGRESS**
35
35
  -->
36
+ ### 0.5.1 (2023-08-05)
37
+
38
+ - sent to the wrong instance, fixed
39
+
40
+ ### 0.5.0 (2023-08-05)
41
+
42
+ - trigger avoid duplicate entries and sort alphabetical
43
+ - adapter stops responding after some time, fixed #42
44
+ - generate Trigger in Action, fixed
45
+ - math value for getstate
46
+ - settings instance #41, menus, fixed
47
+ - no spellcheck for input fields
48
+ - menu go back to last Sides
49
+
36
50
  ### 0.4.2 (2023-07-30)
37
51
 
38
52
  - menu switch ersetzt menu yes-no, on-off, it is possible to customize text and value with this menu
@@ -57,6 +57,8 @@
57
57
  if (settings.usersForGlobal) $("#group_UserInput input[name='Global']").val(settings.usersForGlobal)
58
58
  if (settings.instance) telegramInstance = settings.instance
59
59
  else telegramInstance = "telegram.0"
60
+ console.log("Telegram Instance: " + settings.instance)
61
+ setInstanceSelect(telegramInstance)
60
62
  translateAll()
61
63
 
62
64
 
@@ -204,6 +206,7 @@
204
206
  showUser(activeGroup, showHideUserCheckbox)
205
207
  // User active Button zeigen
206
208
  showHideUserCheckbox(activeGroup)
209
+ generateSelectTrigger(activeGroup)
207
210
  })
208
211
 
209
212
  // Edit Group
@@ -578,7 +581,7 @@
578
581
  <img src="telegram-menu.png" class="logo">
579
582
  </div>
580
583
  </div>
581
- <!-- Header -->
584
+ <!--//SECTION Header -->
582
585
  <div class="row bg--header">
583
586
  <div class="col s12">
584
587
  <ul class="tabs bg--header">
@@ -594,7 +597,7 @@
594
597
  </ul>
595
598
  </div>
596
599
  </div>
597
- <!-- Action Popup -->
600
+ <!--//SECTION Action Popup -->
598
601
  <div id="tab_action" class="modal modal-fixed-footer">
599
602
  <div class="modal-header">
600
603
  </div>
@@ -642,15 +645,16 @@
642
645
  </thead>
643
646
  <tbody class="table-lines table-values">
644
647
  <tr>
645
- <td> <input class="set_id resetInput checkValue" type="text">
648
+ <td> <input class="set_id resetInput checkValue" spellcheck="false" type="text">
646
649
  </td>
647
650
  <td><a class="btn-floating btn-small waves-effect waves-light blue btn_getID"
648
651
  title="Get ID"><i class="material-icons">edit</i></a></td>
649
652
  <td>
650
- <input class="set_value resetInput checkValueSwitch" type="text" value="">
653
+ <input class="set_value resetInput checkValueSwitch" spellcheck="false" type="text"
654
+ value="">
651
655
  </td>
652
656
  <td>
653
- <input class="returnText resetInput " type="text" value="">
657
+ <input class="returnText resetInput " spellcheck="false" type="text" value="">
654
658
  </td>
655
659
  <td>
656
660
  <input type="checkbox" class="filled-in confirm_checkbox resetCheckbox" />
@@ -679,12 +683,12 @@
679
683
  </thead>
680
684
  <tbody class="table-lines table-values">
681
685
  <tr>
682
- <td> <input class="get_id resetInput checkValue" type="text">
686
+ <td> <input class="get_id resetInput checkValue" spellcheck="false" type="text">
683
687
  </td>
684
688
  <td><a class="btn-floating btn-small waves-effect waves-light blue btn_getID"
685
689
  title="Get ID"><i class="material-icons">edit</i></a></td>
686
690
  <td>
687
- <input class="get_text resetInput checkValue" type="text">
691
+ <input class="get_text resetInput checkValue" spellcheck="false" type="text">
688
692
  </td>
689
693
  <td><label>
690
694
  <input type="checkbox" class="filled-in newline_checkbox" checked />
@@ -707,14 +711,14 @@
707
711
  </thead>
708
712
  <tbody class="table-lines table-values">
709
713
  <tr>
710
- <td> <input class="pic_IDs resetInput checkValue" type="text">
714
+ <td> <input class="pic_IDs resetInput checkValue" spellcheck="false" type="text">
711
715
  </td>
712
- <td> <input class="pic_fileName resetInput checkValue" type="text"
716
+ <td> <input class="pic_fileName resetInput checkValue" spellcheck="false" type="text"
713
717
  placeholder="grafana1.png" value="grafana1.png">
714
718
  </td>
715
719
  <td>
716
- <input class="pic_picSendDelay resetInput" type="text" placeholder="5000"
717
- value="5000">
720
+ <input class="pic_picSendDelay resetInput" type="text" spellcheck="false"
721
+ placeholder="5000" value="5000">
718
722
  </td>
719
723
  <td><a class="deleteRow btn-floating btn-small waves-effect waves-light red" disabled><i
720
724
  class="material-icons">delete</i></a></td>
@@ -734,13 +738,13 @@
734
738
  <div class="row " id="group_menu">
735
739
  <div>
736
740
  <a class="btn-add btn-floating btn-small waves-effect waves-light blue disabled translateT"
737
- id="addNewGroup" title="Add new User"><i class="material-icons">group_add</i></a>
741
+ id="addNewGroup" title="Add new Group"><i class="material-icons">group_add</i></a>
738
742
  <a class="btn-delete delete btn-floating btn-small waves-effect waves-light red translateT"
739
743
  id="deleteUser" title="Delete User"><i class="material-icons">delete</i></a>
740
744
  <a class="btn-edit btn-floating btn-small waves-effect waves-light blue translateT" id="editUser"
741
745
  title="Edit User"><i class="material-icons">edit</i></a>
742
746
  <div class="input-field col s4">
743
- <input id="groupname" type="text" class="validate">
747
+ <input id="groupname" spellcheck="false" type="text" class="validate">
744
748
  <label for="groupname" class="translate">Add new Groupname</label>
745
749
  </div>
746
750
  </div>
@@ -772,6 +776,7 @@
772
776
  </div>
773
777
  </div>
774
778
  </header>
779
+ <!-- //SECTION - Navigation -->
775
780
  <div id="tab-nav" class="">
776
781
  <div class="row">
777
782
  <div class="col s12">
@@ -811,7 +816,8 @@
811
816
  </div>
812
817
  <div class="row">
813
818
  <div class="col s3">
814
- <input id="textNoEntry" type="text" class="value translateV" value="Entry not found!">
819
+ <input id="textNoEntry" spellcheck="false" type="text" class="value translateV"
820
+ value="Entry not found!">
815
821
  <label for="textNoEntry" class="translate">Text will be send if no entry was found!</label>
816
822
  </div>
817
823
  <div class="input-field col s3">
@@ -838,11 +844,11 @@
838
844
  </div>
839
845
  <div class="row distance">
840
846
  <div class="input-field col s6">
841
- <input id="tokenGrafana" type="text" class="validate value">
847
+ <input id="tokenGrafana" spellcheck="false" type="text" class="validate value">
842
848
  <label for="tokenGrafana">Token Grafana</label>
843
849
  </div>
844
850
  <div class="input-field col s4">
845
- <input id="directory" type="text" class="validate value"
851
+ <input id="directory" spellcheck="false" type="text" class="validate value"
846
852
  placeholder="/opt/iobroker/grafana/" value="/opt/iobroker/grafana/">
847
853
  <label for="directory" class="translate">Directory</label>
848
854
  </div>
@@ -876,7 +882,7 @@
876
882
  <div class="row">
877
883
  <div class="col s12 dialog-content">
878
884
  <div class=" col s12">
879
- <input id="inputEditUser" type="text">
885
+ <input id="inputEditUser" spellcheck="false" type="text">
880
886
  <label for="inputEditUser" class="translate">Edit Username</label>
881
887
  </div>
882
888
  </div>
@@ -4,7 +4,7 @@
4
4
  function groupUserInput(user, val) {
5
5
  return /*html*/ `<div class="${user}">
6
6
  <label >
7
- <input name="${user}" type="text" value="${val}" >
7
+ <input name="${user}" spellcheck="false" type="text" value="${val}" class="isString" >
8
8
  <span class="translate">Users for this Group, seperate with</span><span> ",".</span>
9
9
  </label>
10
10
  </div>`;
@@ -18,9 +18,9 @@ function navElement(user) {
18
18
  return /*html*/ `
19
19
  <tbody id="${user}"name="${user}" data-name="nav" data-nosave="true" class="user_${user} table_switch_user table_entry value table-lines table-values visibilityArrowBtn" style="display:none">
20
20
  <tr class="startRow">
21
- <td><input type="text" data-name="call" class="isString nav-call translateV startside" value="Startside" ></td>
22
- <td><input type="text" data-name="value" class="isString nav-value " value="Licht, Steckdose && Iobroker, Heizung"></td>
23
- <td><input type="text" data-name="text" class="isString nav-text" value="Wähle eine Aktion"></td>
21
+ <td><input type="text" data-name="call" spellcheck="false" class="isString nav-call translateV startside" value="Startside" ></td>
22
+ <td><input type="text" data-name="value" spellcheck="false" class="isString nav-value " value="Licht, Steckdose && Iobroker, Heizung"></td>
23
+ <td><input type="text" data-name="text" spellcheck="false" class="isString nav-text" value="Wähle eine Aktion"></td>
24
24
  <td></td>
25
25
  <td></td>
26
26
  <td></td>
@@ -46,9 +46,9 @@ function newTableRow_Nav(activuser, users, array) {
46
46
  }
47
47
  return /*html*/ `
48
48
  <tr>
49
- <td><input type="text" data-name="call" class="isString nav-call" value="${call}"></td>
50
- <td><input type="text" data-name="value" class="isString nav-value" value="${value}"></td>
51
- <td><input type="text" data-name="text" class="isString nav-text" value="${text}"></td>
49
+ <td><input type="text" data-name="call" spellcheck="false" class="isString nav-call" value="${call}"></td>
50
+ <td><input type="text" data-name="value" spellcheck="false" class="isString nav-value" value="${value}"></td>
51
+ <td><input type="text" data-name="text" spellcheck="false" class="isString nav-text" value="${text}"></td>
52
52
  <td><a class="deleteRow btn-floating btn-small waves-effect waves-light red"><i class="material-icons">delete</i></a></td>
53
53
  <td><a class="btn-floating btn-small waves-effect waves-light blue btn_down"><i class="material-icons" name="down">arrow_downward</i></a></td>
54
54
  <td><a class="btn-floating btn-small waves-effect waves-light blue btn_up"><i class="material-icons" name="up">arrow_upward</i></a></td>
@@ -70,7 +70,7 @@ function userActivCheckbox(user, val) {
70
70
  <span class="marginTop">${user} <span> </span><span class="translate">active</span>
71
71
  </span></div> `;
72
72
  }
73
- //SECTION - Trigger
73
+ //SECTION - - Trigger
74
74
  function createSelectTrigger(list) {
75
75
  let element = '<option value="" disabled selected class="translate">Choose a trigger</option>';
76
76
  list.forEach(function (e) {
@@ -88,18 +88,18 @@ function newTrInAction(val, array, rows) {
88
88
  }
89
89
  if (val === "get")
90
90
  return /*html*/ `<tr class="onResetDelete">
91
- <td> <input class="get_id checkValue" value="${array[0]}" type="text"></td>
91
+ <td> <input class="get_id checkValue" spellcheck="false" value="${array[0]}" type="text"></td>
92
92
  <td><a class="btn-floating btn-small waves-effect waves-light blue btn_getID" title="Get ID"><i class="material-icons">edit</i></a></td>
93
- <td><input class="get_text checkValue" type="text" value="${array[1]}"></td>
93
+ <td><input class="get_text checkValue" spellcheck="false" type="text" value="${array[1]}"></td>
94
94
  <td><label><input type="checkbox" class="filled-in newline_checkbox" ${array[2]} /><span></span></label></td>
95
95
  <td><a class="deleteRow btn-floating btn-small waves-effect waves-light red" ><i class="material-icons">delete</i></a></td>
96
96
  </tr>`;
97
97
  if (val === "set")
98
98
  return /*html*/ `<tr class="onResetDelete">
99
- <td> <input class="set_id checkValue" type="text" value="${array[0]}"></td>
99
+ <td> <input class="set_id checkValue" spellcheck="false" type="text" value="${array[0]}"></td>
100
100
  <td><a class="btn-floating btn-small waves-effect waves-light blue btn_getID" title="Get ID"><i class="material-icons">edit</i></a></td>
101
- <td><input class="set_value checkValueSwitch" type="text" value="${array[3]}"></td>
102
- <td><input class="returnText resetInput " type="text" value="${array[8]}"></td>
101
+ <td><input class="set_value checkValueSwitch" spellcheck="false" type="text" value="${array[3]}"></td>
102
+ <td><input class="returnText resetInput " spellcheck="false" type="text" value="${array[8]}"></td>
103
103
  <td><label><input type="checkbox" class="filled-in confirm_checkbox" ${array[7]}/><span></span></label></td>
104
104
  <td><label><input type="checkbox" class="filled-in switch_checkbox" ${array[4]}/><span></span></label></td>
105
105
  <td><a class="deleteRow btn-floating btn-small waves-effect waves-light red"><i class="material-icons">delete</i></a></td>
@@ -107,11 +107,10 @@ function newTrInAction(val, array, rows) {
107
107
  </tr>`;
108
108
  if (val === "pic")
109
109
  return /*html*/ `<tr class="onResetDelete">
110
- <td><input class="pic_IDs checkValue" type="text" value="${array[0]}"></td>
111
- <td><input class="pic_fileName checkValue" type="text" placeholder="grafanaX.png" value="${array[6]}"></td>
112
- <td><input class="pic_picSendDelay " type="text" placeholder="5000" value="${array[5]}"></td>
113
- <td><a class="deleteRow btn-floating btn-small waves-effect waves-light red" disabled><i class="material-icons">delete</i></a></td>
114
-
110
+ <td><input class="pic_IDs checkValue" spellcheck="false" type="text" value="${array[0]}"></td>
111
+ <td><input class="pic_fileName checkValue" spellcheck="false" type="text" placeholder="grafanaX.png" value="${array[6]}"></td>
112
+ <td><input class="pic_picSendDelay " spellcheck="false" type="number" placeholder="5000" value="${array[5]}"></td>
113
+ <td><a class="deleteRow btn-floating btn-small waves-effect waves-light red" disabled><i class="material-icons">delete</i></a></td>
115
114
  </tr>`;
116
115
  }
117
116
  //SECTION - Save 2
package/admin/js/main.js CHANGED
@@ -1,6 +1,9 @@
1
1
  /*global newUserBtn ,navElement ,actionElement,createSelectTrigger,newTableRow_Action,newTableRow_Action,newTrInAction, newSelectInstanceRow,userActivCheckbox,$, groupUserInput*/
2
2
  /*eslint no-unused-vars: ["error", { "varsIgnorePattern": "disableEnableInputField|isStringEmty|generate|create|set|fill|reset|add|show|ins|table|get|new|show|checkValueModal|disable|checkUpAndDownArrowBtn|"}]*/
3
3
 
4
+ function setInstanceSelect(instance) {
5
+ $("#select_instance").val(instance);
6
+ }
4
7
  /**
5
8
  *
6
9
  * @param {string} checkbox ID of the checkbox
@@ -222,14 +225,42 @@ function splitTextInArray(activeGroup) {
222
225
  return value_list;
223
226
  }
224
227
 
228
+ //ANCHOR - Trigger erstellen
229
+ //TODO -
225
230
  // @ts-ignore
226
231
  function generateSelectTrigger(activeGroup) {
227
- const list = splitTextInArray(activeGroup);
232
+ let list = [];
233
+ list = splitTextInArray(activeGroup);
234
+ list = deleteDoubleEntrysInArray(list);
235
+ list = sortArray(list);
228
236
  // HTML Elemente löschen und neu aufbauen
229
237
  // @ts-ignore
230
238
  $("#select_trigger").empty().append(createSelectTrigger(list));
231
239
  }
232
240
 
241
+ function deleteDoubleEntrysInArray(arr) {
242
+ return arr.filter((item, index) => arr.indexOf(item) === index);
243
+ }
244
+ /**
245
+ *
246
+ * @param {[]} arr
247
+ * @returns Sorted Array
248
+ */
249
+ function sortArray(arr) {
250
+ arr.sort((a, b) => {
251
+ // @ts-ignore
252
+ const lowerCaseA = a.toLowerCase();
253
+ // @ts-ignore
254
+ const lowerCaseB = b.toLowerCase();
255
+
256
+ if (lowerCaseA < lowerCaseB) return -1;
257
+ if (lowerCaseA > lowerCaseB) return 1;
258
+ return 0;
259
+ });
260
+
261
+ return arr;
262
+ }
263
+
233
264
  // @ts-ignore
234
265
  function fillTable(id, data, newTableRow_Nav, users) {
235
266
  if (data) {
@@ -326,7 +357,7 @@ function insertEditValues(action, $this) {
326
357
  $(`#tab_${action} tbody input.pic_IDs`).val(IDs[0].trim());
327
358
  if (values) $(`#tab_${action} tbody input.set_value`).val(values[0].trim());
328
359
  if (returnText) $(`#tab_${action} tbody input.returnText`).val(returnText[0].trim().replace(/&amp;/g, "&"));
329
- if (texts) $(`#tab_${action} tbody input.get_text`).val(texts[0].trim().replace(/&amp;/g, "&"));
360
+ if (texts) $(`#tab_${action} tbody input.get_text`).val(texts[0].replace(/&amp;/g, "&"));
330
361
  if (picSendDelay) $(`#tab_${action} tbody input.pic_picSendDelay`).val(picSendDelay[0].trim());
331
362
  if (fileName) $(`#tab_${action} tbody input.pic_fileName`).val(fileName[0].trim());
332
363
 
@@ -356,7 +387,7 @@ function insertEditValues(action, $this) {
356
387
  if (confirm && confirm[key].trim() == "true") _confirm = "checked";
357
388
  if (values) _values = values[key].trim();
358
389
  if (returnText) _returnText = returnText[key].trim();
359
- if (texts) _texts = texts[key].trim();
390
+ if (texts) _texts = texts[key];
360
391
  if (picSendDelay) _picSendDelay = picSendDelay[key].trim();
361
392
  if (fileName) _fileName = fileName[key].trim();
362
393
  const array = [
package/io-package.json CHANGED
@@ -1,8 +1,34 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "telegram-menu",
4
- "version": "0.4.2",
4
+ "version": "0.5.1",
5
5
  "news": {
6
+ "0.5.1": {
7
+ "en": "sent to the wrong instance, fixed",
8
+ "de": "an die falsche instanz gesendet, fixiert",
9
+ "ru": "отправлено в неправильный экземпляр, исправлено",
10
+ "pt": "enviado para a instância errada, corrigido",
11
+ "nl": "verzonden naar de verkeerde instantie",
12
+ "fr": "envoyé à la mauvaise instance, fixe",
13
+ "it": "inviato all'istanza sbagliata, fisso",
14
+ "es": "enviado al caso equivocado, fijo",
15
+ "pl": "wysłany do niewłaściwej instancji, ustalony",
16
+ "uk": "відправлений на неправильний екземпляр, фіксований",
17
+ "zh-cn": "向错误案件发出的固定通知"
18
+ },
19
+ "0.5.0": {
20
+ "en": "trigger avoid duplicate entries and sort alphabetical\nadapter stops responding after some time, fixed #42\ngenerate Trigger in Action, fixed\nmath value for getstate\nsettings instance #41, menus, fixed\nno spellcheck for input fields\nmenu go back to last Sides",
21
+ "de": "trigger vermeiden doppelte einträge und sortieren alphabetisch\nadapter stoppt nach einiger zeit, fixiert #42\ntrigger in Aktion generieren, fixiert\nmath wert für getstate\neinstellungen instanz #41, menüs, fixiert\nkeine rechtschreibprüfung für eingabefelder\nmenü zurück zu den letzten Seiten",
22
+ "ru": "триггер избегает дублирования записей и сортировать алфавитный\nадаптер останавливается после некоторого времени, фиксированный #42\nгенерировать триггер в действии, фиксированный\nматематическое значение для getstate\nнастройки экземпляра #41, меню, фиксированные\nбез орфографии для входящих полей\nменю вернуться к последним Сторонам",
23
+ "pt": "gatilho evitar entradas duplicadas e classificar alfabético\nadaptador pára de responder após algum tempo, fixo #42\ngerar gatilho em Ação, fixo\nvalor de matemática para getstate\nsetting instance #41, menus, fixo\nsem verificação ortográfica para campos de entrada\nmenu voltar para os últimos lados",
24
+ "nl": "de trekker ontwijkt duplicaat en alfabetische\nadapter stopt met reageren na enige tijd, gerepareerd #42\ngenereerde Trigger in Actie, gerepareerd\nwiskunde waarde voor onroerend goed\nvertaling:\ngeen spellcheck voor input velden\nmenu gaat terug naar de laatste Sides",
25
+ "fr": "déclencheur éviter les doubles entrées et trier alphabétique\nadaptateur s'arrête après un certain temps, fixe #42\ngénérer Trigger en action, fixe\nmath value for getstate\nparamètres instance #41, menus, fixe\npas de sortcheck pour les champs d'entrée\nmenu retourner aux derniers côtés",
26
+ "it": "trigger evitare voci duplicate e ordinare alfabetico\nadattatore smette di rispondere dopo qualche tempo, fisso #42\ngenerare Trigger in Azione, fisso\nvalore matematico per getstate\nimpostazioni istanza #41, menu, fisso\nnessun spellcheck per i campi di input\nmenu torna all'ultimo lato",
27
+ "es": "gatillo evitar entradas duplicadas y ordenar entradas alfabéticas\nadaptador deja de responder después de algún tiempo, fijo #42\ngenerar Trigger en Acción, fijo\nvalor matemático para getstate\nconfiguración instancia #41, menús, fijo\nno hechizo para campos de entrada\nmenu go back to last Sides",
28
+ "pl": "wykorzystywanie wyjściowe unikanie duplikacji wpisów i alfabetyzacji\npo pewnym czasie przerwy reagują na stałe #42\ngeneruje Triggera w akcji\nwartość matrycowa\nna przykład #41, menus, ustawiony\nzaklęcie dla pól wejściowych\nmenu wraca do ostatniej strony",
29
+ "uk": "уникнути дублікатів записів і сортування алфавіту\nадаптер припиняє реагувати на деякий час, фіксований #42\nгенерувати Трігер в дії, фіксований\nматематичне значення для getstate\nзамість налаштувань #41, меню, фіксовані\nвідсутність орцепції для вхідних полів\nім'я користувача",
30
+ "zh-cn": "2. 避免重复物品和名称\n适应者在一段时间后停止作出反应,固定的编号为42\na. 行动的三倍,固定\n获取国产值\n例如第41号、男性、固定地点\n没有对投入领域进行明确的检查\n男子回到最后的Sides。"
31
+ },
6
32
  "0.4.2": {
7
33
  "en": "menu switch ersetzt menu yes-no, on-off, it is possible to customize text and value with this menu",
8
34
  "de": "menüschalter ersetzen ja-nein, on-off, es ist möglich, text und wert mit diesem menü anpassen",
@@ -67,32 +93,6 @@
67
93
  "pl": "rename\ntworzenie grup dla użytkowników",
68
94
  "uk": "кнопка перейменування\nстворювати групи з користувачами",
69
95
  "zh-cn": "重新命名\n与用户建立团体"
70
- },
71
- "0.1.1": {
72
- "en": "shift rows\nsmall fixes\nDarkmode fixed\noption, return text without value\nget all Values of functions",
73
- "de": "schaltreihen\nkleine fixierungen\nDarkmode fest\noption, text ohne wert zurückgeben\nalle Werte der Funktionen",
74
- "ru": "сменные строки\nнебольшие исправления\nDarkmode фиксированный\nвариант, обратный текст без значения\nполучить все значения функций",
75
- "pt": "turnos\npequenas correções\nDarkmode corrigido\nopção, retornar texto sem valor\nobter todos os valores das funções",
76
- "nl": "quality over quantity (qoq) releases vertaling:\nkleine fixes\nDarkmode gemaakt\noptie, terugkeren zonder waarde\nalle functies krijgen",
77
- "fr": "lignes de quart\npetites corrections\nDarkmode fixed\noption, texte de retour sans valeur\nobtenir toutes les valeurs des fonctions",
78
- "it": "spostare le righe\npiccole correzioni\nDarkmode fisso\nopzione, restituire il testo senza valore\nottenere tutti i valori delle funzioni",
79
- "es": "turno de filas\npequeños accesorios\nModo oscuro fijo\nopción, devolver texto sin valor\nobtener todos los Valores de las funciones",
80
- "pl": "rzędy zwrotne\ndrobne rozwiązanie\nDarkmode fixed\nopcja zwrotu tekstu bez wartości\nuzyskuje wszystkie funkcje",
81
- "uk": "зсувні рядки\nмаленькі кріплення\nDarkmode фіксований\nваріант, повернення тексту без значення\nотримувати всі значення функцій",
82
- "zh-cn": "更替\n小型配件\n达库姆固定\n备选案文:不附加价值的返回案文\n获得所有职能的价值"
83
- },
84
- "0.1.0": {
85
- "en": "Fixes\nStyle\nConfirmation, that the value has been set\nSecond User Menu fixed",
86
- "de": "Behebungen\nStil\nBestätigung, dass der Wert festgelegt wurde\nZweiter Benutzer Menü fix",
87
- "ru": "Исправления\nСтиль\nПодтверждение, что стоимость была установлена\nВторой пользователь Меню фиксированное",
88
- "pt": "Correções\nEstilo\nConfirmação, que o valor foi definido\nSegundo usuário Menu fixo",
89
- "nl": "Vertaling:\nStyle\nBevestiging, dat de waarde is opgezet\nTweede Uer Menu gemaakt",
90
- "fr": "Fixes\nStyle\nConfirmation, que la valeur a été déterminée\nSecond User Menu fixe",
91
- "it": "Fissi\nStile\nConferma, che il valore è stato impostato\nSecondo utente Menu fisso",
92
- "es": "Arreglos\nEstilo\nConfirmación, que se ha fijado el valor\nSegundo Usuario Menú fijo",
93
- "pl": "Fix\nStyl\nTwierdzenie, że wartość została ustalona\nSecond User (ang.). Menutr",
94
- "uk": "Фіксатори\nСтиль\nПідтвердження вартості\nДругий Користувач Меню фіксована",
95
- "zh-cn": "固定\n评 注\n确认已确定价值\n第二个用户 男子固定"
96
96
  }
97
97
  },
98
98
  "titleLang": {
package/lib/js/action.js CHANGED
@@ -1,10 +1,28 @@
1
1
  const sendToTelegram = require("./telegram").sendToTelegram;
2
+ /**
3
+ *
4
+ * @param {string} textToSend
5
+ * @param {string} val
6
+ */
7
+ function calcValue(_this, textToSend, val) {
8
+ const startindex = textToSend.indexOf("{math");
9
+ const endindex = textToSend.indexOf("}", startindex);
10
+ const substring = textToSend.substring(startindex, endindex);
11
+ const mathvalue = substring.replace("{math:", "").replace("}", "");
12
+ try {
13
+ val = eval(val + mathvalue);
14
+ } catch (e) {
15
+ _this.log.error("Error Eval" + JSON.stringify(e));
16
+ }
17
+ textToSend = textToSend.replace(substring, "");
18
+ return { textToSend: textToSend, val: val };
19
+ }
2
20
 
3
21
  /**
4
22
  *
5
23
  * @param {String} textToSend Text which should be send to user
6
24
  */
7
- function replaceValues(textToSend, stateVal, _this) {
25
+ function exchangeValue(textToSend, stateVal, _this) {
8
26
  const startindex = textToSend.indexOf("change{");
9
27
  const match = textToSend.substring(startindex + "change".length + 1, textToSend.indexOf("}", startindex));
10
28
  let objChangeValue;
@@ -165,9 +183,6 @@ async function generateNewObjectStructure(_this, val) {
165
183
  */
166
184
  function generateActions(_this, action, userObject) {
167
185
  try {
168
- _this.log.debug("action set: " + JSON.stringify(action.set));
169
- _this.log.debug("action get: " + JSON.stringify(action.get));
170
- _this.log.debug("action pic: " + JSON.stringify(action.pic));
171
186
  _this.log.debug("action : " + JSON.stringify(action));
172
187
  const listOfSetStateIds = [];
173
188
  action.set.forEach(function (element, key) {
@@ -239,5 +254,6 @@ module.exports = {
239
254
  wertUebermitteln,
240
255
  generateNewObjectStructure,
241
256
  generateActions,
242
- replaceValues,
257
+ exchangeValue,
258
+ calcValue,
243
259
  };
@@ -1,8 +1,9 @@
1
1
  const sendToTelegram = require("./telegram").sendToTelegram;
2
2
  const idBySelector = require("./action").idBySelector;
3
- const replaceValues = require("./action").replaceValues;
3
+ const exchangeValue = require("./action").exchangeValue;
4
+ const calcValue = require("./action").calcValue;
4
5
 
5
- function getstate(_this, part, userToSend) {
6
+ function getstate(_this, part, userToSend, telegramInstance) {
6
7
  try {
7
8
  let text = "";
8
9
  let i = 1;
@@ -20,23 +21,27 @@ function getstate(_this, part, userToSend) {
20
21
  }
21
22
  if (value) {
22
23
  let val = JSON.stringify(value.val);
23
- _this.log.debug("GetValue " + JSON.stringify(value.val));
24
24
  _this.log.debug("Element.text " + JSON.stringify(element.text));
25
25
  let newline = "";
26
- if (element.newline) {
26
+ if (element.newline === "true") {
27
27
  newline = "\n";
28
28
  }
29
29
  if (element.text) {
30
30
  let result = {};
31
- let textToSend;
32
- if (element.text.toString().includes("change{")) {
33
- result = replaceValues(element.text, val, _this);
31
+ let textToSend = element.text.toString();
32
+ if (textToSend.includes("math:")) {
33
+ const result = calcValue(_this, textToSend, val);
34
+ textToSend = result.textToSend;
35
+ val = result.val;
36
+ _this.log.debug(JSON.stringify({ textToSend: textToSend, val: val }));
37
+ }
38
+ if (textToSend.includes("change{")) {
39
+ result = exchangeValue(textToSend, val, _this);
34
40
  val = result["valueChange"];
35
41
  _this.log.debug("result " + JSON.stringify(result));
36
42
  textToSend = result["textToSend"];
37
- } else textToSend = element.text;
43
+ }
38
44
 
39
- // valueChange ? val = valueChange : val;
40
45
  if (textToSend.indexOf("&&") != -1) text += `${textToSend.replace("&&", val)}${newline}`;
41
46
  else text += textToSend + " " + val + newline;
42
47
  } else text += `${val} ${newline}`;
@@ -45,7 +50,7 @@ function getstate(_this, part, userToSend) {
45
50
  _this.log.debug("Length & i: " + JSON.stringify({ length: part.getData.length, i: i }));
46
51
  if (i == part.getData.length) {
47
52
  _this.log.debug("User to send: " + JSON.stringify(userToSend));
48
- if (userToSend) sendToTelegram(_this, userToSend, text);
53
+ if (userToSend) sendToTelegram(_this, userToSend, text, undefined, telegramInstance);
49
54
  }
50
55
  i++;
51
56
  });
@@ -23,13 +23,11 @@ function setstate(_this, part, userToSend, valueFromSubmenu, SubmenuValuePriorit
23
23
  returnText: returnText,
24
24
  userToSend: userToSend,
25
25
  });
26
- _this.log.debug("Ack: " + JSON.stringify(ack));
27
26
  if (element.toggle) {
28
27
  _this.log.debug("Toggle");
29
28
  _this
30
29
  .getForeignStateAsync(element.id)
31
30
  .then((val) => {
32
- _this.log.debug("ValueToggle " + JSON.stringify(val));
33
31
  if (val) _this.setForeignStateAsync(element.id, !val.val, ack);
34
32
  })
35
33
  .catch((e) => {
package/lib/js/subMenu.js CHANGED
@@ -1,8 +1,9 @@
1
1
  const setstate = require("./setstate").setstate;
2
+ const sendToTelegram = require("./telegram").sendToTelegram;
2
3
  let step = 0;
3
- let device2Switch = "";
4
4
  let returnIDToListenTo;
5
5
  let splittedData = [];
6
+ const backMenu = {};
6
7
  /**
7
8
  *
8
9
  * @param {*} _this
@@ -11,18 +12,18 @@ let splittedData = [];
11
12
  * @param {string} userToSend
12
13
  * @returns
13
14
  */
14
- function subMenu(_this, text, groupData, userToSend) {
15
- const splittetText = JSON.stringify(text).split(":");
15
+ function subMenu(_this, text, groupData, userToSend, instanceTelegram, resize_keyboard, one_time_keyboard) {
16
+ const splittetText = JSON.stringify(text).split(`"`)[1].split(":");
16
17
  const callbackData = splittetText[1];
17
- _this.log.debug("splittet text2 " + JSON.stringify(splittetText[2]));
18
- _this.log.debug("callback: " + JSON.stringify(callbackData));
19
- _this.log.debug("callback: " + JSON.stringify(callbackData == "first"));
18
+ let device2Switch = splittetText[2];
19
+ _this.log.debug("callbackData: " + JSON.stringify(callbackData));
20
+ _this.log.debug("splittet Data of callbackData " + JSON.stringify(splittetText[1]));
20
21
  _this.log.debug("devicetoswitch: " + JSON.stringify(device2Switch));
21
22
  _this.log.debug("text: " + JSON.stringify(text));
22
23
 
24
+ //ANCHOR - Switch
23
25
  if (callbackData.includes("switch")) {
24
26
  splittedData = callbackData.split("-");
25
- device2Switch = splittetText[2];
26
27
  const keyboard = {
27
28
  inline_keyboard: [
28
29
  [
@@ -51,53 +52,8 @@ function subMenu(_this, text, groupData, userToSend) {
51
52
  return [null, null, null, returnIDToListenTo];
52
53
  }
53
54
 
54
- if (callbackData === "yes-no") {
55
- const keyboard = {
56
- inline_keyboard: [
57
- [
58
- {
59
- text: "Yes",
60
- callback_data: "menu:yes",
61
- },
62
- {
63
- text: "No",
64
- callback_data: "menu:no",
65
- },
66
- ],
67
- ],
68
- };
69
- return ["Wähle eine Option", JSON.stringify(keyboard), device2Switch];
70
- } else if (callbackData === "yes") {
71
- returnIDToListenTo = setstate(_this, groupData[device2Switch], userToSend, true);
72
- return [null, null, null, returnIDToListenTo];
73
- } else if (callbackData === "no") {
74
- returnIDToListenTo = setstate(_this, groupData[device2Switch], userToSend, false);
75
- return [null, null, null, returnIDToListenTo];
76
- } else if (callbackData === "on-off") {
77
- const keyboard = {
78
- inline_keyboard: [
79
- [
80
- {
81
- text: "On",
82
- callback_data: "menu:on:",
83
- },
84
- {
85
- text: "Off",
86
- callback_data: "menu:off:",
87
- },
88
- ],
89
- ],
90
- };
91
- device2Switch = splittetText[2];
92
- return ["Wähle eine Option", JSON.stringify(keyboard), device2Switch];
93
- } else if (callbackData === "on") {
94
- returnIDToListenTo = setstate(_this, groupData[device2Switch], userToSend, true, true);
95
- return [null, null, null, returnIDToListenTo];
96
- } else if (callbackData === "off") {
97
- returnIDToListenTo = setstate(_this, groupData[device2Switch], userToSend, false, true);
98
- return [null, null, null, returnIDToListenTo];
99
- //SECTION - Percent
100
- } else if (!text.includes("submenu") && callbackData.includes("percent")) {
55
+ //ANCHOR - Percent
56
+ else if (!text.includes("submenu") && callbackData.includes("percent")) {
101
57
  step = parseInt(callbackData.replace("percent", ""));
102
58
  let rowEntrys = 0;
103
59
  let menu = [];
@@ -107,12 +63,12 @@ function subMenu(_this, text, groupData, userToSend) {
107
63
  for (let i = 100; i >= 0; i -= step) {
108
64
  menu.push({
109
65
  text: `${i}%`,
110
- callback_data: `submenu:percent${step}:${i}:`,
66
+ callback_data: `submenu:percent${step},${i}:${device2Switch}`,
111
67
  });
112
68
  if (i != 0 && i - step < 0)
113
69
  menu.push({
114
70
  text: `0%`,
115
- callback_data: `submenu:percent${step}:${0}:`,
71
+ callback_data: `submenu:percent${step},${0}:${device2Switch}`,
116
72
  });
117
73
  rowEntrys++;
118
74
  if (rowEntrys == 8) {
@@ -125,13 +81,13 @@ function subMenu(_this, text, groupData, userToSend) {
125
81
  // @ts-ignore
126
82
  if (rowEntrys != 0) keyboard.inline_keyboard.push(menu);
127
83
 
128
- device2Switch = splittetText[2];
129
84
  return ["Welcher Wert soll gesetzt werden?", JSON.stringify(keyboard), device2Switch];
130
85
  } else if (text.includes(`submenu:percent${step}`)) {
131
- const value = parseInt(text.split(":")[2]);
86
+ const value = parseInt(text.split(":")[1].split(",")[1]);
132
87
  returnIDToListenTo = setstate(_this, groupData[device2Switch], userToSend, value, true);
133
88
  return [null, null, null, returnIDToListenTo];
134
- //SECTION - Number
89
+
90
+ //ANCHOR - Number
135
91
  } else if (!text.includes("submenu") && callbackData.includes("number")) {
136
92
  const splittedData = callbackData.replace("number", "").split("-");
137
93
  let rowEntrys = 0;
@@ -141,13 +97,30 @@ function subMenu(_this, text, groupData, userToSend) {
141
97
  };
142
98
  let unit = "";
143
99
  if (splittedData[3] != "") unit = splittedData[3];
144
- for (let i = parseInt(splittedData[1]); i >= parseInt(splittedData[0]); i -= parseInt(splittedData[2])) {
100
+ let start = 0,
101
+ end = 0;
102
+
103
+ if (parseInt(splittedData[0]) < parseInt(splittedData[1])) {
104
+ start = parseInt(splittedData[1]);
105
+ end = parseInt(splittedData[0]);
106
+ } else {
107
+ start = parseInt(splittedData[0]);
108
+ end = parseInt(splittedData[1]);
109
+ }
110
+ let index = -1;
111
+ for (let i = start; i >= end; i -= parseInt(splittedData[2])) {
112
+ // Zahlen umdrehen
113
+ if (parseInt(splittedData[0]) < parseInt(splittedData[1])) {
114
+ if (i === start) index = end - 1;
115
+ index++;
116
+ } else index = i;
117
+
145
118
  menu.push({
146
- text: `${i}${unit}`,
147
- callback_data: `submenu:${callbackData}:${i}:`,
119
+ text: `${index}${unit}`,
120
+ callback_data: `submenu:${callbackData}:${index}:${device2Switch}`,
148
121
  });
149
- _this.log.debug("menu " + JSON.stringify(menu));
150
- _this.log.debug("keyboard " + JSON.stringify(keyboard.inline_keyboard));
122
+ // _this.log.debug("menu " + JSON.stringify(menu));
123
+ // _this.log.debug("keyboard " + JSON.stringify(keyboard.inline_keyboard));
151
124
  rowEntrys++;
152
125
  if (rowEntrys == 8) {
153
126
  // @ts-ignore
@@ -158,14 +131,47 @@ function subMenu(_this, text, groupData, userToSend) {
158
131
  }
159
132
  // @ts-ignore
160
133
  if (rowEntrys != 0) keyboard.inline_keyboard.push(menu);
161
- device2Switch = splittetText[2];
162
134
  return ["Welcher Wert soll gesetzt werden?", JSON.stringify(keyboard), device2Switch];
163
135
  } else if (text.includes(`submenu:${callbackData}`)) {
164
136
  const value = parseInt(text.split(":")[2]);
137
+ device2Switch = text.split(":")[3];
138
+ _this.log.debug(
139
+ JSON.stringify({ device2Switch: device2Switch, data: groupData, user: userToSend, value: value }),
140
+ );
165
141
  returnIDToListenTo = setstate(_this, groupData[device2Switch], userToSend, value, true);
166
142
  return [null, null, null, returnIDToListenTo];
167
143
  }
144
+ //ANCHOR - Back menu
145
+ else if (callbackData === "back") {
146
+ const list = backMenu[userToSend].list;
147
+ if (list.length !== 0) {
148
+ sendToTelegram(
149
+ _this,
150
+ userToSend,
151
+ list[list.length - 1],
152
+ groupData[list[list.length - 1]].nav,
153
+ instanceTelegram,
154
+ resize_keyboard,
155
+ one_time_keyboard,
156
+ );
157
+ }
158
+ backMenu[userToSend].last = list.pop();
159
+ }
160
+ }
161
+
162
+ function backMenuFuc(_this, nav, part, userToSend) {
163
+ if (!part || !JSON.stringify(part).split(`"`)[1].includes("menu:")) {
164
+ if (backMenu[userToSend] && backMenu[userToSend].list.length === 20) {
165
+ backMenu[userToSend].list.shift();
166
+ } else if (!backMenu[userToSend]) {
167
+ backMenu[userToSend] = { list: [], last: "" };
168
+ }
169
+ if (backMenu[userToSend].last !== "") backMenu[userToSend].list.push(backMenu[userToSend].last);
170
+ backMenu[userToSend].last = nav;
171
+ }
172
+ _this.log.debug("goBackMenu" + JSON.stringify(backMenu));
168
173
  }
169
174
  module.exports = {
170
175
  subMenu: subMenu,
176
+ backMenuFuc,
171
177
  };
@@ -19,7 +19,7 @@ function sendToTelegram(
19
19
  ) {
20
20
  _this.log.debug("Send this Value : " + JSON.stringify(value));
21
21
  _this.log.debug("Send this to : " + JSON.stringify(user));
22
- //TODO - Username mit Telegram abgleichen
22
+ _this.log.debug("Instance : " + JSON.stringify(instance));
23
23
  if (keyboard.length == 0) {
24
24
  _this.sendTo(
25
25
  instance,
@@ -29,7 +29,7 @@ function sendToTelegram(
29
29
  user: user,
30
30
  },
31
31
  function (res) {
32
- console.log("Sent to " + res + " users!");
32
+ console.log("Sent Value to " + res + " users!");
33
33
  },
34
34
  );
35
35
  } else {
package/main.js CHANGED
@@ -16,10 +16,11 @@ const sendToTelegram = require("./lib/js/telegram").sendToTelegram;
16
16
  const editArrayButtons = require("./lib/js/action").editArrayButtons;
17
17
  const generateNewObjectStructure = require("./lib/js/action").generateNewObjectStructure;
18
18
  const generateActions = require("./lib/js/action").generateActions;
19
- const replaceValues = require("./lib/js/action").replaceValues;
19
+ const exchangeValue = require("./lib/js/action").exchangeValue;
20
20
  const setstate = require("./lib/js/setstate").setstate;
21
21
  const getstate = require("./lib/js/getstate").getstate;
22
22
  const subMenu = require("./lib/js/subMenu").subMenu;
23
+ const backMenuFuc = require("./lib/js/subMenu").backMenuFuc;
23
24
  const sendToTelegramSubmenu = require("./lib/js/telegram").sendToTelegramSubmenu;
24
25
  // const lichtAn = require("./lib/js/action").lichtAn;
25
26
  // const wertUebermitteln = require("./lib/js/action").wertUebermitteln;
@@ -49,11 +50,10 @@ class TelegramMenu extends utils.Adapter {
49
50
  async onReady() {
50
51
  this.setState("info.connection", false, true);
51
52
  let instanceTelegram = this.config.instance;
52
- const telegramID = `${instanceTelegram}.communicate.request`;
53
53
  if (instanceTelegram.length == 0) instanceTelegram = "telegram.0";
54
+ const telegramID = `${instanceTelegram}.communicate.request`;
54
55
  const datapoint = `${instanceTelegram}.info.connection`;
55
- this.log.debug("Instance " + JSON.stringify(instanceTelegram));
56
- this.log.debug("Datapoint " + JSON.stringify(datapoint));
56
+ this.log.debug("Datapoint: " + JSON.stringify(datapoint));
57
57
  let telegramAktiv, telegramState;
58
58
 
59
59
  /**
@@ -68,7 +68,7 @@ class TelegramMenu extends utils.Adapter {
68
68
  let token = this.config.tokenGrafana;
69
69
  const directoryPicture = this.config.directory;
70
70
  const userActiveCheckbox = this.config.userActiveCheckbox;
71
- const usersInGroup = this.config.usersInGroup;
71
+ const groupsWithUsers = this.config.usersInGroup;
72
72
  const textNoEntryFound = this.config.textNoEntry;
73
73
  const menu = {
74
74
  data: {},
@@ -109,7 +109,7 @@ class TelegramMenu extends utils.Adapter {
109
109
  subscribeForeignStateIds = returnValue?.ids;
110
110
  if (subscribeForeignStateIds && subscribeForeignStateIds?.length > 0)
111
111
  _subscribeForeignStatesAsync(subscribeForeignStateIds, _this);
112
- this.log.debug("SetForeignStates: " + JSON.stringify(subscribeForeignStateIds));
112
+ this.log.debug("SubscribeForeignStates: " + JSON.stringify(subscribeForeignStateIds));
113
113
  this.log.debug("Name " + JSON.stringify(name));
114
114
  this.log.debug("Array Buttons: " + JSON.stringify(value));
115
115
  this.log.debug("Gen. Actions: " + JSON.stringify(menu.data[name]));
@@ -120,12 +120,13 @@ class TelegramMenu extends utils.Adapter {
120
120
  this.log.debug("Checkbox " + JSON.stringify(checkbox));
121
121
 
122
122
  try {
123
- this.log.debug("GroupList " + JSON.stringify(userList));
123
+ this.log.debug("GroupList: " + JSON.stringify(userList));
124
124
  userList.forEach((group) => {
125
- this.log.debug("Group " + JSON.stringify(group));
125
+ this.log.debug("Group: " + JSON.stringify(group));
126
126
  const startside = [startsides[group]].toString();
127
127
  if (userActiveCheckbox[group])
128
- usersInGroup[group].forEach((user) => {
128
+ groupsWithUsers[group].forEach((user) => {
129
+ backMenuFuc(this, startside, null, user);
129
130
  sendToTelegram(
130
131
  _this,
131
132
  user,
@@ -141,7 +142,6 @@ class TelegramMenu extends utils.Adapter {
141
142
  console.log("Error read UserList" + error);
142
143
  }
143
144
  }
144
- let oldValue;
145
145
  this.on("stateChange", async (id, state) => {
146
146
  try {
147
147
  let userToSend;
@@ -150,19 +150,21 @@ class TelegramMenu extends utils.Adapter {
150
150
  const value = state.val;
151
151
  const user = value.slice(1, value.indexOf("]"));
152
152
  const calledValue = value.slice(value.indexOf("]") + 1, value.length);
153
- this.log.debug("Value: " + JSON.stringify(value));
154
- this.log.debug("User: " + JSON.stringify(user));
155
- this.log.debug("Todo: " + JSON.stringify(calledValue));
156
-
157
- userToSend = null;
153
+ this.log.debug(
154
+ JSON.stringify({
155
+ Value: value,
156
+ User: user,
157
+ Todo: calledValue,
158
+ groups: groupsWithUsers,
159
+ }),
160
+ );
161
+ userToSend = user;
158
162
 
159
- this.log.debug("user in group" + JSON.stringify(usersInGroup));
160
- const groupWithUser = Object.keys(usersInGroup).find((key) =>
161
- usersInGroup[key].includes(user),
163
+ const groupWithUser = Object.keys(groupsWithUsers).find((key) =>
164
+ groupsWithUsers[key].includes(user),
162
165
  );
163
166
  this.log.debug("Group with User " + JSON.stringify(groupWithUser));
164
167
  const groupData = menu.data[groupWithUser];
165
- userToSend = user;
166
168
 
167
169
  this.log.debug("Nav " + JSON.stringify(groupData));
168
170
  this.log.debug("Menu " + JSON.stringify(menu.data));
@@ -173,18 +175,15 @@ class TelegramMenu extends utils.Adapter {
173
175
  userActiveCheckbox[groupWithUser]
174
176
  ) {
175
177
  const part = groupData[calledValue];
176
- this.log.debug("Part " + JSON.stringify(part));
177
178
  // Navigation
178
179
  if (part.nav) {
179
- this.log.debug("User to send: " + JSON.stringify(userToSend));
180
- this.log.debug("Todo " + JSON.stringify(calledValue));
181
- this.log.debug("Part.nav: " + JSON.stringify(part.nav));
182
- //TODO -
180
+ this.log.debug("Menu to Send: " + JSON.stringify(part.nav));
181
+ backMenuFuc(this, calledValue, part.nav, userToSend);
183
182
  if (JSON.stringify(part.nav).includes("menu")) {
184
- this.log.debug("Submenu");
185
183
  callSubMenu(this, part.nav, groupData, userToSend);
186
184
  } else {
187
- if (userToSend)
185
+ if (userToSend) {
186
+ this.log.debug("Send Nav to Telegram");
188
187
  sendToTelegram(
189
188
  this,
190
189
  userToSend,
@@ -194,13 +193,14 @@ class TelegramMenu extends utils.Adapter {
194
193
  resize_keyboard,
195
194
  one_time_keyboard,
196
195
  );
196
+ }
197
197
  }
198
198
  }
199
199
  // Schalten
200
200
  else if (part.switch) {
201
201
  setStateIdsToListenTo = setstate(_this, part, userToSend);
202
202
  } else if (part.getData) {
203
- getstate(_this, part, userToSend);
203
+ getstate(_this, part, userToSend, instanceTelegram);
204
204
  } else if (part.sendPic) {
205
205
  try {
206
206
  this.log.debug("Send Picture");
@@ -220,7 +220,14 @@ class TelegramMenu extends utils.Adapter {
220
220
  timeoutKey += 1;
221
221
  const path = `${directoryPicture}${element.fileName}`;
222
222
  const timeout = this.setTimeout(async () => {
223
- sendToTelegram(_this, userToSend, path);
223
+ this.log.debug("Send Pic to Telegram");
224
+ sendToTelegram(
225
+ _this,
226
+ userToSend,
227
+ path,
228
+ undefined,
229
+ instanceTelegram,
230
+ );
224
231
 
225
232
  let timeoutToClear = {};
226
233
  timeoutToClear = timeouts.filter((item) => item.key == timeoutKey);
@@ -236,8 +243,9 @@ class TelegramMenu extends utils.Adapter {
236
243
  } else if (calledValue.startsWith("menu") || calledValue.startsWith("submenu")) {
237
244
  callSubMenu(this, calledValue, groupData, userToSend);
238
245
  } else {
239
- if (typeof userToSend == "string")
240
- if (checkboxNoEntryFound) sendToTelegram(this, userToSend, textNoEntryFound);
246
+ if (typeof userToSend == "string") this.log.debug("Send No Entry to Telegram");
247
+ if (checkboxNoEntryFound)
248
+ sendToTelegram(this, userToSend, textNoEntryFound, undefined, instanceTelegram);
241
249
  }
242
250
  // Auf Setstate reagieren und Wert schicken
243
251
  } else if (
@@ -260,7 +268,7 @@ class TelegramMenu extends utils.Adapter {
260
268
  let result = {};
261
269
  let valueChange = "";
262
270
  if (textToSend.toString().includes("change{")) {
263
- result = replaceValues(textToSend, state.val, this);
271
+ result = exchangeValue(textToSend, state.val, this);
264
272
  if (result) {
265
273
  textToSend = result["textToSend"];
266
274
  valueChange = result["valueChange"];
@@ -275,22 +283,30 @@ class TelegramMenu extends utils.Adapter {
275
283
  textToSend.toString().indexOf("&amp;&amp;") != -1
276
284
  ? (textToSend = textToSend.replace("&amp;&amp;", value))
277
285
  : (textToSend += " " + value);
278
- sendToTelegram(this, element.userToSend, textToSend);
286
+ this.log.debug("Send Set to Telegram");
287
+ sendToTelegram(
288
+ this,
289
+ element.userToSend,
290
+ textToSend,
291
+ undefined,
292
+ instanceTelegram,
293
+ );
279
294
  // Die Elemente auf die Reagiert wurde entfernen
280
295
  setStateIdsToListenTo.splice(key, 1);
281
296
  }
282
297
  }
283
298
  });
284
- } else {
285
- this.log.debug("else " + JSON.stringify(id));
286
- this.log.debug("else " + JSON.stringify(setStateIdsToListenTo));
287
299
  }
288
300
  }
289
301
 
290
302
  if (state && id == `${instanceTelegram}.info.connection`) {
291
- this.log.debug("Oldvalue " + JSON.stringify(oldValue));
292
- oldValue = state.val;
293
- if (!state.val) telegramAktiv = false;
303
+ if (!state.val) {
304
+ telegramAktiv = false;
305
+ this.setState("info.connection", false, true);
306
+ } else {
307
+ this.setState("info.connection", true, true);
308
+ telegramAktiv = true;
309
+ }
294
310
  }
295
311
  } catch (e) {
296
312
  this.log.debug("Error1 " + JSON.stringify(e));
@@ -307,11 +323,20 @@ class TelegramMenu extends utils.Adapter {
307
323
  * @param {string} userToSend
308
324
  */
309
325
  function callSubMenu(_this, part, groupData, userToSend) {
310
- const subMenuData = subMenu(_this, part, groupData, userToSend);
326
+ const subMenuData = subMenu(
327
+ _this,
328
+ part,
329
+ groupData,
330
+ userToSend,
331
+ instanceTelegram,
332
+ resize_keyboard,
333
+ one_time_keyboard,
334
+ );
311
335
  if (subMenuData && subMenuData[3]) setStateIdsToListenTo = subMenuData[3];
312
336
 
313
337
  _this.log.debug("SubMenuData " + JSON.stringify(subMenuData));
314
- if (subMenuData && subMenuData[0]) sendToTelegramSubmenu(_this, userToSend, subMenuData[0], subMenuData[1]);
338
+ if (subMenuData && subMenuData[0])
339
+ sendToTelegramSubmenu(_this, userToSend, subMenuData[0], subMenuData[1], instanceTelegram);
315
340
  }
316
341
 
317
342
  /**
@@ -321,7 +346,6 @@ class TelegramMenu extends utils.Adapter {
321
346
  */
322
347
  function _subscribeForeignStatesAsync(array, _this) {
323
348
  array.forEach((element) => {
324
- _this.log.debug("Subscribe " + JSON.stringify(element));
325
349
  _this.subscribeForeignStatesAsync(element);
326
350
  });
327
351
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.telegram-menu",
3
- "version": "0.4.2",
3
+ "version": "0.5.1",
4
4
  "description": "Easily create Telegram Menus",
5
5
  "author": {
6
6
  "name": "MiRo1310",
@@ -21,11 +21,11 @@
21
21
  "node": ">= 16"
22
22
  },
23
23
  "dependencies": {
24
- "@iobroker/adapter-core": "^2.6.8"
24
+ "@iobroker/adapter-core": "^3.0.3"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@alcalzone/release-script": "^3.5.9",
28
- "@alcalzone/release-script-plugin-iobroker": "^3.5.9",
28
+ "@alcalzone/release-script-plugin-iobroker": "^3.6.0",
29
29
  "@alcalzone/release-script-plugin-license": "^3.5.9",
30
30
  "@alcalzone/release-script-plugin-manual-review": "^3.5.9",
31
31
  "@iobroker/adapter-dev": "^1.2.0",
@@ -37,15 +37,15 @@
37
37
  "@types/mocha": "^10.0.1",
38
38
  "@types/node": "^20.3.3",
39
39
  "@types/proxyquire": "^1.3.28",
40
- "@types/sinon": "^10.0.13",
40
+ "@types/sinon": "^10.0.15",
41
41
  "@types/sinon-chai": "^3.2.9",
42
42
  "chai": "^4.3.7",
43
43
  "chai-as-promised": "^7.1.1",
44
44
  "eslint": "^8.44.0",
45
- "eslint-config-prettier": "^8.8.0",
45
+ "eslint-config-prettier": "^8.9.0",
46
46
  "eslint-plugin-prettier": "^4.2.1",
47
47
  "mocha": "^10.2.0",
48
- "prettier": "^2.8.8",
48
+ "prettier": "^3.0.0",
49
49
  "proxyquire": "^2.1.3",
50
50
  "sinon": "^15.2.0",
51
51
  "sinon-chai": "^3.7.0",