Skip to content

Commit e88fc7d

Browse files
committed
updates
1 parent 14ab3f5 commit e88fc7d

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

components/telegram_bot_api/sources/message-updates/message-updates.mjs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,24 @@ export default {
1919
optional: true,
2020
},
2121
},
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+
},
2232
methods: {
2333
...base.methods,
34+
_getChatId() {
35+
return this.db.get("chatId");
36+
},
37+
_setChatId(chatId) {
38+
this.db.set("chatId", chatId);
39+
},
2440
getMeta(event, message) {
2541
return {
2642
id: event.update_id,
@@ -36,8 +52,11 @@ export default {
3652
},
3753
processEvent(event) {
3854
const message = event.edited_message ?? event.message;
39-
if (this.chatId && this.chatId != message?.chat?.id) {
40-
return;
55+
if (this.chatId) {
56+
const chatId = this._getChatId();
57+
if (chatId && chatId != message?.chat?.id) {
58+
return;
59+
}
4160
}
4261
this.$emit(event, this.getMeta(event, message));
4362
},

0 commit comments

Comments
 (0)