async def show_strat(self): await self.send_command('SHOW STRAT\r\n') code, response, body = await self.recv_response() if code == ResponseCodes.STRATEGIES_AVAILABLE: return body elif code == ResponseCodes.NO_STRATEGIES_AVAILABLE: return [] raise DictError(code, response)
async def quit(self): await self.send_command('QUIT\r\n') code, response, _ = await self.recv_response() if code == ResponseCodes.CONECTION_CLOSING: self.writer.close() self.connected = False return raise DictError(code, response)
async def show_info(self, database): await self.send_command('SHOW INFO {}\r\n'.format(database)) code, response, body = await self.recv_response() if code == ResponseCodes.DATABASE_INFORMATION: return body elif code == ResponseCodes.INVALID_DATABASE: raise InvalidDatabase(code, response) raise DictError(code, response)
async def show_db(self): await self.send_command('SHOW DB\r\n') code, response, body = await self.recv_response() if code == ResponseCodes.DATABASES_PRESENT: return body elif code == ResponseCodes.NO_DATABASES_PRESENT: return [] raise DictError(code, response)
async def define(self, database, word): await self.send_command('DEFINE {} "{}"\r\n'.format(database, word)) code, response, body = await self.recv_response() if code == ResponseCodes.NO_MATCH: return [] elif code == ResponseCodes.DEFINITIONS_RETRIEVED: return body elif code == ResponseCodes.INVALID_DATABASE: raise InvalidDatabase(code, response) raise DictError(code, response)
async def match(self, database, strategy, word): await self.send_command('MATCH {} {} "{}"\r\n'.format(database, strategy, word)) code, response, body = await self.recv_response() if code == ResponseCodes.NO_MATCH: return [] elif code == ResponseCodes.MATCHES_FOUND: return body elif code == ResponseCodes.INVALID_DATABASE: raise InvalidDatabase(code, response) elif code == ResponseCodes.INVALID_STRATEGY: raise InvalidStrategy(code, response) raise DictError(code, response)
async def client(self, text): await self.send_command('CLIENT {}\r\n'.format(text)) code, response, _ = await self.recv_response() if code == ResponseCodes.OK: return raise DictError(code, response)
async def option_mime(self): await self.send_command('OPTION MIME\r\n') code, response, _ = await self.recv_response() if code == ResponseCodes.OK: return response raise DictError(code, response)
async def help(self): await self.send_command('HELP\r\n') code, response, body = await self.recv_response() if code == ResponseCodes.HELP_TEXT: return body raise DictError(code, response)
async def status(self): await self.send_command('STATUS\r\n') code, response, _ = await self.recv_response() if code == ResponseCodes.STATUS_INFO: return response raise DictError(code, response)
async def show_server(self): await self.send_command('SHOW SERVER\r\n') code, response, body = await self.recv_response() if code == ResponseCodes.SERVER_INFORMATION: return body raise DictError(code, response)