- chatbot/plugins/chat.py +21 -7
chatbot/plugins/chat.py
CHANGED
|
@@ -26,6 +26,7 @@ import base64
|
|
| 26 |
import re
|
| 27 |
import uuid
|
| 28 |
import shlex
|
|
|
|
| 29 |
import subprocess
|
| 30 |
import sys
|
| 31 |
import time
|
|
@@ -92,6 +93,23 @@ blacklist_patterns = [
|
|
| 92 |
r"\bdeath\s*threat\b",
|
| 93 |
]
|
| 94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
def is_command_disabled(text):
|
| 96 |
text_lower = text.lower()
|
| 97 |
if text_lower.startswith("/") and not (
|
|
@@ -1474,12 +1492,8 @@ async def chatbot_talk(client: Client, message: Message):
|
|
| 1474 |
await message.reply_text(CREDITS_DEVELOPER)
|
| 1475 |
return
|
| 1476 |
|
| 1477 |
-
|
| 1478 |
-
|
| 1479 |
-
return await message.reply_text(
|
| 1480 |
-
"You can't write **image** small, it has to be long OR short first\n"
|
| 1481 |
-
"OR Text Too many `MAX_TOO_MANY_TEXT: 350`"
|
| 1482 |
-
)
|
| 1483 |
try:
|
| 1484 |
buttons = [
|
| 1485 |
[
|
|
@@ -1503,7 +1517,7 @@ async def chatbot_talk(client: Client, message: Message):
|
|
| 1503 |
]
|
| 1504 |
await db.backup_chatbot.update_one(
|
| 1505 |
{"user_id": message.from_user.id},
|
| 1506 |
-
{"$set": {"prompt_image":
|
| 1507 |
upsert=True
|
| 1508 |
)
|
| 1509 |
await message.reply_photo(
|
|
|
|
| 26 |
import re
|
| 27 |
import uuid
|
| 28 |
import shlex
|
| 29 |
+
import requests
|
| 30 |
import subprocess
|
| 31 |
import sys
|
| 32 |
import time
|
|
|
|
| 93 |
r"\bdeath\s*threat\b",
|
| 94 |
]
|
| 95 |
|
| 96 |
+
def aigen_check(text: str):
|
| 97 |
+
reason = ""
|
| 98 |
+
try:
|
| 99 |
+
response = requests.get(
|
| 100 |
+
f"https://randydev-ryu-js.hf.space/api/v1/ai/akenox/aigen-v1?query={text}",
|
| 101 |
+
headers={"x-api-key": "akeno_UKQEQMt991kh2Ehh7JqJYKapx8CCyeC"}
|
| 102 |
+
).json()
|
| 103 |
+
ok = json.loads(response["results"])
|
| 104 |
+
|
| 105 |
+
if ok.get("prompt"):
|
| 106 |
+
reason += ok["prompt"]
|
| 107 |
+
if ok.get("is_image") is True:
|
| 108 |
+
return True, reason
|
| 109 |
+
return False, reason
|
| 110 |
+
except (json.decoder.JSONDecodeError, KeyError, TypeError):
|
| 111 |
+
return False, reason
|
| 112 |
+
|
| 113 |
def is_command_disabled(text):
|
| 114 |
text_lower = text.lower()
|
| 115 |
if text_lower.startswith("/") and not (
|
|
|
|
| 1492 |
await message.reply_text(CREDITS_DEVELOPER)
|
| 1493 |
return
|
| 1494 |
|
| 1495 |
+
is_image, new_prompt_gen, = aigen_check(query_base)
|
| 1496 |
+
if is_image:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1497 |
try:
|
| 1498 |
buttons = [
|
| 1499 |
[
|
|
|
|
| 1517 |
]
|
| 1518 |
await db.backup_chatbot.update_one(
|
| 1519 |
{"user_id": message.from_user.id},
|
| 1520 |
+
{"$set": {"prompt_image": new_prompt_gen}},
|
| 1521 |
upsert=True
|
| 1522 |
)
|
| 1523 |
await message.reply_photo(
|