1"use strict";(self.webpackChunknonebot=self.webpackChunknonebot||[]).push([["3750"],{60392(n,e,l){l.r(e),l.d(e,{metadata:()=>i,default:()=>t,frontMatter:()=>c,contentTitle:()=>o,toc:()=>h,assets:()=>r});var i=JSON.parse('{"id":"api/plugin/index","title":"nonebot.plugin","description":"nonebot.plugin \u6A21\u5757","source":"@site/docs/api/plugin/index.md","sourceDirName":"api/plugin","slug":"/api/plugin/","permalink":"/docs/next/api/plugin/","draft":false,"unlisted":false,"editUrl":"https://github.com/nonebot/nonebot2/edit/master/website/docs/api/plugin/index.md","tags":[],"version":"current","lastUpdatedBy":null,"lastUpdatedAt":null,"sidebarPosition":0,"frontMatter":{"mdx":{"format":"md"},"sidebar_position":0,"description":"nonebot.plugin \u6A21\u5757"},"sidebar":"api","previous":{"title":"nonebot.typing","permalink":"/docs/next/api/typing"},"next":{"title":"nonebot.plugin.load","permalink":"/docs/next/api/plugin/load"}}'),d=l(62540),s=l(43023);let c={mdx:{format:"md"},sidebar_position:0,description:"nonebot.plugin \u6A21\u5757"},o="nonebot.plugin",r={},h=[{value:"\u5FEB\u6377\u5BFC\u5165",id:"\u5FEB\u6377\u5BFC\u5165",level:2},{value:"<em>def</em> <code>get_plugin(plugin_id)</code>",id:"get-plugin",level:2},{value:"<em>def</em> <code>get_plugin_by_module_name(module_name)</code>",id:"get-plugin-by-module-name",level:2},{value:"<em>def</em> <code>get_loaded_plugins()</code>",id:"get-loaded-plugins",level:2},{value:"<em>def</em> <code>get_available_plugin_names()</code>",id:"get-available-plugin-names",level:2},{value:"<em>def</em> <code>get_plugin_config(config)</code>",id:"get-plugin-config",level:2}];function x(n){let e={a:"a",code:"code",em:"em",h1:"h1",h2:"h2",header:"header",li:"li",p:"p",strong:"strong",ul:"ul",...(0,s.R)(),...n.components};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(e.header,{children:(0,d.jsx)(e.h1,{id:"nonebotplugin",children:"nonebot.plugin"})}),"\n",(0,d.jsx)(e.p,{children:"\u672C\u6A21\u5757\u4E3A NoneBot \u63D2\u4EF6\u5F00\u53D1\u63D0\u4F9B\u4FBF\u643A\u7684\u5B9A\u4E49\u51FD\u6570\u3002"}),"\n",(0,d.jsx)(e.h2,{id:"\u5FEB\u6377\u5BFC\u5165",children:"\u5FEB\u6377\u5BFC\u5165"}),"\n",(0,d.jsx)(e.p,{children:"\u4E3A\u65B9\u4FBF\u4F7F\u7528\uFF0C\u672C\u6A21\u5757\u4ECE\u5B50\u6A21\u5757\u5BFC\u5165\u4E86\u90E8\u5206\u5185\u5BB9\uFF0C\u4EE5\u4E0B\u5185\u5BB9\u53EF\u4EE5\u76F4\u63A5\u901A\u8FC7\u672C\u6A21\u5757\u5BFC\u5165:"}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsxs)(e.li,{children:[(0,d.jsx)(e.code,{children:"on"})," => ",(0,d.jsx)(e.a,{href:"/docs/next/api/plugin/on#on",children:(0,d.jsx)(e.code,{children:"on"})})]}),"\n",(0,d.jsxs)(e.li,{children:[(0,d.jsx)(e.code,{children:"on_metaevent"})," => ",(0,d.jsx)(e.a,{href:"/docs/next/api/plugin/on#on-metaevent",children:(0,d.jsx)(e.code,{children:"on_metaevent"})})]}),"\n",(0,d.jsxs)(e.li,{children:[(0,d.jsx)(e.code,{children:"on_message"})," => ",(0,d.jsx)(e.a,{href:"/docs/next/api/plugin/on#on-message",children:(0,d.jsx)(e.code,{children:"on_message"})})]}),"\n",(0,d.jsxs)(e.li,{children:[(0,d.jsx)(e.code,{children:"on_notice"})," => ",(0,d.jsx)(e.a,{href:"/docs/next/api/plugin/on#on-notice",children:(0,d.jsx)(e.code,{children:"on_notice"})})]}),"\n",(0,d.jsxs)(e.li,{children:[(0,d.jsx)(e.code,{children:"on_request"})," => ",(0,d.jsx)(e.a,{href:"/docs/next/api/plugin/on#on-request",children:(0,d.jsx)(e.code,{children:"on_request"})})]}),"\n",(0,d.jsxs)(e.li,{children:[(0,d.jsx)(e.code,{children:"on_startswith"})," => ",(0,d.jsx)(e.a,{href:"/docs/next/api/plugin/on#on-startswith",children:(0,d.jsx)(e.code,{children:"on_startswith"})})]}),"\n",(0,d.jsxs)(e.li,{children:[(0,d.jsx)(e.code,{children:"on_endswith"})," => ",(0,d.jsx)(e.a,{href:"/docs/next/api/plugin/on#on-endswith",children:(0,d.jsx)(e.code,{children:"on_endswith"})})]}),"\n",(0,d.jsxs)(e.li,{children:[(0,d.jsx)(e.code,{children:"on_fullmatch"})," => ",(0,d.jsx)(e.a,{href:"/docs/next/api/plugin/on#on-fullmatch",children:(0,d.jsx)(e.code,{children:"on_fullmatch"})})]}),"\n",(0,d.jsxs)(e.li,{children:[(0,d.jsx)(e.code,{children:"on_keyword"})," => ",(0,d.jsx)(e.a,{href:"/docs/next/api/plugin/on#on-keyword",children:(0,d.jsx)(e.code,{children:"on_keyword"})})]}),"\n",(0,d.jsxs)(e.li,{children:[(0,d.jsx)(e.code,{children:"on_command"})," => ",(0,d.jsx)(e.a,{href:"/docs/next/api/plugin/on#on-command",children:(0,d.jsx)(e.code,{children:"on_command"})})]}),"\n",(0,d.jsxs)(e.li,{children:[(0,d.jsx)(e.code,{children:"on_shell_command"})," => ",(0,d.jsx)(e.a,{href:"/docs/next/api/plugin/on#on-shell-command",children:(0,d.jsx)(e.code,{children:"on_shell_command"})})]}),"\n",(0,d.jsxs)(e.li,{children:[(0,d.jsx)(e.code,{children:"on_regex"})," => ",(0,d.jsx)(e.a,{href:"/docs/next/api/plugin/on#on-regex",children:(0,d.jsx)(e.code,{children:"on_regex"})})]}),"\n",(0,d.jsxs)(e.li,{children:[(0,d.jsx)(e.code,{children:"on_type"})," => ",(0,d.jsx)(e.a,{href:"/docs/next/api/plugin/on#on-type",children:(0,d.jsx)(e.code,{children:"on_type"})})]}),"\n",(0,d.jsxs)(e.li,{children:[(0,d.jsx)(e.code,{children:"CommandGroup"})," => ",(0,d.jsx)(e.a,{href:"/docs/next/api/plugin/on#CommandGroup",children:(0,d.jsx)(e.code,{children:"CommandGroup"})})]}),"\n",(0,d.jsxs)(e.li,{children:[(0,d.jsx)(e.code,{children:"Matchergroup"})," => ",(0,d.jsx)(e.a,{href:"/docs/next/api/plugin/on#MatcherGroup",children:(0,d.jsx)(e.code,{children:"MatcherGroup"})})]}),"\n",(0,d.jsxs)(e.li,{children:[(0,d.jsx)(e.code,{children:"load_plugin"})," => ",(0,d.jsx)(e.a,{href:"/docs/next/api/plugin/load#load-plugin",children:(0,d.jsx)(e.code,{children:"load_plugin"})})]}),"\n",(0,d.jsxs)(e.li,{children:[(0,d.jsx)(e.code,{children:"load_plugins"})," => ",(0,d.jsx)(e.a,{href:"/docs/next/api/plugin/load#load-plugins",children:(0,d.jsx)(e.code,{children:"load_plugins"})})]}),"\n",(0,d.jsxs)(e.li,{children:[(0,d.jsx)(e.code,{children:"load_all_plugins"})," => ",(0,d.jsx)(e.a,{href:"/docs/next/api/plugin/load#load-all-plugins",children:(0,d.jsx)(e.code,{children:"load_all_plugins"})})]}),"\n",(0,d.jsxs)(e.li,{children:[(0,d.jsx)(e.code,{children:"load_from_json"})," => ",(0,d.jsx)(e.a,{href:"/docs/next/api/plugin/load#load-from-json",children:(0,d.jsx)(e.code,{children:"load_from_json"})})]}),"\n",(0,d.jsxs)(e.li,{children:[(0,d.jsx)(e.code,{children:"load_from_toml"})," => ",(0,d.jsx)(e.a,{href:"/docs/next/api/plugin/load#load-from-toml",children:(0,d.jsx)(e.code,{children:"load_from_toml"})})]}),"\n",(0,d.jsxs)(e.li,{children:[(0,d.jsx)(e.code,{children:"load_builtin_plugin"})," =>\n",(0,d.jsx)(e.a,{href:"/docs/next/api/plugin/load#load-builtin-plugin",children:(0,d.jsx)(e.code,{children:"load_builtin_plugin"})})]}),"\n",(0,d.jsxs)(e.li,{children:[(0,d.jsx)(e.code,{children:"load_builtin_plugins"})," =>\n",(0,d.jsx)(e.a,{href:"/docs/next/api/plugin/load#load-builtin-plugins",children:(0,d.jsx)(e.code,{children:"load_builtin_plugins"})})]}),"\n",(0,d.jsxs)(e.li,{children:[(0,d.jsx)(e.code,{children:"require"})," => ",(0,d.jsx)(e.a,{href:"/docs/next/api/plugin/load#require",children:(0,d.jsx)(e.code,{children:"require"})})]}),"\n",(0,d.jsxs)(e.li,{children:[(0,d.jsx)(e.code,{children:"PluginMetadata"})," => ",(0,d.jsx)(e.a,{href:"/docs/next/api/plugin/model#PluginMetadata",children:(0,d.jsx)(e.code,{children:"PluginMetadata"})})]}),"\n"]}),"\n",(0,d.jsxs)(e.h2,{id:"get-plugin",children:[(0,d.jsx)(e.em,{children:"def"})," ",(0,d.jsx)(e.code,{children:"get_plugin(plugin_id)"})]}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsxs)(e.li,{children:["\n",(0,d.jsx)(e.p,{children:(0,d.jsx)(e.strong,{children:"\u8BF4\u660E"})}),"\n",(0,d.jsx)(e.p,{children:"\u83B7\u53D6\u5DF2\u7ECF\u5BFC\u5165\u7684\u67D0\u4E2A\u63D2\u4EF6\u3002"}),"\n",(0,d.jsxs)(e.p,{children:["\u5982\u679C\u4E3A ",(0,d.jsx)(e.code,{children:"load_plugins"})," \u6587\u4EF6\u5939\u5BFC\u5165\u7684\u63D2\u4EF6\uFF0C\u5219\u4E3A\u6587\u4EF6(\u5939)\u540D\u3002"]}),"\n",(0,d.jsxs)(e.p,{children:["\u5982\u679C\u4E3A\u5D4C\u5957\u7684\u5B50\u63D2\u4EF6\uFF0C\u6807\u8BC6\u7B26\u4E3A ",(0,d.jsx)(e.code,{children:"\u7236\u63D2\u4EF6\u6807\u8BC6\u7B26:\u5B50\u63D2\u4EF6\u6587\u4EF6(\u5939)\u540D"}),"\u3002"]}),"\n"]}),"\n",(0,d.jsxs)(e.li,{children:["\n",(0,d.jsx)(e.p,{children:(0,d.jsx)(e.strong,{children:"\u53C2\u6570"})}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsxs)(e.li,{children:[(0,d.jsx)(e.code,{children:"plugin_id"})," (str): \u63D2\u4EF6\u6807\u8BC6\u7B26\uFF0C\u5373 ",(0,d.jsx)(e.a,{href:"/docs/next/api/plugin/model#Plugin-id-",children:"Plugin.id_"}),"\u3002"]}),"\n"]}),"\n"]}),"\n",(0,d.jsxs)(e.li,{children:["\n",(0,d.jsx)(e.p,{children:(0,d.jsx)(e.strong,{children:"\u8FD4\u56DE"})}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsxs)(e.li,{children:[(0,d.jsx)(e.a,{href:"/docs/next/api/plugin/model#Plugin",children:"Plugin"})," | None"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,d.jsxs)(e.h2,{id:"get-plugin-by-module-name",children:[(0,d.jsx)(e.em,{children:"def"})," ",(0,d.jsx)(e.code,{children:"get_plugin_by_module_name(module_name)"})]}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsxs)(e.li,{children:["\n",(0,d.jsx)(e.p,{children:(0,d.jsx)(e.strong,{children:"\u8BF4\u660E"})}
1),"\n",(0,d.jsx)(e.p,{children:"\u901A\u8FC7\u6A21\u5757\u540D\u83B7\u53D6\u5DF2\u7ECF\u5BFC\u5165\u7684\u67D0\u4E2A\u63D2\u4EF6\u3002"}),"\n",(0,d.jsx)(e.p,{children:"\u5982\u679C\u63D0\u4F9B\u7684\u6A21\u5757\u540D\u4E3A\u67D0\u4E2A\u63D2\u4EF6\u7684\u5B50\u6A21\u5757\uFF0C\u540C\u6837\u4F1A\u8FD4\u56DE\u8BE5\u63D2\u4EF6\u3002"}),"\n"]}),"\n",(0,d.jsxs)(e.li,{children:["\n",(0,d.jsx)(e.p,{children:(0,d.jsx)(e.strong,{children:"\u53C2\u6570"})}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsxs)(e.li,{children:[(0,d.jsx)(e.code,{children:"module_name"})," (str): \u6A21\u5757\u540D\uFF0C\u5373 ",(0,d.jsx)(e.a,{href:"/docs/next/api/plugin/model#Plugin-module-name",children:"Plugin.module_name"}),"\u3002"]}),"\n"]}),"\n"]}),"\n",(0,d.jsxs)(e.li,{children:["\n",(0,d.jsx)(e.p,{children:(0,d.jsx)(e.strong,{children:"\u8FD4\u56DE"})}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsxs)(e.li,{children:[(0,d.jsx)(e.a,{href:"/docs/next/api/plugin/model#Plugin",children:"Plugin"})," | None"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,d.jsxs)(e.h2,{id:"get-loaded-plugins",children:[(0,d.jsx)(e.em,{children:"def"})," ",(0,d.jsx)(e.code,{children:"get_loaded_plugins()"})]}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsxs)(e.li,{children:["\n",(0,d.jsxs)(e.p,{children:[(0,d.jsx)(e.strong,{children:"\u8BF4\u660E:"})," \u83B7\u53D6\u5F53\u524D\u5DF2\u5BFC\u5165\u7684\u6240\u6709\u63D2\u4EF6\u3002"]}),"\n"]}),"\n",(0,d.jsxs)(e.li,{children:["\n",(0,d.jsx)(e.p,{children:(0,d.jsx)(e.strong,{children:"\u53C2\u6570"})}),"\n",(0,d.jsx)(e.p,{children:"empty"}),"\n"]}),"\n",(0,d.jsxs)(e.li,{children:["\n",(0,d.jsx)(e.p,{children:(0,d.jsx)(e.strong,{children:"\u8FD4\u56DE"})}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsxs)(e.li,{children:["set[",(0,d.jsx)(e.a,{href:"/docs/next/api/plugin/model#Plugin",children:"Plugin"}),"]"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,d.jsxs)(e.h2,{id:"get-available-plugin-names",children:[(0,d.jsx)(e.em,{children:"def"})," ",(0,d.jsx)(e.code,{children:"get_available_plugin_names()"})]}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsxs)(e.li,{children:["\n",(0,d.jsxs)(e.p,{children:[(0,d.jsx)(e.strong,{children:"\u8BF4\u660E:"})," \u83B7\u53D6\u5F53\u524D\u6240\u6709\u53EF\u7528\u7684\u63D2\u4EF6\u6807\u8BC6\u7B26\uFF08\u5305\u542B\u5C1A\u672A\u52A0\u8F7D\u7684\u63D2\u4EF6\uFF09\u3002"]}),"\n"]}),"\n",(0,d.jsxs)(e.li,{children:["\n",(0,d.jsx)(e.p,{children:(0,d.jsx)(e.strong,{children:"\u53C2\u6570"})}),"\n",(0,d.jsx)(e.p,{children:"empty"}),"\n"]}),"\n",(0,d.jsxs)(e.li,{children:["\n",(0,d.jsx)(e.p,{children:(0,d.jsx)(e.strong,{children:"\u8FD4\u56DE"})}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsx)(e.li,{children:"set[str]"}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,d.jsxs)(e.h2,{id:"get-plugin-config",children:[(0,d.jsx)(e.em,{children:"def"})," ",(0,d.jsx)(e.code,{children:"get_plugin_config(config)"})]}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsxs)(e.li,{children:["\n",(0,d.jsxs)(e.p,{children:[(0,d.jsx)(e.strong,{children:"\u8BF4\u660E:"})," \u4ECE\u5168\u5C40\u914D\u7F6E\u83B7\u53D6\u5F53\u524D\u63D2\u4EF6\u9700\u8981\u7684\u914D\u7F6E\u9879\u3002"]}),"\n"]}),"\n",(0,d.jsxs)(e.li,{children:["\n",(0,d.jsx)(e.p,{children:(0,d.jsx)(e.strong,{children:"\u53C2\u6570"})}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsxs)(e.li,{children:[(0,d.jsx)(e.code,{children:"config"})," (type[C])"]}),"\n"]}),"\n"]}),"\n",(0,d.jsxs)(e.li,{children:["\n",(0,d.jsx)(e.p,{children:(0,d.jsx)(e.strong,{children:"\u8FD4\u56DE"})}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsx)(e.li,{children:"C"}),"\n"]}),"\n"]}),"\n"]})]})}function t(n={}){let{wrapper:e}={...(0,s.R)(),...n.components};return e?(0,d.jsx)(e,{...n,children:(0,d.jsx)(x,{...n})}):x(n)}},43023(n,e,l){l.d(e,{R:()=>c,x:()=>o});var i=l(63696);let d={},s=i.createContext(d);function c(n){let e=i.useContext(s);return i.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function o(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(d):n.components||d:c(n.components),i.createElement(s.Provider,{value:e},n.children)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.