|
1 | | -import telegramBotApi from "../../telegram_bot_api.app.mjs"; |
| 1 | +import axios from "axios"; |
2 | 2 |
|
3 | | -export default { |
4 | | - key: "telegram_bot_api-send-text-message-or-reply", |
5 | | - name: "Send a Text Message or Reply", |
6 | | - 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", |
7 | | - version: "0.0.6", |
8 | | - annotations: { |
9 | | - destructiveHint: false, |
10 | | - openWorldHint: true, |
11 | | - readOnlyHint: false, |
12 | | - }, |
13 | | - type: "action", |
14 | | - props: { |
15 | | - telegramBotApi, |
16 | | - chatId: { |
17 | | - propDefinition: [ |
18 | | - telegramBotApi, |
19 | | - "chatId", |
20 | | - ], |
21 | | - }, |
22 | | - text: { |
23 | | - propDefinition: [ |
24 | | - telegramBotApi, |
25 | | - "text", |
26 | | - ], |
27 | | - }, |
28 | | - parse_mode: { |
29 | | - propDefinition: [ |
30 | | - telegramBotApi, |
31 | | - "parse_mode", |
32 | | - ], |
33 | | - }, |
34 | | - disable_notification: { |
35 | | - propDefinition: [ |
36 | | - telegramBotApi, |
37 | | - "disable_notification", |
38 | | - ], |
39 | | - }, |
40 | | - link_preview_options: { |
41 | | - propDefinition: [ |
42 | | - telegramBotApi, |
43 | | - "link_preview_options", |
44 | | - ], |
45 | | - }, |
46 | | - reply_to_message_id: { |
47 | | - propDefinition: [ |
48 | | - telegramBotApi, |
49 | | - "reply_to_message_id", |
50 | | - ], |
51 | | - }, |
52 | | - reply_markup: { |
53 | | - propDefinition: [ |
54 | | - telegramBotApi, |
55 | | - "reply_markup", |
56 | | - ], |
57 | | - }, |
58 | | - }, |
59 | | - async run({ $ }) { |
60 | | - const resp = await this.telegramBotApi.sendMessage(this.chatId, this.text, { |
61 | | - parse_mode: this.parse_mode, |
62 | | - disable_notification: this.disable_notification, |
63 | | - link_preview_options: this.link_preview_options, |
64 | | - reply_to_message_id: this.reply_to_message_id, |
65 | | - reply_markup: this.reply_markup, |
| 3 | +export default async function(event) { |
| 4 | + const telegramToken = "8469316973:AAHawOsGOdQ1alVIPy8FpUW3yN-GoJbpcK4"; |
| 5 | + const chatId = "8409601106"; |
| 6 | + |
| 7 | + // الرسالة اللي جت من TradingView |
| 8 | + const message = event.body.text || JSON.stringify(event.body); |
| 9 | + |
| 10 | + const url = `https://api.telegram.org/bot${telegramToken}/sendMessage`; |
| 11 | + |
| 12 | + try { |
| 13 | + const response = await axios.post(url, { |
| 14 | + chat_id: chatId, |
| 15 | + text: message, |
| 16 | + parse_mode: "Markdown" |
66 | 17 | }); |
67 | | - // eslint-disable-next-line multiline-ternary |
68 | | - $.export("$summary", `Successfully sent a ${this.reply_to_message_id ? "reply" : "text message"} to chat, "${this.chatId}"`); |
69 | | - return resp; |
70 | | - }, |
71 | | -}; |
| 18 | + return response.data; |
| 19 | + } catch (error) { |
| 20 | + return { error: error.message }; |
| 21 | + } |
| 22 | +} |
0 commit comments