/__init__.py Secret
Last active
July 22, 2022 15:01
Revisions
-
balloob revised this gist
Nov 8, 2019 . 1 changed file with 2 additions and 3 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,9 +22,8 @@ async def text_events(event: core.Event): if event.data[ATTR_CHAT_ID] != event.data[ATTR_USER_ID]: return response = await process(hass, event.data[ATTR_TEXT], "telegram-bot") await hass.services.async_call( TELEGRAM_DOMAIN, SERVICE_SEND_MESSAGE, -
balloob revised this gist
Nov 8, 2019 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,5 @@ # Create as custom_components/telegram_bot_conversation/__init__.py # Requires telegram_bot to be set up. from homeassistant import core from homeassistant.components.telegram_bot import ( EVENT_TELEGRAM_TEXT, -
balloob created this gist
Nov 8, 2019 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ # Create as custom_components/telegram_bot_conversation/__init__.py from homeassistant import core from homeassistant.components.telegram_bot import ( EVENT_TELEGRAM_TEXT, ATTR_TEXT, SERVICE_SEND_MESSAGE, DOMAIN as TELEGRAM_DOMAIN, ATTR_MESSAGE, ATTR_TARGET, ATTR_USER_ID, ATTR_CHAT_ID, ) from homeassistant.components.conversation import process DOMAIN = "telegram_bot_conversation" async def async_setup(hass: core.HomeAssistant, config: dict) -> bool: async def text_events(event: core.Event): # Only deal with private chats. if event.data[ATTR_CHAT_ID] != event.data[ATTR_USER_ID]: return print(event.data) text = event.data[ATTR_TEXT] response = await process(hass, text, "telegram-bot") await hass.services.async_call( TELEGRAM_DOMAIN, SERVICE_SEND_MESSAGE, { ATTR_MESSAGE: response.speech["plain"]["speech"], ATTR_TARGET: event.data[ATTR_USER_ID], }, ) hass.bus.async_listen(EVENT_TELEGRAM_TEXT, text_events) return True This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ { "domain": "telegram_bot_conversation", "name": "Telegram Bot <> Conversation", "config_flow": false, "documentation": "", "requirements": [], "dependencies": ["telegram_bot", "conversation"], "codeowners": [] }