Skip to content

feat: add /newchat command and topic precheck for groups#20

Merged
BukeLy merged 2 commits intomainfrom
feat/user-whitelist-security
Jan 11, 2026
Merged

feat: add /newchat command and topic precheck for groups#20
BukeLy merged 2 commits intomainfrom
feat/user-whitelist-security

Conversation

@BukeLy
Copy link
Owner

@BukeLy BukeLy commented Jan 11, 2026

Summary

  • Add /newchat <prompts> local command to create new Topic and send first message to Agent
  • Add topic precheck when bot joins authorized groups (checks is_forum and can_manage_topics)
  • Send detailed setup instructions if precheck fails

Test plan

  • Deploy and test /newchat 你好 in a group with Topics enabled
  • Add bot to a group without Topics enabled, verify precheck notification
  • Add bot to a group without Topic management permission, verify permission notification
  • Check CloudWatch Logs for any errors

Copilot AI review requested due to automatic review settings January 11, 2026 16:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a /newchat command that creates forum topics and sends the first message to an agent, and implements a precheck system to verify groups have Topics enabled and appropriate permissions when the bot joins.

Changes:

  • Added /newchat <prompts> command to create a new forum topic and send the first message to the agent
  • Added topic precheck when bot joins authorized groups to validate forum settings and permissions
  • Modified consumer to handle special is_newchat message format

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 11 comments.

File Description
agent-sdk-client/handler.py Implements /newchat command handler, forum requirements checker, and topic precheck logic on bot join
agent-sdk-client/consumer.py Refactored to handle both regular messages and newchat messages with different data structures
agent-sdk-client/config.toml Added /newchat to local_commands configuration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +53 to +59
# newchat 消息直接使用 message_data
chat_id = message_data['chat_id']
thread_id = message_data['thread_id']
user_message = message_data['text']
message_id = message_data.get('message_id')
else:
# 正常消息解析 Update
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comments "newchat 消息直接使用 message_data" and "正常消息解析 Update" are in Chinese, while most other comments in the codebase are in English. For consistency and maintainability, consider using English for all code comments.

Suggested change
# newchat 消息直接使用 message_data
chat_id = message_data['chat_id']
thread_id = message_data['thread_id']
user_message = message_data['text']
message_id = message_data.get('message_id')
else:
# 正常消息解析 Update
# For new chat messages, use message_data directly
chat_id = message_data['chat_id']
thread_id = message_data['thread_id']
user_message = message_data['text']
message_id = message_data.get('message_id')
else:
# For regular messages, parse the Telegram Update

Copilot uses AI. Check for mistakes.
[local_commands]
# Local-only commands handled by the client
help = "Hello World"
newchat = "创建新对话"
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The config.toml adds /newchat as a local command with response "创建新对话", but /newchat is not actually a local command - it requires async processing and SQS messaging. This is inconsistent with the implementation in handler.py where /newchat is handled specially before the local command check. The entry in local_commands may cause confusion or incorrect behavior if config.is_local_command() is called for /newchat. Consider removing this entry from local_commands or documenting why it's included.

Suggested change
newchat = "创建新对话"

Copilot uses AI. Check for mistakes.
- Add /newchat local command to create new Topic and send first message
- Add topic precheck when bot joins group (is_forum + can_manage_topics)
- Send detailed setup instructions if precheck fails
- Consumer uses message_data text/thread_id (allows handler override)
@BukeLy BukeLy force-pushed the feat/user-whitelist-security branch 2 times, most recently from aa2a59c to eee04a6 Compare January 11, 2026 16:15
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@BukeLy BukeLy force-pushed the feat/user-whitelist-security branch from eee04a6 to 0d38514 Compare January 11, 2026 16:26
@BukeLy BukeLy merged commit 2f3c231 into main Jan 11, 2026
@BukeLy BukeLy deleted the feat/user-whitelist-security branch January 11, 2026 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants