How to use the aiocqhttp.api.ResultStore function in aiocqhttp

To help you get started, we’ve selected a few aiocqhttp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github richardchien / python-aiocqhttp / aiocqhttp / __init__.py View on Github external
async def _handle_ws_reverse_universal(self):
        self._add_ws_reverse_api_connection()
        try:
            while True:
                try:
                    payload = json.loads(await websocket.receive())
                except json.JSONDecodeError:
                    payload = None

                if isinstance(payload, dict) and 'post_type' in payload:
                    # is a event
                    asyncio.ensure_future(
                        self._handle_event_payload_with_response(payload))
                elif payload:
                    # is a api result
                    ResultStore.add(payload)
        finally:
            self._remove_ws_reverse_api_connection()
github richardchien / python-aiocqhttp / aiocqhttp / __init__.py View on Github external
async def _handle_ws_reverse_api(self):
        self._validate_access_token()

        # noinspection PyProtectedMember
        ws = websocket._get_current_object()
        self_id = websocket.headers.get('X-Self-ID', '*')
        self._connected_ws_reverse_api_clients[self_id] = ws
        try:
            while True:
                try:
                    ResultStore.add(json.loads(await websocket.receive()))
                except json.JSONDecodeError:
                    pass
        finally:
            if self_id in self._connected_ws_reverse_api_clients:
                # we must check the existence here,
                # because we allow wildcard ws connections,
                # that is, the self_id may be '*'
                del self._connected_ws_reverse_api_clients[self_id]
github richardchien / python-aiocqhttp / aiocqhttp / __init__.py View on Github external
async def _handle_ws_reverse_api(self):
        self._add_ws_reverse_api_connection()
        try:
            while True:
                try:
                    ResultStore.add(json.loads(await websocket.receive()))
                except json.JSONDecodeError:
                    pass
        finally:
            self._remove_ws_reverse_api_connection()