From 8e97a84ad87beacbee2a36eebbe541760d9e510f Mon Sep 17 00:00:00 2001 From: yanyongyu Date: Wed, 4 Aug 2021 19:35:03 +0800 Subject: [PATCH] :boom: correct message segment mapping funcs --- nonebot/adapters/_base.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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)