fix: python and enums...
This commit is contained in:
parent
a22886334c
commit
c3783253e1
2 changed files with 5 additions and 9 deletions
|
@ -66,13 +66,9 @@ class AppService:
|
|||
|
||||
def callback(self, room: str, event: EventType | str = EventType.MESSAGE) -> Callable:
|
||||
def wrapper(func: Callable[[Event], Awaitable[None]]):
|
||||
if isinstance(event, str):
|
||||
key = EventType[event]
|
||||
else:
|
||||
key = event
|
||||
if event.type not in self._callbacks:
|
||||
self._callbacks[event.type] = {}
|
||||
self._callbacks[key][room] = func
|
||||
if event not in self._callbacks:
|
||||
self._callbacks[event] = {}
|
||||
self._callbacks[event][room] = func
|
||||
return func
|
||||
return wrapper
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from typing import Any
|
||||
from enum import Enum
|
||||
from enum import StrEnum
|
||||
from dataclasses import dataclass
|
||||
|
||||
@dataclass
|
||||
|
@ -7,7 +7,7 @@ class User:
|
|||
avatar_url: str = ""
|
||||
display_name: str = ""
|
||||
|
||||
class EventType(Enum):
|
||||
class EventType(StrEnum):
|
||||
MESSAGE = "m.room.message"
|
||||
MEMBER = "m.room.member"
|
||||
REDACTION = "m.room.redaction"
|
||||
|
|
Loading…
Reference in a new issue