Skip to content

Commit

Permalink
fix #27
Browse files Browse the repository at this point in the history
  • Loading branch information
Wybxc committed Sep 12, 2021
1 parent 9756895 commit 1c1b4e1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion mirai/models/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
此模块提供事件模型。
"""
from datetime import datetime
from typing import TYPE_CHECKING, Any, Optional, Union, cast
from typing import TYPE_CHECKING, Any, Optional, Type, Union, cast

if TYPE_CHECKING:
from typing_extensions import Literal
Expand Down Expand Up @@ -45,6 +45,13 @@ def parse_obj(cls, obj: dict) -> 'Event':
except ValueError:
return Event(type=obj['type'])

@classmethod
def get_subtype(cls, name: str) -> Type['Event']:
try:
return cast(Type[Event], super().get_subtype(name))
except ValueError:
return Event


###############################
# Bot Event
Expand Down

0 comments on commit 1c1b4e1

Please sign in to comment.