mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-11-27 18:45:05 +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 functools import partial
|
||||
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,
|
||||
Generic, Optional, Iterable)
|
||||
|
||||
@ -281,22 +281,22 @@ class MessageSegment(Mapping, abc.ABC, Generic[TM]):
|
||||
return setattr(self, key, value)
|
||||
|
||||
def __iter__(self):
|
||||
yield from self.data.__iter__()
|
||||
yield from asdict(self).keys()
|
||||
|
||||
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):
|
||||
return getattr(self, key, default)
|
||||
|
||||
def keys(self):
|
||||
return self.data.keys()
|
||||
return asdict(self).keys()
|
||||
|
||||
def values(self):
|
||||
return self.data.values()
|
||||
return asdict(self).values()
|
||||
|
||||
def items(self):
|
||||
return self.data.items()
|
||||
return asdict(self).items()
|
||||
|
||||
def copy(self: T) -> T:
|
||||
return deepcopy(self)
|
||||
|
Loading…
Reference in New Issue
Block a user