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 been banned and can no longer create an API key. Reason: Previous issues occurred again.
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.
""" YOU_KEY_TEXT = """ API Key Generated πŸ”‘ **API Key:** {api_key} βš”οΈ **Type Key:** {type} βŒ› **Expired:** {ttn} πŸ“… **Created At:** {create_at} ⚠️ **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()