iobroker.telegram 6.3.0 → 6.5.0
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 +12 -10
- package/admin/i18n/de.json +4 -0
- package/admin/i18n/en.json +4 -0
- package/admin/i18n/es.json +5 -1
- package/admin/i18n/fr.json +4 -0
- package/admin/i18n/it.json +5 -1
- package/admin/i18n/nl.json +4 -0
- package/admin/i18n/pl.json +4 -0
- package/admin/i18n/pt.json +4 -0
- package/admin/i18n/ru.json +4 -0
- package/admin/i18n/uk.json +4 -0
- package/admin/i18n/zh-cn.json +4 -0
- package/admin/jsonConfig.json +23 -0
- package/admin/rules/@mf-types.zip +0 -0
- package/build/help.d.ts +10 -0
- package/build/help.js +77 -0
- package/build/help.js.map +1 -0
- package/build/main.js +103 -15
- package/build/main.js.map +1 -1
- package/build/types.d.ts +4 -0
- package/i18n/de.json +2 -1
- package/i18n/en.json +2 -1
- package/i18n/es.json +2 -1
- package/i18n/fr.json +2 -1
- package/i18n/it.json +2 -1
- package/i18n/nl.json +2 -1
- package/i18n/pl.json +2 -1
- package/i18n/pt.json +2 -1
- package/i18n/ru.json +2 -1
- package/i18n/uk.json +2 -1
- package/i18n/zh-cn.json +2 -1
- package/io-package.json +55 -28
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,6 +31,12 @@ Use telegram service to communicate with ioBroker
|
|
|
31
31
|
|
|
32
32
|
[Documentation](./docs/en/README.md)
|
|
33
33
|
|
|
34
|
+
## Messages for scripts and AI agents
|
|
35
|
+
|
|
36
|
+
`sendTo('telegram.0', 'help', {})` answers `{ help, commands }`: a description of all messages (`send`, `ask`, `call` ...)
|
|
37
|
+
with their parameters and answers for AI agents (e.g. ioBroker.pi-agent) and script authors, and the list of all commands
|
|
38
|
+
with `write` (whether the command has an effect, e.g. sends a message).
|
|
39
|
+
|
|
34
40
|
## Sentry
|
|
35
41
|
|
|
36
42
|
**This adapter uses Sentry libraries to automatically report exceptions and code errors to the developers.** For more details and for information on how to disable the error reporting see [Sentry-Plugin Documentation](https://github.com/ioBroker/plugin-sentry#plugin-sentry)! Sentry reporting is used starting with js-controller 3.0.
|
|
@@ -40,6 +46,12 @@ Use telegram service to communicate with ioBroker
|
|
|
40
46
|
Placeholder for the next version (at the beginning of the line):
|
|
41
47
|
### **WORK IN PROGRESS**
|
|
42
48
|
-->
|
|
49
|
+
### 6.5.0 (2026-11-19)
|
|
50
|
+
- (@GermanBluefox) Added the message `help`: a description of all messages for AI agents (e.g. pi-agent), and `common.supportedMessages.help`
|
|
51
|
+
|
|
52
|
+
### 6.4.0 (2026-11-09)
|
|
53
|
+
- (@GermanBluefox) Voice messages can be converted to text by an `ai-parakeet` instance (new setting "Speech recognition instance"); the text is then processed like a typed message (`communicate.request`, commands, `text2command`, assistant) and also written to the new state `communicate.requestVoiceText`. "Show the recognised text in the chat" answers with what was understood (🎤 …)
|
|
54
|
+
|
|
43
55
|
### 6.3.0 (2026-11-07)
|
|
44
56
|
- (@GermanBluefox) Added "Delete received files after (days)": saved voice messages, photos, videos, audio files and documents older than that are deleted, in the file system or in the file storage, checked every hour. 0 (default) keeps them as before
|
|
45
57
|
|
|
@@ -51,16 +63,6 @@ Use telegram service to communicate with ioBroker
|
|
|
51
63
|
- (@GermanBluefox) Photos and videos are forwarded to the `assistant` instance too: photos (an album as one question, at most 4) with their caption as the question, videos are stored in the file storage of the instance (folder `assistant`, the newest 20) and only their place goes along. Can be switched off with "Photos and videos to the assistant"
|
|
52
64
|
- (@GermanBluefox) Added the state `communicate.pathFileUrl`: the `iobdisk://` URL of the last received file (e.g. `iobdisk://pi4/telegram.0/video/2026-11-04_10-00-00.mp4`), which instances on other hosts can read with `readDiskFile(url)` - the path in `communicate.pathFile` is only valid on the host of telegram. Needs js-controller 8.0 and `saveFilesTo: filesystem`, otherwise the state stays empty
|
|
53
65
|
|
|
54
|
-
### 6.1.0 (2026-11-04)
|
|
55
|
-
- (@GermanBluefox) Voice messages are forwarded to the configured `assistant` instance: it recognises the speech and the answer is sent back to the chat with the recognised text in front (🎤 …). The same user check as for text messages applies; a voice message with a caption is answered by its caption. Needs ioBroker.assistant with voice enabled, a speech recognition engine and ffmpeg on the host
|
|
56
|
-
- (@GermanBluefox) `send` can return the ids of the sent messages again (`returnMessageIds: true`), to edit or delete the message later; failed recipients come with the reason (#1389)
|
|
57
|
-
- (@GermanBluefox) The Blockly block "telegram" has an optional input for the topic (thread id) of a forum group (#952)
|
|
58
|
-
- (@GermanBluefox) Completed the Blockly translations for Ukrainian and Chinese
|
|
59
|
-
|
|
60
|
-
### 6.0.2 (2026-09-12)
|
|
61
|
-
- (@GermanBluefox) Updated packages and improved the rules block
|
|
62
|
-
- (@patricknitsch) Retried getUpdates 409 conflicts quickly before falling back to a slow restartart
|
|
63
|
-
|
|
64
66
|
[Older changelogs can be found there](CHANGELOG_OLD.md)
|
|
65
67
|
|
|
66
68
|
## License
|
package/admin/i18n/de.json
CHANGED
|
@@ -72,6 +72,8 @@
|
|
|
72
72
|
"Set Password": "Passwort festlegen",
|
|
73
73
|
"Set certificates or load it first in the system settings (right top).": "Zertifikate wählen bzw. Zertifikate in den Systemeinstellungen (oben rechts) hinterlegen.",
|
|
74
74
|
"Show the list of rooms before the device selection": "Zeige die Liste der Räume vor der Geräte Auswahl an",
|
|
75
|
+
"Show the recognised text in the chat": "Erkannten Text im Chat anzeigen",
|
|
76
|
+
"Speech recognition instance": "Spracherkennungs-Instanz",
|
|
75
77
|
"Started!": "Bot gestartet.",
|
|
76
78
|
"Store username instead of firstname of remembered users": "Benutzername anstatt Vorname von Benutzern speichern",
|
|
77
79
|
"Text2Command info": "Alle Anfragen werden an diese text2Command-Instanz weitergeleitet",
|
|
@@ -103,6 +105,8 @@
|
|
|
103
105
|
"restarting": "Beenden",
|
|
104
106
|
"restarting_help": "Dieser Text wird an die Clients gesendet, sobald die Adapterinstanz gestoppt wird. Zum Deaktivieren: leer lassen.",
|
|
105
107
|
"server": "Server",
|
|
108
|
+
"speechToTextEcho_help": "Der Bot antwortet auf eine Sprachnachricht zuerst mit dem, was er verstanden hat (🎤 …)",
|
|
109
|
+
"speechToText_help": "Sprachnachrichten werden von dieser ioBroker.ai-parakeet-Instanz erkannt und wie eine Textnachricht verarbeitet (Befehle, text2command, Assistent). Leer: aus",
|
|
106
110
|
"telegram adapter settings": "Adapter-Einstellungen",
|
|
107
111
|
"text2command instance": "text2Command-Instanz",
|
|
108
112
|
"token": "Token",
|
package/admin/i18n/en.json
CHANGED
|
@@ -72,6 +72,8 @@
|
|
|
72
72
|
"Set Password": "Set Password",
|
|
73
73
|
"Set certificates or load it first in the system settings (right top).": "Set certificates or define it first in the system settings (right top).",
|
|
74
74
|
"Show the list of rooms before the device selection": "Show the list of rooms before the device selection",
|
|
75
|
+
"Show the recognised text in the chat": "Show the recognised text in the chat",
|
|
76
|
+
"Speech recognition instance": "Speech recognition instance",
|
|
75
77
|
"Started!": "Started!",
|
|
76
78
|
"Store username instead of firstname of remembered users": "Store username instead of first name of remembered users",
|
|
77
79
|
"Text2Command info": "All requests will be sent to this text2Command instance",
|
|
@@ -103,6 +105,8 @@
|
|
|
103
105
|
"restarting": "Stopping",
|
|
104
106
|
"restarting_help": "This text will be sent to clients once the adapter instance is going to be stopped. Leave blank to deactivate.",
|
|
105
107
|
"server": "server",
|
|
108
|
+
"speechToTextEcho_help": "The bot answers a voice message first with what it understood (🎤 …)",
|
|
109
|
+
"speechToText_help": "Voice messages are recognised by this ioBroker.ai-parakeet instance and processed like a text message (commands, text2command, assistant). Empty: off",
|
|
106
110
|
"telegram adapter settings": "telegram adapter settings",
|
|
107
111
|
"text2command instance": "Text2Command instance",
|
|
108
112
|
"token": "Token",
|
package/admin/i18n/es.json
CHANGED
|
@@ -72,6 +72,8 @@
|
|
|
72
72
|
"Set Password": "Configurar la clave",
|
|
73
73
|
"Set certificates or load it first in the system settings (right top).": "Establezca certificados o cárguelos primero en la configuración del sistema (arriba a la derecha).",
|
|
74
74
|
"Show the list of rooms before the device selection": "Mostrar la lista de habitaciones antes de la selección del dispositivo.",
|
|
75
|
+
"Show the recognised text in the chat": "Mostrar el texto reconocido en el chat",
|
|
76
|
+
"Speech recognition instance": "Instancia de reconocimiento de voz",
|
|
75
77
|
"Started!": "¡Empezado!",
|
|
76
78
|
"Store username instead of firstname of remembered users": "Guardar nombre de usuario en lugar del nombre de los usuarios recordados",
|
|
77
79
|
"Text2Command info": "Todas las solicitudes se enviarán a esta instancia de text2Command",
|
|
@@ -89,7 +91,7 @@
|
|
|
89
91
|
"https://api.telegram.org": "https://api.telegram.org",
|
|
90
92
|
"ioBroker database": "Base de datos de ioBroker",
|
|
91
93
|
"ip": "IP",
|
|
92
|
-
"password": "
|
|
94
|
+
"password": "Clave",
|
|
93
95
|
"password repeat": "Repite la contraseña",
|
|
94
96
|
"polling": "sondeo",
|
|
95
97
|
"pollingInterval": "Intervalo de sondeo",
|
|
@@ -103,6 +105,8 @@
|
|
|
103
105
|
"restarting": "Deteniendo",
|
|
104
106
|
"restarting_help": "Este texto se enviará a los clientes una vez que se detenga la instancia del adaptador. Dejar en blanco para desactivar.",
|
|
105
107
|
"server": "servidor",
|
|
108
|
+
"speechToTextEcho_help": "El bot responde primero a un mensaje de voz con lo que ha entendido (🎤 …)",
|
|
109
|
+
"speechToText_help": "Los mensajes de voz se reconocen con esta instancia de ioBroker.ai-parakeet y se procesan como un mensaje de texto (comandos, text2command, asistente). Vacío: desactivado",
|
|
106
110
|
"telegram adapter settings": "Configuración del adaptador de Telegram",
|
|
107
111
|
"text2command instance": "Instancia Text2Command",
|
|
108
112
|
"token": "Token",
|
package/admin/i18n/fr.json
CHANGED
|
@@ -72,6 +72,8 @@
|
|
|
72
72
|
"Set Password": "Définir le mot de passe",
|
|
73
73
|
"Set certificates or load it first in the system settings (right top).": "Définissez des certificats ou chargez-les d'abord dans les paramètres du système (en haut à droite).",
|
|
74
74
|
"Show the list of rooms before the device selection": "Afficher la liste des pièces avant la sélection de l'appareil",
|
|
75
|
+
"Show the recognised text in the chat": "Afficher le texte reconnu dans le chat",
|
|
76
|
+
"Speech recognition instance": "Instance de reconnaissance vocale",
|
|
75
77
|
"Started!": "Commencé!",
|
|
76
78
|
"Store username instead of firstname of remembered users": "Store username instead of firstname of remembered users",
|
|
77
79
|
"Text2Command info": "Toutes les demandes seront envoyées à cette instance de text2Command",
|
|
@@ -103,6 +105,8 @@
|
|
|
103
105
|
"restarting": "Redémarrage",
|
|
104
106
|
"restarting_help": "Ce texte sera envoyé aux clients une fois que l'instance d'adaptateur va être arrêtée. Laissez vide pour désactiver.",
|
|
105
107
|
"server": "serveur",
|
|
108
|
+
"speechToTextEcho_help": "Le bot répond d'abord à un message vocal avec ce qu'il a compris (🎤 …)",
|
|
109
|
+
"speechToText_help": "Les messages vocaux sont reconnus par cette instance ioBroker.ai-parakeet et traités comme un message texte (commandes, text2command, assistant). Vide : désactivé",
|
|
106
110
|
"telegram adapter settings": "paramètres de l'adaptateur de télégramme",
|
|
107
111
|
"text2command instance": "Instance Text2Command",
|
|
108
112
|
"token": "Token",
|
package/admin/i18n/it.json
CHANGED
|
@@ -72,6 +72,8 @@
|
|
|
72
72
|
"Set Password": "Impostare la password",
|
|
73
73
|
"Set certificates or load it first in the system settings (right top).": "Imposta i certificati o caricali prima nelle impostazioni di sistema (in alto a destra).",
|
|
74
74
|
"Show the list of rooms before the device selection": "Mostra l'elenco delle sale prima della selezione del dispositivo",
|
|
75
|
+
"Show the recognised text in the chat": "Mostra il testo riconosciuto nella chat",
|
|
76
|
+
"Speech recognition instance": "Istanza di riconoscimento vocale",
|
|
75
77
|
"Started!": "Iniziato!",
|
|
76
78
|
"Store username instead of firstname of remembered users": "Store username instead of firstname of remembered users",
|
|
77
79
|
"Text2Command info": "Tutte le richieste verranno inviate a questa istanza text2Command",
|
|
@@ -89,7 +91,7 @@
|
|
|
89
91
|
"https://api.telegram.org": "https://api.telegram.org",
|
|
90
92
|
"ioBroker database": "Database ioBroker",
|
|
91
93
|
"ip": "IP",
|
|
92
|
-
"password": "
|
|
94
|
+
"password": "Password",
|
|
93
95
|
"password repeat": "Ripetizione della Parola d'ordine",
|
|
94
96
|
"polling": "votazione",
|
|
95
97
|
"pollingInterval": "Intervallo di polling",
|
|
@@ -103,6 +105,8 @@
|
|
|
103
105
|
"restarting": "Riavvio",
|
|
104
106
|
"restarting_help": "Questo testo verrà inviato ai client una volta che l'istanza dell'adattatore verrà arrestata. Lascia vuoto per disattivare.",
|
|
105
107
|
"server": "server",
|
|
108
|
+
"speechToTextEcho_help": "Il bot risponde prima a un messaggio vocale con ciò che ha capito (🎤 …)",
|
|
109
|
+
"speechToText_help": "I messaggi vocali vengono riconosciuti da questa istanza di ioBroker.ai-parakeet ed elaborati come un messaggio di testo (comandi, text2command, assistente). Vuoto: disattivato",
|
|
106
110
|
"telegram adapter settings": "impostazioni dell'adattatore telegramma",
|
|
107
111
|
"text2command instance": "Istanza Text2Command",
|
|
108
112
|
"token": "Token",
|
package/admin/i18n/nl.json
CHANGED
|
@@ -72,6 +72,8 @@
|
|
|
72
72
|
"Set Password": "Stel een wachtwoord in",
|
|
73
73
|
"Set certificates or load it first in the system settings (right top).": "Stel certificaten in of laad het eerst in de systeeminstellingen (rechtsboven).",
|
|
74
74
|
"Show the list of rooms before the device selection": "Toon de lijst met kamers vóór de apparaatselectie",
|
|
75
|
+
"Show the recognised text in the chat": "Herkende tekst in de chat tonen",
|
|
76
|
+
"Speech recognition instance": "Instantie voor spraakherkenning",
|
|
75
77
|
"Started!": "Begonnen!",
|
|
76
78
|
"Store username instead of firstname of remembered users": "Store username instead of firstname of remembered users",
|
|
77
79
|
"Text2Command info": "Alle aanvragen worden verzonden naar dit text2Command-exemplaar",
|
|
@@ -103,6 +105,8 @@
|
|
|
103
105
|
"restarting": "Het opnieuw starten",
|
|
104
106
|
"restarting_help": "Deze tekst wordt naar klanten verzonden zodra de adapterinstantie wordt gestopt. Laat leeg om te deactiveren.",
|
|
105
107
|
"server": "server",
|
|
108
|
+
"speechToTextEcho_help": "De bot antwoordt op een spraakbericht eerst met wat hij heeft verstaan (🎤 …)",
|
|
109
|
+
"speechToText_help": "Spraakberichten worden door deze ioBroker.ai-parakeet-instantie herkend en verwerkt als een tekstbericht (commando’s, text2command, assistent). Leeg: uit",
|
|
106
110
|
"telegram adapter settings": "telegram-adapterinstellingen",
|
|
107
111
|
"text2command instance": "Text2Command Instance",
|
|
108
112
|
"token": "Token",
|
package/admin/i18n/pl.json
CHANGED
|
@@ -72,6 +72,8 @@
|
|
|
72
72
|
"Set Password": "Ustaw hasło",
|
|
73
73
|
"Set certificates or load it first in the system settings (right top).": "Ustaw certyfikaty lub załaduj najpierw w ustawieniach systemu (prawy górny).",
|
|
74
74
|
"Show the list of rooms before the device selection": "Pokaż listę pokojów przed wyborem urządzenia",
|
|
75
|
+
"Show the recognised text in the chat": "Pokaż rozpoznany tekst na czacie",
|
|
76
|
+
"Speech recognition instance": "Instancja rozpoznawania mowy",
|
|
75
77
|
"Started!": "Rozpoczęty!",
|
|
76
78
|
"Store username instead of firstname of remembered users": "Store username instead of firstname of remembered users",
|
|
77
79
|
"Text2Command info": "Wszystkie żądania zostaną wysłane do tej instancji text2Command",
|
|
@@ -103,6 +105,8 @@
|
|
|
103
105
|
"restarting": "Ponowne uruchamianie",
|
|
104
106
|
"restarting_help": "Ten tekst zostanie wysłany do klientów, gdy instancja adaptera zostanie zatrzymana. Pozostaw puste, aby dezaktywować.",
|
|
105
107
|
"server": "serwer",
|
|
108
|
+
"speechToTextEcho_help": "Bot najpierw odpowiada na wiadomość głosową tym, co zrozumiał (🎤 …)",
|
|
109
|
+
"speechToText_help": "Wiadomości głosowe są rozpoznawane przez tę instancję ioBroker.ai-parakeet i przetwarzane jak wiadomość tekstowa (polecenia, text2command, asystent). Puste: wyłączone",
|
|
106
110
|
"telegram adapter settings": "ustawienia adaptera telegramu",
|
|
107
111
|
"text2command instance": "Instancja Text2Command",
|
|
108
112
|
"token": "Token",
|
package/admin/i18n/pt.json
CHANGED
|
@@ -72,6 +72,8 @@
|
|
|
72
72
|
"Set Password": "Definir uma senha",
|
|
73
73
|
"Set certificates or load it first in the system settings (right top).": "Defina certificados ou carregue primeiro nas configurações do sistema (parte superior direita).",
|
|
74
74
|
"Show the list of rooms before the device selection": "Mostra a lista de quartos antes da seleção do dispositivo",
|
|
75
|
+
"Show the recognised text in the chat": "Mostrar o texto reconhecido no chat",
|
|
76
|
+
"Speech recognition instance": "Instância de reconhecimento de fala",
|
|
75
77
|
"Started!": "O bot foi iniciado!",
|
|
76
78
|
"Store username instead of firstname of remembered users": "Salvar o nome do usuário em vez do primeiro nome dos usuários",
|
|
77
79
|
"Text2Command info": "Todas as solicitações são encaminhadas para esta instância do Text2Command",
|
|
@@ -103,6 +105,8 @@
|
|
|
103
105
|
"restarting": "Terminar",
|
|
104
106
|
"restarting_help": "Esse texto é enviado aos clientes assim que a instância do adaptador é interrompida. Para desativar deixe em branco.",
|
|
105
107
|
"server": "servidor",
|
|
108
|
+
"speechToTextEcho_help": "O bot responde primeiro a uma mensagem de voz com o que entendeu (🎤 …)",
|
|
109
|
+
"speechToText_help": "As mensagens de voz são reconhecidas por esta instância do ioBroker.ai-parakeet e processadas como uma mensagem de texto (comandos, text2command, assistente). Vazio: desligado",
|
|
106
110
|
"telegram adapter settings": "Configurações do adaptador de Telegrama",
|
|
107
111
|
"text2command instance": "Instância de Text2Command",
|
|
108
112
|
"token": "Token",
|
package/admin/i18n/ru.json
CHANGED
|
@@ -72,6 +72,8 @@
|
|
|
72
72
|
"Set Password": "Установка пароля",
|
|
73
73
|
"Set certificates or load it first in the system settings (right top).": "Нужно выбрать сертификаты или сначала загрузить их в системных настройках (вверху справа).",
|
|
74
74
|
"Show the list of rooms before the device selection": "Показывать список комнат до выбора устройства",
|
|
75
|
+
"Show the recognised text in the chat": "Показывать распознанный текст в чате",
|
|
76
|
+
"Speech recognition instance": "Экземпляр распознавания речи",
|
|
75
77
|
"Started!": "Бот запущен!",
|
|
76
78
|
"Store username instead of firstname of remembered users": "Сохранять логины вместо имен для сохраненных пользователей",
|
|
77
79
|
"Text2Command info": "Все сообщения от клиентов будут пересылаться на этот экземпляр драйвера text2Command",
|
|
@@ -103,6 +105,8 @@
|
|
|
103
105
|
"restarting": "Остановка",
|
|
104
106
|
"restarting_help": "Этот текст будет отправлен клиентам после остановки экземпляра адаптера. Оставьте пустым, чтобы ничего не отсылать.",
|
|
105
107
|
"server": "сервер",
|
|
108
|
+
"speechToTextEcho_help": "Бот сначала отвечает на голосовое сообщение тем, что он понял (🎤 …)",
|
|
109
|
+
"speechToText_help": "Голосовые сообщения распознаются этим экземпляром ioBroker.ai-parakeet и обрабатываются как текстовое сообщение (команды, text2command, ассистент). Пусто: выключено",
|
|
106
110
|
"telegram adapter settings": "Настройки адаптера telegram",
|
|
107
111
|
"text2command instance": "Экземпляр Text2Command",
|
|
108
112
|
"token": "Токен",
|
package/admin/i18n/uk.json
CHANGED
|
@@ -72,6 +72,8 @@
|
|
|
72
72
|
"Set Password": "Встановити пароль",
|
|
73
73
|
"Set certificates or load it first in the system settings (right top).": "Встановіть сертифікати або спочатку визначте їх у налаштуваннях системи (справа вгорі).",
|
|
74
74
|
"Show the list of rooms before the device selection": "Показати список кімнат перед вибором пристрою",
|
|
75
|
+
"Show the recognised text in the chat": "Показувати розпізнаний текст у чаті",
|
|
76
|
+
"Speech recognition instance": "Екземпляр розпізнавання мовлення",
|
|
75
77
|
"Started!": "Почати!",
|
|
76
78
|
"Store username instead of firstname of remembered users": "Зберігайте ім’я користувача замість імен запам’ятованих користувачів",
|
|
77
79
|
"Text2Command info": "Усі запити надсилатимуться до цього екземпляра text2Command",
|
|
@@ -103,6 +105,8 @@
|
|
|
103
105
|
"restarting": "Зупинка",
|
|
104
106
|
"restarting_help": "Цей текст буде надіслано клієнтам, коли екземпляр адаптера буде зупинено. Залиште порожнім, щоб деактивувати.",
|
|
105
107
|
"server": "сервер",
|
|
108
|
+
"speechToTextEcho_help": "Бот спочатку відповідає на голосове повідомлення тим, що він зрозумів (🎤 …)",
|
|
109
|
+
"speechToText_help": "Голосові повідомлення розпізнаються цим екземпляром ioBroker.ai-parakeet і обробляються як текстове повідомлення (команди, text2command, асистент). Порожньо: вимкнено",
|
|
106
110
|
"telegram adapter settings": "налаштування адаптера telegram",
|
|
107
111
|
"text2command instance": "Екземпляр Text2Command",
|
|
108
112
|
"token": "Токен",
|
package/admin/i18n/zh-cn.json
CHANGED
|
@@ -72,6 +72,8 @@
|
|
|
72
72
|
"Set Password": "设置密码",
|
|
73
73
|
"Set certificates or load it first in the system settings (right top).": "设置证书或首先在系统设置中加载它(右上角)。",
|
|
74
74
|
"Show the list of rooms before the device selection": "在设备选择之前显示房间列表",
|
|
75
|
+
"Show the recognised text in the chat": "在聊天中显示识别出的文本",
|
|
76
|
+
"Speech recognition instance": "语音识别实例",
|
|
75
77
|
"Started!": "开始!",
|
|
76
78
|
"Store username instead of firstname of remembered users": "存储用户名而不是记住用户的名字",
|
|
77
79
|
"Text2Command info": "所有请求都将发送到此text2Command实例",
|
|
@@ -103,6 +105,8 @@
|
|
|
103
105
|
"restarting": "停止",
|
|
104
106
|
"restarting_help": "一旦适配器实例即将停止,此文本将发送给客户端。留空以停用。",
|
|
105
107
|
"server": "服务器",
|
|
108
|
+
"speechToTextEcho_help": "机器人先用它听懂的内容回复语音消息(🎤 …)",
|
|
109
|
+
"speechToText_help": "语音消息由此 ioBroker.ai-parakeet 实例识别,并像文本消息一样处理(命令、text2command、助手)。留空:关闭",
|
|
106
110
|
"telegram adapter settings": "电报适配器设置",
|
|
107
111
|
"text2command instance": "Text2Command实例",
|
|
108
112
|
"token": "代币",
|
package/admin/jsonConfig.json
CHANGED
|
@@ -354,6 +354,29 @@
|
|
|
354
354
|
"help": "Photos go to the assistant with their caption as the question. Videos are stored in the file storage of this instance (folder assistant) and only their place goes along.",
|
|
355
355
|
"hidden": "!data.assistantInstance"
|
|
356
356
|
},
|
|
357
|
+
"speechToText": {
|
|
358
|
+
"newLine": true,
|
|
359
|
+
"type": "instance",
|
|
360
|
+
"adapter": "ai-parakeet",
|
|
361
|
+
"xs": 12,
|
|
362
|
+
"sm": 12,
|
|
363
|
+
"md": 4,
|
|
364
|
+
"lg": 4,
|
|
365
|
+
"xl": 4,
|
|
366
|
+
"label": "Speech recognition instance",
|
|
367
|
+
"help": "speechToText_help"
|
|
368
|
+
},
|
|
369
|
+
"speechToTextEcho": {
|
|
370
|
+
"type": "checkbox",
|
|
371
|
+
"xs": 12,
|
|
372
|
+
"sm": 12,
|
|
373
|
+
"md": 8,
|
|
374
|
+
"lg": 8,
|
|
375
|
+
"xl": 8,
|
|
376
|
+
"label": "Show the recognised text in the chat",
|
|
377
|
+
"help": "speechToTextEcho_help",
|
|
378
|
+
"hidden": "!data.speechToText"
|
|
379
|
+
},
|
|
357
380
|
"answerTimeoutSec": {
|
|
358
381
|
"newLine": true,
|
|
359
382
|
"type": "number",
|
|
Binary file
|
package/build/help.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The answer of `help`: what the instance answers, written for an AI agent (e.g. ioBroker.pi-agent, or the MCP
|
|
3
|
+
* server with `send_to`) and for script authors. Keep it in sync with `onMessage` / `processMessage` in main.ts.
|
|
4
|
+
*/
|
|
5
|
+
/** Every command `onMessage` answers; `write: true` = it has an effect (sends, calls, changes the user list) */
|
|
6
|
+
export declare const COMMANDS: {
|
|
7
|
+
command: string;
|
|
8
|
+
write: boolean;
|
|
9
|
+
}[];
|
|
10
|
+
export declare const HELP = "ioBroker.telegram: a Telegram bot. It sends messages, pictures, files and locations to the users of the bot and\nto chats and groups, asks questions with buttons and returns the reply, and receives messages (they go to the state\ncommunicate.request, to text2command or to an assistant instance). It can also call a user via CallMeBot.\nRecipients: the users who authenticated with the bot (stored in communicate.users) and the chats and groups the bot\nhas seen (communicate.chats). Telegram lets a bot write only into chats that wrote to it before.\n\nCommands (sendTo telegram.0):\n- send {text, user?, chatId?, ...options} or just a text: sends a message; answer: the number of addressed\n recipients (0 = no name matched), or with returnMessageIds: true {<chatId>: messageId, error?: {<chatId>: reason}}.\n Recipients: chatId (number or string, a private chat or a group such as \"-1001234567890\") wins over user.\n user: a name (the telegram username, or the first name if the settings use first names or the user has no\n username) or a user id; several separated by \",\" \";\" or space, or an array. Without chatId and user: every\n stored user; a text that starts with \"@name\" then goes only to the user whose name matches.\n text: the message (string or number); <HTML>...</HTML>, <Markdown>...</Markdown> or <MarkdownV2>...</MarkdownV2>\n around it sets parse_mode. A local file path, an http(s) URL of a picture, a URI iobfile://<adapter.0>/<path>,\n iobstate://<state id> or iobobject://<object id>/<path>, or a Buffer is sent as a file: the kind follows the\n extension (jpg, png, gif, bmp: photo; mp4: video; mp3, ogg, wav: audio; webp: sticker; txt, pdf, csv, doc, docx,\n xls, xlsx: document) or the option type. The texts typing, upload_photo, upload_video, record_video, record_audio,\n upload_document, find_location show that action in the chat.\n Options: type (photo, video, audio, document, sticker, animation, mediagroup), fileName (name for a Buffer or\n URI), caption, parse_mode (HTML, Markdown, MarkdownV2), disable_notification (true = silent), message_thread_id\n (topic of a forum group), reply_markup ({keyboard: [[\"A\", \"B\"]], resize_keyboard?, one_time_keyboard?} or\n {inline_keyboard: [[{text, callback_data}]]}), media (with type mediagroup: array of local photo paths), and any\n other parameter of the Bot API method (e.g. disable_web_page_preview, protect_content), passed on unchanged.\n latitude, longitude: sends a location; with title and address too a venue.\n Change a sent message (chat_id, message_id from returnMessageIds): editMessageText {options: {chat_id,\n message_id, ...}} with text = the new text; editMessageCaption {options: {chat_id, message_id}} with text = the\n new caption; editMessageMedia {options: {chat_id, message_id, caption?, parse_mode?, reply_markup?}} with text =\n the new file; editMessageReplyMarkup {reply_markup, options: {chat_id, message_id}}; deleteMessage {options:\n {chat_id, message_id}}. answerCallbackQuery {text?, showAlert?} with chatId or user of the person who pressed\n an inline button: confirms the press (text as a notice, showAlert true = as a dialog).\n- ask {text, user?, chatId?, reply_markup?, ...options of send} or just a text: sends a question and answers with\n the reply within the answer timeout of the settings (default 60 s): the Telegram message ({text, chat, from,\n ...}) or for an inline button the callback query ({data: the callback_data of the button, from, message});\n \"__timeout__\" if nobody replied. The sendTo of the caller must wait longer than that timeout.\n- call {text, user?, users?, lang?, file?, repeats?} or just a text: a voice call in the Telegram app via CallMeBot\n that reads the text. users: array of telegram usernames (@name) or phone numbers (+49...); user: one of them;\n neither: every stored user with a username. lang: a voice such as de-DE-Standard-A (default: by the system\n language). file: URL of an mp3 to play instead of the text. repeats: number of repeats. No answer.\n- sendNotification: for the notification-manager (sends the notification to the users that receive system\n messages); answer {sent}.\n- help: this text and the list of commands {help, commands: [{command, write}]}.\n- adminuser, delUser, systemMessages, delAllUser: for the settings, not for agents.\n\nStates (telegram.0.communicate.*): users (JSON: user id -> {firstName, userName, sysMessages}), chats (JSON: chat\nid -> {title, type: private, group, supergroup or channel}), request (the last received message as \"[name]text\"),\nrequestChatId, requestUserId, requestMessageId of it. Writing with ack false sends: response (a text to every\nuser, or \"@name text\"), responseSilent (the same without notification), responseJson and responseSilentJson (JSON\nlike the message of send), requestResponse (a text into the chat of the last received message).\n\nHow to talk to the user:\n- Ask for the recipient (user, chat or group) when it is not clear; take the names from communicate.users and the\n groups from communicate.chats, never guess a chat id. Without user and chatId send goes to every stored user:\n fine if only the user is stored, else ask.\n- Sending to other people than the user, into groups or to all users, and calls only on the user's explicit request.\n- Name users and chats by their names, not by ids; times in local time.\n- Tell the user to whom the message went; an answer 0 means the name is unknown to the bot.";
|
package/build/help.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The answer of `help`: what the instance answers, written for an AI agent (e.g. ioBroker.pi-agent, or the MCP
|
|
4
|
+
* server with `send_to`) and for script authors. Keep it in sync with `onMessage` / `processMessage` in main.ts.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.HELP = exports.COMMANDS = void 0;
|
|
8
|
+
/** Every command `onMessage` answers; `write: true` = it has an effect (sends, calls, changes the user list) */
|
|
9
|
+
exports.COMMANDS = [
|
|
10
|
+
{ command: 'help', write: false },
|
|
11
|
+
{ command: 'send', write: true },
|
|
12
|
+
{ command: 'ask', write: true },
|
|
13
|
+
{ command: 'call', write: true },
|
|
14
|
+
{ command: 'sendNotification', write: true },
|
|
15
|
+
{ command: 'adminuser', write: false },
|
|
16
|
+
{ command: 'delUser', write: true },
|
|
17
|
+
{ command: 'systemMessages', write: true },
|
|
18
|
+
{ command: 'delAllUser', write: true },
|
|
19
|
+
];
|
|
20
|
+
exports.HELP = `ioBroker.telegram: a Telegram bot. It sends messages, pictures, files and locations to the users of the bot and
|
|
21
|
+
to chats and groups, asks questions with buttons and returns the reply, and receives messages (they go to the state
|
|
22
|
+
communicate.request, to text2command or to an assistant instance). It can also call a user via CallMeBot.
|
|
23
|
+
Recipients: the users who authenticated with the bot (stored in communicate.users) and the chats and groups the bot
|
|
24
|
+
has seen (communicate.chats). Telegram lets a bot write only into chats that wrote to it before.
|
|
25
|
+
|
|
26
|
+
Commands (sendTo telegram.0):
|
|
27
|
+
- send {text, user?, chatId?, ...options} or just a text: sends a message; answer: the number of addressed
|
|
28
|
+
recipients (0 = no name matched), or with returnMessageIds: true {<chatId>: messageId, error?: {<chatId>: reason}}.
|
|
29
|
+
Recipients: chatId (number or string, a private chat or a group such as "-1001234567890") wins over user.
|
|
30
|
+
user: a name (the telegram username, or the first name if the settings use first names or the user has no
|
|
31
|
+
username) or a user id; several separated by "," ";" or space, or an array. Without chatId and user: every
|
|
32
|
+
stored user; a text that starts with "@name" then goes only to the user whose name matches.
|
|
33
|
+
text: the message (string or number); <HTML>...</HTML>, <Markdown>...</Markdown> or <MarkdownV2>...</MarkdownV2>
|
|
34
|
+
around it sets parse_mode. A local file path, an http(s) URL of a picture, a URI iobfile://<adapter.0>/<path>,
|
|
35
|
+
iobstate://<state id> or iobobject://<object id>/<path>, or a Buffer is sent as a file: the kind follows the
|
|
36
|
+
extension (jpg, png, gif, bmp: photo; mp4: video; mp3, ogg, wav: audio; webp: sticker; txt, pdf, csv, doc, docx,
|
|
37
|
+
xls, xlsx: document) or the option type. The texts typing, upload_photo, upload_video, record_video, record_audio,
|
|
38
|
+
upload_document, find_location show that action in the chat.
|
|
39
|
+
Options: type (photo, video, audio, document, sticker, animation, mediagroup), fileName (name for a Buffer or
|
|
40
|
+
URI), caption, parse_mode (HTML, Markdown, MarkdownV2), disable_notification (true = silent), message_thread_id
|
|
41
|
+
(topic of a forum group), reply_markup ({keyboard: [["A", "B"]], resize_keyboard?, one_time_keyboard?} or
|
|
42
|
+
{inline_keyboard: [[{text, callback_data}]]}), media (with type mediagroup: array of local photo paths), and any
|
|
43
|
+
other parameter of the Bot API method (e.g. disable_web_page_preview, protect_content), passed on unchanged.
|
|
44
|
+
latitude, longitude: sends a location; with title and address too a venue.
|
|
45
|
+
Change a sent message (chat_id, message_id from returnMessageIds): editMessageText {options: {chat_id,
|
|
46
|
+
message_id, ...}} with text = the new text; editMessageCaption {options: {chat_id, message_id}} with text = the
|
|
47
|
+
new caption; editMessageMedia {options: {chat_id, message_id, caption?, parse_mode?, reply_markup?}} with text =
|
|
48
|
+
the new file; editMessageReplyMarkup {reply_markup, options: {chat_id, message_id}}; deleteMessage {options:
|
|
49
|
+
{chat_id, message_id}}. answerCallbackQuery {text?, showAlert?} with chatId or user of the person who pressed
|
|
50
|
+
an inline button: confirms the press (text as a notice, showAlert true = as a dialog).
|
|
51
|
+
- ask {text, user?, chatId?, reply_markup?, ...options of send} or just a text: sends a question and answers with
|
|
52
|
+
the reply within the answer timeout of the settings (default 60 s): the Telegram message ({text, chat, from,
|
|
53
|
+
...}) or for an inline button the callback query ({data: the callback_data of the button, from, message});
|
|
54
|
+
"__timeout__" if nobody replied. The sendTo of the caller must wait longer than that timeout.
|
|
55
|
+
- call {text, user?, users?, lang?, file?, repeats?} or just a text: a voice call in the Telegram app via CallMeBot
|
|
56
|
+
that reads the text. users: array of telegram usernames (@name) or phone numbers (+49...); user: one of them;
|
|
57
|
+
neither: every stored user with a username. lang: a voice such as de-DE-Standard-A (default: by the system
|
|
58
|
+
language). file: URL of an mp3 to play instead of the text. repeats: number of repeats. No answer.
|
|
59
|
+
- sendNotification: for the notification-manager (sends the notification to the users that receive system
|
|
60
|
+
messages); answer {sent}.
|
|
61
|
+
- help: this text and the list of commands {help, commands: [{command, write}]}.
|
|
62
|
+
- adminuser, delUser, systemMessages, delAllUser: for the settings, not for agents.
|
|
63
|
+
|
|
64
|
+
States (telegram.0.communicate.*): users (JSON: user id -> {firstName, userName, sysMessages}), chats (JSON: chat
|
|
65
|
+
id -> {title, type: private, group, supergroup or channel}), request (the last received message as "[name]text"),
|
|
66
|
+
requestChatId, requestUserId, requestMessageId of it. Writing with ack false sends: response (a text to every
|
|
67
|
+
user, or "@name text"), responseSilent (the same without notification), responseJson and responseSilentJson (JSON
|
|
68
|
+
like the message of send), requestResponse (a text into the chat of the last received message).
|
|
69
|
+
|
|
70
|
+
How to talk to the user:
|
|
71
|
+
- Ask for the recipient (user, chat or group) when it is not clear; take the names from communicate.users and the
|
|
72
|
+
groups from communicate.chats, never guess a chat id. Without user and chatId send goes to every stored user:
|
|
73
|
+
fine if only the user is stored, else ask.
|
|
74
|
+
- Sending to other people than the user, into groups or to all users, and calls only on the user's explicit request.
|
|
75
|
+
- Name users and chats by their names, not by ids; times in local time.
|
|
76
|
+
- Tell the user to whom the message went; an answer 0 means the name is unknown to the bot.`;
|
|
77
|
+
//# sourceMappingURL=help.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.js","sourceRoot":"","sources":["../src/help.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,gHAAgH;AACnG,QAAA,QAAQ,GAA0C;IAC3D,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE;IACjC,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE;IAChC,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE;IAC/B,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE;IAChC,EAAE,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,IAAI,EAAE;IAC5C,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE;IACtC,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE;IACnC,EAAE,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,IAAI,EAAE;IAC1C,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE;CACzC,CAAC;AAEW,QAAA,IAAI,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4FAwDwE,CAAC"}
|
package/build/main.js
CHANGED
|
@@ -13,6 +13,7 @@ const node_1 = require("node-telegram-bot-api/node");
|
|
|
13
13
|
const adapter_core_1 = require("@iobroker/adapter-core");
|
|
14
14
|
const webserver_1 = require("@iobroker/webserver");
|
|
15
15
|
const iobUri_1 = require("./iobUri");
|
|
16
|
+
const help_1 = require("./help");
|
|
16
17
|
const proxy_1 = require("./proxy");
|
|
17
18
|
const systemLang2CallMe = {
|
|
18
19
|
en: 'en-GB-Standard-A',
|
|
@@ -47,6 +48,8 @@ const actions = [
|
|
|
47
48
|
* a limit a request lost on the way (e.g. the assistant restarted meanwhile) would leave the user without any reply.
|
|
48
49
|
*/
|
|
49
50
|
const ASSISTANT_TIMEOUT_MS = 120_000;
|
|
51
|
+
/** How long the speech recognition (ioBroker.ai-parakeet) may take, including loading the model after idle. */
|
|
52
|
+
const SPEECH_TO_TEXT_TIMEOUT_MS = 90_000;
|
|
50
53
|
/** Rejected by `sendToIfAlive` when the instance did not answer in time. */
|
|
51
54
|
class SendToTimeoutError extends Error {
|
|
52
55
|
}
|
|
@@ -256,7 +259,13 @@ class Telegram extends adapter_core_1.Adapter {
|
|
|
256
259
|
}
|
|
257
260
|
onMessage(obj) {
|
|
258
261
|
if (obj) {
|
|
259
|
-
if (obj.command === '
|
|
262
|
+
if (obj.command === 'help') {
|
|
263
|
+
// A description of all commands for AI agents and scripts; works also without a connection
|
|
264
|
+
if (obj.callback) {
|
|
265
|
+
this.sendTo(obj.from, obj.command, { help: help_1.HELP, commands: help_1.COMMANDS }, obj.callback);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
else if (obj.command === 'adminuser') {
|
|
260
269
|
let adminUserData;
|
|
261
270
|
this.getState('communicate.users', (err, state) => {
|
|
262
271
|
if (err) {
|
|
@@ -362,7 +371,7 @@ class Telegram extends adapter_core_1.Adapter {
|
|
|
362
371
|
*/
|
|
363
372
|
async migrateInstanceIds() {
|
|
364
373
|
const migrated = {};
|
|
365
|
-
for (const key of ['text2command', 'assistantInstance']) {
|
|
374
|
+
for (const key of ['text2command', 'assistantInstance', 'speechToText']) {
|
|
366
375
|
const value = this.config[key];
|
|
367
376
|
if (typeof value === 'string' && value.startsWith('system.adapter.')) {
|
|
368
377
|
const shortId = value.substring('system.adapter.'.length);
|
|
@@ -1719,33 +1728,108 @@ class Telegram extends adapter_core_1.Adapter {
|
|
|
1719
1728
|
}).catch(err => this.log.error(`send Message Error: ${err}`));
|
|
1720
1729
|
}
|
|
1721
1730
|
/**
|
|
1722
|
-
*
|
|
1723
|
-
*
|
|
1724
|
-
*
|
|
1731
|
+
* The checks of the text pipeline for a voice message, done before the recording is recognised: an old message
|
|
1732
|
+
* is dropped, and a user that is not allowed gets the same answer as for a text message. Without it anyone could
|
|
1733
|
+
* use the speech recognition (or talk to the assistant) just by sending a voice message.
|
|
1725
1734
|
*
|
|
1726
1735
|
* @param msg the voice message
|
|
1727
|
-
* @
|
|
1736
|
+
* @returns whether the voice message may be processed
|
|
1728
1737
|
*/
|
|
1729
|
-
async
|
|
1730
|
-
const bot = this.bot;
|
|
1738
|
+
async acceptVoiceMessage(msg) {
|
|
1731
1739
|
const from = msg.from;
|
|
1732
|
-
const user = !this.config.useUsername ? from.first_name : !from.username ? from.first_name : from.username;
|
|
1733
1740
|
const pollingInterval = parseInt(String(this.config.pollingInterval ?? 0), 10) || 0;
|
|
1734
1741
|
if (Date.now() - msg.date * 1000 > pollingInterval + 30000) {
|
|
1735
1742
|
this.log.warn(`Voice message from ${from.first_name} ignored, because too old`);
|
|
1736
|
-
return;
|
|
1743
|
+
return false;
|
|
1737
1744
|
}
|
|
1738
1745
|
if ((this.config.password || this.config.doNotAcceptNewUsers) && !this.storedUsers[from.id]) {
|
|
1739
|
-
await bot.api
|
|
1740
|
-
.sendMessage({
|
|
1746
|
+
await this.bot.api.sendMessage({
|
|
1741
1747
|
chat_id: from.id,
|
|
1742
1748
|
text: adapter_core_1.I18n.translate(this.config.doNotAcceptNewUsers
|
|
1743
1749
|
? 'User is not in the list'
|
|
1744
1750
|
: 'Please enter password in form "/password phrase"'),
|
|
1751
|
+
}).catch(error => this.log.error(`send Message Error: ${error}`));
|
|
1752
|
+
return false;
|
|
1753
|
+
}
|
|
1754
|
+
return true;
|
|
1755
|
+
}
|
|
1756
|
+
/** How long the speech recognition may take (a field so that tests can shorten it). */
|
|
1757
|
+
speechToTextTimeoutMs = SPEECH_TO_TEXT_TIMEOUT_MS;
|
|
1758
|
+
/**
|
|
1759
|
+
* Recognise a voice message with the speech recognition instance (ioBroker.ai-parakeet, `transcribe`) and process
|
|
1760
|
+
* the recognised text like a text message: `communicate.request`, the commands of this adapter, text2command and
|
|
1761
|
+
* the assistant all get it.
|
|
1762
|
+
*
|
|
1763
|
+
* @param msg the voice message
|
|
1764
|
+
* @param download the running download of the recording (OGG/Opus)
|
|
1765
|
+
*/
|
|
1766
|
+
async transcribeVoice(msg, download) {
|
|
1767
|
+
const bot = this.bot;
|
|
1768
|
+
const instance = this.config.speechToText;
|
|
1769
|
+
if (!(await this.acceptVoiceMessage(msg))) {
|
|
1770
|
+
return;
|
|
1771
|
+
}
|
|
1772
|
+
const content = await download;
|
|
1773
|
+
const options = msg.is_topic_message ? { message_thread_id: msg.message_thread_id } : undefined;
|
|
1774
|
+
bot.api.sendChatAction({ ...options, chat_id: msg.chat.id, action: 'typing' }).catch(() => { });
|
|
1775
|
+
// the names of the commands help the recognition to write them as configured (e.g. "ioBroker")
|
|
1776
|
+
const prompt = Object.values(this.commands)
|
|
1777
|
+
.map(command => command.alias)
|
|
1778
|
+
.filter(alias => typeof alias === 'string' && alias)
|
|
1779
|
+
.join(', ');
|
|
1780
|
+
this.log.debug(`Recognise voice message (${content.length} bytes) with ${instance}`);
|
|
1781
|
+
let response;
|
|
1782
|
+
try {
|
|
1783
|
+
response = (await this.sendToIfAlive(instance, 'transcribe', { audio: content.toString('base64'), ...(prompt ? { prompt } : {}) }, this.speechToTextTimeoutMs));
|
|
1784
|
+
}
|
|
1785
|
+
catch (error) {
|
|
1786
|
+
this.log.warn(`Cannot recognise voice message with ${instance}: ${error instanceof Error ? error.message : String(error)}`);
|
|
1787
|
+
response = { error: String(error) };
|
|
1788
|
+
}
|
|
1789
|
+
if (!response) {
|
|
1790
|
+
// the instance is not running: already logged
|
|
1791
|
+
return;
|
|
1792
|
+
}
|
|
1793
|
+
// the model writes a full stop at the end, which would break e.g. "<alias> on"
|
|
1794
|
+
const text = (response.text || '').trim().replace(/[.!]+$/, '');
|
|
1795
|
+
if (response.error || !text) {
|
|
1796
|
+
if (response.error) {
|
|
1797
|
+
this.log.warn(`${instance} cannot recognise the voice message: ${response.error}`);
|
|
1798
|
+
}
|
|
1799
|
+
await bot.api
|
|
1800
|
+
.sendMessage({
|
|
1801
|
+
...options,
|
|
1802
|
+
chat_id: msg.chat.id,
|
|
1803
|
+
text: adapter_core_1.I18n.translate('The voice message could not be recognised.'),
|
|
1745
1804
|
})
|
|
1746
1805
|
.catch(error => this.log.error(`send Message Error: ${error}`));
|
|
1747
1806
|
return;
|
|
1748
1807
|
}
|
|
1808
|
+
this.log.debug(`Recognised voice message: ${text}`);
|
|
1809
|
+
this.setStateSafe('communicate.requestVoiceText', { val: text, ack: true });
|
|
1810
|
+
if (this.config.speechToTextEcho !== false) {
|
|
1811
|
+
// show what was understood, so a wrong answer can be told apart from a misheard command
|
|
1812
|
+
await bot.api
|
|
1813
|
+
.sendMessage({ ...options, chat_id: msg.chat.id, text: `🎤 ${text}` })
|
|
1814
|
+
.catch(error => this.log.error(`send Message Error: ${error}`));
|
|
1815
|
+
}
|
|
1816
|
+
await this.processTelegramText({ ...msg, text });
|
|
1817
|
+
}
|
|
1818
|
+
/**
|
|
1819
|
+
* Forward a voice message to the ioBroker.assistant instance: it recognises the speech, answers like a text
|
|
1820
|
+
* question (same `source`, so the conversation continues) and returns what it heard. The same user check as for
|
|
1821
|
+
* text messages applies — without it anyone could talk to the assistant just by sending a voice message.
|
|
1822
|
+
*
|
|
1823
|
+
* @param msg the voice message
|
|
1824
|
+
* @param download the running download of the recording (OGG/Opus)
|
|
1825
|
+
*/
|
|
1826
|
+
async askAssistantByVoice(msg, download) {
|
|
1827
|
+
const bot = this.bot;
|
|
1828
|
+
const from = msg.from;
|
|
1829
|
+
const user = !this.config.useUsername ? from.first_name : !from.username ? from.first_name : from.username;
|
|
1830
|
+
if (!(await this.acceptVoiceMessage(msg))) {
|
|
1831
|
+
return;
|
|
1832
|
+
}
|
|
1749
1833
|
const content = await download;
|
|
1750
1834
|
const options = msg.is_topic_message ? { message_thread_id: msg.message_thread_id } : undefined;
|
|
1751
1835
|
// recognition + answer take a few seconds: show that something is happening
|
|
@@ -2187,10 +2271,14 @@ class Telegram extends adapter_core_1.Adapter {
|
|
|
2187
2271
|
this.queueAssistantMedia(msg);
|
|
2188
2272
|
}
|
|
2189
2273
|
if (msg.voice) {
|
|
2190
|
-
// Downloaded once: stored as before (communicate.pathFile) and
|
|
2191
|
-
// and
|
|
2274
|
+
// Downloaded once: stored as before (communicate.pathFile) and recognised: with a speech recognition
|
|
2275
|
+
// instance here, and the text goes on like a text message; else with an assistant instance there.
|
|
2276
|
+
// A voice message with a caption is answered by its caption (text pipeline) instead.
|
|
2192
2277
|
const download = this.downloadFile(msg.voice.file_id);
|
|
2193
|
-
if (this.config.
|
|
2278
|
+
if (this.config.speechToText && msg.from && !msg.caption) {
|
|
2279
|
+
this.transcribeVoice(msg, download).catch(err => this.log.error(`Cannot recognise voice message with ${this.config.speechToText}: ${err}`));
|
|
2280
|
+
}
|
|
2281
|
+
else if (this.config.assistantInstance && msg.from && !msg.caption) {
|
|
2194
2282
|
this.askAssistantByVoice(msg, download).catch(err => this.log.error(`Cannot send voice message to ${this.config.assistantInstance}: ${err}`));
|
|
2195
2283
|
}
|
|
2196
2284
|
download
|