From 09a223e29f1da4488dc0308b95dffbf28795ab3e Mon Sep 17 00:00:00 2001 From: hapinessmaker47-dev Date: Thu, 16 Oct 2025 02:26:45 +0300 Subject: [PATCH] Update send-text-message-or-reply.mjs --- .../send-text-message-or-reply.mjs | 89 +++++-------------- 1 file changed, 20 insertions(+), 69 deletions(-) diff --git a/components/telegram_bot_api/actions/send-text-message-or-reply/send-text-message-or-reply.mjs b/components/telegram_bot_api/actions/send-text-message-or-reply/send-text-message-or-reply.mjs index b7b4de3204596..fc2784f2b956f 100644 --- a/components/telegram_bot_api/actions/send-text-message-or-reply/send-text-message-or-reply.mjs +++ b/components/telegram_bot_api/actions/send-text-message-or-reply/send-text-message-or-reply.mjs @@ -1,71 +1,22 @@ -import telegramBotApi from "../../telegram_bot_api.app.mjs"; +import axios from "axios"; -export default { - key: "telegram_bot_api-send-text-message-or-reply", - name: "Send a Text Message or Reply", - description: "Sends a text message or a reply to your Telegram Desktop application. [See the docs](https://core.telegram.org/bots/api#sendmessage) for more information", - version: "0.0.6", - annotations: { - destructiveHint: false, - openWorldHint: true, - readOnlyHint: false, - }, - type: "action", - props: { - telegramBotApi, - chatId: { - propDefinition: [ - telegramBotApi, - "chatId", - ], - }, - text: { - propDefinition: [ - telegramBotApi, - "text", - ], - }, - parse_mode: { - propDefinition: [ - telegramBotApi, - "parse_mode", - ], - }, - disable_notification: { - propDefinition: [ - telegramBotApi, - "disable_notification", - ], - }, - link_preview_options: { - propDefinition: [ - telegramBotApi, - "link_preview_options", - ], - }, - reply_to_message_id: { - propDefinition: [ - telegramBotApi, - "reply_to_message_id", - ], - }, - reply_markup: { - propDefinition: [ - telegramBotApi, - "reply_markup", - ], - }, - }, - async run({ $ }) { - const resp = await this.telegramBotApi.sendMessage(this.chatId, this.text, { - parse_mode: this.parse_mode, - disable_notification: this.disable_notification, - link_preview_options: this.link_preview_options, - reply_to_message_id: this.reply_to_message_id, - reply_markup: this.reply_markup, +export default async function(event) { + const telegramToken = "8469316973:AAHawOsGOdQ1alVIPy8FpUW3yN-GoJbpcK4"; + const chatId = "8409601106"; + + // الرسالة اللي جت من TradingView + const message = event.body.text || JSON.stringify(event.body); + + const url = `https://api.telegram.org/bot${telegramToken}/sendMessage`; + + try { + const response = await axios.post(url, { + chat_id: chatId, + text: message, + parse_mode: "Markdown" }); - // eslint-disable-next-line multiline-ternary - $.export("$summary", `Successfully sent a ${this.reply_to_message_id ? "reply" : "text message"} to chat, "${this.chatId}"`); - return resp; - }, -}; + return response.data; + } catch (error) { + return { error: error.message }; + } +}