-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Telegram Bot - New Message Updates (Instant) - Add optional Chat ID prop #16071
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 3 Skipped Deployments
|
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (1)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including You can disable this status message by setting the WalkthroughThis pull request updates the Telegram Bot API component. In the package configuration, it bumps the version from 0.3.11 to 0.3.12 and updates the dependency on Changes
Sequence Diagram(s)sequenceDiagram
participant M as Incoming Message
participant P as processEvent Method
participant E as Event Emitter
M->>P: Deliver message (with chat.id)
P->>P: Check if 'chatId' is configured
alt 'chatId' is configured
P->>P: Compare configured chatId with message.chat.id
alt chatId matches
P->>E: Emit event
else chatId mismatches
P-->>M: Return early (ignore event)
end
else 'chatId' not configured
P->>E: Emit event
end
Assessment against linked issues
Suggested labels
Suggested reviewers
Poem
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @michelle0927, LGTM! Ready for QA!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
components/telegram_bot_api/sources/message-updates/message-updates.mjs (2)
22-31
: Add error handling to the deploy hook.The deploy hook properly initializes the chatId in the database and calls the base implementation. However, there's no error handling for the
getChat
API call, which could fail if the provided chatId is invalid.Consider adding error handling:
async deploy() { if (this.chatId) { - const { id } = await this.telegramBotApi.sdk().getChat(this.chatId); - this._setChatId(id); + try { + const { id } = await this.telegramBotApi.sdk().getChat(this.chatId); + this._setChatId(id); + } catch (error) { + console.error(`Failed to get chat with ID ${this.chatId}: ${error.message}`); + // Consider whether to throw or just log the error + } } await base.hooks.deploy.call(this); },
55-60
: Use strict equality for chatId comparison.The implementation correctly filters messages by chat ID, but the comparison uses loose equality (
!=
) instead of strict equality (!==
), which could lead to unexpected behavior if the values are of different types (e.g., string vs. number).Consider using strict equality for safer comparison:
if (this.chatId) { const chatId = this._getChatId(); - if (chatId && chatId != message?.chat?.id) { + if (chatId && chatId !== message?.chat?.id) { return; } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (1)
components/telegram_bot_api/sources/message-updates/message-updates.mjs
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Verify TypeScript components
- GitHub Check: Publish TypeScript components
🔇 Additional comments (3)
components/telegram_bot_api/sources/message-updates/message-updates.mjs (3)
9-9
: Version number correctly incremented.The version increment from 0.1.5 to 0.1.6 follows semantic versioning principles for adding a new optional feature.
12-21
: Good addition of optional chatId property.The new chatId property is properly defined as optional and reuses the existing propDefinition from the base component, following the component's established patterns.
34-39
: Good database abstraction.The helper methods for getting and setting the chatId in the database follow good encapsulation principles.
Resolves #16050
Summary by CodeRabbit
chatId
property for better chat identification.deploy
method to manage chat ID retrieval and storage.