mirror of
https://github.com/Xtao-Labs/QQ-GitHub-Bot.git
synced 2025-01-30 15:08:54 +00:00
🎨 update formatter config
This commit is contained in:
parent
76162e5775
commit
027ee55903
@ -33,13 +33,15 @@ nb-cli = {version = "^0.5.0", extras = ["deploy"]}
|
||||
# default = true
|
||||
|
||||
[tool.black]
|
||||
line-length = 90
|
||||
line-length = 80
|
||||
extend-exclude = '''
|
||||
'''
|
||||
|
||||
[tool.isort]
|
||||
profile = "black"
|
||||
line_length = 80
|
||||
length_sort = true
|
||||
skip_gitignore = true
|
||||
force_sort_within_sections = true
|
||||
extra_standard_library = "typing_extensions"
|
||||
|
||||
|
@ -53,14 +53,20 @@ class Github:
|
||||
return await self._requester.close()
|
||||
|
||||
@overload
|
||||
async def get_repo(self, full_name: str, lazy: Literal[True]) -> LazyRepository:
|
||||
async def get_repo(
|
||||
self, full_name: str, lazy: Literal[True]
|
||||
) -> LazyRepository:
|
||||
...
|
||||
|
||||
@overload
|
||||
async def get_repo(self, full_name: str, lazy: Literal[False]) -> Repository:
|
||||
async def get_repo(
|
||||
self, full_name: str, lazy: Literal[False]
|
||||
) -> Repository:
|
||||
...
|
||||
|
||||
async def get_repo(self, full_name: str, lazy: bool = False) -> LazyRepository:
|
||||
async def get_repo(
|
||||
self, full_name: str, lazy: bool = False
|
||||
) -> LazyRepository:
|
||||
"""
|
||||
GET /repos/:owner/:repo
|
||||
|
||||
@ -68,11 +74,17 @@ class Github:
|
||||
"""
|
||||
url = f"/repos/{full_name}"
|
||||
if lazy:
|
||||
return LazyRepository(full_name=full_name, requester=self._requester)
|
||||
return LazyRepository(
|
||||
full_name=full_name, requester=self._requester
|
||||
)
|
||||
response = await self._requester.request_json("GET", url)
|
||||
return Repository.parse_obj({"requester": self._requester, **response.json()})
|
||||
return Repository.parse_obj(
|
||||
{"requester": self._requester, **response.json()}
|
||||
)
|
||||
|
||||
async def render_markdown(self, text: str, context: Optional[Repository] = None):
|
||||
async def render_markdown(
|
||||
self, text: str, context: Optional[Repository] = None
|
||||
):
|
||||
"""
|
||||
POST /markdown
|
||||
|
||||
@ -83,7 +95,9 @@ class Github:
|
||||
# if context:
|
||||
# data["mode"] = "gfm"
|
||||
# data["context"] = context._identity
|
||||
response = await self._requester.request_json("POST", "/markdown", json=data)
|
||||
response = await self._requester.request_json(
|
||||
"POST", "/markdown", json=data
|
||||
)
|
||||
return response.text
|
||||
|
||||
# def get_repos(
|
||||
|
@ -58,7 +58,12 @@ C = TypeVar("C", bound=BaseModel)
|
||||
|
||||
class PaginatedList(AsyncIterator, Generic[C]):
|
||||
def __init__(
|
||||
self, cls: Type[C], requester: Requester, *args, per_page: int = 30, **kwargs
|
||||
self,
|
||||
cls: Type[C],
|
||||
requester: Requester,
|
||||
*args,
|
||||
per_page: int = 30,
|
||||
**kwargs
|
||||
):
|
||||
self.cls = cls
|
||||
self.requester = requester
|
||||
@ -80,7 +85,11 @@ class PaginatedList(AsyncIterator, Generic[C]):
|
||||
|
||||
def __aiter__(self) -> "PaginatedList[C]":
|
||||
return PaginatedList(
|
||||
self.cls, self.requester, *self.args, per_page=self.per_page, **self.kwargs
|
||||
self.cls,
|
||||
self.requester,
|
||||
*self.args,
|
||||
per_page=self.per_page,
|
||||
**self.kwargs
|
||||
)
|
||||
|
||||
async def _get_next_page(self) -> List[C]:
|
||||
@ -91,7 +100,10 @@ class PaginatedList(AsyncIterator, Generic[C]):
|
||||
response = await self.requester.request_json(*self.args, **self.kwargs)
|
||||
content = response.json()
|
||||
self._contents.extend(
|
||||
[parse_obj_as(self.cls, {"requester": self.requester, **x}) for x in content]
|
||||
[
|
||||
parse_obj_as(self.cls, {"requester": self.requester, **x})
|
||||
for x in content
|
||||
]
|
||||
)
|
||||
return content
|
||||
|
||||
|
@ -159,7 +159,9 @@ class Issue(BaseModel):
|
||||
response = await self.requester.request(
|
||||
"GET", self.pull_request.url, headers=headers
|
||||
)
|
||||
return PullRequest.parse_obj({"requester": self.requester, **response.json()})
|
||||
return PullRequest.parse_obj(
|
||||
{"requester": self.requester, **response.json()}
|
||||
)
|
||||
|
||||
async def get_diff(self) -> str:
|
||||
"""
|
||||
@ -168,5 +170,7 @@ class Issue(BaseModel):
|
||||
if not self.pull_request:
|
||||
raise RuntimeError(f"Issue {self.number} is not a pull request")
|
||||
|
||||
response = await self.requester.request("GET", self.pull_request.diff_url)
|
||||
response = await self.requester.request(
|
||||
"GET", self.pull_request.diff_url
|
||||
)
|
||||
return response.text
|
||||
|
@ -30,7 +30,9 @@ class LazyRepository(BaseModel):
|
||||
|
||||
https://docs.github.com/en/rest/reference/issues#get-an-issue
|
||||
"""
|
||||
headers = {"Accept": "application/vnd.github.mockingbird-preview.full+json"}
|
||||
headers = {
|
||||
"Accept": "application/vnd.github.mockingbird-preview.full+json"
|
||||
}
|
||||
response = await self.requester.request(
|
||||
"GET", f"/repos/{self.full_name}/issues/{number}", headers=headers
|
||||
)
|
||||
@ -107,7 +109,9 @@ class LazyRepository(BaseModel):
|
||||
"""
|
||||
data = {}
|
||||
data["config"] = config.dict(exclude_unset=True)
|
||||
data["config"]["insecure_ssl"] = "1" if data["config"]["insecure_ssl"] else "0"
|
||||
data["config"]["insecure_ssl"] = (
|
||||
"1" if data["config"]["insecure_ssl"] else "0"
|
||||
)
|
||||
if events is not None:
|
||||
data["events"] = events
|
||||
if active is not None:
|
||||
|
@ -216,4 +216,6 @@ async def config(
|
||||
:param meta_tag_prefix: the prefix for ``pdfkit`` specific meta tags
|
||||
"""
|
||||
|
||||
return await Config(wkhtmltoimage=wkhtmltoimage, meta_tag_prefix=meta_tag_prefix)
|
||||
return await Config(
|
||||
wkhtmltoimage=wkhtmltoimage, meta_tag_prefix=meta_tag_prefix
|
||||
)
|
||||
|
@ -18,7 +18,9 @@ from typing import Union, Optional
|
||||
|
||||
class Config(object):
|
||||
def __init__(
|
||||
self, wkhtmltoimage: Optional[str] = None, meta_tag_prefix: str = "imgkit-"
|
||||
self,
|
||||
wkhtmltoimage: Optional[str] = None,
|
||||
meta_tag_prefix: str = "imgkit-",
|
||||
):
|
||||
self.meta_tag_prefix = meta_tag_prefix
|
||||
self._wkhtmltoimage = wkhtmltoimage
|
||||
@ -84,7 +86,9 @@ class Config(object):
|
||||
@property
|
||||
def xvfb(self) -> Union[str, bytes]:
|
||||
if not self._xvfb:
|
||||
raise RuntimeError(f"xvfb not installed or Config {self} is never awaited!")
|
||||
raise RuntimeError(
|
||||
f"xvfb not installed or Config {self} is never awaited!"
|
||||
)
|
||||
return self._xvfb
|
||||
|
||||
@xvfb.setter
|
||||
|
@ -96,7 +96,9 @@ class IMGKit(object):
|
||||
def xvfb(self):
|
||||
return self.config.xvfb
|
||||
|
||||
def _gegetate_args(self, options: OPTION_TYPE) -> Generator[str, None, None]:
|
||||
def _gegetate_args(
|
||||
self, options: OPTION_TYPE
|
||||
) -> Generator[str, None, None]:
|
||||
"""
|
||||
Generator of args parts based on options specification.
|
||||
"""
|
||||
@ -155,7 +157,9 @@ class IMGKit(object):
|
||||
|
||||
if "</head>" in source:
|
||||
self.source = StringSource(
|
||||
inp.replace("</head>", self._style_tag(css_data) + "</head>")
|
||||
inp.replace(
|
||||
"</head>", self._style_tag(css_data) + "</head>"
|
||||
)
|
||||
)
|
||||
else:
|
||||
self.source = StringSource(self._style_tag(css_data) + inp)
|
||||
@ -252,7 +256,10 @@ class IMGKit(object):
|
||||
args = self.command(output_path)
|
||||
|
||||
proc = await asyncio.create_subprocess_exec(
|
||||
*args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||
*args,
|
||||
stdin=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
)
|
||||
|
||||
# If the source is a string then we will pipe it into wkhtmltoimage.
|
||||
|
@ -21,7 +21,9 @@ from src.libs import html2img
|
||||
|
||||
async def from_string(
|
||||
string: str,
|
||||
extensions: Optional[Sequence[Union[str, markdown.extensions.Extension]]] = None,
|
||||
extensions: Optional[
|
||||
Sequence[Union[str, markdown.extensions.Extension]]
|
||||
] = None,
|
||||
extension_configs: Optional[Mapping[str, Mapping[str, Any]]] = None,
|
||||
output_format: Optional[Literal["xhtml", "html"]] = None,
|
||||
tab_length: Optional[int] = None,
|
||||
@ -39,7 +41,9 @@ async def from_string(
|
||||
async def from_file(
|
||||
input: Optional[Union[str, BinaryIO]] = None,
|
||||
encoding: Optional[str] = None,
|
||||
extensions: Optional[Sequence[Union[str, markdown.extensions.Extension]]] = None,
|
||||
extensions: Optional[
|
||||
Sequence[Union[str, markdown.extensions.Extension]]
|
||||
] = None,
|
||||
extension_configs: Optional[Mapping[str, Mapping[str, Any]]] = None,
|
||||
output_format: Optional[Literal["xhtml", "html"]] = None,
|
||||
tab_length: Optional[int] = None,
|
||||
|
@ -26,6 +26,8 @@ _sub_plugins = set()
|
||||
# load all github plugin config from global config
|
||||
github_config = Config(**nonebot.get_driver().config.dict())
|
||||
|
||||
_sub_plugins |= nonebot.load_plugins(str((Path(__file__).parent / "plugins").resolve()))
|
||||
_sub_plugins |= nonebot.load_plugins(
|
||||
str((Path(__file__).parent / "plugins").resolve())
|
||||
)
|
||||
|
||||
from . import apis
|
||||
|
@ -42,7 +42,9 @@ class Config(BaseSettings):
|
||||
@validator("github_self_host")
|
||||
def validate_hook(cls, v):
|
||||
if not v:
|
||||
logger.warning("`github_self_host` not provided! github webhook is disabled!")
|
||||
logger.warning(
|
||||
"`github_self_host` not provided! github webhook is disabled!"
|
||||
)
|
||||
return v
|
||||
|
||||
class Config:
|
||||
|
@ -64,7 +64,9 @@ async def get_token_by_code(code: str) -> str:
|
||||
"code": code,
|
||||
}
|
||||
response = await client.post(
|
||||
"https://github.com/login/oauth/access_token", json=data, headers=headers
|
||||
"https://github.com/login/oauth/access_token",
|
||||
json=data,
|
||||
headers=headers,
|
||||
)
|
||||
response.raise_for_status()
|
||||
return response.json()["access_token"]
|
||||
|
@ -51,7 +51,9 @@ async def create_hook(
|
||||
) -> Hook:
|
||||
async with Github(token) as g:
|
||||
repo = await g.get_repo(repo, True) if isinstance(repo, str) else repo
|
||||
config = HookConfig.parse_obj(config) if isinstance(config, dict) else config
|
||||
config = (
|
||||
HookConfig.parse_obj(config) if isinstance(config, dict) else config
|
||||
)
|
||||
|
||||
return await repo.create_hook(config, events, active)
|
||||
|
||||
|
@ -48,7 +48,9 @@ async def _gen_image(
|
||||
html: str, width: int, height: int, wkhtmltoimage: bool = False
|
||||
) -> Optional[bytes]:
|
||||
if not wkhtmltoimage:
|
||||
async with get_new_page(viewport={"width": width, "height": height}) as page:
|
||||
async with get_new_page(
|
||||
viewport={"width": width, "height": height}
|
||||
) as page:
|
||||
await page.set_content(html)
|
||||
img = await page.screenshot(full_page=True)
|
||||
return img
|
||||
|
@ -12,8 +12,18 @@ __author__ = "yanyongyu"
|
||||
|
||||
from ... import redis
|
||||
from .state import get_state_bind_user, set_state_bind_user
|
||||
from .hook import get_repo_hook, set_repo_hook, delete_repo_hook, exists_repo_hook
|
||||
from .token import get_user_token, set_user_token, delete_user_token, exists_user_token
|
||||
from .hook import (
|
||||
get_repo_hook,
|
||||
set_repo_hook,
|
||||
delete_repo_hook,
|
||||
exists_repo_hook,
|
||||
)
|
||||
from .token import (
|
||||
get_user_token,
|
||||
set_user_token,
|
||||
delete_user_token,
|
||||
exists_user_token,
|
||||
)
|
||||
from .bind import (
|
||||
get_group_bind_repo,
|
||||
set_group_bind_repo,
|
||||
|
@ -19,7 +19,9 @@ USER_STATE_FORMAT = "github_state_{state}"
|
||||
|
||||
|
||||
def set_state_bind_user(user_id: str, state: int) -> Optional[bool]:
|
||||
return redis.set(USER_STATE_FORMAT.format(state=state), user_id, timedelta(minutes=5))
|
||||
return redis.set(
|
||||
USER_STATE_FORMAT.format(state=state), user_id, timedelta(minutes=5)
|
||||
)
|
||||
|
||||
|
||||
def get_state_bind_user(state: int) -> Optional[str]:
|
||||
|
@ -35,26 +35,34 @@ class SubscribeConfig:
|
||||
|
||||
def set_subscribe(group_id: str, repo_name: str, **kwargs) -> Optional[bool]:
|
||||
return redis.set(
|
||||
SUBSCRIBE_GROUP_REPO_FORMAT.format(group_id=group_id, repo_name=repo_name),
|
||||
SUBSCRIBE_GROUP_REPO_FORMAT.format(
|
||||
group_id=group_id, repo_name=repo_name
|
||||
),
|
||||
json.dumps(asdict(SubscribeConfig(**kwargs))),
|
||||
)
|
||||
|
||||
|
||||
def delete_subscribe(group_id: str, repo_name: str) -> int:
|
||||
return redis.delete(
|
||||
SUBSCRIBE_GROUP_REPO_FORMAT.format(group_id=group_id, repo_name=repo_name)
|
||||
SUBSCRIBE_GROUP_REPO_FORMAT.format(
|
||||
group_id=group_id, repo_name=repo_name
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def exists_subscribe(group_id: str, repo_name: str) -> int:
|
||||
return redis.exists(
|
||||
SUBSCRIBE_GROUP_REPO_FORMAT.format(group_id=group_id, repo_name=repo_name)
|
||||
SUBSCRIBE_GROUP_REPO_FORMAT.format(
|
||||
group_id=group_id, repo_name=repo_name
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def get_subscribe(group_id: str, repo_name: str) -> Optional[SubscribeConfig]:
|
||||
value = redis.get(
|
||||
SUBSCRIBE_GROUP_REPO_FORMAT.format(group_id=group_id, repo_name=repo_name)
|
||||
SUBSCRIBE_GROUP_REPO_FORMAT.format(
|
||||
group_id=group_id, repo_name=repo_name
|
||||
)
|
||||
)
|
||||
return value if value is None else SubscribeConfig(**json.loads(value))
|
||||
|
||||
|
@ -18,7 +18,9 @@ from src.libs.github.models import Repository
|
||||
from .. import github_config as config
|
||||
|
||||
|
||||
async def get_repo(owner: str, repo_name: str, token: Optional[str] = None) -> Repository:
|
||||
async def get_repo(
|
||||
owner: str, repo_name: str, token: Optional[str] = None
|
||||
) -> Repository:
|
||||
if token:
|
||||
g = Github(token)
|
||||
elif config.github_client_id and config.github_client_secret:
|
||||
|
@ -16,7 +16,12 @@ from nonebot import on_command
|
||||
from nonebot.typing import T_State
|
||||
from nonebot.permission import SUPERUSER
|
||||
from httpx import HTTPStatusError, TimeoutException
|
||||
from nonebot.adapters.cqhttp import GROUP_ADMIN, GROUP_OWNER, Bot, GroupMessageEvent
|
||||
from nonebot.adapters.cqhttp import (
|
||||
GROUP_ADMIN,
|
||||
GROUP_OWNER,
|
||||
Bot,
|
||||
GroupMessageEvent,
|
||||
)
|
||||
|
||||
from src.utils import only_group, allow_cancel
|
||||
|
||||
@ -35,7 +40,9 @@ try:
|
||||
except ImportError:
|
||||
get_user_token = None
|
||||
|
||||
REPO_REGEX: str = r"^(?P<owner>[a-zA-Z0-9][a-zA-Z0-9\-]*)/(?P<repo>[a-zA-Z0-9_\-\.]+)$"
|
||||
REPO_REGEX: str = (
|
||||
r"^(?P<owner>[a-zA-Z0-9][a-zA-Z0-9\-]*)/(?P<repo>[a-zA-Z0-9_\-\.]+)$"
|
||||
)
|
||||
|
||||
bind = on_command(
|
||||
"bind",
|
||||
|
@ -31,6 +31,9 @@ async def handle(bot: Bot):
|
||||
matchers = reduce(lambda x, y: x.union(y.matcher), _sub_plugins, set())
|
||||
docs = "命令列表:\n\n"
|
||||
docs += "\n\n".join(
|
||||
map(lambda x: inspect.cleandoc(x.__doc__), filter(lambda x: x.__doc__, matchers))
|
||||
map(
|
||||
lambda x: inspect.cleandoc(x.__doc__),
|
||||
filter(lambda x: x.__doc__, matchers),
|
||||
)
|
||||
)
|
||||
await help.finish(docs)
|
||||
|
@ -18,7 +18,12 @@ from nonebot import on_regex
|
||||
from nonebot.typing import T_State
|
||||
from playwright.async_api import Error
|
||||
from httpx import HTTPStatusError, TimeoutException
|
||||
from nonebot.adapters.cqhttp import Bot, MessageEvent, MessageSegment, GroupMessageEvent
|
||||
from nonebot.adapters.cqhttp import (
|
||||
Bot,
|
||||
MessageEvent,
|
||||
MessageSegment,
|
||||
GroupMessageEvent,
|
||||
)
|
||||
|
||||
from src.utils import only_group
|
||||
|
||||
@ -91,7 +96,9 @@ async def handle(bot: Bot, event: MessageEvent, state: T_State):
|
||||
owner,
|
||||
repo,
|
||||
number,
|
||||
MessageSegment.image(f"base64://{base64.b64encode(img).decode()}"),
|
||||
MessageSegment.image(
|
||||
f"base64://{base64.b64encode(img).decode()}"
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@ -144,5 +151,7 @@ async def handle_short(bot: Bot, event: GroupMessageEvent, state: T_State):
|
||||
owner,
|
||||
repo,
|
||||
number,
|
||||
MessageSegment.image(f"base64://{base64.b64encode(img).decode()}"),
|
||||
MessageSegment.image(
|
||||
f"base64://{base64.b64encode(img).decode()}"
|
||||
),
|
||||
)
|
||||
|
@ -29,7 +29,9 @@ try:
|
||||
except ImportError:
|
||||
get_user_token = None
|
||||
|
||||
content = on_command("content", is_github_reply, priority=config.github_command_priority)
|
||||
content = on_command(
|
||||
"content", is_github_reply, priority=config.github_command_priority
|
||||
)
|
||||
content.__doc__ = """
|
||||
/content
|
||||
回复机器人一条github信息,给出对应内容
|
||||
@ -57,7 +59,9 @@ async def handle_content(bot: Bot, event: MessageEvent, state: T_State):
|
||||
return
|
||||
|
||||
try:
|
||||
img = await issue_to_image(message_info.owner, message_info.repo, issue_)
|
||||
img = await issue_to_image(
|
||||
message_info.owner, message_info.repo, issue_
|
||||
)
|
||||
except TimeoutException:
|
||||
await content.finish(f"获取issue数据超时!请尝试重试")
|
||||
except Error:
|
||||
@ -69,5 +73,7 @@ async def handle_content(bot: Bot, event: MessageEvent, state: T_State):
|
||||
message_info.owner,
|
||||
message_info.repo,
|
||||
message_info.number,
|
||||
MessageSegment.image(f"base64://{base64.b64encode(img).decode()}"),
|
||||
MessageSegment.image(
|
||||
f"base64://{base64.b64encode(img).decode()}"
|
||||
),
|
||||
)
|
||||
|
@ -29,7 +29,9 @@ try:
|
||||
except ImportError:
|
||||
get_user_token = None
|
||||
|
||||
diff = on_command("diff", is_github_reply, priority=config.github_command_priority)
|
||||
diff = on_command(
|
||||
"diff", is_github_reply, priority=config.github_command_priority
|
||||
)
|
||||
diff.__doc__ = """
|
||||
/diff
|
||||
回复机器人一条github pr信息,给出pr diff
|
||||
@ -57,7 +59,9 @@ async def handle_diff(bot: Bot, event: MessageEvent, state: T_State):
|
||||
return
|
||||
|
||||
try:
|
||||
img = await issue_diff_to_image(message_info.owner, message_info.repo, issue_)
|
||||
img = await issue_diff_to_image(
|
||||
message_info.owner, message_info.repo, issue_
|
||||
)
|
||||
except TimeoutException:
|
||||
await diff.finish(f"获取diff数据超时!请尝试重试")
|
||||
except Error:
|
||||
@ -69,5 +73,7 @@ async def handle_diff(bot: Bot, event: MessageEvent, state: T_State):
|
||||
message_info.owner,
|
||||
message_info.repo,
|
||||
message_info.number,
|
||||
MessageSegment.image(f"base64://{base64.b64encode(img).decode()}"),
|
||||
MessageSegment.image(
|
||||
f"base64://{base64.b64encode(img).decode()}"
|
||||
),
|
||||
)
|
||||
|
@ -18,7 +18,9 @@ from ...libs.redis import MessageInfo
|
||||
from ...utils import send_github_message
|
||||
from . import KEY_GITHUB_REPLY, config, is_github_reply
|
||||
|
||||
link = on_command("link", is_github_reply, priority=config.github_command_priority)
|
||||
link = on_command(
|
||||
"link", is_github_reply, priority=config.github_command_priority
|
||||
)
|
||||
link.__doc__ = """
|
||||
/link
|
||||
回复机器人一条github信息,给出对应链接
|
||||
|
@ -16,7 +16,12 @@ from typing import Dict
|
||||
from nonebot import on_regex
|
||||
from nonebot.typing import T_State
|
||||
from httpx import HTTPStatusError, TimeoutException
|
||||
from nonebot.adapters.cqhttp import Bot, MessageEvent, MessageSegment, GroupMessageEvent
|
||||
from nonebot.adapters.cqhttp import (
|
||||
Bot,
|
||||
MessageEvent,
|
||||
MessageSegment,
|
||||
GroupMessageEvent,
|
||||
)
|
||||
|
||||
from ...libs.repo import get_repo
|
||||
from ... import github_config as config
|
||||
|
@ -97,7 +97,9 @@ else:
|
||||
elif e.response.status_code == 404:
|
||||
await subscribe.reject(f"仓库名 {owner}/{repo_name} 不存在!请重新发送或取消")
|
||||
return
|
||||
logger.opt(colors=True, exception=e).error(f"github_subscribe: create_hook")
|
||||
logger.opt(colors=True, exception=e).error(
|
||||
f"github_subscribe: create_hook"
|
||||
)
|
||||
await subscribe.finish("订阅仓库时发生错误,请联系开发者或重试")
|
||||
return
|
||||
|
||||
|
@ -32,7 +32,9 @@ class Config(BaseSettings):
|
||||
sentry_with_locals: bool = True
|
||||
sentry_ca_certs: Optional[str] = None
|
||||
sentry_before_send: Optional[Callable[[Any, Any], Optional[Any]]] = None
|
||||
sentry_before_breadcrumb: Optional[Callable[[Any, Any], Optional[Any]]] = None
|
||||
sentry_before_breadcrumb: Optional[
|
||||
Callable[[Any, Any], Optional[Any]]
|
||||
] = None
|
||||
sentry_transport: Optional[Any] = None
|
||||
sentry_http_proxy: Optional[str] = None
|
||||
sentry_https_proxy: Optional[str] = None
|
||||
|
@ -25,7 +25,8 @@ status_config = Config(**global_config.dict())
|
||||
|
||||
command = on_command(
|
||||
"状态",
|
||||
permission=(status_config.server_status_only_superusers or None) and SUPERUSER,
|
||||
permission=(status_config.server_status_only_superusers or None)
|
||||
and SUPERUSER,
|
||||
priority=10,
|
||||
)
|
||||
|
||||
@ -78,7 +79,8 @@ async def _poke(bot: Bot, event: Event, state: T_State) -> bool:
|
||||
|
||||
poke = on_message(
|
||||
_poke,
|
||||
permission=(status_config.server_status_only_superusers or None) and SUPERUSER,
|
||||
permission=(status_config.server_status_only_superusers or None)
|
||||
and SUPERUSER,
|
||||
priority=10,
|
||||
)
|
||||
poke.handle()(server_status)
|
||||
|
@ -29,7 +29,9 @@ def memory_status() -> float:
|
||||
|
||||
def disk_usage() -> Dict[str, psutil._common.sdiskusage]:
|
||||
disk_parts = psutil.disk_partitions()
|
||||
disk_usages = {d.mountpoint: psutil.disk_usage(d.mountpoint) for d in disk_parts}
|
||||
disk_usages = {
|
||||
d.mountpoint: psutil.disk_usage(d.mountpoint) for d in disk_parts
|
||||
}
|
||||
return disk_usages
|
||||
|
||||
|
||||
|
@ -52,7 +52,9 @@ def get_cache(sign: str) -> Any:
|
||||
|
||||
|
||||
def save_cache(sign: str, cache: Any, ex: Optional[timedelta] = None) -> None:
|
||||
redis_client.set(CACHE_KEY_FORMAT.format(signature=sign), pickle.dumps(cache), ex)
|
||||
redis_client.set(
|
||||
CACHE_KEY_FORMAT.format(signature=sign), pickle.dumps(cache), ex
|
||||
)
|
||||
|
||||
|
||||
# Export something for other plugin
|
||||
|
Loading…
Reference in New Issue
Block a user