Skip to content
This repository has been archived by the owner on Feb 20, 2024. It is now read-only.

Commit

Permalink
🚨 auto fix by pre-commit-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Feb 5, 2024
1 parent 97a2349 commit 5ea2878
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 41 deletions.
6 changes: 2 additions & 4 deletions examples/event_handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@

# bot.listen 装饰器用来监听指定类型的事件
@bot.listen(Event)
async def _(event: Event, bot: VillaBot):
...
async def _(event: Event, bot: VillaBot): ...


# 手动注册(不建议)
async def handler(event: Event, bot: VillaBot):
...
async def handler(event: Event, bot: VillaBot): ...


bot.register_handler(Event, handler)
Expand Down
30 changes: 10 additions & 20 deletions hertavilla/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
call_api_exceptions: dict[int, type[_ExceptionWithRetcode]] = {}


class PubkeyNoneWarning(Warning):
...
class PubkeyNoneWarning(Warning): ...


class SDKException(Exception):
...
class SDKException(Exception): ...


class HTTPStatusError(SDKException):
Expand Down Expand Up @@ -49,36 +47,28 @@ def __str__(self) -> str:
return repr(self)


class UnknownServerError(CallingApiException, retcode=-502):
...
class UnknownServerError(CallingApiException, retcode=-502): ...


class InvalidRequest(CallingApiException, retcode=-1):
...
class InvalidRequest(CallingApiException, retcode=-1): ...


class InsufficientPermission(CallingApiException, retcode=10318001):
...
class InsufficientPermission(CallingApiException, retcode=10318001): ...


class BotNotAdded(CallingApiException, retcode=10322002):
...
class BotNotAdded(CallingApiException, retcode=10322002): ...


class PermissionDenied(CallingApiException, retcode=10322003):
...
class PermissionDenied(CallingApiException, retcode=10322003): ...


class InvalidMemberBotAccessToken(CallingApiException, retcode=10322004):
...
class InvalidMemberBotAccessToken(CallingApiException, retcode=10322004): ...


class InvalidBotAuthInfo(CallingApiException, retcode=10322005):
...
class InvalidBotAuthInfo(CallingApiException, retcode=10322005): ...


class UnsupportedMsgType(CallingApiException, retcode=10322006):
...
class UnsupportedMsgType(CallingApiException, retcode=10322006): ...


def raise_exception(payload: dict[str, Any]):
Expand Down
8 changes: 4 additions & 4 deletions hertavilla/message/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@


class Component(BaseModel):
id: str # noqa: A003
id: str
"""组件id,由机器人自定义,不能为空字符串。面板内的id需要唯一"""

text: str
"""组件展示文本, 不能为空"""

type: int # noqa: A003
type: int
"""组件类型,目前支持 type=1 按钮组件,未来会扩展更多组件类型"""

need_callback: bool = True
Expand Down Expand Up @@ -141,12 +141,12 @@ class ButtonType(IntEnum):


class Button(Component):
type: Literal[1] = 1 # noqa: A003
type: Literal[1] = 1

c_type: ButtonType
"""组件交互类型"""

input: str = "" # noqa: A003
input: str = ""
"""如果交互类型为输入型,则需要在该字段填充输入内容,不能为空"""

link: str = ""
Expand Down
7 changes: 2 additions & 5 deletions hertavilla/message/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@


class _Segment(abc.ABC):
...

@abc.abstractmethod
async def get_text(self, bot: "VillaBot") -> str:
raise NotImplementedError


class MsgContentInfo(TypedDict):
...
class MsgContentInfo(TypedDict): ...


class MsgContent(BaseModel):
...
class MsgContent(BaseModel): ...
5 changes: 2 additions & 3 deletions hertavilla/message/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class QuoteInfo(TypedDict):


class MentionedInfo(TypedDict):
type: Literal[1, 2] # noqa: A003
type: Literal[1, 2]
"""提及类型:
值为1: @全员
值为2: @部分成员"""
Expand All @@ -59,8 +59,7 @@ class EntityDict(TypedDict):
class _TextEntity(_Segment):
type_: str

def __init__(self, **kwargs) -> None:
...
def __init__(self, **kwargs) -> None: ...

def get_mention(self) -> tuple[Literal[1, 2], str] | None:
return None
Expand Down
6 changes: 2 additions & 4 deletions hertavilla/ws/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@
background_tasks = set()


class StopConnecting(Exception):
...
class StopConnecting(Exception): ...


class Reconnect(Exception):
...
class Reconnect(Exception): ...


class WSConn:
Expand Down
2 changes: 1 addition & 1 deletion hertavilla/ws/payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
class Payload:
header_len: int
"""消息头长度"""
id: int # noqa: A003
id: int
"""消息的序号,请求包的ID单调递增,回应包的ID与请求包的ID一致"""
flag: FlagType
"""消息的方向"""
Expand Down

0 comments on commit 5ea2878

Please sign in to comment.