Refactor text-first chat app adapters to reduce duplicated scaffolding#25
Merged
lsdefine merged 2 commits intolsdefine:mainfrom Mar 13, 2026
Merged
Conversation
shaun0927
added a commit
to shaun0927/GenericAgent
that referenced
this pull request
Apr 17, 2026
Closes lsdefine#95. wechatapp.py was the only adapter under frontends/ without an allowed_users gate, while every other adapter (tg, fs, qq, dingtalk, wecom) reads <platform>_allowed_users from mykey.py and rejects unknown senders. Mirror the QQ adapter's pattern (introduced in PR lsdefine#25): - Read 'wechat_allowed_users' via mykeys, normalize via the same 'set comprehension that keeps non-empty stripped strings' idiom. - Use the existing chatapp_common.public_access() helper so the semantics ('empty or ["*"] means public') match the rest of the ecosystem; this preserves backward compatibility for existing setups that have no wechat_allowed_users key. - Drop unauthorized senders with the same '[<Adapter>] unauthorized user: <id>' log message convention used by qq/dingtalk. Add the optional knob to mykey_template.py next to the other allowed_users entries so users can copy the comment block.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
chatapp_common.pyfsapp.pyas well, while keeping Feishu behavior unchangedWhy
The previous chat-app integration PR landed the features, but the adapter implementations still repeated a lot of scaffolding: text cleaning, restore handling, command handling, and agent task loops. This follow-up keeps the feature set while making the maintenance footprint smaller and the adapter files easier to review.
Impact
qqapp.pygoes from 307 lines to 121 lineswecomapp.pygoes from 274 lines to 108 linesdingtalkapp.pygoes from 317 lines to 140 linesfsapp.pygoes from 538 lines to 465 linesmain: 330 insertions and 746 deletionsTesting
python -m py_compile chatapp_common.py qqapp.py wecomapp.py dingtalkapp.py fsapp.py launch.pyw agentmain.py agent_loop.py llmcore.py