update
Browse files- chatbot/plugins/chat.py +77 -18
chatbot/plugins/chat.py
CHANGED
@@ -7,32 +7,22 @@
|
|
7 |
# This project is proprietary software. Unauthorized redistribution is prohibited.
|
8 |
|
9 |
import asyncio
|
10 |
-
import importlib
|
11 |
-
import math
|
12 |
import random
|
13 |
import os
|
14 |
import base64
|
15 |
import re
|
16 |
import uuid
|
17 |
-
import shlex
|
18 |
-
import requests
|
19 |
-
import subprocess
|
20 |
-
import sys
|
21 |
-
import time
|
22 |
-
import traceback
|
23 |
import requests
|
24 |
import json
|
25 |
-
import
|
26 |
-
import cohere
|
27 |
from datetime import datetime as dt, timedelta
|
28 |
|
29 |
-
from gpytranslate import SyncTranslator
|
30 |
from io import BytesIO
|
31 |
-
from typing import
|
32 |
|
33 |
-
from PIL import Image
|
34 |
from pyrogram import *
|
35 |
-
from pyrogram.enums import ChatMemberStatus
|
36 |
from pyrogram import enums
|
37 |
from pyrogram import Client, filters
|
38 |
from pyrogram.types import *
|
@@ -42,13 +32,13 @@ from database import users_collection, db
|
|
42 |
from logger import LOGS
|
43 |
|
44 |
from akenoai import *
|
45 |
-
from akenoai.types import DifferentAPIDefault
|
46 |
|
47 |
from google import genai
|
48 |
from google.genai import types as ty
|
49 |
|
50 |
trans = SyncTranslator()
|
51 |
-
js = AkenoXJs(DifferentAPIDefault()).connect()
|
52 |
|
53 |
message_memory_state = {}
|
54 |
DISABLED_COMMANDS = [
|
@@ -269,6 +259,73 @@ async def coheresearch(client, callback):
|
|
269 |
])
|
270 |
await callback.edit_message_reply_markup(reply_markup=InlineKeyboardMarkup(keyboard))
|
271 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
272 |
@Client.on_callback_query(filters.regex("^deeps_(on|off)_([a-f0-9]{8})$"))
|
273 |
async def deepsearchmode(client, callback):
|
274 |
user_id = callback.from_user.id
|
@@ -660,8 +717,8 @@ async def createchat_cb(client, callback):
|
|
660 |
if not data:
|
661 |
await callback.answer("Can't found user", True)
|
662 |
return
|
663 |
-
|
664 |
-
if not
|
665 |
await callback.answer("You can reset chat, this no chat found", True)
|
666 |
return
|
667 |
await callback.answer(f"Created Chat: {create_chat_uuid}", True)
|
@@ -1600,3 +1657,5 @@ async def chatbot_talk(client: Client, message: Message):
|
|
1600 |
except Exception as e:
|
1601 |
LOGS.error(f"Error: message.text: {str(e)}")
|
1602 |
return await message.reply_text("Server busy try again later")
|
|
|
|
|
|
7 |
# This project is proprietary software. Unauthorized redistribution is prohibited.
|
8 |
|
9 |
import asyncio
|
|
|
|
|
10 |
import random
|
11 |
import os
|
12 |
import base64
|
13 |
import re
|
14 |
import uuid
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
import requests
|
16 |
import json
|
17 |
+
import cohere # type: ignore
|
|
|
18 |
from datetime import datetime as dt, timedelta
|
19 |
|
20 |
+
from gpytranslate import SyncTranslator # type: ignore
|
21 |
from io import BytesIO
|
22 |
+
from typing import List
|
23 |
|
24 |
+
from PIL import Image # type: ignore
|
25 |
from pyrogram import *
|
|
|
26 |
from pyrogram import enums
|
27 |
from pyrogram import Client, filters
|
28 |
from pyrogram.types import *
|
|
|
32 |
from logger import LOGS
|
33 |
|
34 |
from akenoai import *
|
35 |
+
from akenoai.types import DifferentAPIDefault # type: ignore
|
36 |
|
37 |
from google import genai
|
38 |
from google.genai import types as ty
|
39 |
|
40 |
trans = SyncTranslator()
|
41 |
+
js = AkenoXJs(DifferentAPIDefault()).connect() # type: ignore
|
42 |
|
43 |
message_memory_state = {}
|
44 |
DISABLED_COMMANDS = [
|
|
|
259 |
])
|
260 |
await callback.edit_message_reply_markup(reply_markup=InlineKeyboardMarkup(keyboard))
|
261 |
|
262 |
+
|
263 |
+
def inline_error(inline_text, **args):
|
264 |
+
answers = [
|
265 |
+
InlineQueryResultArticle(
|
266 |
+
title="Error!",
|
267 |
+
thumb_url="https://telegra.ph//file/586a3867c3e16ca6bb4fa.jpg",
|
268 |
+
input_message_content=InputTextMessageContent(
|
269 |
+
message_text=inline_text,
|
270 |
+
disable_web_page_preview=True
|
271 |
+
),
|
272 |
+
**args
|
273 |
+
)
|
274 |
+
]
|
275 |
+
return answers
|
276 |
+
|
277 |
+
@Client.on_inline_query()
|
278 |
+
async def inline_search(client: Client, inline_query: InlineQuery):
|
279 |
+
search_query = inline_query.query.strip()
|
280 |
+
if not search_query:
|
281 |
+
return
|
282 |
+
if search_query:
|
283 |
+
try:
|
284 |
+
response = requests.get(
|
285 |
+
'https://www.googleapis.com/customsearch/v1',
|
286 |
+
params={
|
287 |
+
"key": GOOGLE_API_SEARCH,
|
288 |
+
"cx": "8386c816e6fff4b2a",
|
289 |
+
"q": search_query,
|
290 |
+
"searchType": "image"
|
291 |
+
}
|
292 |
+
)
|
293 |
+
response_json = response.json()
|
294 |
+
if 'items' in response_json:
|
295 |
+
results = []
|
296 |
+
for i, item in enumerate(response_json['items']):
|
297 |
+
title = item['title']
|
298 |
+
description = item['image']['contextLink']
|
299 |
+
url = item['link']
|
300 |
+
result = InlineQueryResultPhoto(
|
301 |
+
photo_url=url,
|
302 |
+
id=str(i),
|
303 |
+
title=title,
|
304 |
+
description=description,
|
305 |
+
thumb_url=url,
|
306 |
+
input_message_content=InputTextMessageContent(
|
307 |
+
message_text=f"**Title:** {title}\n\n**Description:** {description}"
|
308 |
+
),
|
309 |
+
reply_markup=InlineKeyboardMarkup(
|
310 |
+
[[InlineKeyboardButton(text="Open Link", url=url)]]
|
311 |
+
),
|
312 |
+
)
|
313 |
+
results.append(result)
|
314 |
+
await client.answer_inline_query(inline_query.id, results=results, cache_time=10)
|
315 |
+
else:
|
316 |
+
no_found = inline_error("No found result.")
|
317 |
+
await client.answer_inline_query(
|
318 |
+
inline_query.id,
|
319 |
+
results=no_found
|
320 |
+
)
|
321 |
+
except Exception as e:
|
322 |
+
LOGS.error(f"Error Inline: {type(e).__name__}")
|
323 |
+
error_ = inline_error(f"Error try again.")
|
324 |
+
await client.answer_inline_query(
|
325 |
+
inline_query.id,
|
326 |
+
results=error_
|
327 |
+
)
|
328 |
+
|
329 |
@Client.on_callback_query(filters.regex("^deeps_(on|off)_([a-f0-9]{8})$"))
|
330 |
async def deepsearchmode(client, callback):
|
331 |
user_id = callback.from_user.id
|
|
|
717 |
if not data:
|
718 |
await callback.answer("Can't found user", True)
|
719 |
return
|
720 |
+
create_chat_uuid = data.get("create_chat_uuid", None)
|
721 |
+
if not create_chat_uuid:
|
722 |
await callback.answer("You can reset chat, this no chat found", True)
|
723 |
return
|
724 |
await callback.answer(f"Created Chat: {create_chat_uuid}", True)
|
|
|
1657 |
except Exception as e:
|
1658 |
LOGS.error(f"Error: message.text: {str(e)}")
|
1659 |
return await message.reply_text("Server busy try again later")
|
1660 |
+
|
1661 |
+
# Developer by @xtdevs
|