mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-02-20 17:46:51 +08:00
💥 correct message segment mapping funcs
This commit is contained in:
parent
3564228183
commit
8e97a84ad8
@ -10,7 +10,7 @@ import asyncio
|
|||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from typing_extensions import Protocol
|
from typing_extensions import Protocol
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field, asdict
|
||||||
from typing import (Any, Set, List, Dict, Type, Tuple, Union, TypeVar, Mapping,
|
from typing import (Any, Set, List, Dict, Type, Tuple, Union, TypeVar, Mapping,
|
||||||
Generic, Optional, Iterable)
|
Generic, Optional, Iterable)
|
||||||
|
|
||||||
@ -281,22 +281,22 @@ class MessageSegment(Mapping, abc.ABC, Generic[TM]):
|
|||||||
return setattr(self, key, value)
|
return setattr(self, key, value)
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
yield from self.data.__iter__()
|
yield from asdict(self).keys()
|
||||||
|
|
||||||
def __contains__(self, key: Any) -> bool:
|
def __contains__(self, key: Any) -> bool:
|
||||||
return key in self.data
|
return key in asdict(self).keys()
|
||||||
|
|
||||||
def get(self, key: str, default: Any = None):
|
def get(self, key: str, default: Any = None):
|
||||||
return getattr(self, key, default)
|
return getattr(self, key, default)
|
||||||
|
|
||||||
def keys(self):
|
def keys(self):
|
||||||
return self.data.keys()
|
return asdict(self).keys()
|
||||||
|
|
||||||
def values(self):
|
def values(self):
|
||||||
return self.data.values()
|
return asdict(self).values()
|
||||||
|
|
||||||
def items(self):
|
def items(self):
|
||||||
return self.data.items()
|
return asdict(self).items()
|
||||||
|
|
||||||
def copy(self: T) -> T:
|
def copy(self: T) -> T:
|
||||||
return deepcopy(self)
|
return deepcopy(self)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user