Skip to content

Conversation

reorx
Copy link

@reorx reorx commented Jun 18, 2013

出于自用的目的,就把框架改动了一下,大概在以下几个方面:

  1. 引用方式
    改变之前的 import werobot.utils 然后调用 werobot.utils.xxx 的做法,明确地引用所使用的函数 from werobot.utils import xxx
  2. 增加了 examples 文件夹
  3. 合并了所有关于不同类型消息的 handler 测试,并精简了测试代码(去掉冗余的 WeRoBot 和 WeTest 实例化,改为调用统一函数)
  4. 将 test 模块重命名为 testing,后者更符合现今大多数项目的命名规范
  5. 增加了 errors 模块
  6. 大改了 WeRoBot 的运行机制:
    • 每种消息类型只会对应一个函数而不是多个,重复声明会将之前的函数覆盖。因此而去掉了 WeRoBot.handler 装饰器,指定消息类型的处理函数应该明确声明 (Explicit is better than implicit)
    • 增加了 _fallback 伪消息类型用于处理无对应处理函数的消息
    • _get_reply 中使用异常处理机制,将产生异常的消息移交 fallback handler 处理
    • 传递给 create_reply 的 replay 可以是 None,代表无回复。除此外必须是可以生成合法的消息的数据。
    • 增加了 WeRoBot.settings 属性,用于存储和更改配置,并在相应的地方(如 run)引用
    • 增加了对 logging 的配置处理,以后可以在项目中使用 logging 记录日志了

有点专断,所以本来不大好意思提交了……想了下还是发了,毕竟作为这个项目的受益者,回馈是必须的呀~

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling ad7f7e5 on reorx:arbitrary into f0d7b32 on whtsky:master.

@reorx
Copy link
Author

reorx commented Jun 18, 2013

@coveralls Yes I actually only change the way tests were written, but I will try to add more tests to improve the coverage score later, thanks for reminding. BTW, you are not a robot, are you?

@whtsky
Copy link
Collaborator

whtsky commented Jun 19, 2013

@reorx @coveralls 是 coveralls 的机器人…

@whtsky
Copy link
Collaborator

whtsky commented Jun 19, 2013

有不少想合并的地方:

  • fallback
  • testing
  • example
  • 等等

但是有些不想接受的,比如一种类型的消息只能有一个 handler …
有什么办法能只合并几个 commit 么?

@reorx
Copy link
Author

reorx commented Jun 19, 2013

或者我再发一个对非 master 分支的 pull request,是用 develop 还是你再开一个新分支?我这里只能选择你的库里存在的分支。

@reorx
Copy link
Author

reorx commented Jun 19, 2013

可以开个新的 issue 专门讨论下 handler 和消息类型的绑定机制问题。现在一个你的一个我的两个方案,算是各有优缺点吧,我会在 issue 里详细阐述下我的想法。

@whtsky
Copy link
Collaborator

whtsky commented Jun 19, 2013

@reorx develop 分支吧;
直接在这里阐明不好么…

@reorx
Copy link
Author

reorx commented Jun 19, 2013

需要花点时间理清楚,今天没时间。

@reorx reorx closed this Jun 19, 2013
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.

3 participants