From 47bedbcbb6e5230c5ec7649d9592915dec5b3b38 Mon Sep 17 00:00:00 2001 From: Devesh Pal Date: Sun, 18 Dec 2022 17:43:37 +0530 Subject: [PATCH] chore: fix chatbot and other minor issues. - update Chatbot API. - Fix Invalid type of object in database. --- plugins/_chatactions.py | 4 ++-- plugins/chatbot.py | 20 ++++++++++---------- pyUltroid/fns/tools.py | 26 ++++++++++---------------- pyUltroid/startup/funcs.py | 2 +- pyUltroid/version.py | 4 ++-- 5 files changed, 25 insertions(+), 31 deletions(-) diff --git a/plugins/_chatactions.py b/plugins/_chatactions.py index 255650e..94fd7b3 100644 --- a/plugins/_chatactions.py +++ b/plugins/_chatactions.py @@ -224,7 +224,7 @@ async def uname_change(e): async def uname_stuff(id, uname, name): - if udB.get_key("USERNAME_LOG") == "True": + if udB.get_key("USERNAME_LOG"): old_ = udB.get_key("USERNAME_DB") or {} old = old_.get(id) # Ignore Name Logs @@ -247,4 +247,4 @@ async def uname_stuff(id, uname, name): ) old_[id] = uname - udB.set_key("USERNAME_DB", str(old_)) + udB.set_key("USERNAME_DB", old_) diff --git a/plugins/chatbot.py b/plugins/chatbot.py index a39c297..75ade55 100644 --- a/plugins/chatbot.py +++ b/plugins/chatbot.py @@ -12,7 +12,7 @@ __doc__ = get_help("help_chatbot") from pyUltroid.fns.tools import get_chatbot_reply -from . import eod, get_string, inline_mention, udB, ultroid_cmd +from . import eod, get_string, inline_mention, udB, ultroid_cmd, LOGS @ultroid_cmd(pattern="repai") @@ -62,14 +62,14 @@ async def chat_bot_fn(event, type_): temp = event.text.split(maxsplit=1) try: user_ = await event.client.get_entity(await event.client.parse_id(temp[1])) - except BaseException: - if event.is_private: - user_ = event.chat - if not user_: - return await eod( - event, - get_string("chab_1"), - ) + except BaseException as er: + LOGS.exception(er) + user_ = event.chat if event.is_private else None + if not user_: + return await eod( + event, + get_string("chab_1"), + ) key = udB.get_key("CHATBOT_USERS") or {} chat = event.chat_id user = user_.id @@ -85,5 +85,5 @@ async def chat_bot_fn(event, type_): key[chat].remove(user) if chat in key and not key[chat]: del key[chat] - udB.set_key("CHATBOT_USERS", str(key)) + udB.set_key("CHATBOT_USERS", key) await event.eor(f"**ChatBot:**\n{type_}ed {inline_mention(user_)}") diff --git a/pyUltroid/fns/tools.py b/pyUltroid/fns/tools.py index b7622e1..e625cea 100644 --- a/pyUltroid/fns/tools.py +++ b/pyUltroid/fns/tools.py @@ -407,11 +407,8 @@ async def get_paste(data: str, extension: str = "txt"): async def get_chatbot_reply(message): - from .. import ultroid_bot - - chatbot_base = "https://kukiapi.xyz/api/apikey=ULTROIDUSERBOT/Ultroid/{}/message={}" + chatbot_base = "https://kuki-api-lac.vercel.app/message={}" req_link = chatbot_base.format( - ultroid_bot.me.first_name or "ultroid user", message, ) try: @@ -419,7 +416,6 @@ async def get_chatbot_reply(message): except Exception: LOGS.info(f"**ERROR:**`{format_exc()}`") - def check_filename(filroid): if os.path.exists(filroid): no = 1 @@ -559,20 +555,19 @@ def make_html_telegraph(title, html=""): async def Carbon( code, - base_url="https://carbonara-42.herokuapp.com/api/cook", + base_url="https://rayso-api-desvhu-33.koyeb.app/generate", file_name="ultroid", download=False, rayso=False, **kwargs, ): - if rayso: - base_url = "https://raysoapi.herokuapp.com/generate" - kwargs["text"] = code - kwargs["theme"] = kwargs.get("theme", "meadow") - kwargs["darkMode"] = kwargs.get("darkMode", True) - kwargs["title"] = kwargs.get("title", "Ultroid") - else: - kwargs["code"] = code + # if rayso: + kwargs["text"] = code + kwargs["theme"] = kwargs.get("theme", "meadow") + kwargs["darkMode"] = kwargs.get("darkMode", True) + kwargs["title"] = kwargs.get("title", "Ultroid") + # else: + # kwargs["code"] = code con = await async_searcher(base_url, post=True, json=kwargs, re_content=True) if not download: file = BytesIO(con) @@ -621,8 +616,7 @@ def _package_rpc(text, lang_src="auto", lang_tgt="auto"): escaped_parameter = json.dumps(parameter, separators=(",", ":")) rpc = [[[random.choice(GOOGLE_TTS_RPC), escaped_parameter, None, "generic"]]] espaced_rpc = json.dumps(rpc, separators=(",", ":")) - freq_initial = "f.req={}&".format(quote(espaced_rpc)) - freq = freq_initial + freq = "f.req={}&".format(quote(espaced_rpc)) return freq diff --git a/pyUltroid/startup/funcs.py b/pyUltroid/startup/funcs.py index e854b60..530fd00 100644 --- a/pyUltroid/startup/funcs.py +++ b/pyUltroid/startup/funcs.py @@ -256,7 +256,7 @@ async def autopilot(): new_channel = True chat = r.chats[0] channel = get_peer_id(chat) - udB.set_key("LOG_CHANNEL", str(channel)) + udB.set_key("LOG_CHANNEL", channel) assistant = True try: await ultroid_bot.get_permissions(int(channel), asst.me.username) diff --git a/pyUltroid/version.py b/pyUltroid/version.py index e1c53e1..17ee6c6 100644 --- a/pyUltroid/version.py +++ b/pyUltroid/version.py @@ -1,2 +1,2 @@ -__version__ = "2022.08.30" -ultroid_version = "0.7.1" +__version__ = "2022.12.18" +ultroid_version = "0.7.2"