def get_quote(server_type, server_id, quote_id): quote = (server_group_join( Quotes, server_type, server_id).filter(Quotes.id == quote_id)).first() if quote is None: abort(404, f"quote with id {quote_id} does not exist") else: return quote
def get_counter(server_type, server_id, counter_name): counter = (server_group_join(Counter, server_type, server_id).filter( func.lower(Counter.name) == counter_name.lower())).first() if counter is None: abort(404, f"Counter {counter_name} does not exist") else: return counter
def get_alias(server_type, server_id, alias_name): alias = (server_group_join( Alias, server_type, server_id).filter(Alias.name == alias_name)).first() if alias is None: abort(404, f"Alias {alias_name} does not exist") else: return alias
def get_album(server_type, server_id, album_name): album = (server_group_join( Album, server_type, server_id).filter(Album.name == album_name)).first() if album is None: abort(404, f"Album {album_name} does not exist") else: return album
def get(self, server_type, server_id): search = request.args.get("search") quote = (apply_search_query( server_group_join(Quotes, server_type, server_id), search).order_by(func.random()).limit(1).first()) if quote: return quote abort(404, f"no quotes")
def get_keyword(server_type, server_id, key_name, check_case=True): keyWord = (server_group_join(KeyWords, server_type, server_id).filter( func.lower(KeyWords.name) == key_name.lower())).first() if keyWord is None: abort(404, f"Key word {key_name} does not exist") if check_case and keyWord.match_case and keyWord.name != key_name: abort( 400, f"Key word {key_name} does not match the casing of {keyWord.name}", ) else: return keyWord
def get(self, server_type, server_id): # Could potentially add a ?search= param here too, to filter the list return server_group_join(Quotes, server_type, server_id).all()
def get(self, server_type, server_id): return server_group_join(Alias, server_type, server_id).all()
def get(self, server_type, server_id): return server_group_join(Counter, server_type, server_id).all()
def get(self, server_type, server_id): """List all albums on this server""" return server_group_join(Album, server_type, server_id).all()
def get(self, server_type, server_id): return server_group_join(KeyWords, server_type, server_id).all()