From 7e83a4bb3159279855a5eca98f97efdbf468acfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=98=E6=9D=83=20=E9=A9=AC?= Date: Wed, 8 Nov 2023 20:56:05 +0800 Subject: [PATCH] refactor: According to RFC 116: Updated the type of send_to. --- examples/debate.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/examples/debate.py b/examples/debate.py index cf0c0124c..7b03f785b 100644 --- a/examples/debate.py +++ b/examples/debate.py @@ -60,7 +60,7 @@ class Trump(Role): async def _observe(self) -> int: await super()._observe() # accept messages sent (from opponent) to self, disregard own messages from the last round - self._rc.news = [msg for msg in self._rc.news if msg.contain_any({self.name})] + self._rc.news = [msg for msg in self._rc.news if msg.send_to == {self.name}] return len(self._rc.news) async def _act(self) -> Message: @@ -78,8 +78,8 @@ class Trump(Role): content=rsp, role=self.profile, cause_by=ShoutOut, - msg_from=self.name, - msg_to=self.opponent_name, + sent_from=self.name, + send_to=self.opponent_name, ) return msg @@ -102,8 +102,7 @@ class Biden(Role): await super()._observe() # accept the very first human instruction (the debate topic) or messages sent (from opponent) to self, # disregard own messages from the last round - message_filter = {BossRequirement, self.name} - self._rc.news = [msg for msg in self._rc.news if msg.contain_any(message_filter)] + self._rc.news = [msg for msg in self._rc.news if msg.cause_by == BossRequirement or msg.send_to == {self.name}] return len(self._rc.news) async def _act(self) -> Message: @@ -121,8 +120,8 @@ class Biden(Role): content=rsp, role=self.profile, cause_by=ShoutOut, - msg_from=self.name, - msg_to=self.opponent_name, + sent_from=self.name, + send_to=self.opponent_name, ) return msg