Skip to content

Commit

Permalink
chore: fix chatbot and other minor issues.
Browse files Browse the repository at this point in the history
- update Chatbot API.
- Fix Invalid type of object in database.
  • Loading branch information
New-dev0 committed Dec 18, 2022
1 parent fbfde04 commit 47bedbc
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 31 deletions.
4 changes: 2 additions & 2 deletions plugins/_chatactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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_)
20 changes: 10 additions & 10 deletions plugins/chatbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

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")
Expand Down Expand Up @@ -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
Expand All @@ -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_)}")
26 changes: 10 additions & 16 deletions pyUltroid/fns/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,19 +407,15 @@ 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:
return (await async_searcher(req_link, re_json=True)).get("reply")
except Exception:
LOGS.info(f"**ERROR:**`{format_exc()}`")


def check_filename(filroid):
if os.path.exists(filroid):
no = 1
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion pyUltroid/startup/funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ async def _save(exc):
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)
Expand Down
4 changes: 2 additions & 2 deletions pyUltroid/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "2022.08.30"
ultroid_version = "0.7.1"
__version__ = "2022.12.18"
ultroid_version = "0.7.2"

0 comments on commit 47bedbc

Please sign in to comment.