randydev's picture
Update chatbot/plugins/web.py
c62e7c4 verified
raw
history blame
1.91 kB
import asyncio
import time
import os
from pyrogram import Client, filters
from pyrogram.types import *
from pyrogram.enums import *
from pyrogram import *
from database import db
from chatbot.plugins.user_database import users_collection
from chatbot.plugins.keyboards import get_language_keyboard
from chatbot.plugins.languages import LANGUAGES
import akenoai as dev
from . import force_sub
@Client.on_message(
~filters.scheduled
& filters.command(["web"])
& ~filters.forwarded
)
@force_sub
async def askwebcmd(client: Client, message: Message):
pro = await message.reply("Processing your web request...", quote=True)
user_id = message.from_user.id
user = await users_collection.find_one({"user_id": user_id})
lang = user.get("language") if user else None
chat_user = await db.get_chatbot(message.chat.id)
if not chat_user:
return
if len(message.command) > 1:
prompt = message.text.split(maxsplit=1)[1]
elif message.reply_to_message:
prompt = message.reply_to_message.text
else:
return await pro.edit_text("Give ask from GPT-5")
await client.send_chat_action(message.chat.id, enums.ChatAction.TYPING)
await asyncio.sleep(1.5)
if not lang:
await message.reply(
"Please select your preferred language:",
reply_markup=get_language_keyboard()
)
await pro.delete()
return
akeno_api = dev.AkenoPlus(...)
response = await akeno_api.chatgpt_mode_web(
query=prompt,
is_trans="True",
lang=lang
)
data = await akeno_api.get_json(response=response)
await pro.edit_text(data.randydev.message)
@Client.on_message(filters.command("setlang"))
async def setlang_cmd(client: Client, message: Message):
await message.reply(
"Please select your preferred language:",
reply_markup=get_language_keyboard()
)