How to use the aiocqhttp.api._SequenceGenerator 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 / api.py View on Github external
async def call_action(self, action: str, **params) -> Any:
        api_ws = None
        if self._is_available():
            api_ws = self._connected_clients.get(
                event_ws.headers.get('X-Self-ID', '*'))
        elif params.get('self_id'):
            api_ws = self._connected_clients.get(str(params['self_id']))
        elif len(self._connected_clients) == 1:
            api_ws = list(self._connected_clients.values())[0]

        if not api_ws:
            raise ApiNotAvailable

        seq = _SequenceGenerator.next()
        await api_ws.send(json.dumps({
            'action': action,
            'params': params,
            'echo': {
                'seq': seq
            }
        }))
        return _handle_api_result(await ResultStore.fetch(seq))