#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright 2020-2023 (c) Randy W @xtdevs, @xtsea # # from : https://github.com/TeamKillerX # Channel : @RendyProjects # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . import uvicorn from fastapi import FastAPI, Query from templates.config import * logging.basicConfig(level=logging.ERROR) app = FastAPI( title=TITLE, description=DESCRIPTION, version=VERSION, terms_of_service=TERMS_OF_SERVICE, docs_url=DOCS_URL, ) @app.get("/test") def hello_world(): return {"message": "hello world"} @app.get("/ryuzaki/blacklist-words") def blacklist_words(): try: BLACKLIST_WORDS = BadWordsList() results_all = BLACKLIST_WORDS.banned_by_google( file_txt="banned_by_google.txt", storage=True ) return {"status": "true", "results": results_all} except Exception as e: return {"status": "false", "message": f"Internal server error: {str(e)}"} @app.post("/ryuzaki/sibylban") def sibyl_system_ban( user_id: int = Query(..., description="User ID in query parameter"), reason: str = Query(..., description="Reason in query parameter"), api_key: str = Query(..., description="Api key in query parameter"), ): if user_id != TELEGRAM_ID: return {"status": "false", "message": "Only Developer"} clients = SiblyBan(api_key=api_key) try: response = clients.get_ban(user_id=user_id, banlist=True) sibyl_user_id = response.get("randydev", {}).get("sibyl_user_id") if sibyl_user_id: return {"status": "false", "message": "User is already banned"} response_str = clients.add_ban(user_id=user_id, reason=reason, is_banned=True) return {"status": "true", "results": {"message": response_str}} except Exception as e: logging.error(f"Error in sibyl_system_ban: {e}") return {"status": "false", "message": "Internal server error"} if __name__ == "__main__": uvicorn.run(app, host="0.0.0.0")