app/dev/api/bot/lifespan.html

129 lines
88 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html lang="zh-Hans" dir="ltr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>liteyuki.bot.lifespan | 轻雪机器人</title>
<meta name="description" content="一个综合性的机器人应用及管理框架">
<meta name="generator" content="VitePress v1.3.4">
<link rel="preload stylesheet" href="/assets/style.BNCNLzKP.css" as="style">
<script type="module" src="/assets/app.C0Sman5N.js"></script>
<link rel="preload" href="/assets/inter-roman-latin.Di8DUHzh.woff2" as="font" type="font/woff2" crossorigin="">
<link rel="modulepreload" href="/assets/chunks/theme.Cfwe0ZOB.js">
<link rel="modulepreload" href="/assets/chunks/framework.C3o_UkTa.js">
<link rel="modulepreload" href="/assets/dev_api_bot_lifespan.md.B_vxVvHa.lean.js">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="https://fonts.font.im/css?family=Cousine:400,400i,700,700i|Poppins:100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i">
<script id="check-dark-mode">(()=>{const e=localStorage.getItem("vitepress-theme-appearance")||"auto",a=window.matchMedia("(prefers-color-scheme: dark)").matches;(!e||e==="auto"?a:e==="dark")&&document.documentElement.classList.add("dark")})();</script>
<script id="check-mac-os">document.documentElement.classList.toggle("mac",/Mac|iPhone|iPod|iPad/i.test(navigator.platform));</script>
</head>
<body>
<div id="app"><div class="Layout" data-v-7e3343f7><!--[--><!--]--><!--[--><span tabindex="-1" data-v-a977b129></span><a href="#VPContent" class="VPSkipLink visually-hidden" data-v-a977b129> Skip to content </a><!--]--><!----><header class="VPNav" data-v-7e3343f7 data-v-d52d372b><div class="VPNavBar has-sidebar top" data-v-d52d372b data-v-37a6b570><div class="wrapper" data-v-37a6b570><div class="container" data-v-37a6b570><div class="title" data-v-37a6b570><div class="VPNavBarTitle has-sidebar" data-v-37a6b570 data-v-de953605><a class="title" href="/" data-v-de953605><!--[--><!--]--><!--[--><img class="VPImage logo" src="/liteyuki.svg" alt data-v-6e911b93><!--]--><span data-v-de953605>轻雪机器人</span><!--[--><!--]--></a></div></div><div class="content" data-v-37a6b570><div class="content-body" data-v-37a6b570><!--[--><!--]--><div class="VPNavBarSearch search" data-v-37a6b570><!--[--><!----><div id="local-search"><button type="button" class="DocSearch DocSearch-Button" aria-label="打开搜索框"><span class="DocSearch-Button-Container"><span class="vp-icon DocSearch-Search-Icon"></span><span class="DocSearch-Button-Placeholder">搜索文档</span></span><span class="DocSearch-Button-Keys"><kbd class="DocSearch-Button-Key"></kbd><kbd class="DocSearch-Button-Key">K</kbd></span></button></div><!--]--></div><nav aria-labelledby="main-nav-aria-label" class="VPNavBarMenu menu" data-v-37a6b570 data-v-71183eee><span id="main-nav-aria-label" class="visually-hidden" data-v-71183eee> Main Navigation </span><!--[--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/deploy/install.html" tabindex="0" data-v-71183eee data-v-c423e9f4><!--[--><span data-v-c423e9f4>部署</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/usage/basic.html" tabindex="0" data-v-71183eee data-v-c423e9f4><!--[--><span data-v-c423e9f4>使用</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/store/resource.html" tabindex="0" data-v-71183eee data-v-c423e9f4><!--[--><span data-v-c423e9f4>扩展</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/dev/api.html" tabindex="0" data-v-71183eee data-v-c423e9f4><!--[--><span data-v-c423e9f4>开发</span><!--]--></a><!--]--><!--]--></nav><div class="VPFlyout VPNavBarTranslations translations" data-v-37a6b570 data-v-d3047050 data-v-12ec5ee2><button type="button" class="button" aria-haspopup="true" aria-expanded="false" aria-label="Change language" data-v-12ec5ee2><span class="text" data-v-12ec5ee2><span class="vpi-languages option-icon" data-v-12ec5ee2></span><!----><span class="vpi-chevron-down text-icon" data-v-12ec5ee2></span></span></button><div class="menu" data-v-12ec5ee2><div class="VPMenu" data-v-12ec5ee2 data-v-0e22c6c5><!----><!--[--><!--[--><div class="items" data-v-d3047050><p class="title" data-v-d3047050>简体中文</p><!--[--><div class="VPMenuLink" data-v-d3047050 data-v-19363427><a class="VPLink link" href="/en/dev/api/bot/lifespan.html" data-v-19363427><!--[-->English<!--]--></a></div><!--]--></div><!--]--><!--]--></div></div></div><div class="VPNavBarAppearance appearance" data-v-37a6b570 data-v-0a1958c9><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title="Switch to dark theme" aria-checked="false" data-v-0a1958c9 data-v-0f382965 data-v-b19619af><span class="check" data-v-b19619af><span class="icon" data-v-b19619af><!--[--><span class="vpi-sun sun" data-v-0f382965></span><span class="vpi-moon moon" data-v-0f382965></span><!--]--></span></span></button></div><div class="VPSocialLinks VPNavBarSocialLinks social-links" data-v-37a6b570 data-v-edaebeb1 data-v-52782a78><!--[--><a class="VPSocialLink no-icon" href="https://github.com/LiteyukiStudio/LiteyukiBot" aria-label="github" target="_blank" rel="noopener" data-v-52782a78 data-v-974e0aed><span class="vpi-social-github" /></a><!--]--></div><div class="VPFlyout VPNavBarExtra extra" data-v-37a6b570 data-v-c34ef5aa data-v-12ec5ee2><button type="button" class="button" aria-haspopup="true" aria-expanded="false" aria-label="extra nav
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 轻雪生命周期管理,启动、停止、重启</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.life_flag: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">int</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._before_start_funcs: list[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> []</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._after_start_funcs: list[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> []</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._before_process_shutdown_funcs: list[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">PROCESS_LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> []</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._after_shutdown_funcs: list[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> []</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._before_process_restart_funcs: list[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">PROCESS_LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> []</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._after_restart_funcs: list[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> []</span></span></code></pre></div></details><p><a href="https://docs.python.org/3/library/functions.html#staticmethod" target="_blank" rel="noreferrer"><code>@staticmethod</code></a></p><h4 id="async-def-run-funcs-funcs-sequence-lifespan-func-process-lifespan-func-args-kwargs-none" tabindex="-1"><em><strong>async def</strong></em> <code>run_funcs(funcs: Sequence[LIFESPAN_FUNC | PROCESS_LIFESPAN_FUNC], *args, **kwargs) -&gt; None</code> <a class="header-anchor" href="#async-def-run-funcs-funcs-sequence-lifespan-func-process-lifespan-func-args-kwargs-none" aria-label="Permalink to &quot;***async def*** `run_funcs(funcs: Sequence[LIFESPAN_FUNC | PROCESS_LIFESPAN_FUNC], *args, **kwargs) -&gt; None`&quot;"></a></h4><p><strong>说明</strong>: 并发运行异步函数</p><p><strong>参数</strong>:</p><blockquote><ul><li>funcs (<a href="https://docs.python.org/3/library/typing.html#typing.Sequence" target="_blank" rel="noreferrer"><code>Sequence</code></a>[<a href="#var-lifespan-func"><code>ASYNC_LIFESPAN_FUNC</code></a> | <a href="#var-process-lifespan-func"><code>PROCESS_LIFESPAN_FUNC</code></a>]): 函数列表</li></ul></blockquote><details><summary><b>源代码</b><a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/lifespan.py#L43" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">staticmethod</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> run_funcs</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(funcs: Sequence[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> PROCESS_LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">], </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">*</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">args, </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">**</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">kwargs) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 并发运行异步函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> funcs ([`Sequence`](https%3A//docs.python.org/3/library/typing.html#typing.Sequence)[[`ASYNC_LIFESPAN_FUNC`](#var-lifespan-func) | [`PROCESS_LIFESPAN_FUNC`](#var-process-lifespan-func)]): 函数列表</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> tasks </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> [func(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">*</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">args, </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">**</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">kwargs) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> is_coroutine_callable(func) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">else</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> async_wrapper(func)(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">*</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">args, </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">**</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">kwargs) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">for</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> func </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">in</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> funcs]</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> asyncio.gather(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">*</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">tasks)</span></span></code></pre></div></details><h4 id="def-on-before-start-self-func-lifespan-func-lifespan-func" tabindex="-1"><em><strong>def</strong></em> <code>on_before_start(self, func: LIFESPAN_FUNC) -&gt; LIFESPAN_FUNC</code> <a class="header-anchor" href="#def-on-before-start-self-func-lifespan-func-lifespan-func" aria-label="Permalink to &quot;***def*** `on_before_start(self, func: LIFESPAN_FUNC) -&gt; LIFESPAN_FUNC`&quot;"></a></h4><p><strong>说明</strong>: 注册启动时的函数</p><p><strong>参数</strong>:</p><blockquote><ul><li>func (<a href="#var-lifespan-func"><code>LIFESPAN_FUNC</code></a>): 生命周期函数</li></ul></blockquote><p><strong>返回</strong>: <a href="#var-lifespan-func"><code>LIFESPAN_FUNC</code></a>: 生命周期函数</p><details><summary><b>源代码</b><a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/lifespan.py#L53" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_before_start</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, func: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 注册启动时的函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> func ([`LIFESPAN_FUNC`](#var-lifespan-func)): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> [`LIFESPAN_FUNC`](#var-lifespan-func): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._before_start_funcs.append(func)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> func</span></span></code></pre></div></details><h4 id="def-on-after-start-self-func-lifespan-func-lifespan-func" tabindex="-1"><em><strong>def</strong></em> <code>on_after_start(self, func: LIFESPAN_FUNC) -&gt; LIFESPAN_FUNC</code> <a class="header-anchor" href="#def-on-after-start-self-func-lifespan-func-lifespan-func" aria-label="Permalink to &quot;***def*** `on_after_start(self, func: LIFESPAN_FUNC) -&gt; LIFESPAN_FUNC`&quot;"></a></h4><p><strong>说明</strong>: 注册启动时的函数</p><p><strong>参数</strong>:</p><blockquote><ul><li>func (<a href="#var-lifespan-func"><code>LIFESPAN_FUNC</code></a>): 生命周期函数</li></ul></blockquote><p><strong>返回</strong>: <a href="#var-lifespan-func"><code>LIFESPAN_FUNC</code></a>: 生命周期函数</p><details><summary><b>源代码</b><a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/lifespan.py#L64" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_after_start</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, func: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 注册启动时的函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> func ([`LIFESPAN_FUNC`](#var-lifespan-func)): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> [`LIFESPAN_FUNC`](#var-lifespan-func): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._after_start_funcs.append(func)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> func</span></span></code></pre></div></details><h4 id="def-on-before-process-shutdown-self-func-process-lifespan-func-process-lifespan-func" tabindex="-1"><em><strong>def</strong></em> <code>on_before_process_shutdown(self, func: PROCESS_LIFESPAN_FUNC) -&gt; PROCESS_LIFESPAN_FUNC</code> <a class="header-anchor" href="#def-on-before-process-shutdown-self-func-process-lifespan-func-process-lifespan-func" aria-label="Permalink to &quot;***def*** `on_before_process_shutdown(self, func: PROCESS_LIFESPAN_FUNC) -&gt; PROCESS_LIFESPAN_FUNC`&quot;"></a></h4><p><strong>说明</strong>: 注册进程停止前的函数</p><p><strong>参数</strong>:</p><blockquote><ul><li>func (<a href="#var-process-lifespan-func"><code>PROCESS_LIFESPAN_FUNC</code></a>): 进程生命周期函数</li></ul></blockquote><p><strong>返回</strong>: <a href="#var-process-lifespan-func"><code>PROCESS_LIFESPAN_FUNC</code></a>: 进程生命周期函数</p><details><summary><b>源代码</b><a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/lifespan.py#L75" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_before_process_shutdown</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, func: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">PROCESS_LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">PROCESS_LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 注册进程停止前的函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> func ([`PROCESS_LIFESPAN_FUNC`](#var-process-lifespan-func)): 进程生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> [`PROCESS_LIFESPAN_FUNC`](#var-process-lifespan-func): 进程生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._before_process_shutdown_funcs.append(func)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> func</span></span></code></pre></div></details><h4 id="def-on-after-shutdown-self-func-lifespan-func-lifespan-func" tabindex="-1"><em><strong>def</strong></em> <code>on_after_shutdown(self, func: LIFESPAN_FUNC) -&gt; LIFESPAN_FUNC</code> <a class="header-anchor" href="#def-on-after-shutdown-self-func-lifespan-func-lifespan-func" aria-label="Permalink to &quot;***def*** `on_after_shutdown(self, func: LIFESPAN_FUNC) -&gt; LIFESPAN_FUNC`&quot;"></a></h4><p><strong>说明</strong>: 注册停止后的函数</p><p><strong>参数</strong>:</p><blockquote><ul><li>func (<a href="#var-lifespan-func"><code>LIFESPAN_FUNC</code></a>): 生命周期函数</li></ul></blockquote><p><strong>返回</strong>: <a href="#var-lifespan-func"><code>LIFESPAN_FUNC</code></a>: 生命周期函数</p><details><summary><b>源代码</b><a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/lifespan.py#L86" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_after_shutdown</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, func: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 注册停止后的函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> func ([`LIFESPAN_FUNC`](#var-lifespan-func)): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> [`LIFESPAN_FUNC`](#var-lifespan-func): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._after_shutdown_funcs.append(func)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> func</span></span></code></pre></div></details><h4 id="def-on-before-process-restart-self-func-process-lifespan-func-process-lifespan-func" tabindex="-1"><em><strong>def</strong></em> <code>on_before_process_restart(self, func: PROCESS_LIFESPAN_FUNC) -&gt; PROCESS_LIFESPAN_FUNC</code> <a class="header-anchor" href="#def-on-before-process-restart-self-func-process-lifespan-func-process-lifespan-func" aria-label="Permalink to &quot;***def*** `on_before_process_restart(self, func: PROCESS_LIFESPAN_FUNC) -&gt; PROCESS_LIFESPAN_FUNC`&quot;"></a></h4><p><strong>说明</strong>: 注册进程重启前的函数</p><p><strong>参数</strong>:</p><blockquote><ul><li>func (<a href="#var-process-lifespan-func"><code>PROCESS_LIFESPAN_FUNC</code></a>): 进程生命周期函数</li></ul></blockquote><p><strong>返回</strong>: <a href="#var-process-lifespan-func"><code>PROCESS_LIFESPAN_FUNC</code></a>: 进程生命周期函数</p><details><summary><b>源代码</b><a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/lifespan.py#L97" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_before_process_restart</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, func: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">PROCESS_LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">PROCESS_LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 注册进程重启前的函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> func ([`PROCESS_LIFESPAN_FUNC`](#var-process-lifespan-func)): 进程生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> [`PROCESS_LIFESPAN_FUNC`](#var-process-lifespan-func): 进程生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._before_process_restart_funcs.append(func)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> func</span></span></code></pre></div></details><h4 id="def-on-after-restart-self-func-lifespan-func-lifespan-func" tabindex="-1"><em><strong>def</strong></em> <code>on_after_restart(self, func: LIFESPAN_FUNC) -&gt; LIFESPAN_FUNC</code> <a class="header-anchor" href="#def-on-after-restart-self-func-lifespan-func-lifespan-func" aria-label="Permalink to &quot;***def*** `on_after_restart(self, func: LIFESPAN_FUNC) -&gt; LIFESPAN_FUNC`&quot;"></a></h4><p><strong>说明</strong>: 注册重启后的函数</p><p><strong>参数</strong>:</p><blockquote><ul><li>func (<a href="#var-lifespan-func"><code>LIFESPAN_FUNC</code></a>): 生命周期函数</li></ul></blockquote><p><strong>返回</strong>: <a href="#var-lifespan-func"><code>LIFESPAN_FUNC</code></a>: 生命周期函数</p><details><summary><b>源代码</b><a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/lifespan.py#L108" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_after_restart</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, func: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 注册重启后的函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> func ([`LIFESPAN_FUNC`](#var-lifespan-func)): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> [`LIFESPAN_FUNC`](#var-lifespan-func): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._after_restart_funcs.append(func)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> func</span></span></code></pre></div></details><h4 id="async-def-before-start-self-none" tabindex="-1"><em><strong>async def</strong></em> <code>before_start(self) -&gt; None</code> <a class="header-anchor" href="#async-def-before-start-self-none" aria-label="Permalink to &quot;***async def*** `before_start(self) -&gt; None`&quot;"></a></h4><p><strong>说明</strong>: 启动前钩子</p><details><summary><b>源代码</b><a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/lifespan.py#L119" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> before_start</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 启动前钩子</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.debug(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Running before_start functions&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.run_funcs(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._before_start_funcs)</span></span></code></pre></div></details><h4 id="async-def-after-start-self-none" tabindex="-1"><em><strong>async def</strong></em> <code>after_start(self) -&gt; None</code> <a class="header-anchor" href="#async-def-after-start-self-none" aria-label="Permalink to &quot;***async def*** `after_start(self) -&gt; None`&quot;"></a></h4><p><strong>说明</strong>: 启动后钩子</p><details><summary><b>源代码</b><a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/lifespan.py#L126" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> after_start</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 启动后钩子</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.debug(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Running after_start functions&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.run_funcs(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._after_start_funcs)</span></span></code></pre></div></details><h4 id="async-def-before-process-shutdown-self-none" tabindex="-1"><em><strong>async def</strong></em> <code>before_process_shutdown(self) -&gt; None</code> <a class="header-anchor" href="#async-def-before-process-shutdown-self-none" aria-label="Permalink to &quot;***async def*** `before_process_shutdown(self) -&gt; None`&quot;"></a></h4><p><strong>说明</strong>: 停止前钩子</p><details><summary><b>源代码</b><a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/lifespan.py#L133" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> before_process_shutdown</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 停止前钩子</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.debug(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Running before_shutdown functions&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.run_funcs(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._before_process_shutdown_funcs)</span></span></code></pre></div></details><h4 id="async-def-after-shutdown-self-none" tabindex="-1"><em><strong>async def</strong></em> <code>after_shutdown(self) -&gt; None</code> <a class="header-anchor" href="#async-def-after-shutdown-self-none" aria-label="Permalink to &quot;***async def*** `after_shutdown(self) -&gt; None`&quot;"></a></h4><p><strong>说明</strong>: 停止后钩子 未实现</p><details><summary><b>源代码</b><a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/lifespan.py#L140" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> after_shutdown</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 停止后钩子 未实现</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.debug(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Running after_shutdown functions&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.run_funcs(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._after_shutdown_funcs)</span></span></code></pre></div></details><h4 id="async-def-before-process-restart-self-none" tabindex="-1"><em><strong>async def</strong></em> <code>before_process_restart(self) -&gt; None</code> <a class="header-anchor" href="#async-def-before-process-restart-self-none" aria-label="Permalink to &quot;***async def*** `before_process_restart(self) -&gt; None`&quot;"></a></h4><p><strong>说明</strong>: 重启前钩子</p><details><summary><b>源代码</b><a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/lifespan.py#L147" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> before_process_restart</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 重启前钩子</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.debug(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Running before_restart functions&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.run_funcs(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._before_process_restart_funcs)</span></span></code></pre></div></details><h4 id="async-def-after-restart-self-none" tabindex="-1"><em><strong>async def</strong></em> <code>after_restart(self) -&gt; None</code> <a class="header-anchor" href="#async-def-after-restart-self-none" aria-label="Permalink to &quot;***async def*** `after_restart(self) -&gt; None`&quot;"></a></h4><p><strong>说明</strong>: 重启后钩子 未实现</p><details><summary><b>源代码</b><a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/lifespan.py#L154" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> after_restart</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 重启后钩子 未实现</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.debug(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Running after_restart functions&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.run_funcs(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._after_restart_funcs)</span></span></code></pre></div></details></div></div></main><footer class="VPDocFooter" data-v-4981c415 data-v-e27a0cf7><!--[--><!--]--><div class="edit-info" data-v-e27a0cf7><div class="edit-link" data-v-e27a0cf7><a class="VPLink link vp-external-link-icon no-icon edit-link-button" href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/lifespan.py" target="_blank" rel="noreferrer" data-v-e27a0cf7><!--[--><span class="vpi-square-pen edit-link-icon" data-v-e27a0cf7></span> 在 GitHub 上编辑此页<!--]--></a></div><!----></div><nav class="prev-next" aria-labelledby="doc-footer-aria-label" data-v-e27a0cf7><span class="visually-hidden" id="doc-footer-aria-label" data-v-e27a0cf7>Pager</span><div class="pager" data-v-e27a0cf7><a class="VPLink link pager-link prev" href="/dev/api/bot/" data-v-e27a0cf7><!--[--><span class="desc" data-v-e27a0cf7>上一页</span><span class="title" data-v-e27a0cf7>liteyuki.bot</span><!--]--></a></div><div class="pager" data-v-e27a0cf7><a class="VPLink link pager-link next" href="/dev/api/comm/comm.html" data-v-e27a0cf7><!--[--><span class="desc" data-v-e27a0cf7>下一页</span><span class="title" data-v-e27a0cf7>liteyuki.comm</span><!--]--></a></div></nav></footer><!--[--><!--]--></div></div></div><!--[--><!--]--></div></div><footer class="VPFooter has-sidebar" data-v-7e3343f7 data-v-098a46ae><div class="container" data-v-098a46ae><p class="message" data-v-098a46ae>文档由 <a href="https://vitepress.dev/">VitePress</a> 构建 | API引用由 <a href="https://github.com/LiteyukiStudio/litedoc">litedoc</a> 生成</p><p class="copyright" data-v-098a46ae>Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved</p></div></footer><!--[--><!--]--></div></div>
<script>window.__VP_HASH_MAP__=JSON.parse("{\"deploy_config.md\":\"QRt04bcu\",\"deploy_fandq.md\":\"BC91M77d\",\"deploy_install.md\":\"DaqD6Ylg\",\"dev_api_api.md\":\"BjidfGYh\",\"dev_api_bot_bot.md\":\"Do8sEorT\",\"dev_api_bot_index.md\":\"BWSjENmL\",\"dev_api_bot_lifespan.md\":\"B_vxVvHa\",\"dev_api_comm_channel.md\":\"D9FVh_nD\",\"dev_api_comm_comm.md\":\"UNalIkKO\",\"dev_api_comm_event.md\":\"MthZC-SE\",\"dev_api_comm_index.md\":\"Bztx56-h\",\"dev_api_comm_rpc.md\":\"Ctatb5Fy\",\"dev_api_comm_socks_channel.md\":\"BeJH6Jbo\",\"dev_api_comm_storage.md\":\"BspAlO8q\",\"dev_api_config.md\":\"5YZEeFsT\",\"dev_api_core_core.md\":\"D46kyvua\",\"dev_api_core_index.md\":\"BN6y5dmE\",\"dev_api_core_manager.md\":\"DWLgtjP0\",\"dev_api_dev_dev.md\":\"CnxR9aZA\",\"dev_api_dev_index.md\":\"CbQNGO4N\",\"dev_api_dev_observer.md\":\"CLF08-bp\",\"dev_api_dev_plugin.md\":\"B8-Pj2Gj\",\"dev_api_exception.md\":\"BdaZK_3x\",\"dev_api_index.md\":\"Bj6EsNxq\",\"dev_api_log.md\":\"C1VDikdj\",\"dev_api_message_event.md\":\"AxntDJi3\",\"dev_api_message_index.md\":\"B1MCWTHF\",\"dev_api_message_matcher.md\":\"CrqC3-lV\",\"dev_api_message_message.md\":\"Cp-oF0Sy\",\"dev_api_message_on.md\":\"BdoE0DiT\",\"dev_api_message_rule.md\":\"UByA3TJk\",\"dev_api_message_session.md\":\"ZRjlTcix\",\"dev_api_mkdoc.md\":\"BPGO1Znu\",\"dev_api_plugin_index.md\":\"3yEbVRtX\",\"dev_api_plugin_load.md\":\"Bb_Kxjiz\",\"dev_api_plugin_manager.md\":\"wxoQsnAr\",\"dev_api_plugin_model.md\":\"CXJI2586\",\"dev_api_plugin_plugin.md\":\"CSWk8lsR\",\"dev_api_plugins_liteecho.md\":\"CPFGVTjw\",\"dev_api_plugins_plugin_loader_index.md\":\"BKOtyJlM\",\"dev_api_plugins_plugin_loader_plugin_loader.md\":\"Bfz2lNbM\",\"dev_api_utils.md\":\"BfOyfADO\",\"dev_comm.md\":\"BaLcrxQn\",\"dev_lyfunc.md\":\"DGSAE6Uz\",\"dev_plugin.md\":\"7WyHaDzB\",\"dev_resource.md\":\"DU3Q8OBq\",\"en_deploy_config.md\":\"CB-Epa0p\",\"en_deploy_fandq.md\":\"lp1l61Jw\",\"en_deploy_install.md\":\"BnEnd6Nu\",\"en_dev_api_api.md\":\"D-5_3fUd\",\"en_dev_api_bot_bot.md\":\"DVWp_48b\",\"en_dev_api_bot_index.md\":\"D0jrKfDJ\",\"en_dev_api_bot_lifespan.md\":\"CDgzjr91\",\"en_dev_api_comm_channel.md\":\"BY8yNiex\",\"en_dev_api_comm_comm.md\":\"nImwmKaA\",\"en_dev_api_comm_event.md\":\"DWKJlFsA\",\"en_dev_api_comm_index.md\":\"DXB5jsIP\",\"en_dev_api_comm_rpc.md\":\"Db5NdJbe\",\"en_dev_api_comm_socks_channel.md\":\"C3TKJ3cZ\",\"en_dev_api_comm_storage.md\":\"B8fIOByJ\",\"en_dev_api_config.md\":\"paJM3SZQ\",\"en_dev_api_core_core.md\":\"DspKdKLc\",\"en_dev_api_core_index.md\":\"Cu0gmuqG\",\"en_dev_api_core_manager.md\":\"Dv7N4zip\",\"en_dev_api_dev_dev.md\":\"C7bp0nFK\",\"en_dev_api_dev_index.md\":\"B_Clatcv\",\"en_dev_api_dev_observer.md\":\"B2sZAEEn\",\"en_dev_api_dev_plugin.md\":\"dVSn90qu\",\"en_dev_api_exception.md\":\"DTnDyb4J\",\"en_dev_api_index.md\":\"Da9OtAtQ\",\"en_dev_api_log.md\":\"BD04gPQH\",\"en_dev_api_message_event.md\":\"DkU7HnIc\",\"en_dev_api_message_index.md\":\"DEGPA3Qg\",\"en_dev_api_message_matcher.md\":\"fjcL64M7\",\"en_dev_api_message_message.md\":\"D0iZgCWF\",\"en_dev_api_message_on.md\":\"Bpf1nKZ0\",\"en_dev_api_message_rule.md\":\"L6rc-HBj\",\"en_dev_api_message_session.md\":\"DMwGauxy\",\"en_dev_api_mkdoc.md\":\"EVvNGPKX\",\"en_dev_api_plugin_index.md\":\"7EqtiaFh\",\"en_dev_api_plugin_load.md\":\"BWXzuii9\",\"en_dev_api_plugin_manager.md\":\"Cq1g681t\",\"en_dev_api_plugin_model.md\":\"CeWxdiF_\",\"en_dev_api_plugin_plugin.md\":\"C9viahSZ\",\"en_dev_api_plugins_liteecho.md\":\"w4kQQyNd\",\"en_dev_api_plugins_plugin_loader_index.md\":\"DYxIyTd3\",\"en_dev_api_plugins_plugin_loader_plugin_loader.md\":\"CX7_cGXK\",\"en_dev_api_utils.md\":\"D2AasRls\",\"en_dev_comm.md\":\"Cn-onW1y\",\"en_dev_lyfunc.md\":\"C5K1_qgM\",\"en_dev_plugin.md\":\"Xb7vUDpJ\",\"en_dev_resource.md\":\"CYdCh9wj\",\"en_index.md\":\"DVQGNFEI\",\"en_store_plugin.md\":\"DceXsbsh\",\"en_store_resource.md\":\"DwD3Poel\",\"en_usage_agreement.md\":\"DzIdKK2Q\",\"en_usage_basic.md\":\"CxkJTStx\",\"en_usage_extra.md\":\"CHJ4PN4s\",\"index.md\":\"CQL2AFxv\",\"store_plugin.md\":\"BMBIhTm1\",\"store_resource.md\":\"CfhqcpPi\"
</body>
</html>