Skip to content

Commit

Permalink
fix(core): fix query entity
Browse files Browse the repository at this point in the history
  • Loading branch information
RF-Tar-Railt committed Jan 9, 2024
1 parent f02812c commit 5eaee85
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions avilla/core/ryanvk/staff.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,17 @@ async def query_entities(self, pattern: str, **predicators: FollowsPredicater):

def build_handler(artifact: tuple[BaseCollector, QueryHandlerPerform]) -> QueryHandler:
async def handler(predicate: Callable[[str, str], bool] | str, previous: Selector | None = None):
instance, entity = artifact
async for i in entity(instance, predicate, previous):
collector, entity = artifact

def _get_instance(_staff: Staff, _cls: type[N]) -> N:
if _cls not in _staff.instances:
res = _staff.instances[_cls] = _cls(_staff)
else:
res = _staff.instances[_cls]

return res

async for i in entity(_get_instance(self, collector.cls), predicate, previous):
yield i

return handler
Expand Down
2 changes: 1 addition & 1 deletion avilla/elizabeth/perform/event/member.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ async def member_special_title_change(self, raw_event: dict):
group_data = member_data["group"]
group = land.group(str(group_data["id"]))
member = group.member(str(member_data["id"]))
members = await self.connection.call("fetch", "memberList", {"target": raw_event["group"]["id"]})
members = await self.connection.call("fetch", "memberList", {"target": member_data["group"]["id"]})
members = cast(list[dict], members)
operator_data = next((d for d in members if d["id"] == raw_event["operator"]["id"]), None)
operator = group.member(str(operator_data["id"])) if operator_data else group
Expand Down

0 comments on commit 5eaee85

Please sign in to comment.