Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/telegram/bot-data.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"bot":{"name":"TelegramIntegration"},"groups":[{"group":{"name":"Default","is_collapsed":0,"pos":0},"triggers":[{"trigger":{"id":1768,"name":"Send","actions":"[{\"_id\":\"CsLix6iiX\",\"type\":\"restapi\",\"content\":{\"text\":\"\",\"rest_api\":62,\"rest_api_method\":\"temp1695212526903\",\"rest_api_method_params\":[],\"rest_api_method_output\":{\"default_trigger\":\"1769\"},\"attr_options\":{\"no_body\":true}}}]","default":0,"default_unknown":0,"default_always":0,"default_unknown_btn":0,"as_argument":0,"in_progress":0},"events":[],"payloads":[]},{"trigger":{"id":1769,"name":"Debug","actions":"[{\"_id\":\"tV0edgixf\",\"type\":\"text\",\"content\":{\"text\":\"{http_code}\\n{http_error}\\n{content_raw}\\n{http_data}\",\"attr_options\":{\"as_system\":true}},\"skip_resp\":false}]","default":0,"default_unknown":0,"default_always":0,"default_unknown_btn":0,"as_argument":0,"in_progress":0},"events":[],"payloads":[]}]}]}
{"bot":{"name":"TelegramIntegration"},"groups":[{"group":{"name":"Default","is_collapsed":0,"pos":0},"triggers":[{"trigger":{"id":1768,"name":"Send","actions":"[{\"_id\":\"CsLix6iiX\",\"type\":\"restapi\",\"content\":{\"text\":\"\",\"rest_api\":62,\"rest_api_method\":\"temp1695212526903\",\"rest_api_method_params\":[],\"rest_api_method_output\":{\"default_trigger\":\"1769\"},\"attr_options\":{\"no_body\":true}}}]","default":0,"default_unknown":0,"default_always":0,"default_unknown_btn":0,"as_argument":0,"in_progress":0},"events":[],"payloads":[]},{"trigger":{"id":1769,"name":"Debug","actions":"[{\"_id\":\"tV0edgixf\",\"type\":\"text\",\"content\":{\"text\":\"{http_code}\\n{http_error}\\n{content_raw}\\n{http_data}\",\"attr_options\":{\"as_system\":true}},\"skip_resp\":false}]","default":0,"default_unknown":0,"default_always":0,"default_unknown_btn":0,"as_argument":0,"in_progress":0},"events":[],"payloads":[]},{"trigger":{"id":1770,"name":"Send typing","actions":"[{\"_id\":\"telegramTyping\",\"type\":\"restapi\",\"content\":{\"text\":\"\",\"rest_api\":62,\"rest_api_method\":\"telegram_send_typing\",\"rest_api_method_params\":[],\"rest_api_method_output\":{\"default_trigger\":\"1769\"},\"attr_options\":{\"no_body\":true}}}]","default":0,"default_unknown":0,"default_always":0,"default_unknown_btn":0,"as_argument":0,"in_progress":0},"events":[],"payloads":[]}]}]}
2 changes: 1 addition & 1 deletion doc/telegram/rest-api.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name":"TelegramIntegration","description":"","configuration":"{\"host\":\"https:\/\/api.telegram.org\",\"ecache\":false,\"parameters\":[{\"method\":\"POST\",\"authorization\":\"\",\"api_key_location\":\"header\",\"query\":[],\"header\":[],\"conditions\":[],\"postparams\":[],\"userparams\":[],\"output\":[{\"key\":\"\",\"value\":\"\",\"id\":\"temp1706685738487\",\"success_name\":\"Success\",\"success_header\":\"200\"}],\"id\":\"temp1695212526903\",\"name\":\"Send\",\"suburl\":\"\/bot{{args.chat.incoming_chat.incoming_dynamic_array.access_token}}\/sendMessage\",\"body_request_type\":\"raw\",\"body_raw\":\"{\\n \\\"chat_id\\\":{{args.chat.incoming_chat.chat_external_id}},\\\"parse_mode\\\":\\\"HTML\\\",\\n \\\"text\\\":{{msg_html_nobr}}\\n{interactive_api}\\n,\\\"reply_markup\\\":{\\n \\\"resize_keyboard\\\":true,\\n\\\"inline_keyboard\\\":[\\n{button_template}\\n [{\\n \\\"text\\\": {{button_title}},\\n \\\"{is_url}url{\/is_url}{is_button}callback_data{\/is_button}\\\":{{button_payload}}\\n }]\\n{\/button_template}\\n]\\n}\\n\\n{\/interactive_api}\\n}\",\"body_request_type_content\":\"json\",\"remote_message_id\":\"result:message_id\",\"suburl_file\":\"\/bot{{args.chat.incoming_chat.incoming_dynamic_array.access_token}}\/{api_by_ext__tgs}sendSticker{\/api_by_ext}{api_by_ext__ogg}sendVoice{\/api_by_ext}{api_by_ext__mp3_m4a}sendAudio{\/api_by_ext}{api_by_ext__mp4}sendVideo{\/api_by_ext}{image_api}sendPhoto{\/image_api}{file_api}sendDocument{\/file_api}\",\"body_raw_file\":\"{\\n \\\"chat_id\\\":{{args.chat.incoming_chat.chat_external_id}},\\n \\\"{api_by_ext__tgs}sticker{\/api_by_ext}{api_by_ext__ogg}voice{\/api_by_ext}{api_by_ext__mp3_m4a}audio{\/api_by_ext}{api_by_ext__mp4}video{\/api_by_ext}{file_api}document{\/file_api}{image_api}photo{\/image_api}\\\":{{file_url}}\\n{api_by_ext__ogg},\\\"caption\\\":{{msg_clean}}{\/api_by_ext}{api_by_ext__mp3_m4a},\\\"caption\\\":{{msg_clean}}{\/api_by_ext}{api_by_ext__mp4},\\\"caption\\\":{{msg_clean}}{\/api_by_ext}{file_api},\\\"caption\\\":{{msg_clean}}{\/file_api}{image_api},\\\"caption\\\":{{msg_clean}}{\/image_api}\\n}\",\"check_not_empty\":\"{{msg_html_nobr}}\",\"suburl_file_convert\":\"tgs,file_api,mp3_m4a,ogg\",\"suburl_file_skip_ext\":\"tgs\"}]}"}
{"name":"TelegramIntegration","description":"","configuration":"{\"host\":\"https://api.telegram.org\",\"ecache\":false,\"parameters\":[{\"method\":\"POST\",\"authorization\":\"\",\"api_key_location\":\"header\",\"query\":[],\"header\":[],\"conditions\":[],\"postparams\":[],\"userparams\":[],\"output\":[{\"key\":\"\",\"value\":\"\",\"id\":\"temp1706685738487\",\"success_name\":\"Success\",\"success_header\":\"200\"}],\"id\":\"temp1695212526903\",\"name\":\"Send\",\"suburl\":\"/bot{{args.chat.incoming_chat.incoming_dynamic_array.access_token}}/sendMessage\",\"body_request_type\":\"raw\",\"body_raw\":\"{\\n \\\"chat_id\\\":{{args.chat.incoming_chat.chat_external_id}},\\\"parse_mode\\\":\\\"HTML\\\",\\n \\\"text\\\":{{msg_html_nobr}}\\n{interactive_api}\\n,\\\"reply_markup\\\":{\\n \\\"resize_keyboard\\\":true,\\n\\\"inline_keyboard\\\":[\\n{button_template}\\n [{\\n \\\"text\\\": {{button_title}},\\n \\\"{is_url}url{/is_url}{is_button}callback_data{/is_button}\\\":{{button_payload}}\\n }]\\n{/button_template}\\n]\\n}\\n\\n{/interactive_api}\\n}\",\"body_request_type_content\":\"json\",\"remote_message_id\":\"result:message_id\",\"suburl_file\":\"/bot{{args.chat.incoming_chat.incoming_dynamic_array.access_token}}/{api_by_ext__tgs}sendSticker{/api_by_ext}{api_by_ext__ogg}sendVoice{/api_by_ext}{api_by_ext__mp3_m4a}sendAudio{/api_by_ext}{api_by_ext__mp4}sendVideo{/api_by_ext}{image_api}sendPhoto{/image_api}{file_api}sendDocument{/file_api}\",\"body_raw_file\":\"{\\n \\\"chat_id\\\":{{args.chat.incoming_chat.chat_external_id}},\\n \\\"{api_by_ext__tgs}sticker{/api_by_ext}{api_by_ext__ogg}voice{/api_by_ext}{api_by_ext__mp3_m4a}audio{/api_by_ext}{api_by_ext__mp4}video{/api_by_ext}{file_api}document{/file_api}{image_api}photo{/image_api}\\\":{{file_url}}\\n{api_by_ext__ogg},\\\"caption\\\":{{msg_clean}}{/api_by_ext}{api_by_ext__mp3_m4a},\\\"caption\\\":{{msg_clean}}{/api_by_ext}{api_by_ext__mp4},\\\"caption\\\":{{msg_clean}}{/api_by_ext}{file_api},\\\"caption\\\":{{msg_clean}}{/file_api}{image_api},\\\"caption\\\":{{msg_clean}}{/image_api}\\n}\",\"check_not_empty\":\"{{msg_html_nobr}}\",\"suburl_file_convert\":\"tgs,file_api,mp3_m4a,ogg\",\"suburl_file_skip_ext\":\"tgs\"},{\"method\":\"POST\",\"authorization\":\"\",\"api_key_location\":\"header\",\"query\":[],\"header\":[],\"conditions\":[],\"postparams\":[],\"userparams\":[],\"output\":[{\"key\":\"\",\"value\":\"\",\"id\":\"telegram_typing_success\",\"success_name\":\"Success\",\"success_header\":\"200\"}],\"id\":\"telegram_send_typing\",\"name\":\"Send typing\",\"suburl\":\"/bot{{args.chat.incoming_chat.incoming_dynamic_array.access_token}}/sendChatAction\",\"body_request_type\":\"raw\",\"body_request_type_content\":\"json\",\"body_raw\":\"{\\n \\\"chat_id\\\": {{args.chat.incoming_chat.chat_external_id}},\\n \\\"action\\\": \\\"typing\\\"\\n}\",\"check_not_empty\":\"{{args.chat.incoming_chat.chat_external_id}}\"}]}"}
26 changes: 20 additions & 6 deletions providers/TelegramLiveHelperChatActivator.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,26 @@ public static function installOrUpdate()
$botData['bot']->name = 'TelegramIntegration';
$botData['bot']->updateThis(['update' => ['name']]);

foreach ($botData['triggers'] as $triggerItem) {
$actions = $triggerItem->actions_front;
$updatedActions = false;

foreach ($actions as & $action) {
if (isset($action['type']) && $action['type'] === 'restapi' && isset($action['content']['rest_api'])) {
$action['content']['rest_api'] = $restAPI->id;
$updatedActions = true;
}
}
unset($action);

if ($updatedActions === true) {
$triggerItem->actions_front = $actions;
$triggerItem->actions = json_encode($actions);
$triggerItem->updateThis(['update' => ['actions']]);
}
}

$trigger = $botData['triggers'][0];
$actions = $trigger->actions_front;
$actions[0]['content']['rest_api'] = $restAPI->id;
$trigger->actions_front = $actions;
$trigger->actions = json_encode($actions);
$trigger->updateThis(['update' => ['actions']]);

if ($botPrevious && $event = \erLhcoreClassModelChatWebhook::findOne(['filter' => ['event' => ['chat.desktop_client_admin_msg', 'bot_id' => $botPrevious->id]]])) {
$event->removeThis();
Expand Down Expand Up @@ -123,4 +137,4 @@ public static function installOrUpdate()
}
}

?>
?>