PageSourceSearch

https://nonebot.dev/assets/js/ad38aa4a.4f992426.js

js nonebot.dev collected 2026-10-03 23:18:11 UTC 11,197 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunknonebot=self.webpackChunknonebot||[]).push([["2247"],{48942(e,n,s){s.r(n),s.d(n,{metadata:()=>r,default:()=>x,frontMatter:()=>d,contentTitle:()=>l,toc:()=>t,assets:()=>o});var r=JSON.parse('{"id":"api/message","title":"nonebot.message","description":"nonebot.message \u6A21\u5757","source":"@site/versioned_docs/version-2.5.0/api/message.md","sourceDirName":"api","slug":"/api/message","permalink":"/docs/api/message","draft":false,"unlisted":false,"editUrl":"https://github.com/nonebot/nonebot2/edit/master/website/versioned_docs/version-2.5.0/api/message.md","tags":[],"version":"2.5.0","lastUpdatedBy":"noneflow[bot]","lastUpdatedAt":1775014365000,"sidebarPosition":2,"frontMatter":{"mdx":{"format":"md"},"sidebar_position":2,"description":"nonebot.message \u6A21\u5757"},"sidebar":"api","previous":{"title":"nonebot.config","permalink":"/docs/api/config"},"next":{"title":"nonebot.matcher","permalink":"/docs/api/matcher"}}'),c=s(62540),i=s(43023);let d={mdx:{format:"md"},sidebar_position:2,description:"nonebot.message \u6A21\u5757"},l="nonebot.message",o={},t=[{value:"<em>def</em> <code>event_preprocessor(func)</code>",id:"event-preprocessor",level:2},{value:"<em>def</em> <code>event_postprocessor(func)</code>",id:"event-postprocessor",level:2},{value:"<em>def</em> <code>run_preprocessor(func)</code>",id:"run-preprocessor",level:2},{value:"<em>def</em> <code>run_postprocessor(func)</code>",id:"run-postprocessor",level:2},{value:"<em>async def</em> <code>check_and_run_matcher(Matcher, bot, event, state, stack=None, dependency_cache=None)</code>",id:"check-and-run-matcher",level:2},{value:"<em>async def</em> <code>handle_event(bot, event)</code>",id:"handle-event",level:2}];function h(e){let n={a:"a",code:"code",em:"em",h1:"h1",h2:"h2",header:"header",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,i.R)(),...e.components};return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(n.header,{children:(0,c.jsx)(n.h1,{id:"nonebotmessage",children:"nonebot.message"})}),"\n",(0,c.jsx)(n.p,{children:"\u672C\u6A21\u5757\u5B9A\u4E49\u4E86\u4E8B\u4EF6\u5904\u7406\u4E3B\u8981\u6D41\u7A0B\u3002"}),"\n",(0,c.jsx)(n.p,{children:"NoneBot \u5185\u90E8\u5904\u7406\u5E76\u6309\u4F18\u5148\u7EA7\u5206\u53D1\u4E8B\u4EF6\u7ED9\u
16240\u6709\u4E8B\u4EF6\u54CD\u5E94\u5668\uFF0C\u63D0\u4F9B\u4E86\u591A\u4E2A\u63D2\u69FD\u4EE5\u8FDB\u884C\u4E8B\u4EF6\u7684\u9884\u5904\u7406\u7B49\u3002"}),"\n",(0,c.jsxs)(n.h2,{id:"event-preprocessor",children:[(0,c.jsx)(n.em,{children:"def"})," ",(0,c.jsx)(n.code,{children:"event_preprocessor(func)"})]}),"\n",(0,c.jsxs)(n.ul,{children:["\n",(0,c.jsxs)(n.li,{children:["\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.strong,{children:"\u8BF4\u660E"})}),"\n",(0,c.jsx)(n.p,{children:"\u4E8B\u4EF6\u9884\u5904\u7406\u3002"}),"\n",(0,c.jsx)(n.p,{children:"\u88C5\u9970\u4E00\u4E2A\u51FD\u6570\uFF0C\u4F7F\u5B83\u5728\u6BCF\u6B21\u63A5\u6536\u5230\u4E8B\u4EF6\u5E76\u5206\u53D1\u7ED9\u5404\u54CD\u5E94\u5668\u4E4B\u524D\u6267\u884C\u3002"}),"\n"]}),"\n",(0,c.jsxs)(n.li,{children:["\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.strong,{children:"\u53C2\u6570"})}),"\n",(0,c.jsxs)(n.ul,{children:["\n",(0,c.jsxs)(n.li,{children:[(0,c.jsx)(n.code,{children:"func"})," (",(0,c.jsx)(n.a,{href:"/docs/api/typing#T-EventPreProcessor",children:"T_EventPreProcessor"}),")"]}),"\n"]}),"\n"]}),"\n",(0,c.jsxs)(n.li,{children:["\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.strong,{children:"\u8FD4\u56DE"})}),"\n",(0,c.jsxs)(n.ul,{children:["\n",(0,c.jsx)(n.li,{children:(0,c.jsx)(n.a,{href:"/docs/api/typing#T-EventPreProcessor",children:"T_EventPreProcessor"})}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,c.jsxs)(n.h2,{id:"event-postprocessor",children:[(0,c.jsx)(n.em,{children:"def"})," ",(0,c.jsx)(n.code,{children:"event_postprocessor(func)"})]}),"\n",(0,c.jsxs)(n.ul,{children:["\n",(0,c.jsxs)(n.li,{children:["\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.strong,{children:"\u8BF4\u660E"})}),"\n",(0,c.jsx)(n.p,{children:"\u4E8B\u4EF6\u540E\u5904\u7406\u3002"}),"\n",(0,c.jsx)(n.p,{children:"\u88C5\u9970\u4E00\u4E2A\u51FD\u6570\uFF0C\u4F7F\u5B83\u5728\u6BCF\u6B21\u63A5\u6536\u5230\u4E8B\u4EF6\u5E76\u5206\u53D1\u7ED9\u5404\u54CD\u5E94\u5668\u4E4B\u540E\u6267\u884C\u3002"}),"\n"]}),"\n",(0,c.jsxs)(n.li,{children:["\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.strong,{children:"\u53C2\u6570"})}),"\n",(0,c.jsxs)(n.ul,{children:["\n",(0,c.jsxs)(n.li,{children:[(0,c.jsx)(n.code,{children:"func"})," (",(0,c.jsx)(n.a,{href:"/docs/api/typing#T-EventPostProcessor",children:"T_EventPostProcessor"}),")"]}),"\n"]}),"\n"]}),"\n",(0,c.jsxs)(n.li,{children:["\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.strong,{children:"\u8FD4\u56DE"})}),"\n",(0,c.jsxs)(n.ul,{children:["\n",(0,c.jsx)(n.li,{children:(0,c.jsx)(n.a,{href:"/docs/api/typing#T-EventPostProcessor",children:"T_EventPostProcessor"})}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,c.jsxs)(n.h2,{id:"run-preprocessor",children:[(0,c.jsx)(n.em,{children:"def"})," ",(0,c.jsx)(n.code,{children:"run_preprocessor(func)"})]}),"\n",(0,c.jsxs)(n.ul,{children:["\n",(0,c.jsxs)(n.li,{children:["\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.strong,{children:"\u8BF4\u660E"})}),"\n",(0,c.jsx)(n.p,{children:"\u8FD0\u884C\u9884\u5904\u7406\u3002"}),"\n",(0,c.jsx)(n.p,{children:"\u88C5\u9970\u4E00\u4E2A\u51FD\u6570\uFF0C\u4F7F\u5B83\u5728\u6BCF\u6B21\u4E8B\u4EF6\u54CD\u5E94\u5668\u8FD0\u884C\u524D\u6267\u884C\u3002"}),"\n"]}),"\n",(0,c.jsxs)(n.li,{children:["\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.strong,{children:"\u53C2\u6570"})}),"\n",(0,c.jsxs)(n.ul,{children:["\n",(0,c.jsxs)(n.li,{children:[(0,c.jsx)(n.code,{children:"func"})," (",(0,c.jsx)(n.a,{href:"/docs/api/typing#T-RunPreProcessor",children:"T_RunPreProcessor"}),")"]}),"\n"]}),"\n"]}),"\n",(0,c.jsxs)(n.li,{children:["\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.strong,{children:"\u8FD4\u56DE"})}),"\n",(0,c.jsxs)(n.ul,{children:["\n",(0,c.jsx)(n.li,{children:(0,c.jsx)(n.a,{href:"/docs/api/typing#T-RunPreProcessor",children:"T_RunPreProcessor"})}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,c.jsxs)(n.h2,{id:"run-postprocessor",children:[(0,c.jsx)(n.em,{children:"def"})," ",(0,c.jsx)(n.code,{children:"run_postprocessor(func)"})]}),"\n",(0,c.jsxs)(n.ul,{children:["\n",(0,c.jsxs)(n.li,{children:["\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.strong,{children:"\u8BF4\u660E"})}),"\n",(0,c.jsx)(n.p,{children:"\u8FD0\u884C\u540E\u5904\u7406\u3002"}),"\n",(0,c.jsx)(n.p,{children:"\u88C5\u9970\u4E00\u4E2A\u51FD\u6570\uFF0C\u4F7F\u5B83\u5728\u6BCF\u6B21\u4E8B\u4EF6\u54CD\u5E94\u5668\u8FD0\u884C\u540E\u6267\u884C\u3002"}),"\n"]}),"\n",(0,c.jsxs)(n.li,{children:["\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.strong,{children:"\u53C2\u6570"})}),"\n",(0,c.jsxs)(n.ul,{children:["\n",(0,c.jsxs)(n.li,{children:[(0,c.jsx)(n.code,{children:"func"})," (",(0,c.jsx)(n.a,{href:"/docs/api/typing#T-RunPostProcessor",children:"T_RunPostProcessor"}),")"]}),"\n"]}),"\n"]}),"\n",(0,c.jsxs)(n.li,{children:["\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.strong,{children:"\u8FD4\u56DE"})}),"\n",(0,c.jsxs)(n.ul,{children:["\n",(0,c.jsx)(n.li,{children:(0,c.jsx)(n.a,{href:"/docs/api/typing#T-RunPostProcessor",children:"T_RunPostProcessor"})}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,c.jsxs)(n.h2,{id:"check-and-run-matcher",children:[(0,c.jsx)(n.em,{children:"async def"})," ",(0,c.jsx)(n.code,{children:"check_and_run_matcher(Matcher, bot, event, state, stack=None, dependency_cache=None)"})]}),"\n",(0,c.jsxs)(n.ul,{children:["\n",(0,c.jsxs)(n.li,{children:["\n",(0,c.jsxs)(n.p,{children:[(0,c.jsx)(n.strong,{children:"\u8BF4\u660E:"})," \u68C0\u67E5\u5E76\u8FD0\u884C\u4E8B\u4EF6\u54CD\u5E94\u5668\u3002"]}),"\n"]}),"\n",(0,c.jsxs)(n.li,{children:["\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.strong,{children:"\u53C2\u6570"})}),"\n",(0,c.jsxs)(n.ul,{children:["\n",(0,c.jsxs)(n.li,{children:["\n",(0,c.jsxs)(n.p,{children:[(0,c.jsx)(n.code,{children:"Matcher"})," (type[",(0,c.jsx)(n.a,{href:"/docs/api/matcher#Matcher",children:"Matcher"}),"]): \u4E8B\u4EF6\u54CD\u5E94\u5668"]}),"\n"]}),"\n",(0,c.jsxs)(n.li,{children:["\n",(0,c.jsxs)(n.p,{children:[(0,c.jsx)(n.code,{children:"bot"}
1)," (",(0,c.jsx)(n.a,{href:"/docs/api/adapters/#Bot",children:"Bot"}),"): Bot \u5BF9\u8C61"]}),"\n"]}),"\n",(0,c.jsxs)(n.li,{children:["\n",(0,c.jsxs)(n.p,{children:[(0,c.jsx)(n.code,{children:"event"})," (",(0,c.jsx)(n.a,{href:"/docs/api/adapters/#Event",children:"Event"}),"): Event \u5BF9\u8C61"]}),"\n"]}),"\n",(0,c.jsxs)(n.li,{children:["\n",(0,c.jsxs)(n.p,{children:[(0,c.jsx)(n.code,{children:"state"})," (",(0,c.jsx)(n.a,{href:"/docs/api/typing#T-State",children:"T_State"}),"): \u4F1A\u8BDD\u72B6\u6001"]}),"\n"]}),"\n",(0,c.jsxs)(n.li,{children:["\n",(0,c.jsxs)(n.p,{children:[(0,c.jsx)(n.code,{children:"stack"})," (AsyncExitStack | None): \u5F02\u6B65\u4E0A\u4E0B\u6587\u6808"]}),"\n"]}),"\n",(0,c.jsxs)(n.li,{children:["\n",(0,c.jsxs)(n.p,{children:[(0,c.jsx)(n.code,{children:"dependency_cache"})," (",(0,c.jsx)(n.a,{href:"/docs/api/typing#T-DependencyCache",children:"T_DependencyCache"})," | None): \u4F9D\u8D56\u7F13\u5B58"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,c.jsxs)(n.li,{children:["\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.strong,{children:"\u8FD4\u56DE"})}),"\n",(0,c.jsxs)(n.ul,{children:["\n",(0,c.jsx)(n.li,{children:"None"}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,c.jsxs)(n.h2,{id:"handle-event",children:[(0,c.jsx)(n.em,{children:"async def"})," ",(0,c.jsx)(n.code,{children:"handle_event(bot, event)"})]}),"\n",(0,c.jsxs)(n.ul,{children:["\n",(0,c.jsxs)(n.li,{children:["\n",(0,c.jsxs)(n.p,{children:[(0,c.jsx)(n.strong,{children:"\u8BF4\u660E:"})," \u5904\u7406\u4E00\u4E2A\u4E8B\u4EF6\u3002\u8C03\u7528\u8BE5\u51FD\u6570\u4EE5\u5B9E\u73B0\u5206\u53D1\u4E8B\u4EF6\u3002"]}),"\n"]}),"\n",(0,c.jsxs)(n.li,{children:["\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.strong,{children:"\u53C2\u6570"})}),"\n",(0,c.jsxs)(n.ul,{children:["\n",(0,c.jsxs)(n.li,{children:["\n",(0,c.jsxs)(n.p,{children:[(0,c.jsx)(n.code,{children:"bot"})," (",(0,c.jsx)(n.a,{href:"/docs/api/adapters/#Bot",children:"Bot"}),"): Bot \u5BF9\u8C61"]}),"\n"]}),"\n",(0,c.jsxs)(n.li,{children:["\n",(0,c.jsxs)(n.p,{children:[(0,c.jsx)(n.code,{children:"event"})," (",(0,c.jsx)(n.a,{href:"/docs/api/adapters/#Event",children:"Event"}),"): Event \u5BF9\u8C61"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,c.jsxs)(n.li,{children:["\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.strong,{children:"\u8FD4\u56DE"})}),"\n",(0,c.jsxs)(n.ul,{children:["\n",(0,c.jsx)(n.li,{children:"None"}),"\n"]}),"\n"]}),"\n",(0,c.jsxs)(n.li,{children:["\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.strong,{children:"\u7528\u6CD5"})}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-python",children:"driver.task_group.start_soon(handle_event, bot, event)\n"})}),"\n"]}),"\n"]})]})}function x(e={}){let{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,c.jsx)(n,{...e,children:(0,c.jsx)(h,{...e})}):h(e)}},43023(e,n,s){s.d(n,{R:()=>d,x:()=>l});var r=s(63696);let c={},i=r.createContext(c);function d(e){let n=r.useContext(i);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(c):e.components||c:d(e.components),r.createElement(i.Provider,{value:n},e.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.