Skip to content
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

Feature/multiple accounts #150

Merged
merged 5 commits into from
Sep 30, 2016

Conversation

xiewenwei
Copy link
Contributor

@xiewenwei xiewenwei commented Sep 29, 2016

完整支持多微信公众号
原先版本可在声明 wechat_responder 时通过指定参数有限度支持多个微信公众号,其它地方并不支持,比如 Wechat.api 和 wechat 命令行工具并不支持,现在增加完整的多微信公众号支持特性。

使用方法
1.配置文件可增加多个公众号配置,用法类似 Rails 中 database.yml 多数据库配置的处理
development, test, production 段是默认公众号配置
[account_env] 是额外公众号配置,如
wx007_development, wx007_test, wx007_production 增加了 wx007 这个公众号的相关配置。

2.wechat_responder 声明
wechat_responder account: :wx007

3.wechat api 使用
Wechat.api(:wx007) 表示使用 wx007 这个公众号的 api
Wechat.api 和 Wechat.api(:default) 表示默认的 api

4.wechat 命令行使用
增加可选参数 -a, [--account=ACCOUNT]
wechat users -a wx007 表示列举 wx007 这个公众号的粉丝列表

实现原理
关键处理
1.扩展配置文件规则和加载处理,通过 公众号 <-> 配置 的 hash 对象存储多个公众号配置
2.扩展 Wechat.config Wechat.api Wechat::ApiLoader.config 和 Wechat::ApiLoader.with 方法,
允许获取指定公众号的 config 和 api。

@xiewenwei xiewenwei mentioned this pull request Sep 29, 2016
@Eric-Guo Eric-Guo merged commit b9255ea into Eric-Guo:master Sep 30, 2016
@xiewenwei xiewenwei deleted the feature/multiple-accounts branch May 16, 2017 11:57
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