Spaces:
Running
Running
File size: 2,616 Bytes
2f158fd 094aba4 2f158fd 094aba4 2f158fd 094aba4 2f158fd 094aba4 2f158fd 094aba4 2f158fd 094aba4 2f158fd 094aba4 2f158fd 094aba4 2f158fd 094aba4 2f158fd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
#!/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 <https://www.gnu.org/licenses/>.
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")
|