import React from "react";
import CodeBlock from "@theme/CodeBlock";
export type Feature = {
title: string;
tagline?: string;
description?: string;
annotaion?: string;
children?: React.ReactNode;
};
export function HomeFeature({
title,
tagline,
description,
annotaion,
children,
}: Feature): JSX.Element {
return (
{tagline}
{title}
{description}
{children}
{annotaion}
);
}
function HomeFeatureSingleColumn(props: Feature): JSX.Element {
return (
);
}
function HomeFeatureDoubleColumn({
features: [feature1, feature2],
children,
}: {
features: [Feature, Feature];
children?: [React.ReactNode, React.ReactNode];
}): JSX.Element {
const [children1, children2] = children ?? [];
return (
{children1}
{children2}
);
}
function HomeFeatures(): JSX.Element {
return (
<>
{[
"$ pipx install nb-cli",
"$ nb",
// "d8b db .d88b. d8b db d88888b d8888b. .d88b. d888888b",
// "888o 88 .8P Y8. 888o 88 88' 88 `8D .8P Y8. `~~88~~'",
// "88V8o 88 88 88 88V8o 88 88ooooo 88oooY' 88 88 88",
// "88 V8o88 88 88 88 V8o88 88~~~~~ 88~~~b. 88 88 88",
// "88 V888 `8b d8' 88 V888 88. 88 8D `8b d8' 88",
// "VP V8P `Y88P' VP V8P Y88888P Y8888P' `Y88P' YP",
"[?] What do you want to do?",
"❯ Create a NoneBot project.",
" Run the bot in current folder.",
" Manage bot driver.",
" Manage bot adapters.",
" Manage bot plugins.",
" ...",
].join("\n")}
{[
"import nonebot",
"# 加载一个插件",
'nonebot.load_plugin("path.to.your.plugin")',
"# 从文件夹加载插件",
'nonebot.load_plugins("plugins")',
"# 从配置文件加载多个插件",
'nonebot.load_from_json("plugins.json")',
'nonebot.load_from_toml("pyproject.toml")',
].join("\n")}
{[
"import nonebot",
"# OneBot",
"from nonebot.adapters.onebot.v11 import Adapter as OneBotAdapter",
"# QQ 频道",
"from nonebot.adapters.qqguild import Adapter as QQGuildAdapter",
"driver = nonebot.get_driver()",
"driver.register_adapter(OneBotAdapter)",
"driver.register_adapter(QQGuildAdapter)",
].join("\n")}
{[
"from nonebot import on_message",
"# 注册一个消息响应器",
"matcher = on_message()",
"# 注册一个消息处理器",
"# 并重复收到的消息",
"@matcher.handle()",
"async def handler(event: Event) -> None:",
" await matcher.send(event.get_message())",
].join("\n")}
{[
"from nonebot import on_command",
"# 注册一个命令响应器",
'matcher = on_command("help", alias={"帮助"})',
"# 注册一个命令处理器",
"# 通过依赖注入获得命令名以及参数",
"@matcher.handle()",
"async def handler(cmd = Command(), arg = CommandArg()) -> None:",
" await matcher.finish()",
].join("\n")}
>
);
}
export default React.memo(HomeFeatures);