diff --git a/nonebot/adapters/_base.py b/nonebot/adapters/_base.py index 7350aad8..10932667 100644 --- a/nonebot/adapters/_base.py +++ b/nonebot/adapters/_base.py @@ -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)