(window.webpackJsonp=window.webpackJsonp||[]).push([[206],{678:function(e,t,s){"use strict";s.r(t);var a=s(21),v=Object(a.a)({},(function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("ContentSlotsDistributor",{attrs:{"slot-key":e.$parent.slotKey}},[s("h1",{attrs:{id:"创建一个完整的项目"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#创建一个完整的项目"}},[e._v("#")]),e._v(" 创建一个完整的项目")]),e._v(" "),s("p",[e._v("上一章中我们已经运行了一个简单的 NoneBot 实例，在这一章，我们将从零开始一个完整的项目。")]),e._v(" "),s("h2",{attrs:{id:"目录结构"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#目录结构"}},[e._v("#")]),e._v(" 目录结构")]),e._v(" "),s("p",[e._v("可以使用 "),s("code",[e._v("nb-cli")]),e._v(" 或者自行创建完整的项目目录：")]),e._v(" "),s("div",{staticClass:"language-bash line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-bash"}},[s("code",[e._v("nb create\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),e._v(" "),s("pre",{staticClass:"vue-container"},[s("code",[s("p",[e._v("AweSome-Bot\n├── "),s("code",[e._v("awesome_bot")]),e._v(" "),s("em",[e._v("("),s("strong",[e._v("或是 src")]),e._v(")")]),e._v("\n│   └── "),s("code",[e._v("plugins")]),e._v("\n├── "),s("code",[e._v(".env")]),e._v(" "),s("em",[e._v("("),s("strong",[e._v("可选的")]),e._v(")")]),e._v("\n├── "),s("code",[e._v(".env.dev")]),e._v(" "),s("em",[e._v("("),s("strong",[e._v("可选的")]),e._v(")")]),e._v("\n├── "),s("code",[e._v(".env.prod")]),e._v(" "),s("em",[e._v("("),s("strong",[e._v("可选的")]),e._v(")")]),e._v("\n├── .gitignore\n├── "),s("code",[e._v("bot.py")]),e._v("\n├── docker-compose.yml\n├── Dockerfile\n├── "),s("code",[e._v("pyproject.toml")]),e._v("\n└── README.md")]),e._v("\n")])]),e._v(" "),s("ul",[s("li",[s("code",[e._v("awesome_bot/plugins")]),e._v(" 或 "),s("code",[e._v("src/plugins")]),e._v(": 用于存放编写的 bot 插件")]),e._v(" "),s("li",[s("code",[e._v(".env")]),e._v(", "),s("code",[e._v(".env.dev")]),e._v(", "),s("code",[e._v(".env.prod")]),e._v(": 各环境配置文件")]),e._v(" "),s("li",[s("code",[e._v("bot.py")]),e._v(": bot 入口文件")]),e._v(" "),s("li",[s("code",[e._v("pyproject.toml")]),e._v(": 项目依赖管理文件，默认使用 "),s("a",{attrs:{href:"https://python-poetry.org/",target:"_blank",rel:"noopener noreferrer"}},[e._v("poetry"),s("OutboundLink")],1)])]),e._v(" "),s("h2",{attrs:{id:"启动-bot"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#启动-bot"}},[e._v("#")]),e._v(" 启动 Bot")]),e._v(" "),s("p",[e._v("如果你使用 "),s("code",[e._v("nb-cli")])]),e._v(" "),s("div",{staticClass:"language-bash line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-bash"}},[s("code",[e._v("nb run "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("[")]),e._v("--file"),s("span",{pre:!0,attrs:{class:"token operator"}},[e._v("=")]),e._v("bot.py"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("]")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("[")]),e._v("--app"),s("span",{pre:!0,attrs:{class:"token operator"}},[e._v("=")]),e._v("app"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("]")]),e._v("\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("或者使用")]),e._v(" "),s("div",{staticClass:"language-bash line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-bash"}},[s("code",[e._v("python bot.py\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("div",{staticClass:"custom-block tip"},[s("p",{staticClass:"custom-block-title"},[e._v("提示")]),e._v(" "),s("p",[e._v("如果在 bot 入口文件内定义了 asgi server， "),s("code",[e._v("nb-cli")]),e._v(" 将会为你启动"),s("strong",[e._v("冷重载模式")])])])])}),[],!1,null,null,null);t.default=v.exports}}]);