diff --git a/docs/FAQ.md b/docs/FAQ.md new file mode 100644 index 00000000..4514b4c1 --- /dev/null +++ b/docs/FAQ.md @@ -0,0 +1 @@ +# FAQ diff --git a/docs/assets/extra.css b/docs/assets/extra.css new file mode 100644 index 00000000..4b4b3cee --- /dev/null +++ b/docs/assets/extra.css @@ -0,0 +1,9 @@ +.md-header-nav__button.md-logo { + padding: .2rem; + margin: .2rem; +} + +.md-header-nav__button.md-logo img, .md-header-nav__button.md-logo svg { + width: 1.6rem; + height: 1.6rem; +} \ No newline at end of file diff --git a/docs/assets/logos.png b/docs/assets/logos.png new file mode 100644 index 00000000..c3c668dd Binary files /dev/null and b/docs/assets/logos.png differ diff --git a/docs/component/index.md b/docs/component/index.md new file mode 100644 index 00000000..98260ae6 --- /dev/null +++ b/docs/component/index.md @@ -0,0 +1 @@ +# 框架组件 \ No newline at end of file diff --git a/docs/event/index.md b/docs/event/index.md new file mode 100644 index 00000000..710180da --- /dev/null +++ b/docs/event/index.md @@ -0,0 +1 @@ +# 事件和注解 \ No newline at end of file diff --git a/docs/guide/OneBot实例.md b/docs/guide/OneBot实例.md new file mode 100644 index 00000000..e7668ea1 --- /dev/null +++ b/docs/guide/OneBot实例.md @@ -0,0 +1,23 @@ +# OneBot 实例 + +## 什么是 OneBot + +OneBot 是一个聊天机器人应用接口标准,详情戳[这里](https://github.com/howmanybots/onebot)。 + +## OneBot 实现选择 + +如果你使用炸毛框架作为聊天机器人的开发框架,请先选择一种兼容 OneBot 标准的机器人接口。理论上,基于 OneBot 标准开发的**任何** SDK、框架和机器人应用,都可以无缝地在下面的不同实现中切换。当然,在一小部分细节上各实现可能有一些不同。 + +| 项目地址 | 平台 | 核心作者 | 备注 | +| ------------------------------------------------------------ | --------------------------------------------- | -------------- | ------------------------------------------------------------ | +| [richardchien/coolq-http-api](https://github.com/richardchien/coolq-http-api) | CKYU | richardchien | 可在 Mirai 平台使用 [mirai-native](https://github.com/iTXTech/mirai-native) 加载 | +| [Mrs4s/go-cqhttp](https://github.com/Mrs4s/go-cqhttp) | [MiraiGo](https://github.com/Mrs4s/MiraiGo) | Mrs4s | 炸毛框架推荐使用此项目机器人应用 | +| [yyuueexxiinngg/cqhttp-mirai](https://github.com/yyuueexxiinngg/cqhttp-mirai) | [Mirai](https://github.com/mamoe/mirai) | yyuueexxiinngg | | +| [takayama-lily/onebot](https://github.com/takayama-lily/onebot) | [OICQ](https://github.com/takayama-lily/oicq) | takayama | | +| [ProtobufBot](https://github.com/ProtobufBot) | [Mirai](https://github.com/mamoe/mirai) | lz1998 | 事件和 API 数据内容和 OneBot 一致,通信方式不兼容 | + +!!! warning "注意" + + 因为目前炸毛框架 2.0 只支持 WebSocket 方式的 OneBot 实现,所以目前上述项目的连接方式均只可选支持反向 WebSocket 通信的。后期会兼容 HTTP 和正向 WebSocket 通信方式。 + +如果你还没有自己的 QQ,或者是其他原因导致的暂时无法使用上述 OneBot 实例,可以使用炸毛项目中的 OneBot 协议聊天模拟器。但目前还处在开发中,暂不可用。 \ No newline at end of file diff --git a/docs/guide/index.md b/docs/guide/index.md new file mode 100644 index 00000000..000ea345 --- /dev/null +++ b/docs/guide/index.md @@ -0,0 +1,17 @@ +# Welcome to MkDocs + +For full documentation visit [mkdocs.org](https://www.mkdocs.org). + +## Commands + +* `mkdocs new [dir-name]` - Create a new project. +* `mkdocs serve` - Start the live-reloading docs server. +* `mkdocs build` - Build the documentation site. +* `mkdocs -h` - Print help message and exit. + +## Project layout + + mkdocs.yml # The configuration file. + docs/ + index.md # The documentation homepage. + ... # Other markdown pages, images and other files. diff --git a/docs/guide/我需要做什么.md b/docs/guide/我需要做什么.md new file mode 100644 index 00000000..7aaa2981 --- /dev/null +++ b/docs/guide/我需要做什么.md @@ -0,0 +1,3 @@ +# 我需要做什么 + +文档还在写,不急!! \ No newline at end of file diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 00000000..f8c5dc91 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,29 @@ +# 介绍 +炸毛框架由 php-swoole 构建而来,主要面向 API 服务,聊天机器人(CQHTTP 对接),包含 websocket、http 等监听和请求库,用户代码采用模块化处理,可以方便地编写各类功能。 + +框架主要用途为 HTTP 服务器,机器人搭建框架。尤其对于 QQ 机器人消息处理较为方便和全面,提供了众多会话机制和内部调用机制,可以以各种方式设计你自己的模块。 + +在 HTTP 和 WebSocket 服务器上,PHP 的扩展 Swoole 提供了高性能的支持,使其效率可媲美 nginx 静态网页处理的效率。 + +此外,QQ 机器人方面此框架基于 OneBot 标准 的反向 WebSocket 连接,比传统 HTTP 通信更快,未来也会兼容微信公众号开发者模式。 + +## 开始前 +因为框架采用的是 Swoole 的方式来运作的,所以和传统的 php-fpm 处理机制 **完全不同**。你可以参考 Python 的 [aiocqhttp](https://github.com/richardchien/python-aiocqhttp) SDK,运行方式为 cli 环境。 + +在项目运行过程中,会启动 Master、Reactor、Worker 和 TaskWorker 多个进程,在一般情况下,**你不需要知道这些进程是什么,有什么区别**,除非想学习进程间通信和将框架设为多进程运行模式(框架默认采用单进程多协程运行)。 + +若使用本框架只作为机器人框架的话,建议将本框架部署到和 OneBot 标准的客户端同一台服务器上,以减少延迟和断链等网络问题带来的效率影响。 + +!!! note "给开发者的提示" + + 本文档的 **指南** 部分是对框架内各个部分的详细说明,请仔细阅读指南的各个部分后,根据自己的需要选择阅读 **框架组件** 和 **注解事件** 部分。如果对框架还迷糊,可以在阅读完 **指南** 部分后阅读 **进阶** 篇,去了解怎么完成一个功能。 + + +## 框架特色 +- 支持MySQL数据库(连接池),自带查询缓存提高多查询时的效率 +- Websocket 服务器、HTTP 服务器兼容运行,一个框架多个用处 +- 支持命令、自然语言处理等多种插件形式 +- 支持多个机器人账号负载均衡 +- 协程 + TaskWorker 进程重度任务处理机制,保证高效,单个请求响应时间为 0.1 ms 左右 +- 模块分离和自由组合,可根据自身需求自己建立模块内的目录结构和代码结构 +- 灵活的注释注解注册事件方式,弥补 PHP 语言缺少注解的遗憾 \ No newline at end of file diff --git a/docs/javascripts/config.js b/docs/javascripts/config.js new file mode 100644 index 00000000..4141e136 --- /dev/null +++ b/docs/javascripts/config.js @@ -0,0 +1,2 @@ +hljs.initHighlighting() + diff --git a/docs/test.md b/docs/test.md new file mode 100644 index 00000000..42ffaa4f --- /dev/null +++ b/docs/test.md @@ -0,0 +1,25 @@ +# 测试文档 + +## 测试锚点1 + +哈哈哈哈哈 + +## 测试锚点2 + +哦吼 + +## 测试代码段 +```php +if(true) { + return "hahah"; +} +``` + +## 测试 MkDocs +!!! warning "Theme extension prerequisites" + + As the `custom_dir` variable is used for the theme extension process, + Material for MkDocs needs to be installed via `pip` and referenced with the + `name` parameter in `mkdocs.yml`. It will not work when cloning from `git`. + +哦豁 \ No newline at end of file diff --git a/docs/update.md b/docs/update.md new file mode 100644 index 00000000..1b6c0b78 --- /dev/null +++ b/docs/update.md @@ -0,0 +1 @@ +# 更新日志 diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 00000000..3716de98 --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,38 @@ +site_name: 炸毛框架 v2 + +repo_name: '炸毛框架' +repo_url: 'https://github.com/zhamao-robot/zhamao-framework' +edit_uri: 'blob/master/docs/' + +theme: + name: material + logo: assets/logos.png + features: + - navigation.tabs +extra_javascript: + - https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/highlight.min.js + - javascripts/config.js +extra_css: + - assets/extra.css + - https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/styles/default.min.css +markdown_extensions: + - admonition + - pymdownx.tabbed + +copyright: 'Copyright © 2019 - 2020 CrazyBot Team' + +nav: + - 指南: + - 介绍: index.md + - 我需要做什么: guide/我需要做什么.md + - 选择聊天机器人实例: guide/OneBot实例.md + - 事件和注解: + - 事件和注解: event/index.md + - 框架组件: + - 框架组件: component/index.md + - 进阶开发: + - Swoole 进阶: test.md + - FAQ: + - FAQ: FAQ.md + - 更新日志: + - 更新日志: update.md