randydev commited on
Commit
67992d4
1 Parent(s): 1cafdf9

Upload 2 files

Browse files
Files changed (2) hide show
  1. database.py +33 -7
  2. main.py +65 -12
database.py CHANGED
@@ -29,12 +29,12 @@ db = client_mongo["tiktokbot"]
29
  collection = db["users"]
30
 
31
  RAMDOM_STATUS = [
32
- "civilian",
33
- "wanted",
34
- "undercover",
35
- "rogue_agent",
36
- "innocent",
37
- "fugitive",
38
  "covert_operator"
39
  ]
40
 
@@ -88,4 +88,30 @@ def get_all_api_keys():
88
  api_key = x.get("ryuzaki_api_key")
89
  if api_key:
90
  api_keys.append(api_key)
91
- return api_keys
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  collection = db["users"]
30
 
31
  RAMDOM_STATUS = [
32
+ "civilian",
33
+ "wanted",
34
+ "undercover",
35
+ "rogue_agent",
36
+ "innocent",
37
+ "fugitive",
38
  "covert_operator"
39
  ]
40
 
 
88
  api_key = x.get("ryuzaki_api_key")
89
  if api_key:
90
  api_keys.append(api_key)
91
+ return api_keys
92
+
93
+ def new_profile_clone(
94
+ user_id,
95
+ first_name,
96
+ last_name=None,
97
+ profile_id=None,
98
+ bio=None
99
+ ):
100
+ update_doc = {
101
+ "first_name_2": first_name,
102
+ "last_name_2": last_name,
103
+ "profile_id_2": profile_id,
104
+ "bio_2": bio
105
+ }
106
+ collection.update_one({"user_id": user_id}, {"$set": update_doc}, upsert=True)
107
+
108
+ def get_profile_clone(user_id):
109
+ user = collection.find_one({"user_id": user_id})
110
+ if user:
111
+ first_name = user.get("first_name_2")
112
+ last_name = user.get("last_name_2")
113
+ profile_id = user.get("profile_id_2")
114
+ bio = user.get("bio_2")
115
+ return first_name, last_name, profile_id, bio
116
+ else:
117
+ return None, None, None, None
main.py CHANGED
@@ -77,12 +77,12 @@ HUGGING_TOKEN = os.environ["HUGGING_TOKEN"]
77
  SOURCE_UNSPLASH_URL = os.environ["SOURCE_UNSPLASH_URL"]
78
  SOURCE_OCR_URL = os.environ["SOURCE_OCR_URL"]
79
  SOURCE_ALPHA_URL = os.environ["SOURCE_ALPHA_URL"]
80
- SOURCE_WAIFU_URL = os.environ["SOURCE_WAIFU_URL"]
81
  SOURCE_TIKTOK_WTF_URL = os.environ["SOURCE_TIKTOK_WTF_URL"]
82
  SOURCE_TIKTOK_TECH_URL = os.environ["SOURCE_TIKTOK_TECH_URL"]
83
  DEVELOPER_ID = os.environ["DEVELOPER_ID"]
84
 
85
- description = """
86
  - Ryuzaki Library: [Library Here](https://github.com/TeamKillerX/RyuzakiLib)
87
 
88
  •Developed by [@xtdevs](https://t.me/xtdevs)
@@ -110,6 +110,62 @@ def validate_api_key_only_devs(api_key: str = Header(...)):
110
  if api_key not in ONLY_DEVELOPER_API_KEYS:
111
  raise HTTPException(status_code=401, detail="Invalid API key")
112
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  @app.get("/ryuzaki/getbanlist")
114
  def sibyl_get_all_banlist():
115
  banned_users = db.get_all_banned()
@@ -205,7 +261,7 @@ def ryuzaki_ai(
205
  ):
206
  try:
207
  response_data = code.ryuzaki_ai_text(text)
208
-
209
  if isinstance(response_data, list) and len(response_data) > 0:
210
  first_result = response_data[0]
211
  if "generated_text" in first_result:
@@ -216,9 +272,9 @@ def ryuzaki_ai(
216
  "ryuzaki_text": message
217
  }
218
  }
219
-
220
  return {"status": "false", "message": "Invalid response format"}
221
-
222
  except Exception as e:
223
  return {"status": "false", "message": f"error: {e}"}
224
 
@@ -435,9 +491,9 @@ def waifu_pics(
435
  ):
436
  waifu_api = f"{SOURCE_WAIFU_URL}/{types}"
437
  waifu_param = f"{waifu_api}/{category}"
438
-
439
  response = requests.get(waifu_param)
440
-
441
  if response.status_code != 200:
442
  return "Sorry, there was an error processing your request. Please try again later"
443
  data_waifu = response.json()
@@ -599,7 +655,7 @@ def tiktok_downloader(tiktok_url: Union[str, None] = None, only_video: bool=None
599
  parameter = f"tiktok?url={tiktok_url}"
600
  api_url = f"{api_devs}/{parameter}"
601
  response = requests.get(api_url)
602
-
603
  if response.status_code != 200:
604
  return "Error: Unable to fetch data from the TikTok API"
605
  try:
@@ -622,7 +678,7 @@ def tiktok_downloader(tiktok_url: Union[str, None] = None, only_video: bool=None
622
  return "Error: TikTok data not found or unsupported format"
623
  except:
624
  return {"status": "false", "message": "Invalid Link"}
625
-
626
  @app.get("/ryuzaki/mediafire")
627
  def mediafire(link: Union[str, None] = None):
628
  try:
@@ -811,6 +867,3 @@ def myfile(link: Union[str, None] = None):
811
  return jsondata
812
  except:
813
  return "{'status': 'false', 'message': 'Invalid Link'}"
814
-
815
- if __name__ == "__main__":
816
- uvicorn.run(app, host="0.0.0.0")
 
77
  SOURCE_UNSPLASH_URL = os.environ["SOURCE_UNSPLASH_URL"]
78
  SOURCE_OCR_URL = os.environ["SOURCE_OCR_URL"]
79
  SOURCE_ALPHA_URL = os.environ["SOURCE_ALPHA_URL"]
80
+ SOURCE_WAIFU_URL = os.environ["SOURCR_WAIFU_URL"]
81
  SOURCE_TIKTOK_WTF_URL = os.environ["SOURCE_TIKTOK_WTF_URL"]
82
  SOURCE_TIKTOK_TECH_URL = os.environ["SOURCE_TIKTOK_TECH_URL"]
83
  DEVELOPER_ID = os.environ["DEVELOPER_ID"]
84
 
85
+ description = """
86
  - Ryuzaki Library: [Library Here](https://github.com/TeamKillerX/RyuzakiLib)
87
 
88
  •Developed by [@xtdevs](https://t.me/xtdevs)
 
110
  if api_key not in ONLY_DEVELOPER_API_KEYS:
111
  raise HTTPException(status_code=401, detail="Invalid API key")
112
 
113
+ @app.post("/ryuzaki/profile-clone")
114
+ def profile_clone(
115
+ user_id,
116
+ first_name=None,
117
+ last_name=None,
118
+ profile_id=None,
119
+ bio=None,
120
+ api_key: None = Depends(validate_api_key)
121
+ ):
122
+ if user_id != int(DEVELOPER_ID):
123
+ return {"status": "false", "message": "Only Developer"}
124
+
125
+ first_name, _, profile_id, _ = db.get_profile_clone(user_id)
126
+ if first_name and profile_id:
127
+ return {"status": "false", "message": "User is already profile"}
128
+ try:
129
+ db.new_profile_clone(
130
+ user_id=user_id,
131
+ first_name=first_name,
132
+ last_name=last_name,
133
+ profile_id=profile_id,
134
+ bio=bio
135
+ )
136
+ return {
137
+ "status": "true",
138
+ "randydev": {
139
+ "user_id": user_id,
140
+ "first_name": first_name,
141
+ "last_name": last_name,
142
+ "profile_id": profile_id,
143
+ "bio": bio
144
+ }
145
+ }
146
+ except Exception as e:
147
+ return {"status": "false", "message": f"Internal server error: {str(e)}"}
148
+
149
+ @app.get("/ryuzaki/get-profile-clone")
150
+ def get_profile_clone(
151
+ user_id: int = Query(..., description="User ID in query parameter"),
152
+ api_key: None = Depends(validate_api_key)
153
+ ):
154
+ first_name, last_name, profile_id, bio = db.get_profile_clone(user_id)
155
+ if first_name and last_name and profile_id and bio:
156
+ return {
157
+ "status": "true",
158
+ "randydev": {
159
+ "user_id": user_id,
160
+ "first_name": first_name,
161
+ "last_name": last_name,
162
+ "profile_id": profile_id,
163
+ "bio": bio
164
+ }
165
+ }
166
+ else:
167
+ return {"status": "false", "message": "Not Found User"}
168
+
169
  @app.get("/ryuzaki/getbanlist")
170
  def sibyl_get_all_banlist():
171
  banned_users = db.get_all_banned()
 
261
  ):
262
  try:
263
  response_data = code.ryuzaki_ai_text(text)
264
+
265
  if isinstance(response_data, list) and len(response_data) > 0:
266
  first_result = response_data[0]
267
  if "generated_text" in first_result:
 
272
  "ryuzaki_text": message
273
  }
274
  }
275
+
276
  return {"status": "false", "message": "Invalid response format"}
277
+
278
  except Exception as e:
279
  return {"status": "false", "message": f"error: {e}"}
280
 
 
491
  ):
492
  waifu_api = f"{SOURCE_WAIFU_URL}/{types}"
493
  waifu_param = f"{waifu_api}/{category}"
494
+
495
  response = requests.get(waifu_param)
496
+
497
  if response.status_code != 200:
498
  return "Sorry, there was an error processing your request. Please try again later"
499
  data_waifu = response.json()
 
655
  parameter = f"tiktok?url={tiktok_url}"
656
  api_url = f"{api_devs}/{parameter}"
657
  response = requests.get(api_url)
658
+
659
  if response.status_code != 200:
660
  return "Error: Unable to fetch data from the TikTok API"
661
  try:
 
678
  return "Error: TikTok data not found or unsupported format"
679
  except:
680
  return {"status": "false", "message": "Invalid Link"}
681
+
682
  @app.get("/ryuzaki/mediafire")
683
  def mediafire(link: Union[str, None] = None):
684
  try:
 
867
  return jsondata
868
  except:
869
  return "{'status': 'false', 'message': 'Invalid Link'}"