|
<div id="app"><div class="Layout" data-v-a1db1244 data-v-92d87297><span tabindex="-1" data-v-f637ee78></span><a href="#VPContent" class="VPSkipLink visually-hidden" data-v-f637ee78> Skip to content </a><header class="VPNav" data-v-92d87297 data-v-12c8867e><div class="VPNavBar has-sidebar" data-v-12c8867e data-v-447244bd><div class="container" data-v-447244bd><div class="VPNavBarTitle has-sidebar" data-v-447244bd data-v-aaed7263><a class="title" href="/" data-v-aaed7263><img class="VPImage logo" src="/logo.png" alt data-v-ca1a0a93>Koishi</a></div><div class="content" data-v-447244bd><div class="VPNavBarSearch search" data-v-447244bd data-v-fc6e1504><div id="docsearch" data-v-fc6e1504><button type="button" class="DocSearch DocSearch-Button" aria-label="Search" data-v-fc6e1504><span class="DocSearch-Button-Container" data-v-fc6e1504><svg width="20" height="20" class="DocSearch-Search-Icon" viewBox="0 0 20 20" data-v-fc6e1504><path d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round" data-v-fc6e1504></path></svg><span class="DocSearch-Button-Placeholder" data-v-fc6e1504>搜索</span></span><span class="DocSearch-Button-Keys" data-v-fc6e1504><kbd class="DocSearch-Button-Key" data-v-fc6e1504>Ctrl</kbd><kbd class="DocSearch-Button-Key" data-v-fc6e1504>K</kbd></span></button></div></div><nav aria-labelledby="main-nav-aria-label" class="VPNavBarMenu menu" data-v-447244bd data-v-d8cdd395><span id="main-nav-aria-label" class="visually-hidden" data-v-d8cdd395>Main Navigation</span><a class="VPLink link VPNavBarMenuLink" href="/manual/introduction.html" data-v-d8cdd395 data-v-08b6ef03 data-v-97a44ddd>入门</a><a class="VPLink link VPNavBarMenuLink" href="/guide/" data-v-d8cdd395 data-v-08b6ef03 data-v-97a44ddd>开发</a><a class="VPLink link VPNavBarMenuLink active" href="/api/" data-v-d8cdd395 data-v-08b6ef03 data-v-97a44ddd>API</a><div class="VPFlyout VPNavBarMenuGroup" data-v-d8cdd395 data-v-aeb1c475><button type="button" class="button" aria-haspopup="true" aria-expanded="false" data-v-aeb1c475><span class="text" data-v-aeb1c475> 插件 <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="text-icon" data-v-aeb1c475><path d="M12,16c-0.3,0-0.5-0.1-0.7-0.3l-6-6c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l5.3,5.3l5.3-5.3c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-6,6C12.5,15.9,12.3,16,12,16z"></path></svg></span></button><div class="menu" data-v-aeb1c475><div class="VPMenu" data-v-aeb1c475 data-v-079aa243><div class="items" data-v-079aa243><div class="VPMenuLink" data-v-079aa243 data-v-d3c02515><a class="VPLink link" href="/market.html" data-v-d3c02515 data-v-97a44ddd>插件市场</a></div><div class="VPMenuLink" data-v-079aa243 data-v-d3c02515><a class="VPLink link" href="/plugins/" data-v-d3c02515 data-v-97a44ddd>官方插件索引</a></div><div class="VPMenuLink" data-v-079aa243 data-v-d3c02515><a class="VPLink link" href="/ecosystem.html" data-v-d3c02515 data-v-97a44ddd>社区插件导航</a></div></div></div></div></div><a class="VPLink link VPNavBarMenuLink" href="/about/contact.html" data-v-d8cdd395 data-v-08b6ef03 data-v-97a44ddd>更多</a></nav><div class="VPNavBarAppearance appearance" data-v-447244bd data-v-d70ebc80><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" aria-label="toggle dark mode" aria-checked="false" data-v-d70ebc80 data-v-99dcb6e3 data-v-3258a739><span class="check" data-v-3258a739><span class="icon" data-v-3258a739><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="sun" data-v-99dcb6e3><path d="M12,18c-3.3,0-6-2.7-6-6s2.7-6,6-6s6,2.7,6,6S15.3,18,12,18zM12,8c-2.2,0-4,1.8-4,4c0,2.2,1.8,4,4,4c2.2,0,4-1.8,4-4C16,9.8,14.2,8,12,8z"></path><path d="M12,4c-0.6,0-1-0.4-1-1V1c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,3.6,12.6,4,12,4z"></path><path d="M12,24c-0.6,0-1-0.4-1-1v-2c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,23.6,12.6,24,12,24z"></path><path d="M5.6,6.6c-0.3,0-0.5-0.1-0.7-0.3L3.5,4.9c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C6.2,6.5,5.9,6.6,5.6,6.6z"></path><path d="M19.8,20.8c-0.3,0-0.5-0.1-0.7-0.3l-1.4-1.4c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C20.3,20.7,20,20.8,19.8,20.8z"></path><path d="M3,13H1c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S3.6,13,3,13z"></path><path d="M23,13h-2c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S23.6,13,23,13z"></path><path d="M4.2,20.8c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C4.7,20.7,4.5,20.8,4.2,20.8z"></path><path d="M18.4,6.6c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C18.9,6.5,18.6,6.6,18.4,6.6z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="moon" data-v-99dcb6e3><path d="M12.1,22c-0.3,0-0.6,0-0.9,0c-5.5-0.5-9.5-5.4-9-10.9c0.4-4.8,4.2-8.6,9-9c0.4,0,0.8,0.2,1,0.5c0.2,0.3,0.2,0.8-0.1,1.1c-2,2.7-1.4,6.4,1.3,8.4c2.1,1.6,5,1.6,7.1,0c0.3-0.2,0.7-0.3,1.1-0.1c0.3,0.2,0.5,0.6,0.5,1c-0.2,2.7-1.5,5.1-3.6,6.8C16.6,21.2,14.4,22,12.1,22zM9.3,4.4c-2.9,1-5,3.6-5.2,6.8c-0.4,4.4,2.8,8.3,7.2,8.7c2.1,0.2,4.2-0.4,5.8-1.8c1.1-0.9,1.9-2.1,2.4-3.4c-2.5,0.9-5.3,0.5-7.5-1.1C9.2,11.4,8.1,7.7,9.3,4.4z"></path></svg></span></span></button></div><div class="VPSocialLinks VPNavBarSocialLinks social-links" data-v-447244bd data-v-6a2a6555 data-v-b8f6762d><a class="VPSocialLink" href="https://github.com/koishijs/koishi" target="_blank" rel="noopener" data-v-b8f6762d data-v-179ad0ea><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>GitHub</title><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></svg></a><a class="VPSocialLink" href="https://discord.com/invite/xfxYwmd284" target="_blank" rel="noopener" data-v-b8f6762d data-v-179ad0ea><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Discord</title><path d="M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z"/></svg></a></div><div class="VPFlyout VPNavBarExtra extra" data-v-447244bd data-v-b390db70 data-v-aeb1c475><button type="button" class="button" aria-haspopup="true" aria-expanded="false" aria-label="extra navigation" data-v-aeb1c475><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="icon" data-v-aeb1c475><circle cx="12" cy="12" r="2"></circle><circle cx="19" cy="12" r="2"></circle><circle cx="5" cy="12" r="2"></circle></svg></button><div class="menu" data-v-aeb1c475><div class="VPMenu" data-v-aeb1c475 data-v-079aa243><div class="group" data-v-b390db70><div class="item appearance" data-v-b390db70><p class="label" data-v-b390db70>Appearance</p><div class="appearance-action" data-v-b390db70><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" aria-label="toggle dark mode" aria-checked="false" data-v-b390db70 data-v-99dcb6e3 data-v-3258a739><span class="check" data-v-3258a739><span class="icon" data-v-3258a739><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="sun" data-v-99dcb6e3><path d="M12,18c-3.3,0-6-2.7-6-6s2.7-6,6-6s6,2.7,6,6S15.3,18,12,18zM12,8c-2.2,0-4,1.8-4,4c0,2.2,1.8,4,4,4c2.2,0,4-1.8,4-4C16,9.8,14.2,8,12,8z"></path><path d="M12,4c-0.6,0-1-0.4-1-1V1c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,3.6,12.6,4,12,4z"></path><path d="M12,24c-0.6,0-1-0.4-1-1v-2c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,23.6,12.6,24,12,24z"></path><path d="M5.6,6.6c-0.3,0-0.5-0.1-0.7-0.3L3.5,4.9c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C6.2,6.5,5.9,6.6,5.6,6.6z"></path><path d="M19.8,20.8c-0.3,0-0.5-0.1-0.7-0.3l-1.4-1.4c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C20.3,20.7,20,20.8,19.8,20.8z"></path><path d="M3,13H1c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S3.6,13,3,13z"></path><path d="M23,13h-2c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S23.6,13,23,13z"></path><path d="M4.2,20.8c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C4.7,20.7,4.5,20.8,4.2,20.8z"></path><path d="M18.4,6.6c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C18.9,6.5,18.6,6.6,18.4,6.6z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="moon" data-v-99dcb6e3><path d="M12.1,22c-0.3,0-0.6,0-0.9,0c-5.5-0.5-9.5-5.4-9-10.9c0.4-4.8,4.2-8.6,9-9c0.4,0,0.8,0.2,1,0.5c0.2,0.3,0.2,0.8-0.1,1.1c-2,2.7-1.4,6.4,1.3,8.4c2.1,1.6,5,1.6,7.1,0c0.3-0.2,0.7-0.3,1.1-0.1c0.3,0.2,0.5,0.6,0.5,1c-0.2,2.7-1.5,5.1-3.6,6.8C16.6,21.2,14.4,22,12.1,22zM9.3,4.4c-2.9,1-5,3.6-5.2,6.8c-0.4,4.4,2.8,8.3,7.2,8.7c2.1,0.2,4.2-0.4,5.8-1.8c1.1-0.9,1.9-2.1,2.4-3.4c-2.5,0.9-5.3,0.5-7.5-1.1C9.2,11.4,8.1,7.7,9.3,4.4z"></path></svg></span></span></button></div></div></div><div class="group" data-v-b390db70><div class="item social-links" data-v-b390db70><div class="VPSocialLinks social-links-list" data-v-b390db70 data-v-b8f6762d><a class="VPSocialLink" href="https://github.com/koishijs/koishi" target="_blank" rel="noopener" data-v-b8f6762d data-v-179ad0ea><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>GitHub</title><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></svg></a><a class="VPSocialLink" href="https://discord.com/invite/xfxYwmd284" target="_blank" rel="noopener" data-v-b8f6762d data-v-179ad0ea><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Discord</title><path d="M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z"/></svg></a></div></div></div></div></div></div><button type="button" class="VPNavBarHamburger hamburger" aria-label="mobile navigation" aria-expanded="false" aria-controls="VPNavScreen" data-v-447244bd data-v-6bee1efd><span class="container" data-v-6bee1efd><span class="top" data-v-6bee1efd></span><span class="middle" data-v-6bee1efd></span><span class="bottom" data-v-6bee1efd></span></span></button></div></div></div></header><div class="VPLocalNav" data-v-92d87297 data-v-72f15439><button class="menu" aria-expanded="false" aria-controls="VPSidebarNav" data-v-72f15439><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="menu-icon" data-v-72f15439><path d="M17,11H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h14c0.6,0,1,0.4,1,1S17.6,11,17,11z"></path><path d="M21,7H3C2.4,7,2,6.6,2,6s0.4-1,1-1h18c0.6,0,1,0.4,1,1S21.6,7,21,7z"></path><path d="M21,15H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h18c0.6,0,1,0.4,1,1S21.6,15,21,15z"></path><path d="M17,19H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h14c0.6,0,1,0.4,1,1S17.6,19,17,19z"></path></svg><span class="menu-text" data-v-72f15439>Menu</span></button><a class="top-link" href="#" data-v-72f15439> Return to top </a></div><div class="el-scrollbar vp-sidebar" data-v-92d87297><div class="el-scrollbar__wrap el-scrollbar__wrap--hidden-default" style=""><aside class="el-scrollbar__view vp-sidebar-view" style=""><nav class="vp-sidebar-nav" id="VPSidebarNav" aria-labelledby="sidebar-aria-label" tabindex="-1"><span class="visually-hidden" id="sidebar-aria-label"> Sidebar Navigation </span><div class="vp-sidebar-group"><section class="VPSidebarGroup" data-v-a094e895><div class="items" data-v-a094e895><a class="VPLink link link" href="/api/" style="padding-left:0px;" data-v-63c070bf data-v-97a44ddd><span class="link-text" data-v-63c070bf>总览</span></a></div></section></div><div class="vp-sidebar-group"><section class="VPSidebarGroup" data-v-a094e895><div class="title" data-v-a094e895><h2 class="title-text" data-v-a094e895>核心模块</h2><div class="action" data-v-a094e895><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewbox="0 0 24 24" class="icon minus" data-v-a094e895><path d="M19,2H5C3.3,2,2,3.3,2,5v14c0,1.7,1.3,3,3,3h14c1.7,0,3-1.3,3-3V5C22,3.3,20.7,2,19,2zM20,19c0,0.6-0.4,1-1,1H5c-0.6,0-1-0.4-1-1V5c0-0.6,0.4-1,1-1h14c0.6,0,1,0.4,1,1V19z"></path><path d="M16,11H8c-0.6,0-1,0.4-1,1s0.4,1,1,1h8c0.6,0,1-0.4,1-1S16.6,11,16,11z"></path></svg><svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24" class="icon plus" data-v-a094e895><path d="M19,2H5C3.3,2,2,3.3,2,5v14c0,1.7,1.3,3,3,3h14c1.7,0,3-1.3,3-3V5C22,3.3,20.7,2,19,2z M20,19c0,0.6-0.4,1-1,1H5c-0.6,0-1-0.4-1-1V5c0-0.6,0.4-1,1-1h14c0.6,0,1,0.4,1,1V19z"></path><path d="M16,11h-3V8c0-0.6-0.4-1-1-1s-1,0.4-1,1v3H8c-0.6,0-1,0.4-1,1s0.4,1,1,1h3v3c0,0.6,0.4,1,1,1s1-0.4,1-1v-3h3c0.6,0,1-0.4,1-1S16.6,11,16,11z"></path></svg></div></div><div class="items" data-v-a094e895><a class="VPLink link link" href="/api/core/adapter.html" style="padding-left:0px;" data-v-63c070bf data-v-97a44ddd><span class="link-text" data-v-63c070bf>适配器 (Adapter)</span></a><a class="VPLink link link" href="/api/core/app.html" style="padding-left:0px;" data-v-63c070bf data-v-97a44ddd><span class="link-text" data-v-63c070bf>应用 (App)</span></a><a class="VPLink link link active" href="/api/core/bot.html" style="padding-left:0px;" data-v-63c070bf data-v-97a44ddd><span class="link-text" data-v-63c070bf>机器人 (Bot)</span></a><a class="VPLink link link" href="/api/core/command.html" style="padding-left:0px;" data-v-63c070bf data-v-97a44ddd><span class="link-text" data-v-63c070bf>指令 (Command)</span></a><a class="VPLink link link" href="/api/core/context.html" style="padding-left:0px;" data-v-63c070bf data-v-97a44ddd><span class="link-text" data-v-63c070bf>上下文 (Context)</span></a><a class="VPLink link link" href="/api/core/events.html" style="padding-left:0px;" data-v-63c070bf data-v-97a44ddd><span class="link-text" data-v-63c070bf>事件 (Events)</span></a><a class="VPLink link link" href="/api/core/session.html" style="padding-left:0px;" data-v-63c070bf data-v-97a44ddd><span class="link-text" data-v-63c070bf>会话 (Session)</span></a></div></section></div><div class="vp-sidebar-group"><section class="VPSidebarGroup" data-v-a094e895><div class="title" data-v-a094e895><h2 class="title-text" data-v-a094e895>消息元素</h2><div class="action" data-v-a094e895><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewbox="0 0 24 24" class="icon minus" data-v-a094e895><path d="M19,2H5C3.3,2,2,3.3,2,5v14c0,1.7,1.3,3,3,3h14c1.7,0,3-1.3,3-3V5C22,3.3,20.7,2,19,2zM20,19c0,0.6-0.4,1-1,1H5c-0.6,0-1-0.4-1-1V5c0-0.6,0.4-1,1-1h14c0.6,0,1,0.4,1,1V19z"></path><path d="M16,11H8c-0.6,0-1,0.4-1,1s0.4,1,1,1h8c0.6,0,1-0.4,1-1S16.6,11,16,11z"></path></svg><svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24" class="icon plus" data-v-a094e895><path d="M19,2H5C3.3,2,2,3.3,2,5v14c0,1.7,1.3,3,3,3h14c1.7,0,3-1.3,3-3V5C22,3.3,20.7,2,19,2z M20,19c0,0.6-0.4,1-1,1H5c-0.6,0-1-0.4-1-1V5c0-0.6,0.4-1,1-1h14c0.6,0,1,0.4,1,1V19z"></path><path d="M16,11h-3V8c0-0.6-0.4-1-1-1s-1,0.4-1,1v3H8c-0.6,0-1,0.4-1,1s0.4,1,1,1h3v3c0,0.6,0.4,1,1,1s1-0.4,1-1v-3h3c0.6,0,1-0.4,1-1S16.6,11,16,11z"></path></svg></div></div><div class="items" data-v-a094e895><a class="VPLink link link" href="/api/message/syntax.html" style="padding-left:0px;" data-v-63c070bf data-v-97a44ddd><span class="link-text" data-v-63c070bf>语法规范</span></a><a class="VPLink link link" href="/api/message/elements.html" style="padding-left:0px;" data-v-63c070bf data-v-97a44ddd><span class="link-text" data-v-63c070bf>标准元素</span></a><a class="VPLink link link" href="/api/message/components.html" style="padding-left:0px;" data-v-63c070bf data-v-97a44ddd><span class="link-text" data-v-63c070bf>内置组件</span></a><a class="VPLink link link" href="/api/message/api.html" style="padding-left:0px;" data-v-63c070bf data-v-97a44ddd><span class="link-text" data-v-63c070bf>渲染 API</span></a></div></section></div><div class="vp-sidebar-group"><section class="VPSidebarGroup" data-v-a094e895><div class="title" data-v-a094e895><h2 class="title-text" data-v-a094e895>内置服务</h2><div class="action" data-v-a094e895><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewbox="0 0 24 24" class="icon minus" data-v-a094e895><path d="M19,2H5C3.3,2,2,3.3,2,5v14c0,1.7,1.3,3,3,3h14c1.7,0,3-1.3,3-3V5C22,3.3,20.7,2,19,2zM20,19c0,0.6-0.4,1-1,1H5c-0.6,0-1-0.4-1-1V5c0-0.6,0.4-1,1-1h14c0.6,0,1,0.4,1,1V19z"></path><path d="M16,11H8c-0.6,0-1,0.4-1,1s0.4,1,1,1h8c0.6,0,1-0.4,1-1S16.6,11,16,11z"></path></svg><svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24" class="icon plus" data-v-a094e895><path d="M19,2H5C3.3,2,2,3.3,2,5v14c0,1.7,1.3,3,3,3h14c1.7,0,3-1.3,3-3V5C22,3.3,20.7,2,19,2z M20,19c0,0.6-0.4,1-1,1H5c-0.6,0-1-0.4-1-1V5c0-0.6,0.4-1,1-1h14c0.6,0,1,0.4,1,1V19z"></path><path d="M16,11h-3V8c0-0.6-0.4-1-1-1s-1,0.4-1,1v3H8c-0.6,0-1,0.4-1,1s0.4,1,1,1h3v3c0,0.6,0.4,1,1,1s1-0.4,1-1v-3h3c0.6,0,1-0.4,1-1S16.6,11,16,11z"></path></svg></div></div><div class="items" data-v-a094e895><a class="VPLink link link" href="/api/service/bots.html" style="padding-left:0px;" data-v-63c070bf data-v-97a44ddd><span class="link-text" data-v-63c070bf>机器人 (Bots)</span></a><a class="VPLink link link" href="/api/service/i18n.html" style="padding-left:0px;" data-v-63c070bf data-v-97a44ddd><span class="link-text" data-v-63c070bf>国际化 (I18n)</span></a><a class="VPLink link link" href="/api/service/lifecycle.html" style="padding-left:0px;" data-v-63c070bf data-v-97a44ddd><span class="link-text" data-v-63c070bf>事件系统 (Lifecycle)</span></a><a class="VPLink link link" href="/api/service/registry.html" style="padding-left:0px;" data-v-63c070bf data-v-97a44ddd><span class="link-text" data-v-63c070bf>插件系统 (Registry)</span></a><a class="VPLink link link" href="/api/service/selector.html" style="padding-left:0px;" data-v-63c070bf data-v-97a44ddd><span class="link-text" data-v-63c070bf>选择器 (Selector)</span></a><a class="VPLink link link" href="/api/service/router.html" style="padding-left:0px;" data-v-63c070bf data-v-97a44ddd><span class="link-text" data-v-63c070bf>网络服务 (Router)</span></a><a class="VPLink link link" href="/api/service/http.html" style="padding-left:0px;" data-v-63c070bf data-v-97a44ddd><span class="link-text" data-v-63c070bf>网络请求 (HTTP)</span></a></div></section></div><div class="vp-sidebar-group"><section class="VPSidebarGroup" data-v-a094e895><div class="title" data-v-a094e895><h2 class="title-text" data-v-a094e895>数据库</h2><div class="action" data-v-a094e895><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewbox="0 0 24 24" class="icon minus" data-v-a094e895><path d="M19,2H5C3.3,2,2,3.3,2,5v14c0,1.7,1.3,3,3,3h14c1.7,0,3-1.3,3-3V5C22,3.3,20.7,2,19,2zM20,19c0,0.6-0.4,1-1,1H5c-0.6,0-1-0.4-1-1V5c0-0.6,0.4-1,1-1h14c0.6,0,1,0.4,1,1V19z"></path><path d="M16,11H8c-0.6,0-1,0.4-1,1s0.4,1,1,1h8c0.6,0,1-0.4,1-1S16.6,11,16,11z"></path></svg><svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24" class="icon plus" data-v-a094e895><path d="M19,2H5C3.3,2,2,3.3,2,5v14c0,1.7,1.3,3,3,3h14c1.7,0,3-1.3,3-3V5C22,3.3,20.7,2,19,2z M20,19c0,0.6-0.4,1-1,1H5c-0.6,0-1-0.4-1-1V5c0-0.6,0.4-1,1-1h14c0.6,0,1,0.4,1,1V19z"></path><path d="M16,11h-3V8c0-0.6-0.4-1-1-1s-1,0.4-1,1v3H8c-0.6,0-1,0.4-1,1s0.4,1,1,1h3v3c0,0.6,0.4,1,1,1s1-0.4,1-1v-3h3c0.6,0,1-0.4,1-1S16.6,11,16,11z"></path></svg></div></div><div class="items" data-v-a094e895><a class="VPLink link link" href="/api/database/built-in.html" style="padding-left:0px;" data-v-63c070bf data-v-97a44ddd><span class="link-text" data-v-63c070bf>内置数据结构</span></a><a class="VPLink link link" href="/api/database/database.html" style="padding-left:0px;" data-v-63c070bf data-v-97a44ddd><span class="link-text" data-v-63c070bf>数据库操作 (Database)</span></a><a class="VPLink link link" href="/api/database/model.html" style="padding-left:0px;" data-v-63c070bf data-v-97a44ddd><span class="link-text" data-v-63c070bf>数据模型 (Model)</span></a><a class="VPLink link link" href="/api/database/query.html" style="padding-left:0px;" data-v-63c070bf data-v-97a44ddd><span class="link-text" data-v-63c070bf>查询表达式 (Query)</span></a><a class="VPLink link link" href="/api/database/evaluation.html" style="padding-left:0px;" data-v-63c070bf data-v-97a44ddd><span class="link-text" data-v-63c070bf>求值表达式 (Eval)</span></a></div></section></div><div class="vp-sidebar-group"><section class="VPSidebarGroup" data-v-a094e895><div class="title" data-v-a094e895><h2 class="title-text" data-v-a094e895>其他功能</h2><div class="action" data-v-a094e895><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewbox="0 0 24 24" class="icon minus" data-v-a094e895><path d="M19,2H5C3.3,2,2,3.3,2,5v14c0,1.7,1.3,3,3,3h14c1.7,0,3-1.3,3-3V5C22,3.3,20.7,2,19,2zM20,19c0,0.6-0.4,1-1,1H5c-0.6,0-1-0.4-1-1V5c0-0.6,0.4-1,1-1h14c0.6,0,1,0.4,1,1V19z"></path><path d="M16,11H8c-0.6,0-1,0.4-1,1s0.4,1,1,1h8c0.6,0,1-0.4,1-1S16.6,11,16,11z"></path></svg><svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24" class="icon plus" data-v-a094e895><path d="M19,2H5C3.3,2,2,3.3,2,5v14c0,1.7,1.3,3,3,3h14c1.7,0,3-1.3,3-3V5C22,3.3,20.7,2,19,2z M20,19c0,0.6-0.4,1-1,1H5c-0.6,0-1-0.4-1-1V5c0-0.6,0.4-1,1-1h14c0.6,0,1,0.4,1,1V19z"></path><path d="M16,11h-3V8c0-0.6-0.4-1-1-1s-1,0.4-1,1v3H8c-0.6,0-1,0.4-1,1s0.4,1,1,1h3v3c0,0.6,0.4,1,1,1s1-0.4,1-1v-3h3c0.6,0,1-0.4,1-1S16.6,11,16,11z"></path></svg></div></div><div class="items" data-v-a094e895><a class="VPLink link link" href="/api/utils/schema.html" style="padding-left:0px;" data-v-63c070bf data-v-97a44ddd><span class="link-text" data-v-63c070bf>配置模式 (Schema)</span></a><a class="VPLink link link" href="/api/utils/observer.html" style="padding-left:0px;" data-v-63c070bf data-v-97a44ddd><span class="link-text" data-v-63c070bf>观察者 (Observer)</span></a><a class="VPLink link link" href="/api/utils/logger.html" style="padding-left:0px;" data-v-63c070bf data-v-97a44ddd><span class="link-text" data-v-63c070bf>输出日志 (Logger)</span></a><a class="VPLink link link" href="/api/utils/random.html" style="padding-left:0px;" data-v-63c070bf data-v-97a44ddd><span class="link-text" data-v-63c070bf>随机操作 (Random)</span></a><a class="VPLink link link" href="/api/utils/misc.html" style="padding-left:0px;" data-v-63c070bf data-v-97a44ddd><span class="link-text" data-v-63c070bf>其他工具 (Misc)</span></a></div></section></div><div class="vp-sidebar-group"><section class="VPSidebarGroup" data-v-a094e895><div class="title" data-v-a094e895><h2 class="title-text" data-v-a094e895>测试工具</h2><div class="action" data-v-a094e895><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewbox="0 0 24 24" class="icon minus" data-v-a094e895><path d="M19,2H5C3.3,2,2,3.3,2,5v14c0,1.7,1.3,3,3,3h14c1.7,0,3-1.3,3-3V5C22,3.3,20.7,2,19,2zM20,19c0,0.6-0.4,1-1,1H5c-0.6,0-1-0.4-1-1V5c0-0.6,0.4-1,1-1h14c0.6,0,1,0.4,1,1V19z"></path><path d="M16,11H8c-0.6,0-1,0.4-1,1s0.4,1,1,1h8c0.6,0,1-0.4,1-1S16.6,11,16,11z"></path></svg><svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24" class="icon plus" data-v-a094e895><path d="M19,2H5C3.3,2,2,3.3,2,5v14c0,1.7,1.3,3,3,3h14c1.7,0,3-1.3,3-3V5C22,3.3,20.7,2,19,2z M20,19c0,0.6-0.4,1-1,1H5c-0.6,0-1-0.4-1-1V5c0-0.6,0.4-1,1-1h14c0.6,0,1,0.4,1,1V19z"></path><path d="M16,11h-3V8c0-0.6-0.4-1-1-1s-1,0.4-1,1v3H8c-0.6,0-1,0.4-1,1s0.4,1,1,1h3v3c0,0.6,0.4,1,1,1s1-0.4,1-1v-3h3c0.6,0,1-0.4,1-1S16.6,11,16,11z"></path></svg></div></div><div class="items" data-v-a094e895><a class="VPLink link link" href="/api/testing/" style="padding-left:0px;" data-v-63c070bf data-v-97a44ddd><span class="link-text" data-v-63c070bf>模拟环境 (Mock)</span></a></div></section></div></nav></aside></div><div style="display:none;" class="el-scrollbar__bar is-horizontal"><div class="el-scrollbar__thumb" style="width:0;transform:translateX(0%);"></div></div><div style="display:none;" class="el-scrollbar__bar is-vertical"><div class="el-scrollbar__thumb" style="height:0;transform:translateY(0%);"></div></div></div><div id="VPContent" class="has-sidebar VPContent" data-v-92d87297><div class="VPDoc has-sidebar has-aside" data-v-92d87297 data-v-6b6fcb79><div class="container" data-v-6b6fcb79><div class="aside" data-v-6b6fcb79><div class="aside-curtain" data-v-6b6fcb79></div><div class="aside-container" data-v-6b6fcb79><div class="aside-content" data-v-6b6fcb79><div class="VPDocAside" data-v-6b6fcb79 data-v-c8158c08><div class="VPDocAsideOutline" data-v-c8158c08 data-v-1c535019><div class="content" data-v-1c535019><div class="outline-marker" data-v-1c535019></div><div class="outline-title" data-v-1c535019>目录</div><nav aria-labelledby="doc-outline-aria-label" data-v-1c535019><span class="visually-hidden" id="doc-outline-aria-label" data-v-1c535019> Table of Contents for current page </span><ul class="root" data-v-1c535019 data-v-f1f7b818></ul></nav></div></div><div class="spacer" data-v-c8158c08></div></div></div></div></div><div class="content" data-v-6b6fcb79><div class="content-container" data-v-6b6fcb79><main class="main" data-v-6b6fcb79><div style="position:relative;" class="vp-doc _api_core_bot" data-v-6b6fcb79><div><h1 id="机器人" tabindex="-1">机器人 (Bot) <a class="header-anchor" href="#机器人" aria-hidden="true">#</a></h1><p><strong>机器人 (Bot)</strong> 是适配器的核心,它将不同平台的 API 封装成统一的格式供 Koishi 使用。而不同的适配器也可以自行扩展 Bot 实例上的属性和方法。</p><p>标有 <span class="badge tip" style="" data-v-247eb287>内置</span> 的 API 已经由 @koishijs/core 提供,适配器可以覆盖对应的方法,但是无需自行实现。</p><h2 id="构造函数选项" tabindex="-1">构造函数选项 <a class="header-anchor" href="#构造函数选项" aria-hidden="true">#</a></h2><p>不同的适配器可能对应了不同的 Bot 配置项,但是有一些配置项是公用的:</p><h3 id="options-protocol" tabindex="-1">options.protocol <a class="header-anchor" href="#options-protocol" aria-hidden="true">#</a></h3><ul><li>类型: <code>string</code></li></ul><p>部分适配器可能提供了多种协议实现,此时你可能需要指定一个协议。</p><h3 id="options-platform" tabindex="-1">options.platform <a class="header-anchor" href="#options-platform" aria-hidden="true">#</a></h3><ul><li>类型: <code>string</code></li></ul><p>要使用的用户数据字段名称。默认情况下你可以使用适配器名作为字段访问到你的账号,但是对于同一个适配器连接多个服务器的情况,你可能需要对各自账户做出区分。配置不同的 platform 可以确保不会出现串数据的情况。</p><h2 id="实例属性" tabindex="-1">实例属性 <a class="header-anchor" href="#实例属性" aria-hidden="true">#</a></h2><h3 id="bot-config" tabindex="-1">bot.config <a class="header-anchor" href="#bot-config" aria-hidden="true">#</a></h3><ul><li>类型: <code>object</code></li></ul><p>构造 Bot 实例时所使用的配置项。</p><h3 id="bot-app" tabindex="-1">bot.app <a class="header-anchor" href="#bot-app" aria-hidden="true">#</a></h3><ul><li>类型: <a href="./context.html"><code>Context</code></a></li></ul><p>当前 Bot 所在的根 <a href="./context.html">Context</a> 实例。</p><h3 id="bot-adapter" tabindex="-1">bot.adapter <a class="header-anchor" href="#bot-adapter" aria-hidden="true">#</a></h3><ul><li>类型: <a href="./adapter.html"><code>Adapter</code></a></li></ul><p>当前 Bot 所在的 <a href="./adapter.html">Adapter</a> 实例。</p><h3 id="bot-platform" tabindex="-1">bot.platform <a class="header-anchor" href="#bot-platform" aria-hidden="true">#</a></h3><ul><li>类型: <code>string</code></li></ul><p>当前 Bot 的平台名称,会受到 <a href="#options-platform">options.platform</a> 影响。</p><h3 id="bot-username" tabindex="-1">bot.username <a class="header-anchor" href="#bot-username" aria-hidden="true">#</a></h3><ul><li>类型: <code>string</code></li></ul><p>当前 Bot 的用户名。</p><h3 id="bot-selfid" tabindex="-1">bot.selfId <a class="header-anchor" href="#bot-selfid" aria-hidden="true">#</a></h3><ul><li>类型: <code>string</code></li></ul><p>当前 Bot 的平台账号。</p><h3 id="bot-sid" tabindex="-1">bot.sid <a class="header-anchor" href="#bot-sid" aria-hidden="true">#</a></h3><ul><li>类型: <code>string</code></li></ul><p>当前 Bot 的唯一标识符。</p><h3 id="bot-status" tabindex="-1">bot.status <a class="header-anchor" href="#bot-status" aria-hidden="true">#</a></h3><ul><li>可选值: online, offline, connect, disconnect, reconnect</li></ul><p>当前 Bot 的运行状态。</p><h2 id="处理消息" tabindex="-1">处理消息 <a class="header-anchor" href="#处理消息" aria-hidden="true">#</a></h2><h3 id="bot-sendmessage" tabindex="-1">bot.sendMessage(channelId, content, guildId?) <a class="header-anchor" href="#bot-sendmessage" aria-hidden="true">#</a></h3><ul><li><strong>channelId:</strong> <code>string</code> 频道 ID</li><li><strong>content:</strong> <code>string</code> 要发送的内容</li><li><strong>guildId:</strong> <code>string</code> 群组 ID</li><li>返回值: <code>Promise<string[]></code> 发送的消息 ID</li></ul><p>向特定频道发送消息。</p><h3 id="bot-sendprivatemessage" tabindex="-1">bot.sendPrivateMessage(userId, content) <a class="header-anchor" href="#bot-sendprivatemessage" aria-hidden="true">#</a></h3><ul><li><strong>userId:</strong> <code>string</code> 对方 ID</li><li><strong>content:</strong> <code>string</code> 要发送的内容</li><li>返回值: <code>Promise<string[]></code> 发送的消息 ID</li></ul><p>向特定用户发送私聊消息。</p><h3 id="bot-getmessage" tabindex="-1">bot.getMessage(channelId, messageId) <a class="header-anchor" href="#bot-getmessage" aria-hidden="true">#</a></h3><ul><li><strong>channelId:</strong> <code>string</code> 频道 ID</li><li><strong>messageId:</strong> <code>string</code> 消息 ID</li><li>返回值: <code>Promise<MessageInfo></code></li></ul><p>获取特定消息。</p><div class="language-ts"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre><code><span class="line"><span style="color:var(--shiki-token-keyword);">export</span><span style="color:var(--shiki-token-text);"> </span><span style="color:var(--shiki-token-keyword);">interface</span><span style="color:var(--shiki-token-text);"> </span><span style="color:var(--shiki-token-constant);">MessageInfo</span><span style="color:var(--shiki-token-text);"> {</span></span> |