Update main.py
Browse files
main.py
CHANGED
@@ -39,6 +39,53 @@ client = Client(
|
|
39 |
bot_token=BOT_TOKEN
|
40 |
)
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
CUSTOM_KEY = """
|
43 |
**Welcome to Ryzenth API!**
|
44 |
|
@@ -63,6 +110,44 @@ To ensure a safe and fair environment for everyone, please adhere to the followi
|
|
63 |
If you encounter any issues or feel harassed, please contact our support team immediately.
|
64 |
"""
|
65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
@client.on_callback_query(filters.regex("^custom_ban"))
|
67 |
async def cb_custom_bans(client, query):
|
68 |
keyboard_back = InlineKeyboardMarkup(
|
@@ -119,65 +204,334 @@ async def cb_custom_key(client, query):
|
|
119 |
reply_markup=keyboard_back
|
120 |
)
|
121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
try:
|
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 |
try:
|
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 |
@client.on_message(
|
183 |
filters.incoming
|
@@ -185,34 +539,16 @@ async def check_membership(channel_id, bot, msg):
|
|
185 |
& filters.private
|
186 |
)
|
187 |
async def welcome_start(client: Client, message: Message):
|
188 |
-
if message.from_user.id in NOT_ALLOWED_NON_PROGRAMMER:
|
189 |
-
return await message.reply_text("As long as the account is restricted, you will not be able to send messages to bots")
|
190 |
-
response = set_user_update_in_db(
|
191 |
-
user_id=message.from_user.id,
|
192 |
-
first_name=message.from_user.first_name,
|
193 |
-
username=message.from_user.username if message.from_user else None
|
194 |
-
)
|
195 |
-
if response is None:
|
196 |
-
return await message.reply_text("Try again problem")
|
197 |
keyboard = InlineKeyboardMarkup(
|
198 |
[
|
199 |
[
|
200 |
InlineKeyboardButton(
|
201 |
-
text="
|
202 |
-
|
203 |
)
|
204 |
]
|
205 |
]
|
206 |
)
|
207 |
-
await client.send_message(
|
208 |
-
"@xtdevs",
|
209 |
-
USER_TRACK.format(
|
210 |
-
user_id=message.from_user.id if message.from_user else 0,
|
211 |
-
first_name=message.from_user.first_name,
|
212 |
-
username=message.from_user.username if message.from_user else None,
|
213 |
-
user_db=response["message"]
|
214 |
-
)
|
215 |
-
)
|
216 |
await message.reply_text(
|
217 |
WELCOME_TEXT.format(
|
218 |
first_name=message.from_user.first_name
|
@@ -220,146 +556,4 @@ async def welcome_start(client: Client, message: Message):
|
|
220 |
reply_markup=keyboard
|
221 |
)
|
222 |
|
223 |
-
@client.on_message(
|
224 |
-
filters.incoming
|
225 |
-
& filters.command(["hubsearch"])
|
226 |
-
& filters.private
|
227 |
-
& ~filters.forwarded
|
228 |
-
)
|
229 |
-
async def searchhub(client: Client, message: Message):
|
230 |
-
if message.from_user.id in NOT_ALLOWED_NON_PROGRAMMER:
|
231 |
-
return await message.reply_text("As long as the account is restricted, you will not be able to send messages to bots")
|
232 |
-
user_id = message.from_user.id
|
233 |
-
query = message.text.split(" ", 1)[1] if len(message.command) > 1 else None
|
234 |
-
if not query:
|
235 |
-
return await message.reply_text("please search for pornohub.")
|
236 |
-
pro = await message.reply_text("Processing.....")
|
237 |
-
if query in not_allowed:
|
238 |
-
return await pro.edit_text("I don't understand, can you help me?")
|
239 |
-
try:
|
240 |
-
user_status = check_user_expiration(user_id)
|
241 |
-
protect_content = not user_status["free_mode"]
|
242 |
-
response = await api.x_search(query=query)
|
243 |
-
if response is None:
|
244 |
-
return await pro.edit_text("nothing found gay")
|
245 |
-
link = response[0]
|
246 |
-
file_path, thumb, _ = await api.x_download(url=link, is_stream=True)
|
247 |
-
upload_text = f"**⬆️ 𝖴𝗉𝗅𝗈𝖺𝖽𝗂𝗇𝗀 video ...**"
|
248 |
-
await pro.edit_text(upload_text)
|
249 |
-
await client.send_message(
|
250 |
-
"@xtdevs",
|
251 |
-
USER_LOGS.format(
|
252 |
-
user_id=message.from_user.id if message.from_user else 0,
|
253 |
-
first_name=message.from_user.first_name,
|
254 |
-
username=message.from_user.username if message.from_user else None,
|
255 |
-
type_text=query
|
256 |
-
)
|
257 |
-
)
|
258 |
-
await client.send_video(
|
259 |
-
message.chat.id,
|
260 |
-
file_path,
|
261 |
-
caption=f"• Powered by {client.me.mention}",
|
262 |
-
thumb=thumb,
|
263 |
-
has_spoiler=True,
|
264 |
-
protect_content=protect_content,
|
265 |
-
progress=progress,
|
266 |
-
progress_args=(
|
267 |
-
pro,
|
268 |
-
time.time(),
|
269 |
-
upload_text
|
270 |
-
)
|
271 |
-
)
|
272 |
-
await pro.delete()
|
273 |
-
os.remove(thumb)
|
274 |
-
os.remove(file_path)
|
275 |
-
except Exception as e:
|
276 |
-
await pro.edit_text(str(e))
|
277 |
-
|
278 |
-
def is_pornohub_url(url):
|
279 |
-
import re
|
280 |
-
pattern = r"(https?)://www\.xnxx\.com/([\w\-]+)?/(\w+)"
|
281 |
-
match = re.search(pattern, url)
|
282 |
-
return bool(match)
|
283 |
-
|
284 |
-
@client.on_message(
|
285 |
-
filters.incoming
|
286 |
-
& filters.command(["hubdl"])
|
287 |
-
& filters.private
|
288 |
-
& ~filters.forwarded
|
289 |
-
)
|
290 |
-
async def porno_download(client: Client, message: Message):
|
291 |
-
if message.from_user.id in NOT_ALLOWED_NON_PROGRAMMER:
|
292 |
-
return await message.reply_text("As long as the account is restricted, you will not be able to send messages to bots")
|
293 |
-
user_id = message.from_user.id
|
294 |
-
link = message.text.split(" ", 1)[1] if len(message.command) > 1 else None
|
295 |
-
if not link:
|
296 |
-
return await message.reply_text("please link for pornohub.")
|
297 |
-
if not is_pornohub_url(link):
|
298 |
-
return await message.reply_text("invalid link.")
|
299 |
-
pro = await message.reply_text("Processing.....")
|
300 |
-
try:
|
301 |
-
user_status = check_user_expiration(user_id)
|
302 |
-
protect_content = not user_status["free_mode"]
|
303 |
-
file_path, thumb, _ = await api.x_download(url=link, is_stream=True)
|
304 |
-
upload_text = f"**⬆️ 𝖴𝗉𝗅𝗈𝖺𝖽𝗂𝗇𝗀 video ...**"
|
305 |
-
await pro.edit_text(upload_text)
|
306 |
-
await client.send_message(
|
307 |
-
"@xtdevs",
|
308 |
-
USER_LOGS.format(
|
309 |
-
user_id=message.from_user.id if message.from_user else 0,
|
310 |
-
first_name=message.from_user.first_name,
|
311 |
-
username=message.from_user.username if message.from_user else None,
|
312 |
-
type_text=link
|
313 |
-
),
|
314 |
-
disable_web_page_preview=True
|
315 |
-
)
|
316 |
-
await client.send_video(
|
317 |
-
message.chat.id,
|
318 |
-
file_path,
|
319 |
-
caption=f"• Powered by {client.me.mention}",
|
320 |
-
thumb=thumb,
|
321 |
-
has_spoiler=True,
|
322 |
-
protect_content=protect_content,
|
323 |
-
progress=progress,
|
324 |
-
progress_args=(
|
325 |
-
pro,
|
326 |
-
time.time(),
|
327 |
-
upload_text
|
328 |
-
)
|
329 |
-
)
|
330 |
-
await pro.delete()
|
331 |
-
os.remove(thumb)
|
332 |
-
os.remove(file_path)
|
333 |
-
except Exception as e:
|
334 |
-
await pro.edit_text(str(e))
|
335 |
-
|
336 |
-
@client.on_message(
|
337 |
-
filters.incoming
|
338 |
-
& filters.command(["freemode"])
|
339 |
-
& filters.private
|
340 |
-
)
|
341 |
-
async def freemode_handler(client, message):
|
342 |
-
user_id = message.from_user.id
|
343 |
-
free_mode_status = toggle_free_mode(user_id)
|
344 |
-
if free_mode_status.get("free_mode_enabled"):
|
345 |
-
await message.reply(f"Free mode activated for user {user_id}.")
|
346 |
-
elif "wait" in free_mode_status["message"]:
|
347 |
-
await message.reply(f"{free_mode_status['message']}")
|
348 |
-
else:
|
349 |
-
await message.reply(f"Free mode deactivated for user {user_id}.")
|
350 |
-
|
351 |
-
@client.on_message(
|
352 |
-
filters.incoming
|
353 |
-
& filters.command(["check_status"])
|
354 |
-
& filters.private
|
355 |
-
)
|
356 |
-
async def check_status_handler(client, message):
|
357 |
-
user_id = message.from_user.id
|
358 |
-
response = requests.get(f"https://private-akeno.randydev.my.id/api/v2/akenohub/check?user_id={user_id}")
|
359 |
-
if response.status_code == 200:
|
360 |
-
data = response.json()
|
361 |
-
await message.reply(data["message"])
|
362 |
-
else:
|
363 |
-
await message.reply("Error checking status.")
|
364 |
-
|
365 |
client.run()
|
|
|
39 |
bot_token=BOT_TOKEN
|
40 |
)
|
41 |
|
42 |
+
PYTHON_COHERE = """
|
43 |
+
```py
|
44 |
+
import json
|
45 |
+
from akenoai import OldAkenoXToJs
|
46 |
+
|
47 |
+
response = await OldAkenoXToJs.randydev(
|
48 |
+
"ai/cohere/command-plus",
|
49 |
+
api_key="{api_key}",
|
50 |
+
custom_dev_fast=True,
|
51 |
+
query="what is AkenoX AI?",
|
52 |
+
chatHistory=[],
|
53 |
+
system_prompt="You are a helpful AI assistant designed to provide clear and concise responses."
|
54 |
+
)
|
55 |
+
|
56 |
+
print(response)
|
57 |
+
```
|
58 |
+
"""
|
59 |
+
|
60 |
+
BANNED_APIKEY = """
|
61 |
+
You have <b>been banned and can no longer create an API key.</b>
|
62 |
+
|
63 |
+
<b>Reason:</b> <code>Previous issues occurred again.</code>
|
64 |
+
|
65 |
+
<blockquote>
|
66 |
+
Also, stop monitoring and asking for other people's API keys this is against the rules.
|
67 |
+
|
68 |
+
Calm down! If you get a message like that, it means there is a serious problem with your account.
|
69 |
+
You shouldn't touch other people's APIs carelessly,
|
70 |
+
let alone keep trying if they've been blocked.
|
71 |
+
|
72 |
+
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.
|
73 |
+
</blockquote>
|
74 |
+
"""
|
75 |
+
|
76 |
+
YOU_KEY_TEXT = """
|
77 |
+
AkenoX API Key Generated
|
78 |
+
|
79 |
+
🔑 **API Key:** <spoiler>{api_key}</spoiler>
|
80 |
+
|
81 |
+
⚔️ **Type Key:** <code>{type}</code>
|
82 |
+
|
83 |
+
⌛ **Expired:** <code>{ttn}</code>
|
84 |
+
|
85 |
+
📅 **Created At:** <code>{create_at}</code>
|
86 |
+
|
87 |
+
⚠️ **Warning:** Do not share this token with anyone!
|
88 |
+
"""
|
89 |
CUSTOM_KEY = """
|
90 |
**Welcome to Ryzenth API!**
|
91 |
|
|
|
110 |
If you encounter any issues or feel harassed, please contact our support team immediately.
|
111 |
"""
|
112 |
|
113 |
+
@client.on_callback_query(filters.regex("^banyes_"))
|
114 |
+
async def cb_banned_nothing(client, query):
|
115 |
+
action = query.data.split("_", 1)[1]
|
116 |
+
if action == "yes":
|
117 |
+
keyboard_back = InlineKeyboardMarkup(
|
118 |
+
[
|
119 |
+
[
|
120 |
+
InlineKeyboardButton(
|
121 |
+
text="Yes, delete the key",
|
122 |
+
callback_data="banned_and_key"
|
123 |
+
)
|
124 |
+
],
|
125 |
+
[
|
126 |
+
InlineKeyboardButton(
|
127 |
+
text="NO, Back",
|
128 |
+
callback_data="custom_key"
|
129 |
+
)
|
130 |
+
]
|
131 |
+
]
|
132 |
+
)
|
133 |
+
await query.edit_message_text(
|
134 |
+
text="You are about to delete your API Key",
|
135 |
+
reply_markup=keyboard_back
|
136 |
+
)
|
137 |
+
elif action == "no":
|
138 |
+
keyboard_back = InlineKeyboardMarkup(
|
139 |
+
[[
|
140 |
+
InlineKeyboardButton(
|
141 |
+
"🔙 Back",
|
142 |
+
callback_data="custom_key"
|
143 |
+
)
|
144 |
+
]]
|
145 |
+
)
|
146 |
+
await query.edit_message_text(
|
147 |
+
text=CUSTOM_KEY,
|
148 |
+
reply_markup=keyboard_back
|
149 |
+
)
|
150 |
+
|
151 |
@client.on_callback_query(filters.regex("^custom_ban"))
|
152 |
async def cb_custom_bans(client, query):
|
153 |
keyboard_back = InlineKeyboardMarkup(
|
|
|
204 |
reply_markup=keyboard_back
|
205 |
)
|
206 |
|
207 |
+
@client.on_callback_query(filters.regex("^banned_and_key"))
|
208 |
+
async def cb_banned_and_key(client, query):
|
209 |
+
user_id = query.from_user.id
|
210 |
+
url = "https://randydev-ryu-js.hf.space/api/v1/key/ban-and-delete"
|
211 |
+
params = {"user_id": user_id}
|
212 |
+
response = requests.post(
|
213 |
+
url,
|
214 |
+
params=params,
|
215 |
+
headers={"x-api-key": os.environ.get("AKENOX_KEY")}
|
216 |
+
)
|
217 |
+
if response.status_code != 200:
|
218 |
+
return await query.answer("Error api try again", True)
|
219 |
|
220 |
+
resonse_data = response.json()
|
221 |
+
keyboard_back = InlineKeyboardMarkup(
|
222 |
+
[
|
223 |
+
[
|
224 |
+
InlineKeyboardButton(
|
225 |
+
"❌ Back",
|
226 |
+
callback_data="close"
|
227 |
+
)
|
228 |
+
]
|
229 |
+
]
|
230 |
+
)
|
231 |
+
await query.edit_message_text(
|
232 |
+
text=resonse_data["message"],
|
233 |
+
reply_markup=keyboard_back
|
234 |
+
)
|
235 |
+
|
236 |
+
@Client.on_callback_query(filters.regex("api_key_upgraded"))
|
237 |
+
async def cb_api_key_upgraded(client, query):
|
238 |
+
return await query.answer("You can ask the developer support", True)
|
239 |
+
|
240 |
+
@client.on_callback_query(filters.regex("run_cohere"))
|
241 |
+
async def cb_run_cohere(client, query):
|
242 |
+
user_id = query.from_user.id
|
243 |
+
url = "https://randydev-ryu-js.hf.space/api/v2/key/generate-key"
|
244 |
+
url_two = "https://randydev-ryu-js.hf.space/api/v1/ai/cohere/command-plus"
|
245 |
+
response = requests.post(
|
246 |
+
url,
|
247 |
+
params={"user_id": user_id},
|
248 |
+
headers={"x-api-key": os.environ.get("AKENOX_KEY")}
|
249 |
+
)
|
250 |
+
if response.status_code != 200:
|
251 |
+
return await query.answer("Error api try again", True)
|
252 |
+
|
253 |
+
data_json = response.json()
|
254 |
+
if data_json.get("apiKey", False):
|
255 |
+
response_two = requests.get(
|
256 |
+
url_two,
|
257 |
+
headers={"x-api-key": data_json["apiKey"]},
|
258 |
+
params={"query": "hello world!"}
|
259 |
+
).json()
|
260 |
+
if response_two.get("results") is None:
|
261 |
+
return await query.answer("API key is expired", True)
|
262 |
+
return await query.answer(response_two.get("results"), True)
|
263 |
+
else:
|
264 |
+
return await query.answer("Error api try again", True)
|
265 |
+
|
266 |
+
@client.on_callback_query(filters.regex("example_cohere"))
|
267 |
+
async def cb_new_cohere(client, query):
|
268 |
+
user_id = query.from_user.id
|
269 |
+
if not await db_client.get_privacy_policy(user_id):
|
270 |
+
return await query.answer("You must agree to the privacy policy first.", True)
|
271 |
+
url = "https://randydev-ryu-js.hf.space/api/v2/key/generate-key"
|
272 |
+
response = requests.post(
|
273 |
+
url,
|
274 |
+
params={"user_id": user_id},
|
275 |
+
headers={"x-api-key": os.environ.get("AKENOX_KEY")}
|
276 |
+
)
|
277 |
+
if response.status_code != 200:
|
278 |
+
return await query.answer("Error api try again", True)
|
279 |
+
|
280 |
+
data_json = response.json()
|
281 |
+
if data_json.get("apiKey", False):
|
282 |
+
keyboard_back = InlineKeyboardMarkup(
|
283 |
+
[
|
284 |
+
[
|
285 |
+
InlineKeyboardButton(
|
286 |
+
"▶️ Run Code",
|
287 |
+
callback_data="run_cohere"
|
288 |
+
),
|
289 |
+
],
|
290 |
+
[
|
291 |
+
InlineKeyboardButton(
|
292 |
+
"🔙 Back",
|
293 |
+
callback_data="custom_key"
|
294 |
+
)
|
295 |
+
]
|
296 |
+
]
|
297 |
+
)
|
298 |
+
return await query.edit_message_text(
|
299 |
+
PYTHON_COHERE.format(
|
300 |
+
api_key=data_json["apiKey"]
|
301 |
+
),
|
302 |
+
reply_markup=keyboard_back
|
303 |
+
)
|
304 |
+
else:
|
305 |
+
return await query.answer("Error api try again", True)
|
306 |
+
|
307 |
+
@client.on_callback_query(filters.regex("revokedkey"))
|
308 |
+
async def cb_new_revokekey(client, query):
|
309 |
+
user_id = query.from_user.id
|
310 |
+
if not query.from_user.username:
|
311 |
+
return await query.answer("Required username first", True)
|
312 |
try:
|
313 |
+
url = "https://randydev-ryu-js.hf.space/api/v1/key/revoked-key"
|
314 |
+
response = requests.post(
|
315 |
+
url,
|
316 |
+
params={
|
317 |
+
"user_id": user_id,
|
318 |
+
"username": query.from_user.username
|
319 |
+
},
|
320 |
+
headers={"x-api-key": os.environ.get("AKENOX_KEY")}
|
321 |
+
)
|
322 |
+
response.raise_for_status()
|
323 |
+
data_json = response.json()
|
324 |
+
except requests.exceptions.RequestException:
|
325 |
+
return await query.answer("API request failed, please try again.", True)
|
326 |
+
|
327 |
+
if data_json.get("is_banned", False):
|
328 |
+
keyboard_back = InlineKeyboardMarkup(
|
329 |
+
[
|
330 |
+
[InlineKeyboardButton("Support Group", url="https://t.me/AkenoXDevSupport")],
|
331 |
+
[InlineKeyboardButton("🔙 Back", callback_data="custom_key")]
|
332 |
+
]
|
333 |
+
)
|
334 |
+
return await query.edit_message_text(
|
335 |
+
BANNED_APIKEY,
|
336 |
+
reply_markup=keyboard_back
|
337 |
+
)
|
338 |
+
if data_json.get("is_deleted", False):
|
339 |
+
keyboard_back = InlineKeyboardMarkup(
|
340 |
+
[
|
341 |
+
[InlineKeyboardButton("Support Group", url="https://t.me/AkenoXDevSupport")],
|
342 |
+
[InlineKeyboardButton("🔙 Back", callback_data="custom_key")]
|
343 |
+
]
|
344 |
+
)
|
345 |
+
return await query.edit_message_text(
|
346 |
+
data_json.get("message", "Unknown error"),
|
347 |
+
reply_markup=keyboard_back
|
348 |
+
)
|
349 |
+
if api_key := data_json.get("apiKey", False):
|
350 |
+
await query.answer(data_json["message"], True)
|
351 |
+
keyboard_back = InlineKeyboardMarkup(
|
352 |
+
[
|
353 |
[
|
354 |
+
InlineKeyboardButton(
|
355 |
+
"🔑 API Key",
|
356 |
+
copy_text=api_key
|
357 |
+
),
|
358 |
+
InlineKeyboardButton(
|
359 |
+
"⚠️ Revoke Key",
|
360 |
+
callback_data="revokedkey"
|
361 |
+
),
|
362 |
+
],
|
363 |
+
[
|
364 |
+
InlineKeyboardButton(
|
365 |
+
"❌ Back",
|
366 |
+
callback_data="close"
|
367 |
+
)
|
368 |
]
|
369 |
+
]
|
370 |
+
)
|
371 |
+
return await query.edit_message_text(
|
372 |
+
YOU_KEY_TEXT.format(
|
373 |
+
api_key=api_key,
|
374 |
+
create_at=data_json.get("createdAt", ""),
|
375 |
+
type=data_json.get("type", "Free"),
|
376 |
+
ttn=data_json.get("expiresAt", "Unlimited")
|
377 |
+
),
|
378 |
+
reply_markup=keyboard_back
|
379 |
+
)
|
380 |
+
return await query.answer("Error api try again", True)
|
381 |
+
|
382 |
+
@client.on_callback_query(filters.regex("createkeyprem"))
|
383 |
+
async def cb_new_keyprem(client, query):
|
384 |
+
user_id = query.from_user.id
|
385 |
try:
|
386 |
+
url = "https://randydev-ryu-js.hf.space/api/v2/key/generate-key"
|
387 |
+
response = requests.post(
|
388 |
+
url,
|
389 |
+
params={"user_id": user_id},
|
390 |
+
headers={"x-api-key": os.environ.get("AKENOX_KEY")}
|
391 |
+
)
|
392 |
+
response.raise_for_status()
|
393 |
+
data_json = response.json()
|
394 |
+
except requests.exceptions.RequestException:
|
395 |
+
return await query.answer("API request failed, please try again.", True)
|
396 |
+
|
397 |
+
if data_json.get("is_banned", False):
|
398 |
+
keyboard_back = InlineKeyboardMarkup(
|
399 |
+
[
|
400 |
[
|
401 |
+
InlineKeyboardButton(
|
402 |
+
"Support Group",
|
403 |
+
url="https://t.me/AkenoXDevSupport"
|
404 |
+
),
|
|
|
|
|
405 |
]
|
406 |
+
]
|
407 |
+
)
|
408 |
+
return await query.edit_message_text(
|
409 |
+
BANNED_APIKEY,
|
410 |
+
reply_markup=keyboard_back
|
411 |
+
)
|
412 |
+
if api_key := data_json.get("apiKey", False):
|
413 |
+
keyboard_back = InlineKeyboardMarkup(
|
414 |
+
[
|
415 |
+
[
|
416 |
+
InlineKeyboardButton(
|
417 |
+
"🔑 API Key",
|
418 |
+
copy_text=api_key
|
419 |
+
),
|
420 |
+
InlineKeyboardButton(
|
421 |
+
"🔁 Update Expired",
|
422 |
+
callback_data="api_key_upgraded"
|
423 |
+
)
|
424 |
+
],
|
425 |
+
[
|
426 |
+
InlineKeyboardButton(
|
427 |
+
"❓ Example Cohere",
|
428 |
+
callback_data="example_cohere"
|
429 |
+
)
|
430 |
+
],
|
431 |
+
[
|
432 |
+
InlineKeyboardButton(
|
433 |
+
"🔙 Back",
|
434 |
+
callback_data="custom_key"
|
435 |
+
)
|
436 |
+
]
|
437 |
+
]
|
438 |
+
)
|
439 |
+
return await query.edit_message_text(
|
440 |
+
YOU_KEY_TEXT.format(
|
441 |
+
api_key=api_key,
|
442 |
+
create_at=data_json.get("createdAt", ""),
|
443 |
+
type=data_json.get("type", "No"),
|
444 |
+
ttn=data_json.get("expiresAt", "No")
|
445 |
+
),
|
446 |
+
reply_markup=keyboard_back
|
447 |
+
)
|
448 |
+
return await query.answer("Error api try again", True)
|
449 |
+
|
450 |
+
@client.on_callback_query(filters.regex("createkey"))
|
451 |
+
async def cb_new_key(client, query):
|
452 |
+
user_id = query.from_user.id
|
453 |
+
if not query.from_user.username:
|
454 |
+
return await query.answer("Required username first", True)
|
455 |
+
|
456 |
+
url = "https://randydev-ryu-js.hf.space/api/v1/key/generate-key"
|
457 |
+
url_two = f"https://randydev-ryu-js.hf.space/api/v1/user/check-ban?user_id={user_id}"
|
458 |
+
try:
|
459 |
+
response = requests.post(
|
460 |
+
url,
|
461 |
+
params={
|
462 |
+
"user_id": user_id,
|
463 |
+
"username": query.from_user.username
|
464 |
+
},
|
465 |
+
headers={"x-api-key": os.environ.get("AKENOX_KEY")}
|
466 |
+
)
|
467 |
+
response_two = requests.get(
|
468 |
+
url_two,
|
469 |
+
headers={"x-api-key": os.environ.get("AKENOX_KEY")}
|
470 |
+
)
|
471 |
+
response.raise_for_status()
|
472 |
+
response_two.raise_for_status()
|
473 |
+
data_json = response.json()
|
474 |
+
data_json_two = response_two.json()
|
475 |
+
except requests.exceptions.RequestException:
|
476 |
+
return await query.answer("API request failed, please try again.", True)
|
477 |
+
|
478 |
+
if data_json_two.get("is_ban", False):
|
479 |
+
return await query.answer("You been blocked from Developer.", True)
|
480 |
+
|
481 |
+
if data_json.get("is_deleted", False):
|
482 |
+
keyboard_back = InlineKeyboardMarkup(
|
483 |
+
[
|
484 |
+
[InlineKeyboardButton("Support Group", url="https://t.me/AkenoXDevSupport")],
|
485 |
+
[InlineKeyboardButton("🔙 Back", callback_data="custom_key")]
|
486 |
+
]
|
487 |
+
)
|
488 |
+
return await query.edit_message_text(
|
489 |
+
data_json.get("message", "Unknown error"),
|
490 |
+
reply_markup=keyboard_back
|
491 |
+
)
|
492 |
+
|
493 |
+
if data_json.get("is_banned", False):
|
494 |
+
keyboard_back = InlineKeyboardMarkup(
|
495 |
+
[
|
496 |
+
[InlineKeyboardButton("Support Group", url="https://t.me/AkenoXDevSupport")],
|
497 |
+
[InlineKeyboardButton("🔙 Back", callback_data="custom_key")]
|
498 |
+
]
|
499 |
+
)
|
500 |
+
return await query.edit_message_text(
|
501 |
+
BANNED_APIKEY,
|
502 |
+
reply_markup=keyboard_back
|
503 |
+
)
|
504 |
+
if api_key := data_json.get("apiKey"):
|
505 |
+
keyboard_back = InlineKeyboardMarkup(
|
506 |
+
[
|
507 |
+
[
|
508 |
+
InlineKeyboardButton(
|
509 |
+
"🔑 API Key",
|
510 |
+
copy_text=api_key
|
511 |
+
),
|
512 |
+
InlineKeyboardButton(
|
513 |
+
"⚠️ Revoke Key",
|
514 |
+
callback_data="revokedkey"
|
515 |
+
),
|
516 |
+
],
|
517 |
+
[
|
518 |
+
InlineKeyboardButton(
|
519 |
+
"🔙 Back",
|
520 |
+
callback_data="custom_key"
|
521 |
+
)
|
522 |
+
]
|
523 |
+
]
|
524 |
+
)
|
525 |
+
return await query.edit_message_text(
|
526 |
+
YOU_KEY_TEXT.format(
|
527 |
+
api_key=api_key,
|
528 |
+
create_at=data_json.get("createdAt", ""),
|
529 |
+
type=data_json.get("type", "Free"),
|
530 |
+
ttn=data_json.get("expiresAt", "Unlimited")
|
531 |
+
),
|
532 |
+
reply_markup=keyboard_back
|
533 |
+
)
|
534 |
+
return await query.answer("Error: API key not generated, please try again.", True)
|
535 |
|
536 |
@client.on_message(
|
537 |
filters.incoming
|
|
|
539 |
& filters.private
|
540 |
)
|
541 |
async def welcome_start(client: Client, message: Message):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
542 |
keyboard = InlineKeyboardMarkup(
|
543 |
[
|
544 |
[
|
545 |
InlineKeyboardButton(
|
546 |
+
text="🆕 Get API Key",
|
547 |
+
callback_data="custom_key"
|
548 |
)
|
549 |
]
|
550 |
]
|
551 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
552 |
await message.reply_text(
|
553 |
WELCOME_TEXT.format(
|
554 |
first_name=message.from_user.first_name
|
|
|
556 |
reply_markup=keyboard
|
557 |
)
|
558 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
559 |
client.run()
|