@oneuptime/common 9.2.26 → 9.2.27
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/Server/Types/Workflow/Components/Index.ts +2 -0
- package/Server/Types/Workflow/Components/Telegram/SendMessageToChat.ts +146 -0
- package/Types/Workflow/ComponentID.ts +1 -0
- package/Types/Workflow/Components/Telegram.ts +76 -0
- package/Types/Workflow/Components.ts +7 -0
- package/build/dist/Server/Types/Workflow/Components/Index.js +2 -0
- package/build/dist/Server/Types/Workflow/Components/Index.js.map +1 -1
- package/build/dist/Server/Types/Workflow/Components/Telegram/SendMessageToChat.js +119 -0
- package/build/dist/Server/Types/Workflow/Components/Telegram/SendMessageToChat.js.map +1 -0
- package/build/dist/Types/Workflow/ComponentID.js +1 -0
- package/build/dist/Types/Workflow/ComponentID.js.map +1 -1
- package/build/dist/Types/Workflow/Components/Telegram.js +69 -0
- package/build/dist/Types/Workflow/Components/Telegram.js.map +1 -0
- package/build/dist/Types/Workflow/Components.js +7 -0
- package/build/dist/Types/Workflow/Components.js.map +1 -1
- package/package.json +1 -1
|
@@ -28,6 +28,7 @@ import ManualTrigger from "./Manual";
|
|
|
28
28
|
import MicrosoftTeamsSendMessageToChannel from "./MicrosoftTeams/SendMessageToChannel";
|
|
29
29
|
import Schedule from "./Schedule";
|
|
30
30
|
import SlackSendMessageToChannel from "./Slack/SendMessageToChannel";
|
|
31
|
+
import TelegramSendMessageToChat from "./Telegram/SendMessageToChat";
|
|
31
32
|
import WebhookTrigger from "./Webhook";
|
|
32
33
|
import BaseModel from "../../../../Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel";
|
|
33
34
|
import Dictionary from "../../../../Types/Dictionary";
|
|
@@ -41,6 +42,7 @@ const Components: Dictionary<ComponentCode> = {
|
|
|
41
42
|
[ComponentID.DiscordSendMessageToChannel]: new DiscordSendMessageToChannel(),
|
|
42
43
|
[ComponentID.MicrosoftTeamsSendMessageToChannel]:
|
|
43
44
|
new MicrosoftTeamsSendMessageToChannel(),
|
|
45
|
+
[ComponentID.TelegramSendMessageToChat]: new TelegramSendMessageToChat(),
|
|
44
46
|
[ComponentID.Log]: new Log(),
|
|
45
47
|
[ComponentID.Schedule]: new Schedule(),
|
|
46
48
|
[ComponentID.JavaScriptCode]: new JavaScriptCode(),
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import ComponentCode, { RunOptions, RunReturnType } from "../../ComponentCode";
|
|
2
|
+
import HTTPErrorResponse from "../../../../../Types/API/HTTPErrorResponse";
|
|
3
|
+
import HTTPResponse from "../../../../../Types/API/HTTPResponse";
|
|
4
|
+
import URL from "../../../../../Types/API/URL";
|
|
5
|
+
import APIException from "../../../../../Types/Exception/ApiException";
|
|
6
|
+
import BadDataException from "../../../../../Types/Exception/BadDataException";
|
|
7
|
+
import { JSONObject } from "../../../../../Types/JSON";
|
|
8
|
+
import ComponentMetadata, {
|
|
9
|
+
Port,
|
|
10
|
+
} from "../../../../../Types/Workflow/Component";
|
|
11
|
+
import ComponentID from "../../../../../Types/Workflow/ComponentID";
|
|
12
|
+
import TelegramComponents from "../../../../../Types/Workflow/Components/Telegram";
|
|
13
|
+
import API from "../../../../../Utils/API";
|
|
14
|
+
import CaptureSpan from "../../../../Utils/Telemetry/CaptureSpan";
|
|
15
|
+
|
|
16
|
+
export default class SendMessageToChat extends ComponentCode {
|
|
17
|
+
public constructor() {
|
|
18
|
+
super();
|
|
19
|
+
|
|
20
|
+
const Component: ComponentMetadata | undefined = TelegramComponents.find(
|
|
21
|
+
(i: ComponentMetadata) => {
|
|
22
|
+
return i.id === ComponentID.TelegramSendMessageToChat;
|
|
23
|
+
},
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
if (!Component) {
|
|
27
|
+
throw new BadDataException("Component not found.");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
this.setMetadata(Component);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@CaptureSpan()
|
|
34
|
+
public override async run(
|
|
35
|
+
args: JSONObject,
|
|
36
|
+
options: RunOptions,
|
|
37
|
+
): Promise<RunReturnType> {
|
|
38
|
+
const successPort: Port | undefined = this.getMetadata().outPorts.find(
|
|
39
|
+
(p: Port) => {
|
|
40
|
+
return p.id === "success";
|
|
41
|
+
},
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
if (!successPort) {
|
|
45
|
+
throw options.onError(new BadDataException("Success port not found"));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const errorPort: Port | undefined = this.getMetadata().outPorts.find(
|
|
49
|
+
(p: Port) => {
|
|
50
|
+
return p.id === "error";
|
|
51
|
+
},
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
if (!errorPort) {
|
|
55
|
+
throw options.onError(new BadDataException("Error port not found"));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (!args["bot-token"]) {
|
|
59
|
+
throw options.onError(
|
|
60
|
+
new BadDataException("Telegram Bot Token not found"),
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (!args["chat-id"]) {
|
|
65
|
+
throw options.onError(new BadDataException("Telegram Chat ID not found"));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (!args["text"]) {
|
|
69
|
+
throw options.onError(new BadDataException("Telegram message not found"));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const botToken: string = args["bot-token"]?.toString() as string;
|
|
73
|
+
const chatId: string = args["chat-id"]?.toString() as string;
|
|
74
|
+
const text: string = args["text"]?.toString() as string;
|
|
75
|
+
|
|
76
|
+
const telegramApiUrl: URL = URL.fromString(
|
|
77
|
+
`https://api.telegram.org/bot${botToken}/sendMessage`,
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
let apiResult: HTTPResponse<JSONObject> | HTTPErrorResponse | null = null;
|
|
81
|
+
|
|
82
|
+
try {
|
|
83
|
+
// https://core.telegram.org/bots/api#sendmessage
|
|
84
|
+
apiResult = await API.post({
|
|
85
|
+
url: telegramApiUrl,
|
|
86
|
+
data: {
|
|
87
|
+
chat_id: chatId,
|
|
88
|
+
text: text,
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const helpMessage: string =
|
|
93
|
+
" Note: For usernames, the user must have started a conversation with the bot first. For groups/channels, the bot must be added as a member or admin.";
|
|
94
|
+
|
|
95
|
+
if (apiResult instanceof HTTPErrorResponse) {
|
|
96
|
+
// Telegram returns errors in 'description' field
|
|
97
|
+
const telegramError: string =
|
|
98
|
+
(apiResult.data?.["description"] as string) ||
|
|
99
|
+
apiResult.message ||
|
|
100
|
+
"Server Error.";
|
|
101
|
+
return Promise.resolve({
|
|
102
|
+
returnValues: {
|
|
103
|
+
error: telegramError + helpMessage,
|
|
104
|
+
},
|
|
105
|
+
executePort: errorPort,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Check if Telegram returned ok: false (some errors return 200 OK)
|
|
110
|
+
if (apiResult.data && apiResult.data["ok"] === false) {
|
|
111
|
+
const telegramError: string =
|
|
112
|
+
(apiResult.data["description"] as string) || "Telegram API Error.";
|
|
113
|
+
return Promise.resolve({
|
|
114
|
+
returnValues: {
|
|
115
|
+
error: telegramError + helpMessage,
|
|
116
|
+
},
|
|
117
|
+
executePort: errorPort,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return Promise.resolve({
|
|
122
|
+
returnValues: {},
|
|
123
|
+
executePort: successPort,
|
|
124
|
+
});
|
|
125
|
+
} catch (err) {
|
|
126
|
+
const helpMessage: string =
|
|
127
|
+
" Note: For usernames, the user must have started a conversation with the bot first. For groups/channels, the bot must be added as a member or admin.";
|
|
128
|
+
|
|
129
|
+
if (err instanceof HTTPErrorResponse) {
|
|
130
|
+
// Telegram returns errors in 'description' field
|
|
131
|
+
const telegramError: string =
|
|
132
|
+
(err.data?.["description"] as string) ||
|
|
133
|
+
err.message ||
|
|
134
|
+
"Server Error.";
|
|
135
|
+
return Promise.resolve({
|
|
136
|
+
returnValues: {
|
|
137
|
+
error: telegramError + helpMessage,
|
|
138
|
+
},
|
|
139
|
+
executePort: errorPort,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
throw options.onError(new APIException("Something wrong happened."));
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -4,6 +4,7 @@ enum ComponentID {
|
|
|
4
4
|
SlackSendMessageToChannel = "slack-send-message-to-channel",
|
|
5
5
|
MicrosoftTeamsSendMessageToChannel = "microsoft-teams-send-message-to-channel",
|
|
6
6
|
DiscordSendMessageToChannel = "discord-send-message-to-channel",
|
|
7
|
+
TelegramSendMessageToChat = "telegram-send-message-to-chat",
|
|
7
8
|
Schedule = "schedule",
|
|
8
9
|
JavaScriptCode = "javascript",
|
|
9
10
|
Manual = "manual",
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import IconProp from "../../Icon/IconProp";
|
|
2
|
+
import ComponentID from "../ComponentID";
|
|
3
|
+
import ComponentMetadata, {
|
|
4
|
+
ComponentInputType,
|
|
5
|
+
ComponentType,
|
|
6
|
+
} from "./../Component";
|
|
7
|
+
|
|
8
|
+
const components: Array<ComponentMetadata> = [
|
|
9
|
+
{
|
|
10
|
+
id: ComponentID.TelegramSendMessageToChat,
|
|
11
|
+
title: "Send Message to Telegram",
|
|
12
|
+
category: "Telegram",
|
|
13
|
+
description: "Send message to Telegram chat",
|
|
14
|
+
iconProp: IconProp.SendMessage,
|
|
15
|
+
componentType: ComponentType.Component,
|
|
16
|
+
arguments: [
|
|
17
|
+
{
|
|
18
|
+
id: "bot-token",
|
|
19
|
+
name: "Telegram Bot Token",
|
|
20
|
+
description:
|
|
21
|
+
"Need help creating a bot? Check docs here: https://core.telegram.org/bots#how-do-i-create-a-bot",
|
|
22
|
+
type: ComponentInputType.Text,
|
|
23
|
+
required: true,
|
|
24
|
+
placeholder: "1234567890:ABCdefGHIjklMNOpqrsTUVwxyZ",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: "chat-id",
|
|
28
|
+
name: "Chat ID",
|
|
29
|
+
description:
|
|
30
|
+
"The unique identifier for the target chat or username of the target channel (in the format @channelusername). Please make sure the bot is added to the channel as an administrator.",
|
|
31
|
+
type: ComponentInputType.Text,
|
|
32
|
+
required: true,
|
|
33
|
+
placeholder: "@channelname",
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: "text",
|
|
37
|
+
name: "Message Text",
|
|
38
|
+
description: "Message to send to Telegram.",
|
|
39
|
+
type: ComponentInputType.LongText,
|
|
40
|
+
required: true,
|
|
41
|
+
placeholder: "Test Telegram message from OneUptime",
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
returnValues: [
|
|
45
|
+
{
|
|
46
|
+
id: "error",
|
|
47
|
+
name: "Error",
|
|
48
|
+
description: "Error, if there is any.",
|
|
49
|
+
type: ComponentInputType.Text,
|
|
50
|
+
required: false,
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
inPorts: [
|
|
54
|
+
{
|
|
55
|
+
title: "In",
|
|
56
|
+
description:
|
|
57
|
+
"Please connect components to this port for this component to work.",
|
|
58
|
+
id: "in",
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
outPorts: [
|
|
62
|
+
{
|
|
63
|
+
title: "Success",
|
|
64
|
+
description: "This is executed when the message is successfully posted",
|
|
65
|
+
id: "success",
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
title: "Error",
|
|
69
|
+
description: "This is executed when there is an error",
|
|
70
|
+
id: "error",
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
|
|
76
|
+
export default components;
|
|
@@ -11,6 +11,7 @@ import ManualComponents from "./Components/Manual";
|
|
|
11
11
|
import MicrosoftTeamsComponents from "./Components/MicrosoftTeams";
|
|
12
12
|
import ScheduleComponents from "./Components/Schedule";
|
|
13
13
|
import SlackComponents from "./Components/Slack";
|
|
14
|
+
import TelegramComponents from "./Components/Telegram";
|
|
14
15
|
import WebhookComponents from "./Components/Webhook";
|
|
15
16
|
import WorkflowComponents from "./Components/Workflow";
|
|
16
17
|
|
|
@@ -20,6 +21,7 @@ const components: Array<ComponentMetadata> = [
|
|
|
20
21
|
...ScheduleComponents,
|
|
21
22
|
...SlackComponents,
|
|
22
23
|
...DiscordComponents,
|
|
24
|
+
...TelegramComponents,
|
|
23
25
|
...ConditionComponents,
|
|
24
26
|
...JsonComponents,
|
|
25
27
|
...JavaScriptComponents,
|
|
@@ -58,6 +60,11 @@ export const Categories: Array<ComponentCategory> = [
|
|
|
58
60
|
description: "Integrate OneUptime with your Microsoft Teams.",
|
|
59
61
|
icon: IconProp.SendMessage,
|
|
60
62
|
},
|
|
63
|
+
{
|
|
64
|
+
name: "Telegram",
|
|
65
|
+
description: "Integrate OneUptime with your Telegram chats and channels.",
|
|
66
|
+
icon: IconProp.SendMessage,
|
|
67
|
+
},
|
|
61
68
|
{
|
|
62
69
|
name: "Conditions",
|
|
63
70
|
description: "Add logic to your workflows.",
|
|
@@ -27,6 +27,7 @@ import ManualTrigger from "./Manual";
|
|
|
27
27
|
import MicrosoftTeamsSendMessageToChannel from "./MicrosoftTeams/SendMessageToChannel";
|
|
28
28
|
import Schedule from "./Schedule";
|
|
29
29
|
import SlackSendMessageToChannel from "./Slack/SendMessageToChannel";
|
|
30
|
+
import TelegramSendMessageToChat from "./Telegram/SendMessageToChat";
|
|
30
31
|
import WebhookTrigger from "./Webhook";
|
|
31
32
|
import Text from "../../../../Types/Text";
|
|
32
33
|
import ComponentID from "../../../../Types/Workflow/ComponentID";
|
|
@@ -36,6 +37,7 @@ const Components = {
|
|
|
36
37
|
[ComponentID.SlackSendMessageToChannel]: new SlackSendMessageToChannel(),
|
|
37
38
|
[ComponentID.DiscordSendMessageToChannel]: new DiscordSendMessageToChannel(),
|
|
38
39
|
[ComponentID.MicrosoftTeamsSendMessageToChannel]: new MicrosoftTeamsSendMessageToChannel(),
|
|
40
|
+
[ComponentID.TelegramSendMessageToChat]: new TelegramSendMessageToChat(),
|
|
39
41
|
[ComponentID.Log]: new Log(),
|
|
40
42
|
[ComponentID.Schedule]: new Schedule(),
|
|
41
43
|
[ComponentID.JavaScriptCode]: new JavaScriptCode(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Index.js","sourceRoot":"","sources":["../../../../../../Server/Types/Workflow/Components/Index.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,mCAAmC,CAAC;AAChE,OAAO,QAAQ,MAAM,yBAAyB,CAAC;AAE/C,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,mBAAmB,MAAM,iCAAiC,CAAC;AAClE,OAAO,kBAAkB,MAAM,gCAAgC,CAAC;AAChE,OAAO,mBAAmB,MAAM,iCAAiC,CAAC;AAClE,OAAO,kBAAkB,MAAM,gCAAgC,CAAC;AAChE,OAAO,iBAAiB,MAAM,+BAA+B,CAAC;AAC9D,OAAO,gBAAgB,MAAM,8BAA8B,CAAC;AAC5D,OAAO,iBAAiB,MAAM,+BAA+B,CAAC;AAC9D,OAAO,iBAAiB,MAAM,+BAA+B,CAAC;AAC9D,OAAO,iBAAiB,MAAM,+BAA+B,CAAC;AAC9D,OAAO,mBAAmB,MAAM,iCAAiC,CAAC;AAClE,OAAO,kBAAkB,MAAM,gCAAgC,CAAC;AAChE,OAAO,MAAM,MAAM,qBAAqB,CAAC;AACzC,OAAO,2BAA2B,MAAM,gCAAgC,CAAC;AACzE,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,UAAU,MAAM,mBAAmB,CAAC;AAC3C,OAAO,SAAS,MAAM,kBAAkB,CAAC;AACzC,OAAO,UAAU,MAAM,mBAAmB,CAAC;AAC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AC5D,gBAAuB,CACxB,CAAC;IACJ,CAAC;AACH,CAAC;AAED,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import ComponentCode from "../../ComponentCode";
|
|
11
|
+
import HTTPErrorResponse from "../../../../../Types/API/HTTPErrorResponse";
|
|
12
|
+
import URL from "../../../../../Types/API/URL";
|
|
13
|
+
import APIException from "../../../../../Types/Exception/ApiException";
|
|
14
|
+
import BadDataException from "../../../../../Types/Exception/BadDataException";
|
|
15
|
+
import ComponentID from "../../../../../Types/Workflow/ComponentID";
|
|
16
|
+
import TelegramComponents from "../../../../../Types/Workflow/Components/Telegram";
|
|
17
|
+
import API from "../../../../../Utils/API";
|
|
18
|
+
import CaptureSpan from "../../../../Utils/Telemetry/CaptureSpan";
|
|
19
|
+
export default class SendMessageToChat extends ComponentCode {
|
|
20
|
+
constructor() {
|
|
21
|
+
super();
|
|
22
|
+
const Component = TelegramComponents.find((i) => {
|
|
23
|
+
return i.id === ComponentID.TelegramSendMessageToChat;
|
|
24
|
+
});
|
|
25
|
+
if (!Component) {
|
|
26
|
+
throw new BadDataException("Component not found.");
|
|
27
|
+
}
|
|
28
|
+
this.setMetadata(Component);
|
|
29
|
+
}
|
|
30
|
+
async run(args, options) {
|
|
31
|
+
var _a, _b, _c, _d, _e;
|
|
32
|
+
const successPort = this.getMetadata().outPorts.find((p) => {
|
|
33
|
+
return p.id === "success";
|
|
34
|
+
});
|
|
35
|
+
if (!successPort) {
|
|
36
|
+
throw options.onError(new BadDataException("Success port not found"));
|
|
37
|
+
}
|
|
38
|
+
const errorPort = this.getMetadata().outPorts.find((p) => {
|
|
39
|
+
return p.id === "error";
|
|
40
|
+
});
|
|
41
|
+
if (!errorPort) {
|
|
42
|
+
throw options.onError(new BadDataException("Error port not found"));
|
|
43
|
+
}
|
|
44
|
+
if (!args["bot-token"]) {
|
|
45
|
+
throw options.onError(new BadDataException("Telegram Bot Token not found"));
|
|
46
|
+
}
|
|
47
|
+
if (!args["chat-id"]) {
|
|
48
|
+
throw options.onError(new BadDataException("Telegram Chat ID not found"));
|
|
49
|
+
}
|
|
50
|
+
if (!args["text"]) {
|
|
51
|
+
throw options.onError(new BadDataException("Telegram message not found"));
|
|
52
|
+
}
|
|
53
|
+
const botToken = (_a = args["bot-token"]) === null || _a === void 0 ? void 0 : _a.toString();
|
|
54
|
+
const chatId = (_b = args["chat-id"]) === null || _b === void 0 ? void 0 : _b.toString();
|
|
55
|
+
const text = (_c = args["text"]) === null || _c === void 0 ? void 0 : _c.toString();
|
|
56
|
+
const telegramApiUrl = URL.fromString(`https://api.telegram.org/bot${botToken}/sendMessage`);
|
|
57
|
+
let apiResult = null;
|
|
58
|
+
try {
|
|
59
|
+
// https://core.telegram.org/bots/api#sendmessage
|
|
60
|
+
apiResult = await API.post({
|
|
61
|
+
url: telegramApiUrl,
|
|
62
|
+
data: {
|
|
63
|
+
chat_id: chatId,
|
|
64
|
+
text: text,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
const helpMessage = " Note: For usernames, the user must have started a conversation with the bot first. For groups/channels, the bot must be added as a member or admin.";
|
|
68
|
+
if (apiResult instanceof HTTPErrorResponse) {
|
|
69
|
+
// Telegram returns errors in 'description' field
|
|
70
|
+
const telegramError = ((_d = apiResult.data) === null || _d === void 0 ? void 0 : _d["description"]) ||
|
|
71
|
+
apiResult.message ||
|
|
72
|
+
"Server Error.";
|
|
73
|
+
return Promise.resolve({
|
|
74
|
+
returnValues: {
|
|
75
|
+
error: telegramError + helpMessage,
|
|
76
|
+
},
|
|
77
|
+
executePort: errorPort,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
// Check if Telegram returned ok: false (some errors return 200 OK)
|
|
81
|
+
if (apiResult.data && apiResult.data["ok"] === false) {
|
|
82
|
+
const telegramError = apiResult.data["description"] || "Telegram API Error.";
|
|
83
|
+
return Promise.resolve({
|
|
84
|
+
returnValues: {
|
|
85
|
+
error: telegramError + helpMessage,
|
|
86
|
+
},
|
|
87
|
+
executePort: errorPort,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return Promise.resolve({
|
|
91
|
+
returnValues: {},
|
|
92
|
+
executePort: successPort,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
const helpMessage = " Note: For usernames, the user must have started a conversation with the bot first. For groups/channels, the bot must be added as a member or admin.";
|
|
97
|
+
if (err instanceof HTTPErrorResponse) {
|
|
98
|
+
// Telegram returns errors in 'description' field
|
|
99
|
+
const telegramError = ((_e = err.data) === null || _e === void 0 ? void 0 : _e["description"]) ||
|
|
100
|
+
err.message ||
|
|
101
|
+
"Server Error.";
|
|
102
|
+
return Promise.resolve({
|
|
103
|
+
returnValues: {
|
|
104
|
+
error: telegramError + helpMessage,
|
|
105
|
+
},
|
|
106
|
+
executePort: errorPort,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
throw options.onError(new APIException("Something wrong happened."));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
__decorate([
|
|
114
|
+
CaptureSpan(),
|
|
115
|
+
__metadata("design:type", Function),
|
|
116
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
117
|
+
__metadata("design:returntype", Promise)
|
|
118
|
+
], SendMessageToChat.prototype, "run", null);
|
|
119
|
+
//# sourceMappingURL=SendMessageToChat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SendMessageToChat.js","sourceRoot":"","sources":["../../../../../../../Server/Types/Workflow/Components/Telegram/SendMessageToChat.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,aAA4C,MAAM,qBAAqB,CAAC;AAC/E,OAAO,iBAAiB,MAAM,4CAA4C,CAAC;AAE3E,OAAO,GAAG,MAAM,8BAA8B,CAAC;AAC/C,OAAO,YAAY,MAAM,6CAA6C,CAAC;AACvE,OAAO,gBAAgB,MAAM,iDAAiD,CAAC;AAK/E,OAAO,WAAW,MAAM,2CAA2C,CAAC;AACpE,OAAO,kBAAkB,MAAM,mDAAmD,CAAC;AACnF,OAAO,GAAG,MAAM,0BAA0B,CAAC;AAC3C,OAAO,WAAW,MAAM,yCAAyC,CAAC;AAElE,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,aAAa;IAC1D;QACE,KAAK,EAAE,CAAC;QAER,MAAM,SAAS,GAAkC,kBAAkB,CAAC,IAAI,CACtE,CAAC,CAAoB,EAAE,EAAE;YACvB,OAAO,CAAC,CAAC,EAAE,KAAK,WAAW,CAAC,yBAAyB,CAAC;QACxD,CAAC,CACF,CAAC;QAEF,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,IAAI,gBAAgB,CAAC,sBAAsB,CAAC,CAAC;QACrD,CAAC;QAED,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IAC9B,CAAC;IAGqB,AAAN,KAAK,CAAC,GAAG,CACvB,IAAgB,EAChB,OAAmB;;QAEnB,MAAM,WAAW,GAAqB,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,IAAI,CACpE,CAAC,CAAO,EAAE,EAAE;YACV,OAAO,CAAC,CAAC,EAAE,KAAK,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a,GACjB,CAAC,MAAA,GAAG,CAAC,IAAI,0CAAG,aAAa,CAAY;oBACrC,GAAG,CAAC,OAAO;oBACX,eAAe,CAAC;gBAClB,OAAO,OAAO,CAAC,OAAO,CAAC;oBACrB,YAAY,EAAE;wBACZ,KAAK,EAAE,aAAa,GAAG,WAAW;qBACnC;oBACD,WAAW,EAAE,SAAS;iBACvB,CAAC,CAAC;YACL,CAAC;YAED,MAAM,OAAO,CAAC,OAAO,CAAC,IAAI,YAAY,CAAC,2BAA2B,CAAC,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;CACF;AAhHuB;IADrB,WAAW,EAAE;;;;4CAgHb"}
|
|
@@ -5,6 +5,7 @@ var ComponentID;
|
|
|
5
5
|
ComponentID["SlackSendMessageToChannel"] = "slack-send-message-to-channel";
|
|
6
6
|
ComponentID["MicrosoftTeamsSendMessageToChannel"] = "microsoft-teams-send-message-to-channel";
|
|
7
7
|
ComponentID["DiscordSendMessageToChannel"] = "discord-send-message-to-channel";
|
|
8
|
+
ComponentID["TelegramSendMessageToChat"] = "telegram-send-message-to-chat";
|
|
8
9
|
ComponentID["Schedule"] = "schedule";
|
|
9
10
|
ComponentID["JavaScriptCode"] = "javascript";
|
|
10
11
|
ComponentID["Manual"] = "manual";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComponentID.js","sourceRoot":"","sources":["../../../../Types/Workflow/ComponentID.ts"],"names":[],"mappings":"AAAA,IAAK,
|
|
1
|
+
{"version":3,"file":"ComponentID.js","sourceRoot":"","sources":["../../../../Types/Workflow/ComponentID.ts"],"names":[],"mappings":"AAAA,IAAK,WAoBJ;AApBD,WAAK,WAAW;IACd,kCAAmB,CAAA;IACnB,0BAAW,CAAA;IACX,0EAA2D,CAAA;IAC3D,6FAA8E,CAAA;IAC9E,8EAA+D,CAAA;IAC/D,0EAA2D,CAAA;IAC3D,oCAAqB,CAAA;IACrB,4CAA6B,CAAA;IAC7B,gCAAiB,CAAA;IACjB,0CAA2B,CAAA;IAC3B,0CAA2B,CAAA;IAC3B,uCAAwB,CAAA;IACxB,iCAAkB,CAAA;IAClB,iCAAkB,CAAA;IAClB,mCAAoB,CAAA;IACpB,uCAAwB,CAAA;IACxB,qCAAsB,CAAA;IACtB,uCAAwB,CAAA;IACxB,iCAAkB,CAAA;AACpB,CAAC,EApBI,WAAW,KAAX,WAAW,QAoBf;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import IconProp from "../../Icon/IconProp";
|
|
2
|
+
import ComponentID from "../ComponentID";
|
|
3
|
+
import { ComponentInputType, ComponentType, } from "./../Component";
|
|
4
|
+
const components = [
|
|
5
|
+
{
|
|
6
|
+
id: ComponentID.TelegramSendMessageToChat,
|
|
7
|
+
title: "Send Message to Telegram",
|
|
8
|
+
category: "Telegram",
|
|
9
|
+
description: "Send message to Telegram chat",
|
|
10
|
+
iconProp: IconProp.SendMessage,
|
|
11
|
+
componentType: ComponentType.Component,
|
|
12
|
+
arguments: [
|
|
13
|
+
{
|
|
14
|
+
id: "bot-token",
|
|
15
|
+
name: "Telegram Bot Token",
|
|
16
|
+
description: "Need help creating a bot? Check docs here: https://core.telegram.org/bots#how-do-i-create-a-bot",
|
|
17
|
+
type: ComponentInputType.Text,
|
|
18
|
+
required: true,
|
|
19
|
+
placeholder: "1234567890:ABCdefGHIjklMNOpqrsTUVwxyZ",
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
id: "chat-id",
|
|
23
|
+
name: "Chat ID",
|
|
24
|
+
description: "The unique identifier for the target chat or username of the target channel (in the format @channelusername). Please make sure the bot is added to the channel as an administrator.",
|
|
25
|
+
type: ComponentInputType.Text,
|
|
26
|
+
required: true,
|
|
27
|
+
placeholder: "@channelname",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: "text",
|
|
31
|
+
name: "Message Text",
|
|
32
|
+
description: "Message to send to Telegram.",
|
|
33
|
+
type: ComponentInputType.LongText,
|
|
34
|
+
required: true,
|
|
35
|
+
placeholder: "Test Telegram message from OneUptime",
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
returnValues: [
|
|
39
|
+
{
|
|
40
|
+
id: "error",
|
|
41
|
+
name: "Error",
|
|
42
|
+
description: "Error, if there is any.",
|
|
43
|
+
type: ComponentInputType.Text,
|
|
44
|
+
required: false,
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
inPorts: [
|
|
48
|
+
{
|
|
49
|
+
title: "In",
|
|
50
|
+
description: "Please connect components to this port for this component to work.",
|
|
51
|
+
id: "in",
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
outPorts: [
|
|
55
|
+
{
|
|
56
|
+
title: "Success",
|
|
57
|
+
description: "This is executed when the message is successfully posted",
|
|
58
|
+
id: "success",
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
title: "Error",
|
|
62
|
+
description: "This is executed when there is an error",
|
|
63
|
+
id: "error",
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
export default components;
|
|
69
|
+
//# sourceMappingURL=Telegram.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Telegram.js","sourceRoot":"","sources":["../../../../../Types/Workflow/Components/Telegram.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,qBAAqB,CAAC;AAC3C,OAAO,WAAW,MAAM,gBAAgB,CAAC;AACzC,OAA0B,EACxB,kBAAkB,EAClB,aAAa,GACd,MAAM,gBAAgB,CAAC;AAExB,MAAM,UAAU,GAA6B;IAC3C;QACE,EAAE,EAAE,WAAW,CAAC,yBAAyB;QACzC,KAAK,EAAE,0BAA0B;QACjC,QAAQ,EAAE,UAAU;QACpB,WAAW,EAAE,+BAA+B;QAC5C,QAAQ,EAAE,QAAQ,CAAC,WAAW;QAC9B,aAAa,EAAE,aAAa,CAAC,SAAS;QACtC,SAAS,EAAE;YACT;gBACE,EAAE,EAAE,WAAW;gBACf,IAAI,EAAE,oBAAoB;gBAC1B,WAAW,EACT,iGAAiG;gBACnG,IAAI,EAAE,kBAAkB,CAAC,IAAI;gBAC7B,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,uCAAuC;aACrD;YACD;gBACE,EAAE,EAAE,SAAS;gBACb,IAAI,EAAE,SAAS;gBACf,WAAW,EACT,qLAAqL;gBACvL,IAAI,EAAE,kBAAkB,CAAC,IAAI;gBAC7B,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,cAAc;aAC5B;YACD;gBACE,EAAE,EAAE,MAAM;gBACV,IAAI,EAAE,cAAc;gBACpB,WAAW,EAAE,8BAA8B;gBAC3C,IAAI,EAAE,kBAAkB,CAAC,QAAQ;gBACjC,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,sCAAsC;aACpD;SACF;QACD,YAAY,EAAE;YACZ;gBACE,EAAE,EAAE,OAAO;gBACX,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE,yBAAyB;gBACtC,IAAI,EAAE,kBAAkB,CAAC,IAAI;gBAC7B,QAAQ,EAAE,KAAK;aAChB;SACF;QACD,OAAO,EAAE;YACP;gBACE,KAAK,EAAE,IAAI;gBACX,WAAW,EACT,oEAAoE;gBACtE,EAAE,EAAE,IAAI;aACT;SACF;QACD,QAAQ,EAAE;YACR;gBACE,KAAK,EAAE,SAAS;gBAChB,WAAW,EAAE,0DAA0D;gBACvE,EAAE,EAAE,SAAS;aACd;YACD;gBACE,KAAK,EAAE,OAAO;gBACd,WAAW,EAAE,yCAAyC;gBACtD,EAAE,EAAE,OAAO;aACZ;SACF;KACF;CACF,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -10,6 +10,7 @@ import ManualComponents from "./Components/Manual";
|
|
|
10
10
|
import MicrosoftTeamsComponents from "./Components/MicrosoftTeams";
|
|
11
11
|
import ScheduleComponents from "./Components/Schedule";
|
|
12
12
|
import SlackComponents from "./Components/Slack";
|
|
13
|
+
import TelegramComponents from "./Components/Telegram";
|
|
13
14
|
import WebhookComponents from "./Components/Webhook";
|
|
14
15
|
import WorkflowComponents from "./Components/Workflow";
|
|
15
16
|
const components = [
|
|
@@ -18,6 +19,7 @@ const components = [
|
|
|
18
19
|
...ScheduleComponents,
|
|
19
20
|
...SlackComponents,
|
|
20
21
|
...DiscordComponents,
|
|
22
|
+
...TelegramComponents,
|
|
21
23
|
...ConditionComponents,
|
|
22
24
|
...JsonComponents,
|
|
23
25
|
...JavaScriptComponents,
|
|
@@ -54,6 +56,11 @@ export const Categories = [
|
|
|
54
56
|
description: "Integrate OneUptime with your Microsoft Teams.",
|
|
55
57
|
icon: IconProp.SendMessage,
|
|
56
58
|
},
|
|
59
|
+
{
|
|
60
|
+
name: "Telegram",
|
|
61
|
+
description: "Integrate OneUptime with your Telegram chats and channels.",
|
|
62
|
+
icon: IconProp.SendMessage,
|
|
63
|
+
},
|
|
57
64
|
{
|
|
58
65
|
name: "Conditions",
|
|
59
66
|
description: "Add logic to your workflows.",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Components.js","sourceRoot":"","sources":["../../../../Types/Workflow/Components.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,kBAAkB,CAAC;AAExC,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAC7C,OAAO,mBAAmB,MAAM,wBAAwB,CAAC;AACzD,OAAO,iBAAiB,MAAM,sBAAsB,CAAC;AACrD,OAAO,eAAe,MAAM,oBAAoB,CAAC;AACjD,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAC3D,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAC7C,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;AACnD,OAAO,wBAAwB,MAAM,6BAA6B,CAAC;AACnE,OAAO,kBAAkB,MAAM,uBAAuB,CAAC;AACvD,OAAO,eAAe,MAAM,oBAAoB,CAAC;AACjD,OAAO,iBAAiB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U;QAChB,WAAW,EAAE,+CAA+C;QAC5D,IAAI,EAAE,QAAQ,CAAC,KAAK;KACrB;IACD;QACE,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,yCAAyC;QACtD,IAAI,EAAE,QAAQ,CAAC,KAAK;KACrB;IACD;QACE,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,0CAA0C;QACvD,IAAI,EAAE,QAAQ,CAAC,MAAM;KACtB;CACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"Components.js","sourceRoot":"","sources":["../../../../Types/Workflow/Components.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,kBAAkB,CAAC;AAExC,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAC7C,OAAO,mBAAmB,MAAM,wBAAwB,CAAC;AACzD,OAAO,iBAAiB,MAAM,sBAAsB,CAAC;AACrD,OAAO,eAAe,MAAM,oBAAoB,CAAC;AACjD,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAC3D,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAC7C,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;AACnD,OAAO,wBAAwB,MAAM,6BAA6B,CAAC;AACnE,OAAO,kBAAkB,MAAM,uBAAuB,CAAC;AACvD,OAAO,eAAe,MAAM,oBAAoB,CAAC;AACjD,OAAO,kBAAkB,MAAM,uBAAuB,CAAC;AACvD,OAAO,iBAAiB,MAAM,sBAAsB,CAAC;AACrD,OAAO,kBAAkB,MAAM,uBAAuB,CAAC;AAEvD,MAAM,UAAU,GAA6B;IAC3C,GAAG,aAAa;IAChB,GAAG,aAAa;IAChB,GAAG,kBAAkB;IACrB,GAAG,eAAe;IAClB,GAAG,iBAAiB;IACpB,GAAG,kBAAkB;IACrB,GAAG,mBAAmB;IACtB,GAAG,cAAc;IACjB,GAAG,oBAAoB;IACvB,GAAG,eAAe;IAClB,GAAG,iBAAiB;IACpB,GAAG,kBAAkB;IACrB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