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

代码结构说明 #3

Open
lloydzhou opened this issue Dec 19, 2023 · 0 comments
Open

代码结构说明 #3

lloydzhou opened this issue Dec 19, 2023 · 0 comments
Assignees

Comments

@lloydzhou
Copy link
Contributor

.
├── bot
│   ├── base.py
│   ├── feishu.py
│   └── init.py
├── broker.py
├── ctx.py
├── event.py
├── globals.py
├── init.py
└── message.py

  1. globals以及ctx是参考flask的设计
  2. ctx定义了三个不同的context类,在对应的地方调用with的时候,会生成context对象,这个对象会把当前的变量注册到globals中的ContextVar变量里面
  3. 实际使用的时候,可以直接以全局变量的模式直接利用 LocalProxy 拿到当前的context变量或者context内部的变量
  4. message.py只定义了一个可以将json变成支持属性直接拿到key对应的value,实际上类似tornado里面的ObjectDict
  5. event,这里主要写的是接收消息的逻辑,后面会改成receiver 更改变量名 #2
  6. broker 这里是整个消息中心的逻辑,内部有两个队列,会去调用对应的bot处理消息。同时还负责消息的流转
  7. bot文件夹里面,主要是应用自己处理消息的逻辑,这里的bot会在broker内部被调用,去处理消息,以及负责发送消息到im平台
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

No branches or pull requests

2 participants