Skip to content

Commit c60b18a

Browse files
authored
Telegram Bot - New Message Updates (Instant) - Add optional Chat ID prop (#16071)
* add chatId prop to message-updates * pnpm-lock.yaml * updates * pnpm-lock.yaml * pnpm-lock.yaml
1 parent 68609c0 commit c60b18a

File tree

3 files changed

+44
-15
lines changed

3 files changed

+44
-15
lines changed

Diff for: components/telegram_bot_api/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/telegram_bot_api",
3-
"version": "0.3.11",
3+
"version": "0.3.12",
44
"description": "Pipedream Telegram_bot_api Components",
55
"main": "telegram_bot_api.app.mjs",
66
"keywords": [
@@ -10,7 +10,7 @@
1010
"homepage": "https://pipedream.com/apps/telegram_bot_api",
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"dependencies": {
13-
"@pipedream/platform": "^0.9.0",
13+
"@pipedream/platform": "^3.0.3",
1414
"node-telegram-bot-api": "^0.54.0",
1515
"uuid": "^8.3.2"
1616
},

Diff for: components/telegram_bot_api/sources/message-updates/message-updates.mjs

+33-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,37 @@ export default {
66
key: "telegram_bot_api-message-updates",
77
name: "New Message Updates (Instant)",
88
description: "Emit new event each time a Telegram message is created or updated.",
9-
version: "0.1.5",
9+
version: "0.1.6",
1010
type: "source",
1111
dedupe: "unique",
12+
props: {
13+
...base.props,
14+
chatId: {
15+
propDefinition: [
16+
base.props.telegramBotApi,
17+
"chatId",
18+
],
19+
optional: true,
20+
},
21+
},
22+
hooks: {
23+
...base.hooks,
24+
async deploy() {
25+
if (this.chatId) {
26+
const { id } = await this.telegramBotApi.sdk().getChat(this.chatId);
27+
this._setChatId(id);
28+
}
29+
await base.hooks.deploy.call(this);
30+
},
31+
},
1232
methods: {
1333
...base.methods,
34+
_getChatId() {
35+
return this.db.get("chatId");
36+
},
37+
_setChatId(chatId) {
38+
this.db.set("chatId", chatId);
39+
},
1440
getMeta(event, message) {
1541
return {
1642
id: event.update_id,
@@ -26,6 +52,12 @@ export default {
2652
},
2753
processEvent(event) {
2854
const message = event.edited_message ?? event.message;
55+
if (this.chatId) {
56+
const chatId = this._getChatId();
57+
if (chatId && chatId != message?.chat?.id) {
58+
return;
59+
}
60+
}
2961
this.$emit(event, this.getMeta(event, message));
3062
},
3163
},

Diff for: pnpm-lock.yaml

+9-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)