File size: 19,064 Bytes
b3eb313 7ee59b3 6381cdf cae3d8b b3eb313 43d0b09 cae3d8b b3eb313 2dadbc4 ce99a3f b3eb313 559bba5 b3eb313 16f2403 9d33254 16f2403 559bba5 b3eb313 559bba5 d09a97a 559bba5 e69fe51 559bba5 16f2403 559bba5 9d33254 559bba5 9e157a6 16f2403 9e157a6 16f2403 9d33254 16f2403 e69fe51 16f2403 e69fe51 16f2403 9d33254 16f2403 e69fe51 16f2403 43d0b09 16f2403 43d0b09 16f2403 43d0b09 16f2403 43d0b09 9d33254 94c7f54 b3eb313 16f2403 b3eb313 9d33254 b3eb313 cae3d8b f8b0b62 d5cee92 cae3d8b 087cf98 ae86d52 087cf98 cae3d8b b3eb313 cae3d8b b3eb313 cae3d8b |
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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 |
import logging
import time
import os
import requests
from pyrogram import *
from pyrogram.types import *
from pyrogram.errors import *
from config import *
logging.basicConfig(
level=logging.WARNING, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
)
logging.getLogger("pyrogram").setLevel(logging.WARNING)
client = Client(
"Ryzenth",
api_id=API_ID,
api_hash=API_HASH,
bot_token=BOT_TOKEN
)
PYTHON_COHERE = """
```py
import json
from akenoai import OldAkenoXToJs
response = await OldAkenoXToJs.randydev(
"ai/cohere/command-plus",
api_key="{api_key}",
custom_dev_fast=True,
query="what is AkenoX AI?",
chatHistory=[],
system_prompt="You are a helpful AI assistant designed to provide clear and concise responses."
)
print(response)
```
"""
BANNED_APIKEY = """
You have <b>been banned and can no longer create an API key.</b>
<b>Reason:</b> <code>Previous issues occurred again.</code>
<blockquote>
Also, stop monitoring and asking for other people's API keys this is against the rules.
Calm down! If you get a message like that, it means there is a serious problem with your account.
You shouldn't touch other people's APIs carelessly,
let alone keep trying if they've been blocked.
Before making a fuss, make sure you understand the situation first. Answer properly, and if there's an issue, clarify it with a clear mind. Don't just react emotionally think before you speak. If youβre really in the right, explain it properly instead of causing more problems.
</blockquote>
"""
YOU_KEY_TEXT = """
API Key Generated
π **API Key:** <spoiler>{api_key}</spoiler>
βοΈ **Type Key:** <code>{type}</code>
β **Expired:** <code>{ttn}</code>
π
**Created At:** <code>{create_at}</code>
β οΈ **Warning:** Do not share this token with anyone!
"""
CUSTOM_KEY = """
**Welcome to Ryzenth API!**
Weβre excited to have you here! Hereβs what you can enjoy:
β¨ **Features**:
- **V1**: Free and unlimited access for all users.
- **V2**: Premium features with a 30-day free trial.
π¨ **Important Rules**:
To ensure a safe and fair environment for everyone, please adhere to the following rules:
1. **Prohibited Actions**:
- Exploiting or abusing the API for malicious purposes.
- Sharing API keys or credentials with unauthorized users.
- Violating any applicable laws or regulations.
2. **Consequences**:
- Breaking the rules will result in immediate suspension or banning.
- Harassment or misuse of the API will not be tolerated.
π **Your Safety Matters**:
If you encounter any issues or feel harassed, please contact our support team immediately.
"""
@client.on_callback_query(filters.regex("^banyes_"))
async def cb_banned_nothing(client, query):
action = query.data.split("_", 1)[1]
if action == "yes":
keyboard_back = InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="Yes, delete the key",
callback_data="banned_and_key"
)
],
[
InlineKeyboardButton(
text="NO, Back",
callback_data="custom_key"
)
]
]
)
await query.edit_message_text(
text="You are about to delete your API Key",
reply_markup=keyboard_back
)
elif action == "no":
keyboard_back = InlineKeyboardMarkup(
[[
InlineKeyboardButton(
"π Back",
callback_data="custom_key"
)
]]
)
await query.edit_message_text(
text=CUSTOM_KEY,
reply_markup=keyboard_back
)
@client.on_callback_query(filters.regex("^custom_ban"))
async def cb_custom_bans(client, query):
keyboard_back = InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="Delete key Permanent",
callback_data="banyes_yes"
)
],
[
InlineKeyboardButton(
text="NO, Back",
callback_data="custom_key"
)
]
]
)
await query.edit_message_text(
text="You choose one can delete api key permanently or back",
reply_markup=keyboard_back
)
@client.on_callback_query(filters.regex("^custom_key"))
async def cb_custom_key(client, query):
keyboard_back = InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
"API key V1",
callback_data="createkey"
),
InlineKeyboardButton(
"API key V2",
callback_data="createkeyprem"
),
],
[
InlineKeyboardButton(
"Delete API Key",
callback_data="custom_ban"
),
],
[
InlineKeyboardButton(
"βοΈ Back",
callback_data="back"
)
]
]
)
return await query.edit_message_text(
text=CUSTOM_KEY,
reply_markup=keyboard_back
)
@client.on_callback_query(filters.regex("^banned_and_key"))
async def cb_banned_and_key(client, query):
user_id = query.from_user.id
url = "https://randydev-ryu-js.hf.space/api/v1/key/ban-and-delete"
params = {"user_id": user_id}
response = requests.post(
url,
params=params,
headers={"x-api-key": os.environ.get("AKENOX_KEY")}
)
if response.status_code != 200:
return await query.answer("Error api try again", True)
resonse_data = response.json()
keyboard_back = InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
"βοΈ Back",
callback_data="back"
)
]
]
)
await query.edit_message_text(
text=resonse_data["message"],
reply_markup=keyboard_back
)
@Client.on_callback_query(filters.regex("api_key_upgraded"))
async def cb_api_key_upgraded(client, query):
return await query.answer("You can ask the developer support", True)
@client.on_callback_query(filters.regex("run_cohere"))
async def cb_run_cohere(client, query):
user_id = query.from_user.id
url = "https://randydev-ryu-js.hf.space/api/v2/key/generate-key"
url_two = "https://randydev-ryu-js.hf.space/api/v1/ai/cohere/command-plus"
response = requests.post(
url,
params={"user_id": user_id},
headers={"x-api-key": os.environ.get("AKENOX_KEY")}
)
if response.status_code != 200:
return await query.answer("Error api try again", True)
data_json = response.json()
if data_json.get("apiKey", False):
response_two = requests.get(
url_two,
headers={"x-api-key": data_json["apiKey"]},
params={"query": "hello world!"}
).json()
if response_two.get("results") is None:
return await query.answer("API key is expired", True)
return await query.answer(response_two.get("results"), True)
else:
return await query.answer("Error api try again", True)
@client.on_callback_query(filters.regex("example_cohere"))
async def cb_new_cohere(client, query):
user_id = query.from_user.id
if not await db_client.get_privacy_policy(user_id):
return await query.answer("You must agree to the privacy policy first.", True)
url = "https://randydev-ryu-js.hf.space/api/v2/key/generate-key"
response = requests.post(
url,
params={"user_id": user_id},
headers={"x-api-key": os.environ.get("AKENOX_KEY")}
)
if response.status_code != 200:
return await query.answer("Error api try again", True)
data_json = response.json()
if data_json.get("apiKey", False):
keyboard_back = InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
"βΆοΈ Run Code",
callback_data="run_cohere"
),
],
[
InlineKeyboardButton(
"π Back",
callback_data="custom_key"
)
]
]
)
return await query.edit_message_text(
PYTHON_COHERE.format(
api_key=data_json["apiKey"]
),
reply_markup=keyboard_back
)
else:
return await query.answer("Error api try again", True)
@client.on_callback_query(filters.regex("revokedkey"))
async def cb_new_revokekey(client, query):
user_id = query.from_user.id
if not query.from_user.username:
return await query.answer("Required username first", True)
try:
url = "https://randydev-ryu-js.hf.space/api/v1/key/revoked-key"
response = requests.post(
url,
params={
"user_id": user_id,
"username": query.from_user.username
},
headers={"x-api-key": os.environ.get("AKENOX_KEY")}
)
response.raise_for_status()
data_json = response.json()
except requests.exceptions.RequestException:
return await query.answer("API request failed, please try again.", True)
if data_json.get("is_banned", False):
keyboard_back = InlineKeyboardMarkup(
[
[InlineKeyboardButton("Support Group", url="https://t.me/AkenoXDevSupport")],
[InlineKeyboardButton("π Back", callback_data="custom_key")]
]
)
return await query.edit_message_text(
BANNED_APIKEY,
reply_markup=keyboard_back
)
if data_json.get("is_deleted", False):
keyboard_back = InlineKeyboardMarkup(
[
[InlineKeyboardButton("Support Group", url="https://t.me/AkenoXDevSupport")],
[InlineKeyboardButton("π Back", callback_data="custom_key")]
]
)
return await query.edit_message_text(
data_json.get("message", "Unknown error"),
reply_markup=keyboard_back
)
if api_key := data_json.get("apiKey", False):
await query.answer(data_json["message"], True)
keyboard_back = InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
"π API Key",
copy_text=api_key
),
InlineKeyboardButton(
"β οΈ Revoke Key",
callback_data="revokedkey"
),
],
[
InlineKeyboardButton(
"βοΈ Back",
callback_data="back"
)
]
]
)
return await query.edit_message_text(
YOU_KEY_TEXT.format(
api_key=api_key,
create_at=data_json.get("createdAt", ""),
type=data_json.get("type", "Free"),
ttn=data_json.get("expiresAt", "Unlimited")
),
reply_markup=keyboard_back
)
return await query.answer("Error api try again", True)
@client.on_callback_query(filters.regex("createkeyprem"))
async def cb_new_keyprem(client, query):
user_id = query.from_user.id
try:
url = "https://randydev-ryu-js.hf.space/api/v2/key/generate-key"
response = requests.post(
url,
params={"user_id": user_id},
headers={"x-api-key": os.environ.get("AKENOX_KEY")}
)
response.raise_for_status()
data_json = response.json()
except requests.exceptions.RequestException:
return await query.answer("API request failed, please try again.", True)
if data_json.get("is_banned", False):
keyboard_back = InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
"Support Group",
url="https://t.me/AkenoXDevSupport"
),
]
]
)
return await query.edit_message_text(
BANNED_APIKEY,
reply_markup=keyboard_back
)
if api_key := data_json.get("apiKey", False):
keyboard_back = InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
"π API Key",
copy_text=api_key
),
InlineKeyboardButton(
"π Update Expired",
callback_data="api_key_upgraded"
)
],
[
InlineKeyboardButton(
"β Example Cohere",
callback_data="example_cohere"
)
],
[
InlineKeyboardButton(
"π Back",
callback_data="custom_key"
)
]
]
)
return await query.edit_message_text(
YOU_KEY_TEXT.format(
api_key=api_key,
create_at=data_json.get("createdAt", ""),
type=data_json.get("type", "No"),
ttn=data_json.get("expiresAt", "No")
),
reply_markup=keyboard_back
)
return await query.answer("Error api try again", True)
@client.on_callback_query(filters.regex("createkey"))
async def cb_new_key(client, query):
user_id = query.from_user.id
if not query.from_user.username:
return await query.answer("Required username first", True)
url = "https://randydev-ryu-js.hf.space/api/v1/key/generate-key"
url_two = f"https://randydev-ryu-js.hf.space/api/v1/user/check-ban?user_id={user_id}"
try:
response = requests.post(
url,
params={
"user_id": user_id,
"username": query.from_user.username
},
headers={"x-api-key": os.environ.get("AKENOX_KEY")}
)
response_two = requests.get(
url_two,
headers={"x-api-key": os.environ.get("AKENOX_KEY")}
)
response.raise_for_status()
response_two.raise_for_status()
data_json = response.json()
data_json_two = response_two.json()
except requests.exceptions.RequestException:
return await query.answer("API request failed, please try again.", True)
if data_json_two.get("is_ban", False):
return await query.answer("You been blocked from Developer.", True)
if data_json.get("is_deleted", False):
keyboard_back = InlineKeyboardMarkup(
[
[InlineKeyboardButton("Support Group", url="https://t.me/AkenoXDevSupport")],
[InlineKeyboardButton("π Back", callback_data="custom_key")]
]
)
return await query.edit_message_text(
data_json.get("message", "Unknown error"),
reply_markup=keyboard_back
)
if data_json.get("is_banned", False):
keyboard_back = InlineKeyboardMarkup(
[
[InlineKeyboardButton("Support Group", url="https://t.me/AkenoXDevSupport")],
[InlineKeyboardButton("π Back", callback_data="custom_key")]
]
)
return await query.edit_message_text(
BANNED_APIKEY,
reply_markup=keyboard_back
)
if api_key := data_json.get("apiKey"):
keyboard_back = InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
"π API Key",
copy_text=api_key
),
InlineKeyboardButton(
"β οΈ Revoke Key",
callback_data="revokedkey"
),
],
[
InlineKeyboardButton(
"π Back",
callback_data="custom_key"
)
]
]
)
return await query.edit_message_text(
YOU_KEY_TEXT.format(
api_key=api_key,
create_at=data_json.get("createdAt", ""),
type=data_json.get("type", "Free"),
ttn=data_json.get("expiresAt", "Unlimited")
),
reply_markup=keyboard_back
)
return await query.answer("Error: API key not generated, please try again.", True)
@client.on_callback_query(filters.regex("close"))
async def closed_button(client, query):
await query.message.delete()
@client.on_callback_query(filters.regex("back"))
async def back_menu(client, query):
keyboard = InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="π Get API Key",
callback_data="custom_key"
)
],
[
InlineKeyboardButton(
text="π Documentation",
url="https://github.com/TeamKillerX/Ryzenth"
)
]
]
)
return await query.edit_message_text(
f"Welcome {query.from_user.mention} to Ryzenth API.",
reply_markup=keyboard
)
@client.on_message(
filters.incoming
& filters.command("start")
& filters.private
)
async def welcome_start(client: Client, message: Message):
keyboard = InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="π Get API Key",
callback_data="custom_key"
)
],
[
InlineKeyboardButton(
text="π Documentation",
url="https://github.com/TeamKillerX/Ryzenth"
)
]
]
)
await client.send_message(
-1002290885889,
"Ryzenth API (Start) Logs\n\n"
f"First Name: {message.from_user.mention}\n"
f"UserID: `{message.from_user.id}`\n"
f"Username: `{message.from_user.username if message.from_user else None}`\n",
reply_markup=InlineKeyboardMarkup([[
InlineKeyboardButton("π View User", url=f"tg://openmessage?user_id={message.from_user.id}")
]])
)
await message.reply_text(
f"Welcome {message.from_user.mention} to Ryzenth API",
reply_markup=keyboard
)
if __name__ == "__main__":
client.run() |