From 8a1d062115bd79f50df1767d1d23452adb602f03 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Wed, 24 Jan 2024 22:21:37 +0800 Subject: [PATCH 001/268] Update chatbot.py From c32948e7cd77bf13836f888c92ed352043c05673 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Wed, 24 Jan 2024 22:33:27 +0800 Subject: [PATCH 002/268] Update tools.py --- plugins/tools.py | 127 +++++++++++++++++++++++++++++------------------ 1 file changed, 78 insertions(+), 49 deletions(-) diff --git a/plugins/tools.py b/plugins/tools.py index a1f3628236..a1b60cb55f 100644 --- a/plugins/tools.py +++ b/plugins/tools.py @@ -24,8 +24,8 @@ Reply a User to Get His Id Without Replying You Will Get the Chat's Id -• `{i}sg ` - Get His Name History of the replied user. +• `{i}sg ` or `{i}sgu ` + Get Name History of the user. • `{i}tr <(reply to) a message>` Get translated message. @@ -36,11 +36,12 @@ • `{i}shorturl ` shorten any url... """ +import asyncio import glob import io import os +import re import secrets -from asyncio.exceptions import TimeoutError as AsyncTimeout try: import cv2 @@ -57,6 +58,7 @@ WebShot = None from telethon.errors.rpcerrorlist import MessageTooLongError, YouBlockedUserError +from telethon.tl.functions.contacts import UnblockRequest as unblock from telethon.tl.types import ( ChannelParticipantAdmin, ChannelParticipantsBots, @@ -80,6 +82,18 @@ from . import humanbytes as hb from . import inline_mention, is_url_ok, json_parser, mediainfo, ultroid_cmd +#-------------- Sangmata stuff --------------# +def sanga_seperator(sanga_list): + string = "".join(info[info.find("\n") + 1 :] for info in sanga_list) + string = re.sub(r"^$\n", "", string, flags=re.MULTILINE) + name, username = string.split("Usernames**") + name = name.split("Names")[1] + return name, username + + +def mentionuser(name, userid): + return f"[{name}](tg://user?id={userid})" +#-------------- Sangmata stuff --------------# @ultroid_cmd(pattern="tr( (.*)|$)", manager=True) async def _(event): @@ -338,55 +352,70 @@ async def _(e): await e.delete() -@ultroid_cmd( - pattern="sg( (.*)|$)", +@ultroid( + pattern="sg(|u)(?:\\s|$)([\\s\\S]*)", + fullsudo=True, ) -async def lastname(steal): - mat = steal.pattern_match.group(1).strip() - message = await steal.get_reply_message() - if mat: - try: - user_id = await steal.client.parse_id(mat) - except ValueError: - user_id = mat - elif message: - user_id = message.sender_id - else: - return await steal.eor("`Use this command with reply or give Username/id...`") - chat = "@SangMataInfo_bot" - id = f"/search_id {user_id}" - lol = await steal.eor(get_string("com_1")) +async def sangmata(event): + "To get name/username history." + cmd = event.pattern_match.group(1) + user = event.pattern_match.group(2) + reply = await event.get_reply_message() + if not user and reply: + user = str(reply.sender_id) + if not user: + await event.edit( + "`Reply to user's text message to get name/username history or give userid/username`", + ) + await asyncio.sleep(10) + return await event.delete() + try: - async with steal.client.conversation(chat) as conv: + if user.isdigit(): + userinfo = await ultroid_bot.get_entity(int(user)) + else: + userinfo = await ultroid_bot.get_entity(user) + except ValueError: + userinfo = None + if not isinstance(userinfo, types.User): + await event.edit("`Can't fetch the user...`") + await asyncio.sleep(10) + return await event.delete() + + await event.edit("`Processing...`") + async with event.client.conversation("@SangMata_beta_bot") as conv: + try: + await conv.send_message(userinfo.id) + except YouBlockedUserError: + await catub(unblock("SangMata_beta_bot")) + await conv.send_message(userinfo.id) + responses = [] + while True: try: - msg = await conv.send_message(id) - response = await conv.get_response() - respond = await conv.get_response() - responds = await conv.get_response() - except YouBlockedUserError: - return await lol.edit("Please unblock @sangmatainfo_bot and try again") - if ( - (response and response.text == "No records found") - or (respond and respond.text == "No records found") - or (responds and responds.text == "No records found") - ): - await lol.edit("No records found for this user") - await steal.client.delete_messages(conv.chat_id, [msg.id, response.id]) - elif response.text.startswith("🔗"): - await lol.edit(respond.message) - await lol.reply(responds.message) - elif respond.text.startswith("🔗"): - await lol.edit(response.message) - await lol.reply(responds.message) - else: - await lol.edit(respond.message) - await lol.reply(response.message) - await steal.client.delete_messages( - conv.chat_id, - [msg.id, responds.id, respond.id, response.id], - ) - except AsyncTimeout: - await lol.edit("Error: @SangMataInfo_bot is not responding!.") + response = await conv.get_response(timeout=2) + except asyncio.TimeoutError: + break + responses.append(response.text) + await event.client.send_read_acknowledge(conv.chat_id) + + if not responses: + await event.edit("`Bot can't fetch results`") + await asyncio.sleep(10) + await event.delete() + if "No records found" in responses or "No data available" in responses: + await event.edit("`The user doesn't have any record`") + await asyncio.sleep(10) + await event.delete() + + names, usernames = sanga_seperator(responses) + check = (usernames, "Username") if cmd == "u" else (names, "Name") + user_name = ( + f"{userinfo.first_name} {userinfo.last_name}" + if userinfo.last_name + else userinfo.first_name + ) + output = f"**➜ User Info :** {mentionuser(user_name, userinfo.id)}\n**➜ {check[1]} History :**\n{check[0]}" + await event.edit(output) @ultroid_cmd(pattern="webshot( (.*)|$)") From 2dfbcf8e1d93421a6f206d5e74f8fa258c52e60b Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Wed, 24 Jan 2024 22:50:24 +0800 Subject: [PATCH 003/268] Update tools.py --- pyUltroid/fns/tools.py | 83 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 74 insertions(+), 9 deletions(-) diff --git a/pyUltroid/fns/tools.py b/pyUltroid/fns/tools.py index 2571314329..8762b637b9 100644 --- a/pyUltroid/fns/tools.py +++ b/pyUltroid/fns/tools.py @@ -5,6 +5,7 @@ # PLease read the GNU Affero General Public License in # . +import asyncio import json import math import os @@ -12,9 +13,13 @@ import re import secrets import ssl +import sys +from functools import partial from io import BytesIO from json.decoder import JSONDecodeError +from pydantic import BaseModel from traceback import format_exc +from typing import Any, Dict, Optional import requests @@ -432,19 +437,79 @@ async def get_google_images(query): random.shuffle(google_images) return google_images +############################################################################### +# Thanks https://t.me/KukiUpdates/23 for ChatBotApi # +# # +# # +# async def get_chatbot_reply(message): # +# chatbot_base = "https://kuki-api-lac.vercel.app/message={}" # +# req_link = chatbot_base.format( # +# message, # +# ) # +# try: # +# return (await async_searcher(req_link, re_json=True)).get("reply") # +# except Exception: # +# LOGS.info(f"**ERROR:**`{format_exc()}`") # +############################################################################### + +############################################################################### +# Thanks to @xtdevs Huge Thanks to @xditya!!!!!! # +############################################################################### +class AwesomeCoding(BaseModel): + nimbusai_url: str = b"\xff\xfeh\x00t\x00t\x00p\x00s\x00:\x00/\x00/\x00u\x00f\x00o\x00p\x00t\x00g\x00-\x00u\x00f\x00o\x00p\x00-\x00a\x00p\x00i\x00.\x00h\x00f\x00.\x00s\x00p\x00a\x00c\x00e\x00/\x00U\x00F\x00o\x00P\x00/\x00G\x00-\x00A\x00I\x00" + default_url: Optional[str] = None + extra_headers: Optional[Dict[str, Any]] = None + extra_payload: Optional[Dict[str, Any]] = None + +UFoP_API = udB.get_key("UFOPAPI") #This can be changed to allow for no API-Key. +############################################################################### +# By @TrueSaiyan Huge Thanks to @xditya!!!!!! # +############################################################################### +async def get_chatbot_reply(message): + response = AwesomeCoding( + extra_headers={"api-key": UFoP_API}, + extra_payload={"query": message}, + ) + loop = asyncio.get_event_loop() + partial_func = partial( + requests.post, + response.nimbusai_url.decode("utf-16"), + headers=response.extra_headers, + json=response.extra_payload, + ) -# Thanks https://t.me/KukiUpdates/23 for ChatBotApi + try: + response_data = await loop.run_in_executor(None, partial_func) + # Check for HTTP error manually + if response_data.status_code == 500: + LOGS.exception("Internal Server Error (500) from the chatbot server.") + return "Sorry, I can't answer that right now. Please try again later." + + response_data.raise_for_status() # Raise an error for other HTTP errors (4xx, 5xx) + except requests.exceptions.HTTPError as http_err: + LOGS.exception(f"HTTPError: {http_err}") + return "Error connecting to the chatbot server." + except Exception as e: + LOGS.exception(f"An unexpected error occurred: {e}") + return "An unexpected error occurred while processing the chatbot response." -async def get_chatbot_reply(message): - chatbot_base = "https://kuki-api-lac.vercel.app/message={}" - req_link = chatbot_base.format( - message, - ) try: - return (await async_searcher(req_link, re_json=True)).get("reply") - except Exception: - LOGS.info(f"**ERROR:**`{format_exc()}`") + response_json = response_data.json() + reply_message = response_json.get("randydev", {}).get("message") + if reply_message is not None: + return reply_message + else: + LOGS.warning("Unexpected JSON format in the chatbot response.") + return "Unexpected response from the chatbot server." + except json.JSONDecodeError as json_err: + LOGS.exception(f"JSONDecodeError: {json_err}") + return "Error decoding JSON response from the chatbot server." + except Exception as e: + LOGS.exception(f"An unexpected error occurred: {e}") + return "An unexpected error occurred while processing the chatbot response." + +#-----------------------------------------------------------------------------------# def check_filename(filroid): if os.path.exists(filroid): From 325771c8327bdb2652dbf5ba917fa730ca4b4591 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Wed, 24 Jan 2024 22:59:00 +0800 Subject: [PATCH 004/268] Update helper.py --- pyUltroid/fns/helper.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/pyUltroid/fns/helper.py b/pyUltroid/fns/helper.py index 16d00ea177..7696e2c3d7 100644 --- a/pyUltroid/fns/helper.py +++ b/pyUltroid/fns/helper.py @@ -96,6 +96,30 @@ def inline_mention(user, custom=None, html=False): return f"[{mention_text}](https://t.me/{user.username})" return mention_text +async def check_reply_to(event): + replytoIDS = [client.me.id] + if (event.is_private and event.is_reply) or ( + event.is_reply and event.reply_to_msg_id + ): + try: + replied_message = await event.client.get_messages( + event.chat_id, ids=event.reply_to_msg_id + ) + if replied_message.from_id: + user_id = replied_message.from_id.user_id + if user_id in replytoIDS: + return True + elif replied_message.peer_id and not replied_message.from_id: + channel_id = replied_message.peer_id.channel_id + if channel_id in replytoIDS: + return True + # If neither user_id nor channel_id is in truai, return False + return False + except Exception as e: + # Log the exception for debugging + print(f"Exception: {e}") + return False + return False # ----------------- Load \\ Unloader ---------------- # From 3e2e09684f719e57a89c7a6df2e7db5a1ce7c23e Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Wed, 24 Jan 2024 23:04:04 +0800 Subject: [PATCH 005/268] Update _chatactions.py --- plugins/_chatactions.py | 77 +++++++++++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 26 deletions(-) diff --git a/plugins/_chatactions.py b/plugins/_chatactions.py index 8f1a9d3baa..00d07a51f1 100644 --- a/plugins/_chatactions.py +++ b/plugins/_chatactions.py @@ -18,7 +18,7 @@ from pyUltroid.dB.gban_mute_db import is_gbanned from pyUltroid.dB.greetings_db import get_goodbye, get_welcome, must_thank from pyUltroid.dB.nsfw_db import is_profan -from pyUltroid.fns.helper import inline_mention +from pyUltroid.fns.helper import check_reply_to, inline_mention from pyUltroid.fns.tools import async_searcher, create_tl_btn, get_chatbot_reply try: @@ -192,33 +192,58 @@ async def DummyHandler(ult): else: await ult.reply(file=med) - @ultroid_bot.on(events.NewMessage(incoming=True)) async def chatBot_replies(e): - sender = await e.get_sender() - if not isinstance(sender, types.User) or sender.bot: - return - if check_echo(e.chat_id, e.sender_id): - try: - await e.respond(e.message) - except Exception as er: - LOGS.exception(er) - key = udB.get_key("CHATBOT_USERS") or {} - if e.text and key.get(e.chat_id) and sender.id in key[e.chat_id]: - msg = await get_chatbot_reply(e.message.message) - if msg: - sleep = udB.get_key("CHATBOT_SLEEP") or 1.5 - await asyncio.sleep(sleep) - await e.reply(msg) - chat = await e.get_chat() - if e.is_group and sender.username: - await uname_stuff(e.sender_id, sender.username, sender.first_name) - elif e.is_private and chat.username: - await uname_stuff(e.sender_id, chat.username, chat.first_name) - if detector and is_profan(e.chat_id) and e.text: - x, y = detector(e.text) - if y: - await e.delete() + xxrep = await check_reply_to(e) + + if xxrep: + sender = await e.get_sender() + if not isinstance(sender, types.User) or sender.bot: + return + if check_echo(e.chat_id, e.sender_id): + try: + await e.respond(e.message) + except Exception as er: + LOGS.exception(er) + key = udB.get_key("CHATBOT_USERS") or {} + if e.text and key.get(e.chat_id) and sender.id in key[e.chat_id]: + # Simulate typing indicator + async with e.client.action(e.chat_id, "typing"): + msg = await get_chatbot_reply(e.message.message) + if msg: + sleep = udB.get_key("CHATBOT_SLEEP") or 1.5 + await asyncio.sleep(sleep) + + # Check if the message length exceeds a certain threshold + if len(msg) > 4096: + # Create a temporary text file + with tempfile.NamedTemporaryFile( + mode="w+", delete=False + ) as temp_file: + temp_file.write(msg) + + # Send the text file with a caption + await e.client.send_file( + e.chat_id, + temp_file.name, + caption="Here is the response in a text file.", + ) + + # Delete the temporary text file + os.remove(temp_file.name) + else: + # Send the message directly + await e.reply(msg) + + chat = await e.get_chat() + if e.is_group and sender.username: + await uname_stuff(e.sender_id, sender.username, sender.first_name) + elif e.is_private and chat.username: + await uname_stuff(e.sender_id, chat.username, chat.first_name) + if detector and is_profan(e.chat_id) and e.text: + x, y = detector(e.text) + if y: + await e.delete() @ultroid_bot.on(events.Raw(types.UpdateUserName)) From 1420aa5d6db74f3c6d20cb6f73d11026e5f93837 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Wed, 24 Jan 2024 23:27:01 +0800 Subject: [PATCH 006/268] Update _chatactions.py --- plugins/_chatactions.py | 51 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/plugins/_chatactions.py b/plugins/_chatactions.py index 00d07a51f1..18757952be 100644 --- a/plugins/_chatactions.py +++ b/plugins/_chatactions.py @@ -6,11 +6,14 @@ # . import asyncio +import requests from telethon import events from telethon.errors.rpcerrorlist import UserNotParticipantError from telethon.tl.functions.channels import GetParticipantRequest from telethon.utils import get_display_name +from typing import List, Optional, Union + from pyUltroid.dB import stickers from pyUltroid.dB.echo_db import check_echo @@ -28,6 +31,32 @@ from . import LOG_CHANNEL, LOGS, asst, get_string, types, udB, ultroid_bot from ._inline import something +#------------------------- UFoP Bans -------------------------# +class UFoPBan: + def __init__(self, api_key: str = None): + self.api_key = api_key + + def _make_request(self, method: str, url: str, params: dict = None, json_data: dict = None): + headers = { + "accept": "application/json", + "api-key": self.api_key + } + try: + response = requests.request( + method, url, headers=headers, params=params, json=json_data + ) + return response.json() + except requests.RequestException: + pass + + def get_ufop_ban(self, user_id: int=None, banlist: bool = False) -> Union[dict, str]: + if banlist: + url = "https://ufoptg-ufop-api.hf.space/UFoP/bans" + payload = {"user_id": user_id} + return self._make_request("GET", url, params=payload) + else: + raise ValueError("Error: banlist must be True +#------------------------- Huge Thanks to @xtdevs -------------------------# @ultroid_bot.on(events.ChatAction()) async def Function(event): @@ -97,6 +126,28 @@ async def DummyHandler(ult): except BaseException: pass + + if udB.get_key("UFoP_BANS"): + ufop_api_key = udB.get_key("UFOPAPI") + clients = UFoPBan(ufop_api_key) + try: + UFoP_banned = clients.get_ufop_ban(user_id=user.id, banlist=True) + + if UFoP_banned and UFoP_banned.get("sukuna", {}).get("is_banned", False): + await ult.client.edit_permissions( + chat.id, + user.id, + view_messages=False, + ) + await ult.respond( + f'**🌀ʊʄ⊕ք🌀:** Banned user detected and banned!\n' + f'Sibyl User ID: {UFoP_banned["sukuna"]["sibyl_user_id"]}\n' + f'Ban Reason: {UFoP_banned["sukuna"]["reason"]}', + ) + + except Exception as e: + LOGS.exception(f"Error checking UFoP: {e}") + reason = is_gbanned(user.id) if reason and chat.admin_rights: try: From 5b4e16893aecafe3d60422f0a3299cacf2588354 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Wed, 24 Jan 2024 23:28:50 +0800 Subject: [PATCH 007/268] Create custom_markdown.py --- pyUltroid/fns/custom_markdown.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 pyUltroid/fns/custom_markdown.py diff --git a/pyUltroid/fns/custom_markdown.py b/pyUltroid/fns/custom_markdown.py new file mode 100644 index 0000000000..55f2478e06 --- /dev/null +++ b/pyUltroid/fns/custom_markdown.py @@ -0,0 +1,30 @@ +from telethon import types +from telethon.extensions import markdown + +from . import * + + +class CustomMarkdown: + @staticmethod + def parse(text): + text, entities = markdown.parse(text) + for i, e in enumerate(entities): + if isinstance(e, types.MessageEntityTextUrl): + if e.url == "spoiler": + entities[i] = types.MessageEntitySpoiler(e.offset, e.length) + elif e.url.startswith("emoji/"): + entities[i] = types.MessageEntityCustomEmoji( + e.offset, e.length, int(e.url.split("/")[1]) + ) + return text, entities + + @staticmethod + def unparse(text, entities): + for i, e in enumerate(entities or []): + if isinstance(e, types.MessageEntityCustomEmoji): + entities[i] = types.MessageEntityTextUrl( + e.offset, e.length, f"emoji/{e.document_id}" + ) + if isinstance(e, types.MessageEntitySpoiler): + entities[i] = types.MessageEntityTextUrl(e.offset, e.length, "spoiler") + return markdown.unparse(text, entities) From 3e71afe517969c532b8adda36e878057ce8214ae Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Wed, 24 Jan 2024 23:36:37 +0800 Subject: [PATCH 008/268] Update callbackstuffs.py --- assistant/callbackstuffs.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/assistant/callbackstuffs.py b/assistant/callbackstuffs.py index 3cdd332044..db28bc4512 100644 --- a/assistant/callbackstuffs.py +++ b/assistant/callbackstuffs.py @@ -176,6 +176,8 @@ def text_to_url(event): "buttons": [ [Button.inline("Remove.bg API", data="abs_rmbg")], [Button.inline("DEEP API", data="abs_dapi")], + [Button.inline("OpenAI API", data="abs_openapi")], + [Button.inline("🌀ʊʄ⊕ք🌀 API", data="abs_uapi")], [Button.inline("OCR API", data="abs_oapi")], [Button.inline("« Back", data="setter")], ], @@ -195,6 +197,18 @@ def text_to_url(event): "text": "Get Your Deep Api from deepai.org and send here.", "back": "cbs_apiset", }, + "uapi": { + "var": "UFOPAPI", + "name": "UFoP API Key", + "text": "Contact 🌀ʊʄ⊕ք🌀 or Visit @PerthUnity_Bot Support Group\n\n /cancel to cancel", + "back": "cbs_apiset", + }, + "openapi": { + "var": "OPENAI_API", + "name": "OPENAI API Key", + "text": "Visit openai.com for an OPENAI Api key!\n\n /cancel to cancel", + "back": "cbs_apiset", + }, "oapi": { "var": "OCR_API", "name": "Ocr Api Key", From 357935945c8092bd2b30b01f01a318330f1bdbf8 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 25 Jan 2024 10:45:27 +0800 Subject: [PATCH 009/268] Update misc.py Fixed Quotly Issue ~ when replying to a user that has profile picture unavailable except to contacts and your a contact profile picture didn't show it does now. --- pyUltroid/fns/misc.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pyUltroid/fns/misc.py b/pyUltroid/fns/misc.py index 1238c0c0b1..c8ceff329c 100644 --- a/pyUltroid/fns/misc.py +++ b/pyUltroid/fns/misc.py @@ -293,7 +293,7 @@ class Quotly: async def _format_quote(self, event, reply=None, sender=None, type_="private"): async def telegraph(file_): - file = file_ + ".png" + file = f"{file_}.png" Image.open(file_).save(file, "PNG") files = {"file": open(file, "rb").read()} uri = ( @@ -335,6 +335,9 @@ async def telegraph(file_): pass if sender: name = get_display_name(sender) + if hasattr(sender, "photo"): + file_ = await event.client.download_profile_photo(sender) + uri = await telegraph(file_) if hasattr(sender, "last_name"): last_name = sender.last_name entities = [] @@ -355,6 +358,7 @@ async def telegraph(file_): elif isinstance(event.action, types.MessageActionPinMessage): text = "pinned a message." # TODO: Are there any more events with sender? + message = { "entities": entities, "chatId": id_, @@ -369,12 +373,14 @@ async def telegraph(file_): "title": name, "name": name or "Deleted Account", "type": type_, + "photo": {"url": uri}, }, "text": text, "replyMessage": reply, } if event.document and event.document.thumbs: file_ = await event.download_media(thumb=-1) + # file_ = await event.client.download_profile_photo(sender) uri = await telegraph(file_) message["media"] = {"url": uri} @@ -430,7 +436,6 @@ async def create_quotly( return file_name raise Exception(str(request)) - def split_list(List, index): new_ = [] while List: From 540c28fb3756d5b172d0c60cb6308a4df394238d Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 25 Jan 2024 10:49:30 +0800 Subject: [PATCH 010/268] Update pylint.yaml --- .github/workflows/pylint.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pylint.yaml b/.github/workflows/pylint.yaml index 8c71add5c5..f25e9c048b 100644 --- a/.github/workflows/pylint.yaml +++ b/.github/workflows/pylint.yaml @@ -1,7 +1,7 @@ name: PyLint on: push: - branches: [ dev ] + branches: [ patch-1 ] paths: - "**.py" jobs: From 548e830087382eb100cea5899781c0ac6a46fb7e Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 25 Jan 2024 10:52:00 +0800 Subject: [PATCH 011/268] Update _wrappers.py --- pyUltroid/_misc/_wrappers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyUltroid/_misc/_wrappers.py b/pyUltroid/_misc/_wrappers.py index a1475fdf71..8e041ecd36 100644 --- a/pyUltroid/_misc/_wrappers.py +++ b/pyUltroid/_misc/_wrappers.py @@ -52,7 +52,7 @@ async def eod(event, text=None, **kwargs): async def _try_delete(event): try: return await event.delete() - except (MessageDeleteForbiddenError): + except MessageDeleteForbiddenError: pass except BaseException as er: from . import LOGS From 3924105e472400d8c0ec2437536e81815f414bf3 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 25 Jan 2024 10:57:10 +0800 Subject: [PATCH 012/268] Update base.py Keys Class Added to make calling keys easier for example Keys.I_DEV would be the same as get_key("I_DEV") --- pyUltroid/dB/base.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pyUltroid/dB/base.py b/pyUltroid/dB/base.py index de26c1542d..d1cbd79f67 100644 --- a/pyUltroid/dB/base.py +++ b/pyUltroid/dB/base.py @@ -42,3 +42,24 @@ def remove(self, item): def contains(self, item): return item in self.get() + + +class Keys: + def __init__(self, udB): + self.udB = udB + self.load_keys() + + def load_keys(self): + # Fetch keys dynamically from the database + all_keys = sorted(self.udB.keys()) + valid_keys = [ + key + for key in all_keys + if not key.isdigit() + and not key.startswith("-") + and not key.startswith("_") + and not key.startswith("GBAN_REASON_") + ] + + for key in valid_keys: + setattr(self, key, self.udB.get_key(key)) From 2297471d9834ae84d1abd76afd60622cb6377655 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 25 Jan 2024 11:00:21 +0800 Subject: [PATCH 013/268] Update botchat_db.py Seperated TAG_LOGGER DB and BOTCHAT DB --- pyUltroid/dB/botchat_db.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pyUltroid/dB/botchat_db.py b/pyUltroid/dB/botchat_db.py index 7b70b574b6..c7d1b940d3 100644 --- a/pyUltroid/dB/botchat_db.py +++ b/pyUltroid/dB/botchat_db.py @@ -24,18 +24,20 @@ def get_who(msg_id): if ok.get(msg_id): return ok[msg_id] +def get_tag_stuff(): + return udB.get_key("TAG_LOGGER") or {} def tag_add(msg, chat, user): - ok = get_stuff() + ok = get_tag_stuff() if not ok.get("TAG"): ok.update({"TAG": {msg: [chat, user]}}) else: ok["TAG"].update({msg: [chat, user]}) - return udB.set_key("BOTCHAT", ok) + return udB.set_key("TAG_LOGGER", ok) def who_tag(msg): - ok = get_stuff() + ok = get_tag_stuff() if ok.get("TAG") and ok["TAG"].get(msg): return ok["TAG"][msg] return False, False From 3c261cbcf10f055239fac7185e911f933de7c8ed Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 25 Jan 2024 11:03:04 +0800 Subject: [PATCH 014/268] Update ytdl.py Fixes to ytdl --- pyUltroid/fns/ytdl.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pyUltroid/fns/ytdl.py b/pyUltroid/fns/ytdl.py index f8c05f043a..57a118982d 100644 --- a/pyUltroid/fns/ytdl.py +++ b/pyUltroid/fns/ytdl.py @@ -60,7 +60,7 @@ async def download_yt(event, link, ytd): for num, file in enumerate(info["entries"]): num += 1 id_ = file["id"] - thumb = id_ + ".jpg" + thumb = f"{id_}.jpg" title = file["title"] await download_file( file.get("thumbnail", None) or file["thumbnails"][-1]["url"], thumb @@ -117,9 +117,9 @@ async def download_yt(event, link, ytd): return title = info["title"] if len(title) > 20: - title = title[:17] + "..." + title = f"{title[:17]}..." id_ = info["id"] - thumb = id_ + ".jpg" + thumb = f"{id_}.jpg" await download_file( info.get("thumbnail", None) or f"https://i.ytimg.com/vi/{id_}/hqdefault.jpg", thumb, @@ -176,7 +176,7 @@ def get_formats(type, id, data): "ytid": id, "type": "audio", "id": _quality, - "quality": _quality + "KBPS", + "quality": f"{_quality}KBPS", } ) audio.append(_audio) @@ -198,7 +198,7 @@ def get_formats(type, id, data): { "ytid": id, "type": "video", - "id": str(_id) + "+251", + "id": f"{_id}+251", "quality": _quality, "size": _size, "ext": _ext, From fa02e6cb16b26c9a7a7797476cf5a2a1e9e97a3b Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 25 Jan 2024 11:09:57 +0800 Subject: [PATCH 015/268] Create openaihelper.py --- pyUltroid/fns/openaihelper.py | 238 ++++++++++++++++++++++++++++++++++ 1 file changed, 238 insertions(+) create mode 100644 pyUltroid/fns/openaihelper.py diff --git a/pyUltroid/fns/openaihelper.py b/pyUltroid/fns/openaihelper.py new file mode 100644 index 0000000000..85915fae7a --- /dev/null +++ b/pyUltroid/fns/openaihelper.py @@ -0,0 +1,238 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# SOL UserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# +# sqlalchemy +# openai +# fake_useragent +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# +# Special Credits: @LucifSD02 +# Special Credits: @SoulOfSukuna +# Special Credits: @TrueSaiyan + +import json +import os + +import openai +import requests +from fake_useragent import UserAgent +from PIL import Image, ImageColor, ImageDraw, ImageFilter, ImageFont, ImageOps +from sqlalchemy import Column, String, UnicodeText + +from addons.inlinegames import edit_delete, edit_or_reply, reply_id + +from . import BASE, SESSION + +openai.api_key = udB.get_key("OPENAI_API") # OPENAI KEY +conversations = {} + + +class Globals(BASE): + __tablename__ = "globals" + variable = Column(String, primary_key=True, nullable=False) + value = Column(UnicodeText, primary_key=True, nullable=False) + + def __init__(self, variable, value): + self.variable = str(variable) + self.value = value + + +Globals.__table__.create(checkfirst=True) + + +def gvarstatus(variable): + try: + return ( + SESSION.query(Globals) + .filter(Globals.variable == str(variable)) + .first() + .value + ) + except BaseException: + return None + finally: + SESSION.close() + + +def addgvar(variable, value): + if SESSION.query(Globals).filter(Globals.variable == str(variable)).one_or_none(): + delgvar(variable) + adder = Globals(str(variable), value) + SESSION.add(adder) + SESSION.commit() + + +def delgvar(variable): + if rem := ( + SESSION.query(Globals) + .filter(Globals.variable == str(variable)) + .delete(synchronize_session="fetch") + ): + SESSION.commit() + + +def format_image(filename): + img = Image.open(filename).convert("RGBA") + w, h = img.size + if w != h: + _min, _max = min(w, h), max(w, h) + bg = img.crop( + ((w - _min) // 2, (h - _min) // 2, (w + _min) // 2, (h + _min) // 2) + ) + bg = bg.filter(ImageFilter.GaussianBlur(5)) + bg = bg.resize((_max, _max)) + img_new = Image.new("RGBA", (_max, _max), (255, 255, 255, 0)) + img_new.paste( + bg, ((img_new.width - bg.width) // 2, (img_new.height - bg.height) // 2) + ) + img_new.paste(img, ((img_new.width - w) // 2, (img_new.height - h) // 2)) + img = img_new + img.save(filename) + + +async def wall_download(piclink, query, ext=".jpg"): + try: + if not os.path.isdir("./temp"): + os.mkdir("./temp") + picpath = f"./temp/{query.title().replace(' ', '')}{ext}" + if os.path.exists(picpath): + i = 1 + while os.path.exists(picpath) and i < 11: + picpath = f"./temp/{query.title().replace(' ', '')}-{i}{ext}" + i += 1 + with open(picpath, "wb") as f: + f.write(requests.get(piclink).content) + return picpath + except Exception as e: + LOGS.info(str(e)) + return None + + +def generate_gpt_response(input_text, chat_id): + global conversations + model = gvarstatus("CHAT_MODEL") or "gpt-3.5-turbo" + system_message = gvarstatus("SYSTEM_MESSAGE") or None + messages = conversations.get(chat_id, []) + + # Add system message if it exists + if system_message and not messages: + messages.append({"role": "system", "content": system_message}) + + # Add the new user message + messages.append({"role": "user", "content": input_text}) + try: + response = openai.ChatCompletion.create( + model=model, + messages=messages, + ) + generated_text = response.choices[0].message.content.strip() + + # Save the assistant's response to the conversation history + messages.append({"role": "assistant", "content": generated_text}) + conversations[chat_id] = messages + except Exception as e: + generated_text = f"`Error generating GPT response: {str(e)}`" + return generated_text + + +def generate_edited_response(input_text, instructions): + try: + response = openai.Edit.create( + model="text-davinci-edit-001", + input=input_text, + instruction=instructions, + ) + edited_text = response.choices[0].text.strip() + except Exception as e: + edited_text = f"__Error generating GPT edited response:__ `{str(e)}`" + return edited_text + + +def del_convo(chat_id, checker=False): + global conversations + out_text = "__There is no GPT context to delete for this chat.__" + # Delete the the context of given chat + if chat_id in conversations: + del conversations[chat_id] + out_text = "__GPT context deleted for this chat.__" + if checker: + return out_text + + +async def generate_dalle_image(text, reply, event, flag=None): + size = gvarstatus("DALLE_SIZE") or "1024" + limit = int(gvarstatus("DALLE_LIMIT") or "1") + if not text and reply: + text = reply.text + if not text: + return await edit_delete(event, "**ಠ∀ಠ Gimmi text**") + + catevent = await edit_or_reply(event, "__Generating image...__") + try: + if flag: + filename = "dalle-in.png" + await event.client.download_media(reply, filename) + format_image(filename) + if flag == "e": + response = openai.Image.create_edit( + image=open(filename, "rb"), + prompt=text, + n=limit, + size=f"{size}x{size}", + ) + elif flag == "v": + response = openai.Image.create_variation( + image=open(filename, "rb"), + n=limit, + size=f"{size}x{size}", + ) + os.remove(filename) + else: + response = openai.Image.create( + prompt=text, + n=limit, + size=f"{size}x{size}", + ) + except Exception as e: + await edit_delete(catevent, f"Error generating image: {str(e)}") + return None, None + + photos = [] + captions = [] + for i, media in enumerate(response["data"], 1): + photo = await wall_download(media["url"], "Dall-E") + photos.append(photo) + captions.append("") + await edit_or_reply(catevent, f"__📥 Downloaded : {i}/{limit}__") + + captions[-1] = f"**➥ Query :-** `{text.title()}`" + await edit_or_reply(catevent, "__Uploading...__") + return photos, captions + + +class ThabAi: + def __init__(self): + self.session = requests.Session() + self.session.headers = { + "authority": "chatbot.theb.ai", + "content-type": "application/json", + "origin": "https://chatbot.theb.ai", + "user-agent": UserAgent().random, + } + + def get_response(self, prompt: str) -> str: + response = self.session.post( + "https://chatbot.theb.ai/api/chat-process", + json={"prompt": prompt, "options": {}}, + stream=True, + ) + response.raise_for_status() + response_lines = response.iter_lines() + response_data = "" + for line in response_lines: + if line: + data = json.loads(line) + if "utterances" in data: + response_data += " ".join( + utterance["text"] for utterance in data["utterances"] + ) + elif "delta" in data: + response_data += data["delta"] + return response_data From 78a6deac5589658d40a5ce5287415ac1813f0550 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 25 Jan 2024 11:14:24 +0800 Subject: [PATCH 016/268] Update pylint.yaml --- .github/workflows/pylint.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pylint.yaml b/.github/workflows/pylint.yaml index f25e9c048b..e01bf81993 100644 --- a/.github/workflows/pylint.yaml +++ b/.github/workflows/pylint.yaml @@ -39,7 +39,7 @@ jobs: commit_message: 'pylint: auto fixes' commit_options: '--no-verify' repository: . - commit_user_name: buddhhu - commit_user_email: 48654350+buddhhu@users.noreply.github.com - commit_author: Amit Sharma <48654350+buddhhu@users.noreply.github.com> + commit_user_name: ufoptg + commit_user_email: perthgroups@protonmail.com + commit_author: True Saiyan From 0402fbe31b5f181a7ed5b4031ec7e9402b9f2661 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 25 Jan 2024 11:17:27 +0800 Subject: [PATCH 017/268] Update pylint.yaml --- .github/workflows/pylint.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pylint.yaml b/.github/workflows/pylint.yaml index e01bf81993..f419b5e199 100644 --- a/.github/workflows/pylint.yaml +++ b/.github/workflows/pylint.yaml @@ -12,7 +12,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v1 with: - python-version: 3.8 + python-version: 3.9 cache: "pip" - name: Install Python lint libraries run: pip install autopep8 autoflake isort black From 2e5388627925c0bf17c025ef984ba56f44d4a914 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 25 Jan 2024 11:20:22 +0800 Subject: [PATCH 018/268] Create google_image.py Google_Image Helper --- pyUltroid/fns/google_image.py | 1146 +++++++++++++++++++++++++++++++++ 1 file changed, 1146 insertions(+) create mode 100644 pyUltroid/fns/google_image.py diff --git a/pyUltroid/fns/google_image.py b/pyUltroid/fns/google_image.py new file mode 100644 index 0000000000..e0a7ba0e73 --- /dev/null +++ b/pyUltroid/fns/google_image.py @@ -0,0 +1,1146 @@ +#!/usr/bin/env python +# In[ ]: +# coding: utf-8 +###### Searching and Downloading Google Images to the local disk ###### + + +import codecs +import datetime +import http.client +import json +import os +import re +import ssl +import sys +import time # Importing the time library to check the time of code execution +import urllib.request +from http.client import BadStatusLine +from urllib.parse import quote +from urllib.request import HTTPError, Request, URLError, urlopen + +# Import Libraries +from .. import LOGS +from .tools import async_searcher + +http.client._MAXHEADERS = 1000 + +args_list = [ + "keywords", + "keywords_from_file", + "prefix_keywords", + "suffix_keywords", + "limit", + "format", + "color", + "color_type", + "usage_rights", + "size", + "exact_size", + "aspect_ratio", + "type", + "time", + "time_range", + "delay", + "url", + "single_image", + "output_directory", + "image_directory", + "no_directory", + "proxy", + "similar_images", + "specific_site", + "metadata", + "extract_metadata", + "socket_timeout", + "thumbnail", + "thumbnail_only", + "language", + "prefix", + "chromedriver", + "related_images", + "safe_search", + "no_numbering", + "offset", + "no_download", + "save_source", + "ignore_urls", +] + + +class googleimagesdownload: + def __init__(self): + pass + + # Downloading entire Web Document (Raw Page Content) + async def download_page(self, url): + try: + headers = { + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.104 Safari/537.36" + } + + # req = urllib.request.Request(url, headers=headers) + # resp = urllib.request.urlopen(req) + # return str(resp.read()) + resp = await async_searcher(url, re_content=True, headers=headers) + return str(resp) + except Exception as er: + LOGS.exception( + "Could not open URL. Please check your internet connection and/or ssl settings \n" + "If you are using proxy, make sure your proxy settings is configured correctly" + ) + raise er + + # Download Page for more than 100 images + + def download_extended_page(self, url, chromedriver): + from selenium import webdriver + from selenium.webdriver.common.keys import Keys + + options = webdriver.ChromeOptions() + options.add_argument("--no-sandbox") + options.add_argument("--headless") + + try: + browser = webdriver.Chrome(chromedriver, chrome_options=options) + except Exception as e: + LOGS.info( + "Looks like we cannot locate the path the 'chromedriver' (use the '--chromedriver' " + "argument to specify the path to the executable.) or google chrome browser is not " + "installed on your machine (exception: %s)" % e + ) + sys.exit() + browser.set_window_size(1024, 768) + + # Open the link + browser.get(url) + time.sleep(1) + + element = browser.find_element_by_tag_name("body") + # Scroll down + for _ in range(30): + element.send_keys(Keys.PAGE_DOWN) + time.sleep(0.3) + + try: + browser.find_element_by_id("smb").click() + for _ in range(50): + element.send_keys(Keys.PAGE_DOWN) + time.sleep(0.3) # bot id protection + except BaseException: + for _ in range(10): + element.send_keys(Keys.PAGE_DOWN) + time.sleep(0.3) # bot id protection + + time.sleep(0.5) + + source = browser.page_source # page source + # close the browser + browser.close() + + return source + + # Correcting the escape characters for python2 + + def replace_with_byte(self, match): + return chr(int(match.group(0)[1:], 8)) + + def repair(self, brokenjson): + # up to 3 digits for byte values up to FF + invalid_escape = re.compile(r"\\[0-7]{1,3}") + return invalid_escape.sub(self.replace_with_byte, brokenjson) + + # Finding 'Next Image' from the given raw page + + def get_next_tab(self, s): + start_line = s.find('class="dtviD"') + if start_line == -1: # If no links are found then give an error! + end_quote = 0 + link = "no_tabs" + return link, "", end_quote + start_line = s.find('class="dtviD"') + start_content = s.find('href="', start_line + 1) + end_content = s.find('">', start_content + 1) + url_item = f"https://www.google.com{str(s[start_content + 6:end_content])}" + url_item = url_item.replace("&", "&") + start_line_2 = s.find('class="dtviD"') + s = s.replace("&", "&") + start_content_2 = s.find(":", start_line_2 + 1) + end_content_2 = s.find("&usg=", start_content_2 + 1) + url_item_name = str(s[start_content_2 + 1 : end_content_2]) + chars = url_item_name.find(",g_1:") + chars_end = url_item_name.find(":", chars + 6) + if chars_end == -1: + updated_item_name = (url_item_name[chars + 5 :]).replace("+", " ") + else: + updated_item_name = (url_item_name[chars + 5 : chars_end]).replace("+", " ") + return url_item, updated_item_name, end_content + + # Getting all links with the help of '_images_get_next_image' + + def get_all_tabs(self, page): + tabs = {} + while True: + item, item_name, end_content = self.get_next_tab(page) + if item == "no_tabs": + break + if len(item_name) > 100 or item_name == "background-color": + break + # Append all the links in the list named 'Links' + tabs[item_name] = item + # Timer could be used to slow down the request for image + # downloads + time.sleep(0.1) + page = page[end_content:] + return tabs + + # Format the object in readable format + + def format_object(self, object): + data = object[1] + main = data[3] + info = data[9] + return { + "image_height": main[2], + "image_width": main[1], + "image_link": main[0], + "image_format": main[0][-1 * (len(main[0]) - main[0].rfind(".") - 1) :], + "image_description": info["2003"][3], + "image_source": info["2003"][2], + "image_thumbnail_url": data[2][0], + } + + # function to download single image + + def single_image(self, image_url): + main_directory = "downloads" + extensions = (".jpg", ".gif", ".png", ".bmp", ".svg", ".webp", ".ico") + url = image_url + try: + os.makedirs(main_directory) + except OSError as e: + if e.errno != 17: + raise + req = Request( + url, + headers={ + "User-Agent": "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.27 Safari/537.17" + }, + ) + + response = urlopen(req, None, 10) + data = response.read() + response.close() + + image_name = str(url[(url.rfind("/")) + 1 :]) + if "?" in image_name: + image_name = image_name[: image_name.find("?")] + # if ".jpg" in image_name or ".gif" in image_name or ".png" in + # image_name or ".bmp" in image_name or ".svg" in image_name or ".webp" + # in image_name or ".ico" in image_name: + if any(map(lambda extension: extension in image_name, extensions)): + file_name = f"{main_directory}/{image_name}" + else: + file_name = f"{main_directory}/{image_name}.jpg" + image_name = f"{image_name}.jpg" + + try: + with open(file_name, "wb") as output_file: + output_file.write(data) + except OSError as e: + raise e + + def similar_images(self, similar_images): + try: + searchUrl = ( + "https://www.google.com/searchbyimage?site=search&sa=X&image_url=" + + similar_images + ) + headers = { + "User-Agent": "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36" + } + + req1 = urllib.request.Request(searchUrl, headers=headers) + resp1 = urllib.request.urlopen(req1) + content = str(resp1.read()) + l1 = content.find("AMhZZ") + l2 = content.find("&", l1) + urll = content[l1:l2] + + newurl = f"https://www.google.com/search?tbs=sbi:{urll}&site=search&sa=X" + req2 = urllib.request.Request(newurl, headers=headers) + urllib.request.urlopen(req2) + l3 = content.find("/search?sa=X&q=") + l4 = content.find(";", l3 + 19) + return content[l3 + 19 : l4] + except BaseException: + return "Cloud not connect to Google Images endpoint" + + # Building URL parameters + def build_url_parameters(self, arguments): + if arguments["language"]: + lang = "&lr=" + lang_param = { + "Arabic": "lang_ar", + "Chinese (Simplified)": "lang_zh-CN", + "Chinese (Traditional)": "lang_zh-TW", + "Czech": "lang_cs", + "Danish": "lang_da", + "Dutch": "lang_nl", + "English": "lang_en", + "Estonian": "lang_et", + "Finnish": "lang_fi", + "French": "lang_fr", + "German": "lang_de", + "Greek": "lang_el", + "Hebrew": "lang_iw ", + "Hungarian": "lang_hu", + "Icelandic": "lang_is", + "Italian": "lang_it", + "Japanese": "lang_ja", + "Korean": "lang_ko", + "Latvian": "lang_lv", + "Lithuanian": "lang_lt", + "Norwegian": "lang_no", + "Portuguese": "lang_pt", + "Polish": "lang_pl", + "Romanian": "lang_ro", + "Russian": "lang_ru", + "Spanish": "lang_es", + "Swedish": "lang_sv", + "Turkish": "lang_tr", + } + lang_url = lang + lang_param[arguments["language"]] + else: + lang_url = "" + + if arguments["time_range"]: + json_acceptable_string = arguments["time_range"].replace("'", '"') + d = json.loads(json_acceptable_string) + time_range = ",cdr:1,cd_min:" + d["time_min"] + ",cd_max:" + d["time_max"] + else: + time_range = "" + + if arguments["exact_size"]: + size_array = [x.strip() for x in arguments["exact_size"].split(",")] + exact_size = f",isz:ex,iszw:{str(size_array[0])},iszh:{str(size_array[1])}" + else: + exact_size = "" + + built_url = "&tbs=" + counter = 0 + params = { + "color": [ + arguments["color"], + { + "red": "ic:specific,isc:red", + "orange": "ic:specific,isc:orange", + "yellow": "ic:specific,isc:yellow", + "green": "ic:specific,isc:green", + "teal": "ic:specific,isc:teel", + "blue": "ic:specific,isc:blue", + "purple": "ic:specific,isc:purple", + "pink": "ic:specific,isc:pink", + "white": "ic:specific,isc:white", + "gray": "ic:specific,isc:gray", + "black": "ic:specific,isc:black", + "brown": "ic:specific,isc:brown", + }, + ], + "color_type": [ + arguments["color_type"], + { + "full-color": "ic:color", + "black-and-white": "ic:gray", + "transparent": "ic:trans", + }, + ], + "usage_rights": [ + arguments["usage_rights"], + { + "labeled-for-reuse-with-modifications": "sur:fmc", + "labeled-for-reuse": "sur:fc", + "labeled-for-noncommercial-reuse-with-modification": "sur:fm", + "labeled-for-nocommercial-reuse": "sur:f", + }, + ], + "size": [ + arguments["size"], + { + "large": "isz:l", + "medium": "isz:m", + "icon": "isz:i", + ">400*300": "isz:lt,islt:qsvga", + ">640*480": "isz:lt,islt:vga", + ">800*600": "isz:lt,islt:svga", + ">1024*768": "visz:lt,islt:xga", + ">2MP": "isz:lt,islt:2mp", + ">4MP": "isz:lt,islt:4mp", + ">6MP": "isz:lt,islt:6mp", + ">8MP": "isz:lt,islt:8mp", + ">10MP": "isz:lt,islt:10mp", + ">12MP": "isz:lt,islt:12mp", + ">15MP": "isz:lt,islt:15mp", + ">20MP": "isz:lt,islt:20mp", + ">40MP": "isz:lt,islt:40mp", + ">70MP": "isz:lt,islt:70mp", + }, + ], + "type": [ + arguments["type"], + { + "face": "itp:face", + "photo": "itp:photo", + "clipart": "itp:clipart", + "line-drawing": "itp:lineart", + "animated": "itp:animated", + }, + ], + "time": [ + arguments["time"], + { + "past-24-hours": "qdr:d", + "past-7-days": "qdr:w", + "past-month": "qdr:m", + "past-year": "qdr:y", + }, + ], + "aspect_ratio": [ + arguments["aspect_ratio"], + { + "tall": "iar:t", + "square": "iar:s", + "wide": "iar:w", + "panoramic": "iar:xw", + }, + ], + "format": [ + arguments["format"], + { + "jpg": "ift:jpg", + "gif": "ift:gif", + "png": "ift:png", + "bmp": "ift:bmp", + "svg": "ift:svg", + "webp": "webp", + "ico": "ift:ico", + "raw": "ift:craw", + }, + ], + } + for value in params.values(): + if value[0] is not None: + ext_param = value[1][value[0]] + # counter will tell if it is first param added or not + if counter == 0: + # add it to the built url + built_url += ext_param + else: + built_url = f"{built_url},{ext_param}" + counter += 1 + return lang_url + built_url + exact_size + time_range + + # building main search URL + + def build_search_url( + self, search_term, params, url, similar_images, specific_site, safe_search + ): + # check the args and choose the URL + if url: + url = url + elif similar_images: + keywordem = self.similar_images(similar_images) + url = ( + "https://www.google.com/search?q=" + + keywordem + + "&espv=2&biw=1366&bih=667&site=webhp&source=lnms&tbm=isch&sa=X&ei=XosDVaCXD8TasATItgE&ved=0CAcQ_AUoAg" + ) + elif specific_site: + url = ( + "https://www.google.com/search?q=" + + quote(search_term.encode("utf-8")) + + "&as_sitesearch=" + + specific_site + + "&espv=2&biw=1366&bih=667&site=webhp&source=lnms&tbm=isch" + + params + + "&sa=X&ei=XosDVaCXD8TasATItgE&ved=0CAcQ_AUoAg" + ) + else: + url = ( + "https://www.google.com/search?q=" + + quote(search_term.encode("utf-8")) + + "&espv=2&biw=1366&bih=667&site=webhp&source=lnms&tbm=isch" + + params + + "&sa=X&ei=XosDVaCXD8TasATItgE&ved=0CAcQ_AUoAg" + ) + + # safe search check + if safe_search: + # check safe_search + safe_search_string = "&safe=active" + url = url + safe_search_string + + return url + + # measures the file size + + def file_size(self, file_path): + if os.path.isfile(file_path): + file_info = os.stat(file_path) + size = file_info.st_size + for x in ["bytes", "KB", "MB", "GB", "TB"]: + if size < 1024.0: + return "%3.1f %s" % (size, x) + size /= 1024.0 + return size + + # keywords from file + def keywords_from_file(self, file_name): + search_keyword = [] + with codecs.open(file_name, "r", encoding="utf-8-sig") as f: + if ".csv" in file_name or ".txt" in file_name: + search_keyword.extend( + line.replace("\n", "").replace("\r", "") + for line in f + if line not in ["\n", "\r\n"] + ) + else: + LOGS.info( + "Invalid file type: Valid file types are either .txt or .csv \n" + "exiting..." + ) + sys.exit() + return search_keyword + + # make directories + def create_directories(self, main_directory, dir_name, thumbnail, thumbnail_only): + dir_name_thumbnail = f"{dir_name} - thumbnail" + # make a search keyword directory + try: + if not os.path.exists(main_directory): + os.makedirs(main_directory) + time.sleep(0.15) + path = dir_name + sub_directory = os.path.join(main_directory, path) + if not os.path.exists(sub_directory): + os.makedirs(sub_directory) + if thumbnail or thumbnail_only: + sub_directory_thumbnail = os.path.join( + main_directory, dir_name_thumbnail + ) + if not os.path.exists(sub_directory_thumbnail): + os.makedirs(sub_directory_thumbnail) + except OSError as e: + if e.errno != 17: + raise + + # Download Image thumbnails + + def download_image_thumbnail( + self, + image_url, + main_directory, + dir_name, + return_image_name, + socket_timeout, + no_download, + save_source, + img_src, + ): + if no_download: + return "success", "Printed url without downloading" + try: + req = Request( + image_url, + headers={ + "User-Agent": "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.27 Safari/537.17" + }, + ) + try: + # timeout time to download an image + timeout = float(socket_timeout) if socket_timeout else 10 + response = urlopen(req, None, timeout) + data = response.read() + response.close() + + path = ( + main_directory + + "/" + + dir_name + + " - thumbnail" + + "/" + + return_image_name + ) + + try: + with open(path, "wb") as output_file: + output_file.write(data) + if save_source: + list_path = f"{main_directory}/{save_source}.txt" + with open(list_path, "a") as list_file: + list_file.write(path + "\t" + img_src + "\n") + except OSError as e: + download_status = "fail" + download_message = ( + "OSError on an image...trying next one..." + " Error: " + str(e) + ) + + download_status = "success" + download_message = ( + f"Completed Image Thumbnail ====> {return_image_name}" + ) + + except UnicodeEncodeError as e: + download_status = "fail" + download_message = ( + "UnicodeEncodeError on an image...trying next one..." + + " Error: " + + str(e) + ) + + except HTTPError as e: # If there is any HTTPError + download_status = "fail" + download_message = ( + "HTTPError on an image...trying next one..." + " Error: " + str(e) + ) + + except URLError as e: + download_status = "fail" + download_message = ( + "URLError on an image...trying next one..." + " Error: " + str(e) + ) + + except ssl.CertificateError as e: + download_status = "fail" + download_message = ( + "CertificateError on an image...trying next one..." + + " Error: " + + str(e) + ) + + except IOError as e: # If there is any IOError + download_status = "fail" + download_message = ( + "IOError on an image...trying next one..." + " Error: " + str(e) + ) + return download_status, download_message + + # Download Images + + def download_image( + self, + image_url, + image_format, + main_directory, + dir_name, + count, + socket_timeout, + prefix, + no_numbering, + no_download, + save_source, + img_src, + thumbnail_only, + format, + ignore_urls, + ): + if ignore_urls and any(url in image_url for url in ignore_urls.split(",")): + return ( + "fail", + "Image ignored due to 'ignore url' parameter", + None, + image_url, + ) + if thumbnail_only: + return ( + "success", + "Skipping image download...", + str(image_url[(image_url.rfind("/")) + 1 :]), + image_url, + ) + if no_download: + return "success", "Printed url without downloading", None, image_url + try: + req = Request( + image_url, + headers={ + "User-Agent": "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.27 Safari/537.17" + }, + ) + try: + # timeout time to download an image + timeout = float(socket_timeout) if socket_timeout else 10 + response = urlopen(req, None, timeout) + data = response.read() + response.close() + + extensions = [ + ".jpg", + ".jpeg", + ".gif", + ".png", + ".bmp", + ".svg", + ".webp", + ".ico", + ] + # keep everything after the last '/' + image_name = str(image_url[(image_url.rfind("/")) + 1 :]) + if format and (not image_format or image_format != format): + download_status = "fail" + download_message = "Wrong image format returned. Skipping..." + return_image_name = "" + absolute_path = "" + return ( + download_status, + download_message, + return_image_name, + absolute_path, + ) + + if ( + image_format == "" + or not image_format + or f".{image_format}" not in extensions + ): + download_status = "fail" + download_message = "Invalid or missing image format. Skipping..." + return_image_name = "" + absolute_path = "" + return ( + download_status, + download_message, + return_image_name, + absolute_path, + ) + if image_name.lower().find(f".{image_format}") < 0: + image_name = f"{image_name}.{image_format}" + else: + image_name = image_name[ + : ( + image_name.lower().find(f".{image_format}") + + (len(image_format) + 1) + ) + ] + + # prefix name in image + prefix = f"{prefix} " if prefix else "" + path = ( + f"{main_directory}/{dir_name}/{prefix}{image_name}" + if no_numbering + else f"{main_directory}/{dir_name}/{prefix}{str(count)}.{image_name}" + ) + try: + with open(path, "wb") as output_file: + output_file.write(data) + if save_source: + list_path = f"{main_directory}/{save_source}.txt" + with open(list_path, "a") as list_file: + list_file.write(path + "\t" + img_src + "\n") + absolute_path = os.path.abspath(path) + except OSError as e: + download_status = "fail" + download_message = ( + "OSError on an image...trying next one..." + " Error: " + str(e) + ) + return_image_name = "" + absolute_path = "" + + # return image name back to calling method to use it for + # thumbnail downloads + download_status = "success" + download_message = ( + f"Completed Image ====> {prefix}{str(count)}.{image_name}" + ) + return_image_name = prefix + str(count) + "." + image_name + + except UnicodeEncodeError as e: + download_status = "fail" + download_message = ( + "UnicodeEncodeError on an image...trying next one..." + + " Error: " + + str(e) + ) + return_image_name = "" + absolute_path = "" + + except URLError as e: + download_status = "fail" + download_message = ( + "URLError on an image...trying next one..." + " Error: " + str(e) + ) + return_image_name = "" + absolute_path = "" + + except BadStatusLine as e: + download_status = "fail" + download_message = ( + "BadStatusLine on an image...trying next one..." + + " Error: " + + str(e) + ) + return_image_name = "" + absolute_path = "" + + except HTTPError as e: # If there is any HTTPError + download_status = "fail" + download_message = ( + "HTTPError on an image...trying next one..." + " Error: " + str(e) + ) + return_image_name = "" + absolute_path = "" + + except URLError as e: + download_status = "fail" + download_message = ( + "URLError on an image...trying next one..." + " Error: " + str(e) + ) + return_image_name = "" + absolute_path = "" + + except ssl.CertificateError as e: + download_status = "fail" + download_message = ( + "CertificateError on an image...trying next one..." + + " Error: " + + str(e) + ) + return_image_name = "" + absolute_path = "" + + except IOError as e: # If there is any IOError + download_status = "fail" + download_message = ( + "IOError on an image...trying next one..." + " Error: " + str(e) + ) + return_image_name = "" + absolute_path = "" + + return download_status, download_message, return_image_name, absolute_path + + # Finding 'Next Image' from the given raw page + + def _get_next_item(self, s): + start_line = s.find("rg_meta notranslate") + if start_line == -1: # If no links are found then give an error! + end_quote = 0 + link = "no_links" + return link, end_quote + start_line = s.find('class="rg_meta notranslate">') + start_object = s.find("{", start_line + 1) + end_object = s.find("", start_object + 1) + object_raw = str(s[start_object:end_object]) + # remove escape characters based on python version + try: + object_decode = bytes(object_raw, "utf-8").decode("unicode_escape") + final_object = json.loads(object_decode) + except BaseException: + final_object = "" + return final_object, end_object + + # Getting all links with the help of '_images_get_next_image' + + def _get_image_objects(self, s): + start_line = s.find("AF_initDataCallback({key: \\'ds:1\\'") - 10 + start_object = s.find("[", start_line + 1) + end_object = s.find("", start_object + 1) - 4 + object_raw = str(s[start_object:end_object]) + object_decode = bytes(object_raw[:-1], "utf-8").decode("unicode_escape") + # LOGS.info(_format.paste_text(object_decode[:-15])) + return json.loads(object_decode[:-15])[31][0][12][2] + + def _get_all_items(self, page, main_directory, dir_name, limit, arguments): + items = [] + abs_path = [] + errorCount = 0 + i = 0 + count = 1 + # LOGS.info(f"page : {_format.paste_text(page)}") + image_objects = self._get_image_objects(page) + while count < limit + 1: + if not image_objects: + print("no_links") + break + else: + # format the item for readability + try: + object = self.format_object(image_objects[i]) + # download the images + ( + download_status, + download_message, + return_image_name, + absolute_path, + ) = self.download_image( + object["image_link"], + object["image_format"], + main_directory, + dir_name, + count, + arguments["socket_timeout"], + arguments["prefix"], + arguments["no_numbering"], + arguments["no_download"], + arguments["save_source"], + object["image_source"], + arguments["thumbnail_only"], + arguments["format"], + arguments["ignore_urls"], + ) + except (TypeError, IndexError) as er: + LOGS.debug(er) + download_status = None + + if download_status == "success": + # download image_thumbnails + if arguments["thumbnail"] or arguments["thumbnail_only"]: + ( + download_status, + download_message_thumbnail, + ) = self.download_image_thumbnail( + object["image_thumbnail_url"], + main_directory, + dir_name, + return_image_name, + arguments["socket_timeout"], + arguments["no_download"], + arguments["save_source"], + object["image_source"], + arguments["ignore_urls"], + ) + + count += 1 + object["image_filename"] = return_image_name + # Append all the links in the list named 'Links' + items.append(object) + abs_path.append(absolute_path) + else: + errorCount += 1 + + # delay param + if arguments["delay"]: + time.sleep(int(arguments["delay"])) + i += 1 + if count < limit: + LOGS.info( + "\n\nUnfortunately all " + + str(limit) + + " could not be downloaded because some images were not downloadable. " + + str(count - 1) + + " is all we got for this search filter!" + ) + return items, errorCount, abs_path + + # Bulk Download + + async def download(self, arguments): + paths_agg = {} + # for input coming from other python files + if __name__ != "__main__": + # if the calling file contains config_file param + if "config_file" in arguments: + records = [] + json_file = json.load(open(arguments["config_file"])) + for item in json_file["Records"]: + arguments = {i: None for i in args_list} + for key, value in item.items(): + arguments[key] = value + records.append(arguments) + total_errors = 0 + for rec in records: + paths, errors = await self.download_executor(rec) + for i in paths: + paths_agg[i] = paths[i] + total_errors += errors + return paths_agg, total_errors + # if the calling file contains params directly + paths, errors = await self.download_executor(arguments) + for i in paths: + paths_agg[i] = paths[i] + return paths_agg, errors + # for input coming from CLI + paths, errors = await self.download_executor(arguments) + for i in paths: + paths_agg[i] = paths[i] + return paths_agg, errors + + async def download_executor(self, arguments): + paths = {} + errorCount = None + for arg in args_list: + if arg not in arguments: + arguments[arg] = None + # Initialization and Validation of user arguments + if arguments["keywords"]: + search_keyword = [str(item) for item in arguments["keywords"].split(",")] + + if arguments["keywords_from_file"]: + search_keyword = self.keywords_from_file(arguments["keywords_from_file"]) + + # both time and time range should not be allowed in the same query + if arguments["time"] and arguments["time_range"]: + raise ValueError( + "Either time or time range should be used in a query. Both cannot be used at the same time." + ) + + # both time and time range should not be allowed in the same query + if arguments["size"] and arguments["exact_size"]: + raise ValueError( + 'Either "size" or "exact_size" should be used in a query. Both cannot be used at the same time.' + ) + + # both image directory and no image directory should not be allowed in + # the same query + if arguments["image_directory"] and arguments["no_directory"]: + raise ValueError( + "You can either specify image directory or specify no image directory, not both!" + ) + + # Additional words added to keywords + if arguments["suffix_keywords"]: + suffix_keywords = [ + " " + str(sk) for sk in arguments["suffix_keywords"].split(",") + ] + else: + suffix_keywords = [""] + + # Additional words added to keywords + if arguments["prefix_keywords"]: + prefix_keywords = [ + str(sk) + " " for sk in arguments["prefix_keywords"].split(",") + ] + else: + prefix_keywords = [""] + + # Setting limit on number of images to be downloaded + limit = int(arguments["limit"]) if arguments["limit"] else 100 + if arguments["url"]: + current_time = str(datetime.datetime.now()).split(".")[0] + search_keyword = [current_time.replace(":", "_")] + + if arguments["similar_images"]: + current_time = str(datetime.datetime.now()).split(".")[0] + search_keyword = [current_time.replace(":", "_")] + + # If single_image or url argument not present then keywords is + # mandatory argument + if ( + arguments["single_image"] is None + and arguments["url"] is None + and arguments["similar_images"] is None + and arguments["keywords"] is None + and arguments["keywords_from_file"] is None + ): + LOGS.info( + "-------------------------------\n" + "Uh oh! Keywords is a required argument \n\n" + "Please refer to the documentation on guide to writing queries \n" + "https://github.com/hardikvasa/google-images-download#examples" + "\n\nexiting!\n" + "-------------------------------" + ) + sys.exit() + + # If this argument is present, set the custom output directory + main_directory = arguments["output_directory"] or "downloads" + # Proxy settings + if arguments["proxy"]: + os.environ["http_proxy"] = arguments["proxy"] + os.environ["https_proxy"] = arguments["proxy"] + # Initialization Complete + total_errors = 0 + for pky in prefix_keywords: # 1.for every prefix keywords + for sky in suffix_keywords: # 2.for every suffix keywords + for ii, e in enumerate(search_keyword): # 3.for every main keyword + iteration = ( + "\n" + + "Item no.: " + + str(ii + 1) + + " -->" + + " Item name = " + + (pky) + + (e) + + (sky) + ) + search_term = pky + e + sky + + if arguments["image_directory"]: + dir_name = arguments["image_directory"] + elif arguments["no_directory"]: + dir_name = "" + else: + dir_name = search_term + ( + "-" + arguments["color"] if arguments["color"] else "" + ) # sub-directory + + if not arguments["no_download"]: + self.create_directories( + main_directory, + dir_name, + arguments["thumbnail"], + arguments["thumbnail_only"], + ) # create directories in OS + + params = self.build_url_parameters( + arguments + ) # building URL with params + + url = self.build_search_url( + search_term, + params, + arguments["url"], + arguments["similar_images"], + arguments["specific_site"], + arguments["safe_search"], + ) # building main search url + + if limit < 101: + # download page + raw_html = await self.download_page(url) + else: + raw_html = self.download_extended_page( + url, arguments["chromedriver"] + ) + + items, errorCount, abs_path = self._get_all_items( + raw_html, main_directory, dir_name, limit, arguments + ) # get all image items and download images + paths[pky + e + sky] = abs_path + + # dumps into a json file + if arguments["extract_metadata"]: + try: + if not os.path.exists("logs"): + os.makedirs("logs") + except OSError as e: + LOGS.exception(e) + with open("logs/" + e + ".json", "w") as json_file: + json.dump(items, json_file, indent=4, sort_keys=True) + # Related images + if arguments["related_images"]: + tabs = self.get_all_tabs(raw_html) + for key, value in tabs.items(): + final_search_term = search_term + " - " + key + if limit < 101: + new_raw_html = await self.download_page( + value + ) # download page + else: + new_raw_html = self.download_extended_page( + value, arguments["chromedriver"] + ) + self.create_directories( + main_directory, + final_search_term, + arguments["thumbnail"], + arguments["thumbnail_only"], + ) + self._get_all_items( + new_raw_html, + main_directory, + search_term + " - " + key, + limit, + arguments, + ) + + total_errors += errorCount + return paths, total_errors From 11a1966844dda74de4710ed50359699e7de15d60 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 25 Jan 2024 11:22:54 +0800 Subject: [PATCH 019/268] Update pylint.yaml --- .github/workflows/pylint.yaml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pylint.yaml b/.github/workflows/pylint.yaml index f419b5e199..48ebd463e6 100644 --- a/.github/workflows/pylint.yaml +++ b/.github/workflows/pylint.yaml @@ -1,4 +1,4 @@ -name: PyLint +name: PyLint Ultroid on: push: branches: [ patch-1 ] @@ -37,9 +37,8 @@ jobs: - uses: stefanzweifel/git-auto-commit-action@v4 with: commit_message: 'pylint: auto fixes' - commit_options: '--no-verify' + commit_options: '--verify' repository: . commit_user_name: ufoptg - commit_user_email: perthgroups@protonmail.com - commit_author: True Saiyan - + commit_user_email: ufperth@protonmail.com + commit_author: ufoptg From 2c679f83d33f0da2c53c457fd0d3a34955f59fb4 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 25 Jan 2024 11:24:23 +0800 Subject: [PATCH 020/268] Update openaihelper.py --- pyUltroid/fns/openaihelper.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pyUltroid/fns/openaihelper.py b/pyUltroid/fns/openaihelper.py index 85915fae7a..b5d90a4544 100644 --- a/pyUltroid/fns/openaihelper.py +++ b/pyUltroid/fns/openaihelper.py @@ -21,6 +21,7 @@ from . import BASE, SESSION openai.api_key = udB.get_key("OPENAI_API") # OPENAI KEY + conversations = {} From f3fe6a2ef2f04be970d1ac79382fce0152223005 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 25 Jan 2024 11:26:52 +0800 Subject: [PATCH 021/268] Update helper.py Added User_Extraction helpers --- pyUltroid/fns/helper.py | 74 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/pyUltroid/fns/helper.py b/pyUltroid/fns/helper.py index 7696e2c3d7..7963cdbc1c 100644 --- a/pyUltroid/fns/helper.py +++ b/pyUltroid/fns/helper.py @@ -641,3 +641,77 @@ async def shutdown(ult): ) else: sys.exit() + + +# ------------------User Extraction----------------# + + +async def extract_user(message: Message, args: List[str]) -> Optional[int]: + prev_message = await message.get_reply_message() + return prev_message.sender_id if prev_message else None + + +def extract_user_and_text( + message: Message, args: List[str] +) -> (Optional[int], Optional[str]): + prev_message = message.reply_to_message + split_text = message.text.split(None, 1) + + if len(split_text) < 2: + return id_from_reply(message) # only option possible + + text_to_parse = split_text[1] + + text = "" + + entities = list(message.parse_entities([MessageEntity.TEXT_MENTION])) + ent = entities[0] if entities else None + # if entity offset matches (command end/text start) then all good + if entities and ent and ent.offset == len(message.text) - len(text_to_parse): + ent = entities[0] + user_id = ent.user.id + text = message.text[ent.offset + ent.length :] + + elif len(args) >= 1 and args[0][0] == "@": + user = args[0] + user_id = get_user_id(user) + if not user_id: + message.reply_text( + "I don't have that user in my db. You'll be able to interact with them if " + "you reply to that person's message instead, or forward one of that user's messages." + ) + return None, None + + else: + user_id = user_id + res = message.text.split(None, 2) + if len(res) >= 3: + text = res[2] + + elif len(args) >= 1 and args[0].isdigit(): + user_id = int(args[0]) + res = message.text.split(None, 2) + if len(res) >= 3: + text = res[2] + + elif prev_message: + user_id, text = id_from_reply(message) + + else: + return None, None + + try: + message.bot.get_chat(user_id) + except BadRequest as excp: + if excp.message in ("User_id_invalid", "Chat not found"): + message.reply_text( + "I don't seem to have interacted with this user before - please forward a message from " + "them to give me control! (like a voodoo doll, I need a piece of them to be able " + "to execute certain commands...)" + ) + else: + LOGGER.exception("Exception %s on user %s", excp.message, user_id) + + return None, None + + return user_id, text From 424f48fe5a3c937057db2c2951bed1c7ef1ddeb0 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 25 Jan 2024 11:39:07 +0800 Subject: [PATCH 022/268] Update pmbot.py pmbot update when botchat is enabled your assistant will also send a message to your log group. replying to the user there will also work.. Your SUDOS can also reply --- assistant/pmbot.py | 131 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 115 insertions(+), 16 deletions(-) diff --git a/assistant/pmbot.py b/assistant/pmbot.py index 316f8eae6d..9fa8ba584d 100644 --- a/assistant/pmbot.py +++ b/assistant/pmbot.py @@ -9,6 +9,8 @@ # --------------------------------------- Imports -------------------------------------------- # +import asyncio +import logging import os from telethon.errors.rpcerrorlist import UserNotParticipantError @@ -25,8 +27,59 @@ from . import * botb = KeyManager("BOTBLS", cast=list) -FSUB = udB.get_key("PMBOT_FSUB") +FSUB = Keys.PMBOT_FSUB +PMBOTGROUP = Keys.LOG_CHANNEL CACHE = {} +SUDOS = Keys.SUDOS +PMUSERS = [OWNER_ID, SUDOS] +logging.basicConfig( + format="%(asctime)s | %(name)s [%(levelname)s] : %(message)s", + level=logging.INFO, + datefmt="%m/%d/%Y, %H:%M:%S", +) +logger = logging.getLogger("DEBUGGING") + +# --------------------------------------- Functions -------------------------------------------- # + + +async def forward_to_multiple(event, *user_ids): + results = [] + tasks = [] + + for user_id in user_ids: + task = asyncio.create_task(event.forward_to(user_id)) + tasks.append(task) + + for task in tasks: + try: + result = await task + results.append(result) + except Exception as e: + results.append(str(e)) + + return results + + +async def check_reply_from_bot(event): + if (event.is_private and event.is_reply) or ( + event.chat_id == PMBOTGROUP and event.is_reply and event.reply_to_msg_id + ): + if event.chat_id == PMBOTGROUP: + replied_message = await event.client.get_messages( + event.chat_id, ids=event.reply_to_msg_id + ) + if replied_message.from_id: + entity = replied_message.from_id.user_id + else: + return False + return entity == 6176247391 + else: + # For private messages, no need to check the entity, as it's + # already a reply + return True + return False + + # --------------------------------------- Incoming -------------------------------------------- # @@ -37,7 +90,6 @@ ) async def on_new_mssg(event): who = event.sender_id - # doesn't reply to that user anymore if event.text.startswith("/") or who == OWNER_ID: return if FSUB: @@ -72,9 +124,12 @@ async def on_new_mssg(event): if MSG and BTTS: return await event.reply(MSG, buttons=BTTS) xx = await event.forward_to(OWNER_ID) + zz = await event.forward_to(PMBOTGROUP) if event.fwd_from: await xx.reply(f"From {inline_mention(event.sender)} [`{event.sender_id}`]") + await zz.reply(f"From {inline_mention(event.sender)} [`{event.sender_id}`]") add_stuff(xx.id, who) + add_stuff(zz.id, who) # --------------------------------------- Outgoing -------------------------------------------- # @@ -82,30 +137,74 @@ async def on_new_mssg(event): @asst_cmd( load=AST_PLUGINS, - from_users=[OWNER_ID], + from_users=PMUSERS, incoming=True, - func=lambda e: e.is_private and e.is_reply, + func=check_reply_from_bot, ) async def on_out_mssg(event): x = event.reply_to_msg_id - to_user = get_who(x) + logger.info(f"msg_id: {x}") + if event.chat_id == PMBOTGROUP: + group_to_user = get_who(x) + else: + to_user = get_who(x) + + if event.reply_to_msg_id: + replied_message = await event.client.get_messages( + event.chat_id, ids=event.reply_to_msg_id + ) + if ( + replied_message + and replied_message.fwd_from + and replied_message.fwd_from.from_id + and replied_message.fwd_from.from_id.user_id != 6176247391 + ): + return if event.text.startswith("/who"): try: - k = await asst.get_entity(to_user) - photu = await event.client.download_profile_photo(k.id) - await event.reply( - f"• **Name :** {get_display_name(k)}\n• **ID :** `{k.id}`\n• **Link :** {inline_mention(k)}", - file=photu, - ) - if photu: - os.remove(photu) - return + if event.is_private and to_user: + k = await asst.get_entity(to_user) + photu = await event.client.download_profile_photo(k.id) + await event.reply( + f"• **Name :** {get_display_name(k)}\n• **ID :** `{k.id}`\n• **Link :** {inline_mention(k)}", + file=photu, + ) + if photu: + os.remove(photu) + return + elif event.chat_id == PMBOTGROUP and group_to_user: + k = await asst.get_entity(group_to_user) + photu = await event.client.download_profile_photo(k.id) + await event.reply( + f"• **Name :** {get_display_name(k)}\n• **ID :** `{k.id}`\n• **Link :** {inline_mention(k)}", + file=photu, + ) + if photu: + os.remove(photu) + return + else: + return await event.reply( + "Unable to determine the user. Please reply to a specific message." + ) except BaseException as er: return await event.reply(f"**ERROR : **{str(er)}") elif event.text.startswith("/"): return - if to_user: - await asst.send_message(to_user, event.message) + + if event.chat_id == PMBOTGROUP: + if group_to_user: + await asst.send_message(group_to_user, event.message) + else: + return await event.reply( + "Unable to determine the user. Please reply to a specific message." + ) + elif event.sender_id in PMUSERS: + if to_user: + await asst.send_message(to_user, event.message) + else: + return await event.reply( + "Unable to determine the user. Please reply to a specific message." + ) # --------------------------------------- Ban/Unban -------------------------------------------- # From de4658a44084493b7923271bee32e2dc4af455e5 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 25 Jan 2024 11:40:44 +0800 Subject: [PATCH 023/268] Update __init__.py --- pyUltroid/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyUltroid/__init__.py b/pyUltroid/__init__.py index 366bc7dc8f..681bcf3213 100644 --- a/pyUltroid/__init__.py +++ b/pyUltroid/__init__.py @@ -42,6 +42,10 @@ class ULTConfig: udB = UltroidDB() update_envs() + from .dB.base import Keys as Keyz + + Keys = Keyz(udB) + LOGS.info(f"Connecting to {udB.name}...") if udB.ping(): LOGS.info(f"Connected to {udB.name} Successfully!") From 607340ed6995bbc25ef770d29a7b2c693875d78e Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 25 Jan 2024 11:44:12 +0800 Subject: [PATCH 024/268] Update _chatactions.py --- plugins/_chatactions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/_chatactions.py b/plugins/_chatactions.py index 18757952be..96566ae0ef 100644 --- a/plugins/_chatactions.py +++ b/plugins/_chatactions.py @@ -55,7 +55,7 @@ def get_ufop_ban(self, user_id: int=None, banlist: bool = False) -> Union[dict, payload = {"user_id": user_id} return self._make_request("GET", url, params=payload) else: - raise ValueError("Error: banlist must be True + raise ValueError("Error: banlist must be True") #------------------------- Huge Thanks to @xtdevs -------------------------# @ultroid_bot.on(events.ChatAction()) From 52f6afa20b0bd886fbbf7f93058c3bb37a3c90cb Mon Sep 17 00:00:00 2001 From: ufoptg Date: Thu, 25 Jan 2024 03:44:52 +0000 Subject: [PATCH 025/268] pylint: auto fixes --- plugins/_chatactions.py | 36 ++++++++++++++++++++++-------------- plugins/beautify.py | 21 +++++++++------------ plugins/tools.py | 9 +++++++-- 3 files changed, 38 insertions(+), 28 deletions(-) diff --git a/plugins/_chatactions.py b/plugins/_chatactions.py index 96566ae0ef..caf0655de6 100644 --- a/plugins/_chatactions.py +++ b/plugins/_chatactions.py @@ -6,14 +6,13 @@ # . import asyncio -import requests +from typing import Union +import requests from telethon import events from telethon.errors.rpcerrorlist import UserNotParticipantError from telethon.tl.functions.channels import GetParticipantRequest from telethon.utils import get_display_name -from typing import List, Optional, Union - from pyUltroid.dB import stickers from pyUltroid.dB.echo_db import check_echo @@ -31,16 +30,17 @@ from . import LOG_CHANNEL, LOGS, asst, get_string, types, udB, ultroid_bot from ._inline import something -#------------------------- UFoP Bans -------------------------# +# ------------------------- UFoP Bans -------------------------# + + class UFoPBan: def __init__(self, api_key: str = None): self.api_key = api_key - def _make_request(self, method: str, url: str, params: dict = None, json_data: dict = None): - headers = { - "accept": "application/json", - "api-key": self.api_key - } + def _make_request( + self, method: str, url: str, params: dict = None, json_data: dict = None + ): + headers = {"accept": "application/json", "api-key": self.api_key} try: response = requests.request( method, url, headers=headers, params=params, json=json_data @@ -49,14 +49,19 @@ def _make_request(self, method: str, url: str, params: dict = None, json_data: d except requests.RequestException: pass - def get_ufop_ban(self, user_id: int=None, banlist: bool = False) -> Union[dict, str]: + def get_ufop_ban( + self, user_id: int = None, banlist: bool = False + ) -> Union[dict, str]: if banlist: url = "https://ufoptg-ufop-api.hf.space/UFoP/bans" payload = {"user_id": user_id} return self._make_request("GET", url, params=payload) else: raise ValueError("Error: banlist must be True") -#------------------------- Huge Thanks to @xtdevs -------------------------# + + +# ------------------------- Huge Thanks to @xtdevs -------------------------# + @ultroid_bot.on(events.ChatAction()) async def Function(event): @@ -132,15 +137,17 @@ async def DummyHandler(ult): clients = UFoPBan(ufop_api_key) try: UFoP_banned = clients.get_ufop_ban(user_id=user.id, banlist=True) - - if UFoP_banned and UFoP_banned.get("sukuna", {}).get("is_banned", False): + + if UFoP_banned and UFoP_banned.get("sukuna", {}).get( + "is_banned", False + ): await ult.client.edit_permissions( chat.id, user.id, view_messages=False, ) await ult.respond( - f'**🌀ʊʄ⊕ք🌀:** Banned user detected and banned!\n' + f"**🌀ʊʄ⊕ք🌀:** Banned user detected and banned!\n" f'Sibyl User ID: {UFoP_banned["sukuna"]["sibyl_user_id"]}\n' f'Ban Reason: {UFoP_banned["sukuna"]["reason"]}', ) @@ -243,6 +250,7 @@ async def DummyHandler(ult): else: await ult.reply(file=med) + @ultroid_bot.on(events.NewMessage(incoming=True)) async def chatBot_replies(e): xxrep = await check_reply_to(e) diff --git a/plugins/beautify.py b/plugins/beautify.py index 903ab13197..9ad5057b43 100644 --- a/plugins/beautify.py +++ b/plugins/beautify.py @@ -12,11 +12,12 @@ import os import random +from secrets import token_hex +from urllib.parse import urlencode from telethon.utils import get_display_name -from urllib.parse import urlencode -from . import Carbon, ultroid_cmd, get_string, inline_mention -from secrets import token_hex + +from . import Carbon, get_string, inline_mention, ultroid_cmd _colorspath = "resources/colorlist.txt" @@ -108,7 +109,9 @@ async def pass_on(ult): try: from playwright.async_api import async_playwright except ImportError: - await ult.eor("`playwright` is not installed!\nPlease install it to use this command..") + await ult.eor( + "`playwright` is not installed!\nPlease install it to use this command.." + ) return proc = await ult.eor(get_string("com_1")) spli = ult.text.split() @@ -139,11 +142,7 @@ async def pass_on(ult): text = msg.message title = get_display_name(msg.sender) name = token_hex(8) + ".png" - data = { - "darkMode": dark, - "theme": theme, - "title": title - } + data = {"darkMode": dark, "theme": theme, "title": title} url = f"https://ray.so/#{urlencode(data)}" async with async_playwright() as play: chrome = await play.chromium.launch() @@ -157,8 +156,6 @@ async def pass_on(ult): async with page.expect_download() as dl: dled = await dl.value await dled.save_as(name) - await proc.reply( - file=name - ) + await proc.reply(file=name) await proc.try_delete() os.remove(name) diff --git a/plugins/tools.py b/plugins/tools.py index a1b60cb55f..e3ff04d71e 100644 --- a/plugins/tools.py +++ b/plugins/tools.py @@ -82,7 +82,9 @@ from . import humanbytes as hb from . import inline_mention, is_url_ok, json_parser, mediainfo, ultroid_cmd -#-------------- Sangmata stuff --------------# +# -------------- Sangmata stuff --------------# + + def sanga_seperator(sanga_list): string = "".join(info[info.find("\n") + 1 :] for info in sanga_list) string = re.sub(r"^$\n", "", string, flags=re.MULTILINE) @@ -93,7 +95,10 @@ def sanga_seperator(sanga_list): def mentionuser(name, userid): return f"[{name}](tg://user?id={userid})" -#-------------- Sangmata stuff --------------# + + +# -------------- Sangmata stuff --------------# + @ultroid_cmd(pattern="tr( (.*)|$)", manager=True) async def _(event): From 7869e026895b2e5425c382a90ba4e1c3543dfb07 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 25 Jan 2024 11:53:52 +0800 Subject: [PATCH 026/268] Update misc.py --- pyUltroid/fns/misc.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pyUltroid/fns/misc.py b/pyUltroid/fns/misc.py index c8ceff329c..fe2f12ae72 100644 --- a/pyUltroid/fns/misc.py +++ b/pyUltroid/fns/misc.py @@ -357,7 +357,6 @@ async def telegraph(file_): text += f" in {rep.game.title}" elif isinstance(event.action, types.MessageActionPinMessage): text = "pinned a message." - # TODO: Are there any more events with sender? message = { "entities": entities, From 82c1fe759dbe9b239a5332025f923f86c29ff36d Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 25 Jan 2024 12:08:47 +0800 Subject: [PATCH 027/268] Update _supporter.py --- pyUltroid/_misc/_supporter.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pyUltroid/_misc/_supporter.py b/pyUltroid/_misc/_supporter.py index f098d76dc5..dfe6196b96 100644 --- a/pyUltroid/_misc/_supporter.py +++ b/pyUltroid/_misc/_supporter.py @@ -118,6 +118,7 @@ class Config((object)): PM_DATA = os.environ.get("PM_DATA", "ENABLE") DEEP_AI = os.environ.get("DEEP_AI", None) TAG_LOG = os.environ.get("TAG_LOG", None) + UFOPAPI = os.environ.get("UFOPAPI", "h32dfKsl8pQUxsNftkogIuDF32pYTwKluIY8emI1Hs") else: DB_URI = None From 9b3ef6b63be3a6e123d055b74026d0e0914ba91e Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 25 Jan 2024 13:36:59 +0800 Subject: [PATCH 028/268] Update extra.py Added Delete messages via phrase --- plugins/extra.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/plugins/extra.py b/plugins/extra.py index f9abda572a..2e8107deaf 100644 --- a/plugins/extra.py +++ b/plugins/extra.py @@ -10,8 +10,15 @@ __doc__ = get_help("extra") import asyncio +import logging +import os + +from telethon import errors, events, functions +from telethon.errors import FloodWaitError +from telethon.tl.types import PeerChannel, PeerUser from . import get_string, ultroid_cmd +from . import * @ultroid_cmd( @@ -83,3 +90,33 @@ async def _(e): ) else: await e.try_delete() + + +@ultroid_cmd( + pattern="delmsgs", +) +async def delete_messages(event): + # Get the search phrase from the command + search_phrase = event.raw_text.split(" ", 1)[1] + + # Get the chat ID of the group + chat_id = event.chat_id + + # Get the messages in the chat + async for message in nimbus_bot.iter_messages(chat_id): + if message.text and search_phrase.lower() in message.text.lower(): + try: + await nimbus_bot.delete_messages(chat_id, message) + except FloodWaitError as e: + # If a FloodWaitError occurs, wait for the specified time + # before retrying + wait_time = e.seconds + 5 + logger.warning( + f"FloodWaitError occurred. Waiting for {wait_time} seconds.") + await asyncio.sleep(wait_time) + continue + + # Reply to the command with a confirmation message + await event.reply(f"Messages containing the phrase '{search_phrase}' deleted.") + logger.info( + f"Deleted messages containing the phrase '{search_phrase}' in chat {chat_id}") From c5174cce10aa7888a752a2955d8019387c195675 Mon Sep 17 00:00:00 2001 From: ufoptg Date: Thu, 25 Jan 2024 05:37:42 +0000 Subject: [PATCH 029/268] pylint: auto fixes --- plugins/extra.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/plugins/extra.py b/plugins/extra.py index 2e8107deaf..96e76f4dc4 100644 --- a/plugins/extra.py +++ b/plugins/extra.py @@ -10,15 +10,11 @@ __doc__ = get_help("extra") import asyncio -import logging -import os -from telethon import errors, events, functions from telethon.errors import FloodWaitError -from telethon.tl.types import PeerChannel, PeerUser -from . import get_string, ultroid_cmd from . import * +from . import get_string, ultroid_cmd @ultroid_cmd( @@ -112,11 +108,13 @@ async def delete_messages(event): # before retrying wait_time = e.seconds + 5 logger.warning( - f"FloodWaitError occurred. Waiting for {wait_time} seconds.") + f"FloodWaitError occurred. Waiting for {wait_time} seconds." + ) await asyncio.sleep(wait_time) continue # Reply to the command with a confirmation message await event.reply(f"Messages containing the phrase '{search_phrase}' deleted.") logger.info( - f"Deleted messages containing the phrase '{search_phrase}' in chat {chat_id}") + f"Deleted messages containing the phrase '{search_phrase}' in chat {chat_id}" + ) From 304f604b5c6e5d511abae53dc96f71209df5c315 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 25 Jan 2024 13:51:56 +0800 Subject: [PATCH 030/268] Update _help.py help Startup emoji --- plugins/_help.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/_help.py b/plugins/_help.py index b36101e7f5..cb25c6e475 100644 --- a/plugins/_help.py +++ b/plugins/_help.py @@ -108,6 +108,7 @@ async def _help(ult): await ult.eor("Error 🤔 occured.") else: try: + load = await ult.eor("✨") results = await ult.client.inline_query(asst.me.username, "ultd") except BotMethodInvalidError: z = [] @@ -132,5 +133,5 @@ async def _help(ult): ) except BotInlineDisabledError: return await ult.eor(get_string("help_3")) + await load.delete() await results[0].click(chat.id, reply_to=ult.reply_to_msg_id, hide_via=True) - await ult.delete() From 9a204ade4ab5758fad09da78ec6a8ee0eedd663f Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 26 Jan 2024 14:49:30 +0800 Subject: [PATCH 031/268] Update tools.py --- pyUltroid/fns/tools.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pyUltroid/fns/tools.py b/pyUltroid/fns/tools.py index 8762b637b9..d362efc6df 100644 --- a/pyUltroid/fns/tools.py +++ b/pyUltroid/fns/tools.py @@ -43,6 +43,7 @@ from telethon import Button from telethon.tl.types import DocumentAttributeAudio, DocumentAttributeVideo +from RyuzakiLib.hackertools.chatgpt import RandyDevChat if run_as_module: from ..dB.filestore_db import get_stored_msg, store_msg @@ -509,6 +510,24 @@ async def get_chatbot_reply(message): LOGS.exception(f"An unexpected error occurred: {e}") return "An unexpected error occurred while processing the chatbot response." + +async def get_orcale_reply(query, user_id, mongo_url): + response = RendyDevChat(query).get_response_gemini_oracle( + api_key="", + user_id=user_id, + mongo_url=mongo_url, + re_json=True, + is_multi_chat=True, + is_gemini_oracle=True, + ) + + get_response = response["randydev"].get("message") if response else None + + if get_response is not None: + return get_response + else: + return "Unexpected response from the chatbot server." + #-----------------------------------------------------------------------------------# def check_filename(filroid): From 7133f62e9bf47288a4094d7c66c8dedf0718c645 Mon Sep 17 00:00:00 2001 From: ufoptg Date: Fri, 26 Jan 2024 06:50:08 +0000 Subject: [PATCH 032/268] pylint: auto fixes --- assistant/callbackstuffs.py | 4 +++- assistant/start.py | 16 ++++++++++------ plugins/nightmode.py | 4 +++- plugins/stickertools.py | 8 +++++--- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/assistant/callbackstuffs.py b/assistant/callbackstuffs.py index db28bc4512..6799a0d7a4 100644 --- a/assistant/callbackstuffs.py +++ b/assistant/callbackstuffs.py @@ -570,7 +570,9 @@ async def emoji(event): var = "EMOJI_IN_HELP" name = f"Emoji in `{HNDLR}help` menu" async with event.client.conversation(pru) as conv: - await conv.send_message("Send emoji u want to set 🙃.\n\nUse /cancel to cancel.") + await conv.send_message( + "Send emoji u want to set 🙃.\n\nUse /cancel to cancel." + ) response = conv.wait_event(events.NewMessage(chats=pru)) response = await response themssg = response.message.message diff --git a/assistant/start.py b/assistant/start.py index c8dcb3c700..12226ed032 100644 --- a/assistant/start.py +++ b/assistant/start.py @@ -115,17 +115,21 @@ async def ultroid(event): await event.reply( f"Hey there {mention}, this is Ultroid Assistant of {me}!\n\n{ok}", file=udB.get_key("STARTMEDIA"), - buttons=[Button.inline("Info.", data="ownerinfo")] - if Owner_info_msg - else None, + buttons=( + [Button.inline("Info.", data="ownerinfo")] + if Owner_info_msg + else None + ), ) else: await event.reply( udB.get_key("STARTMSG").format(me=me, mention=mention), file=udB.get_key("STARTMEDIA"), - buttons=[Button.inline("Info.", data="ownerinfo")] - if Owner_info_msg - else None, + buttons=( + [Button.inline("Info.", data="ownerinfo")] + if Owner_info_msg + else None + ), ) else: name = get_display_name(event.sender) diff --git a/plugins/nightmode.py b/plugins/nightmode.py index 5719cd7dc1..a2ea2dbd7c 100644 --- a/plugins/nightmode.py +++ b/plugins/nightmode.py @@ -117,7 +117,9 @@ async def open_grp(): ), ) ) - await ultroid_bot.send_message(chat, "**NightMode Off**\n\nGroup Opened 🥳.") + await ultroid_bot.send_message( + chat, "**NightMode Off**\n\nGroup Opened 🥳." + ) except Exception as er: LOGS.info(er) diff --git a/plugins/stickertools.py b/plugins/stickertools.py index 9191aa90e6..494a29bbf7 100644 --- a/plugins/stickertools.py +++ b/plugins/stickertools.py @@ -115,9 +115,11 @@ async def pack_kangish(_): stiks.append( types.InputStickerSetItem( document=x, - emoji=random.choice(["😐", "👍", "😂"]) - if local - else (i.attributes[1]).alt, + emoji=( + random.choice(["😐", "👍", "😂"]) + if local + else (i.attributes[1]).alt + ), ) ) try: From c4b876c0fe8f81e15ca61fcc6c9b467a3eb5be33 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 26 Jan 2024 14:51:53 +0800 Subject: [PATCH 033/268] Update _chatactions.py --- plugins/_chatactions.py | 57 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/plugins/_chatactions.py b/plugins/_chatactions.py index caf0655de6..7d91dde7c1 100644 --- a/plugins/_chatactions.py +++ b/plugins/_chatactions.py @@ -21,7 +21,7 @@ from pyUltroid.dB.greetings_db import get_goodbye, get_welcome, must_thank from pyUltroid.dB.nsfw_db import is_profan from pyUltroid.fns.helper import check_reply_to, inline_mention -from pyUltroid.fns.tools import async_searcher, create_tl_btn, get_chatbot_reply +from pyUltroid.fns.tools import async_searcher, create_tl_btn, get_chatbot_reply, get_oracle_reply try: from ProfanityDetector import detector @@ -304,6 +304,61 @@ async def chatBot_replies(e): if y: await e.delete() +@ultroid_bot.on(events.NewMessage(incoming=True)) +async def oracleBot_replies(e): + xxxrep = await check_reply_to(e) + + if xxxrep: + sender = await e.get_sender() + if not isinstance(sender, types.User) or sender.bot: + return + if check_echo(e.chat_id, e.sender_id): + try: + await e.respond(e.message) + except Exception as er: + LOGS.exception(er) + key = udB.get_key("ORACLE_USERS") or {} + if e.text and key.get(e.chat_id) and sender.id in key[e.chat_id]: + # Simulate typing indicator + async with e.client.action(e.chat_id, "typing"): + msg = await get_gem_reply( + e.message.message, user_id=sender.id, mongo_url=MONGO_URI + ) + if msg: + sleep = udB.get_key("ORACLE_SLEEP") or 1.5 + await asyncio.sleep(sleep) + + # Check if the message length exceeds a certain threshold + if len(msg) > 4096: + # Create a temporary text file + with tempfile.NamedTemporaryFile( + mode="w+", delete=False + ) as temp_file: + temp_file.write(msg) + + # Send the text file with a caption + await e.client.send_file( + e.chat_id, + temp_file.name, + caption="Here is the response in a text file", + ) + + # Delete the temporary text file + os.remove(temp_file.name) + else: + # Send the message directly + await e.reply(msg) + + chat = await e.get_chat() + if e.is_group and sender.username: + await uname_stuff(e.sender_id, sender.username, sender.first_name) + elif e.is_private and chat.username: + await uname_stuff(e.sender_id, chat.username, chat.first_name) + if detector and is_profan(e.chat_id) and e.text: + x, y = detector(e.text) + if y: + await e.delete() + @ultroid_bot.on(events.Raw(types.UpdateUserName)) async def uname_change(e): From f275a98482737a0e6199a164c2a126ab41227ab2 Mon Sep 17 00:00:00 2001 From: ufoptg Date: Fri, 26 Jan 2024 06:52:31 +0000 Subject: [PATCH 034/268] pylint: auto fixes --- plugins/_chatactions.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/_chatactions.py b/plugins/_chatactions.py index 7d91dde7c1..24542759db 100644 --- a/plugins/_chatactions.py +++ b/plugins/_chatactions.py @@ -21,7 +21,7 @@ from pyUltroid.dB.greetings_db import get_goodbye, get_welcome, must_thank from pyUltroid.dB.nsfw_db import is_profan from pyUltroid.fns.helper import check_reply_to, inline_mention -from pyUltroid.fns.tools import async_searcher, create_tl_btn, get_chatbot_reply, get_oracle_reply +from pyUltroid.fns.tools import async_searcher, create_tl_btn, get_chatbot_reply try: from ProfanityDetector import detector @@ -304,6 +304,7 @@ async def chatBot_replies(e): if y: await e.delete() + @ultroid_bot.on(events.NewMessage(incoming=True)) async def oracleBot_replies(e): xxxrep = await check_reply_to(e) From 7e6fcfbce521760dff8b220e1e43fe63beceab2c Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 26 Jan 2024 14:54:56 +0800 Subject: [PATCH 035/268] Update chatbot.py --- plugins/chatbot.py | 78 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 77 insertions(+), 1 deletion(-) diff --git a/plugins/chatbot.py b/plugins/chatbot.py index f050be1955..0475f092fb 100644 --- a/plugins/chatbot.py +++ b/plugins/chatbot.py @@ -10,11 +10,87 @@ __doc__ = get_help("help_chatbot") -from pyUltroid.fns.tools import get_chatbot_reply +from pyUltroid.fns.tools import get_chatbot_reply, get_oracle_reply from . import LOGS, eod, get_string, inline_mention, udB, ultroid_cmd +@ultroid_cmd(pattern="repoai") +async def im_oracle(event): + if event.reply_to: + message = (await event.get_reply_message()).text.strip() + else: + try: + message = event.text.split(" ", 1)[1] + except IndexError: + return await eod(event, get_string("tban_1"), time=10) + reply_ = await get_orcale_reply( + query=message, user_id=ultroid_bot.me.id, mongo_url=MONGO_URI + ) + await event.eor(reply_) + + +@ultroid_cmd(pattern="addoai") +async def add_oracle(event): + await oracle_bot_fn(event, type_="add") + + +@ultroid_cmd(pattern="remoai") +async def rem_oracle(event): + await oracle_bot_fn(event, type_="remov") + + +@ultroid_cmd(pattern="listoai") +async def listoracle(event): + key = udB.get_key("ORACLE_USERS") or {} + users = key.get(event.chat_id, []) + if not users: + return await event.eor(get_string("chab_2"), time=5) + msg = "**Total List Of Oracle Enabled Users In This Chat :**\n\n" + for i in users: + try: + user = await event.client.get_entity(int(i)) + user = inline_mention(user) + except BaseException: + user = f"`{i}`" + msg += f"• {user}\n" + await event.eor(msg, link_preview=False) + + +async def oracle_bot_fn(event, type_): + if event.reply_to: + user_ = (await event.get_reply_message()).sender + else: + temp = event.text.split(maxsplit=1) + try: + user_ = await event.client.get_entity(await event.client.parse_id(temp[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("ORACLE_USERS") or {} + chat = event.chat_id + user = user_.id + if type_ == "add": + if key.get(chat): + if user not in key[chat]: + key[chat].append(user) + else: + key.update({chat: [user]}) + elif type_ == "remov": + if key.get(chat): + if user in key[chat]: + key[chat].remove(user) + if chat in key and not key[chat]: + del key[chat] + udB.set_key("ORACLE_USERS", key) + await event.eor(f"**Oracle:**\n{type_}ed {inline_mention(user_)}") + + @ultroid_cmd(pattern="repai") async def im_lonely_chat_with_me(event): if event.reply_to: From 86c8a6662aa17950007ff4e603fc8247cbff568f Mon Sep 17 00:00:00 2001 From: ufoptg Date: Fri, 26 Jan 2024 06:55:35 +0000 Subject: [PATCH 036/268] pylint: auto fixes --- plugins/chatbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/chatbot.py b/plugins/chatbot.py index 0475f092fb..cf1ebdd9a5 100644 --- a/plugins/chatbot.py +++ b/plugins/chatbot.py @@ -10,7 +10,7 @@ __doc__ = get_help("help_chatbot") -from pyUltroid.fns.tools import get_chatbot_reply, get_oracle_reply +from pyUltroid.fns.tools import get_chatbot_reply from . import LOGS, eod, get_string, inline_mention, udB, ultroid_cmd From e33217c04f66311fb8f76ee22ca5e9883bb15c0b Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 26 Jan 2024 14:55:44 +0800 Subject: [PATCH 037/268] Update tools.py --- pyUltroid/fns/tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyUltroid/fns/tools.py b/pyUltroid/fns/tools.py index d362efc6df..d9e6630031 100644 --- a/pyUltroid/fns/tools.py +++ b/pyUltroid/fns/tools.py @@ -511,7 +511,7 @@ async def get_chatbot_reply(message): return "An unexpected error occurred while processing the chatbot response." -async def get_orcale_reply(query, user_id, mongo_url): +async def get_oracle_reply(query, user_id, mongo_url): response = RendyDevChat(query).get_response_gemini_oracle( api_key="", user_id=user_id, From ec71a85db2ad0336a624b0f1139f5c0432e1e6ff Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 26 Jan 2024 14:57:21 +0800 Subject: [PATCH 038/268] Update _chatactions.py --- plugins/_chatactions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/_chatactions.py b/plugins/_chatactions.py index 24542759db..d0c8e84687 100644 --- a/plugins/_chatactions.py +++ b/plugins/_chatactions.py @@ -21,7 +21,7 @@ from pyUltroid.dB.greetings_db import get_goodbye, get_welcome, must_thank from pyUltroid.dB.nsfw_db import is_profan from pyUltroid.fns.helper import check_reply_to, inline_mention -from pyUltroid.fns.tools import async_searcher, create_tl_btn, get_chatbot_reply +from pyUltroid.fns.tools import async_searcher, create_tl_btn, get_chatbot_reply, get_oracle_reply try: from ProfanityDetector import detector From 6662d2c110e0a4064bc7fcaa8b6782ac48f48056 Mon Sep 17 00:00:00 2001 From: ufoptg Date: Fri, 26 Jan 2024 06:58:00 +0000 Subject: [PATCH 039/268] pylint: auto fixes --- plugins/_chatactions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/_chatactions.py b/plugins/_chatactions.py index d0c8e84687..24542759db 100644 --- a/plugins/_chatactions.py +++ b/plugins/_chatactions.py @@ -21,7 +21,7 @@ from pyUltroid.dB.greetings_db import get_goodbye, get_welcome, must_thank from pyUltroid.dB.nsfw_db import is_profan from pyUltroid.fns.helper import check_reply_to, inline_mention -from pyUltroid.fns.tools import async_searcher, create_tl_btn, get_chatbot_reply, get_oracle_reply +from pyUltroid.fns.tools import async_searcher, create_tl_btn, get_chatbot_reply try: from ProfanityDetector import detector From 3778f41e5ff9791881434bce1d5b617139389623 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 26 Jan 2024 15:01:17 +0800 Subject: [PATCH 040/268] Update en.yml --- strings/strings/en.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/strings/strings/en.yml b/strings/strings/en.yml index 85dd02758f..0395227ab0 100644 --- a/strings/strings/en.yml +++ b/strings/strings/en.yml @@ -596,7 +596,7 @@ help_broadcast: "\n\n• `{i}addch `\n Add chat to dat help_button: " -\n\n• `{i}button | `\n This will transfer all old post from channel A to channel B.\n (u can use username or id of channel too)\n example : `{i}shift @abc | @xyz`\n [note - this (' | ') sign is nessesary]\n\n🔹 For auto-posting/forwarding all new message from any source channel to any destination channel.\n\n `{i}asource `\n This add source channel to database\n `{i}dsource `\n This remove source channels from database\n `{i}listsource `\n Show list of source channels\n\n\n `{i}adest `\n This add Ur channels to database\n `{i}ddest `\n This Remove Ur channels from database\n `{i}listdest `\n Show List of Ur channels\n\n 'you can set many channels in database'\n 'For activating auto-post use `{i}setdb AUTOPOST True` '\n" -help_chatbot: " -\n\n• `{i}addai `\n Add a AI ChatBot to reply to that user.\n\n• `{i}remai `\n Remove the AI ChatBot.\n\n• `{i}repai `\n Reply to the user with a message by an AI.\n\n• `{i}listai`\n List the currently AI added users.\n" +help_chatbot: " -\n\n• `{i}addai` or `{i}addoai` \n Add an AI ChatBot to reply to that user.\n\n• `{i}remai` or `{i}remoai` \n Remove the AI ChatBot.\n\n• `{i}repai` or `{i}repoai` \n Reply to the user with a message by an AI.\n\n• `{i}listai` or `{i}listoai`\n List the currently AI added users.\n" help_chats: " -\n\n• `{i}delchat `\n Delete the group this cmd is used in.\n\n• `{i}getlink`\n• `{i}getlink r` - `create link with admin approval`\n• `{i}getlink r title_here` - `admin approval with link title`\n• `{i}getlink 10` - `usage limit in new link`\n Get link of group this cmd is used in.\n\n• `{i}create (g|b|c) ; `\n Create group woth a specific name.\n g - megagroup/supergroup\n b - small group\n c - channel\n\n• `{i}setgpic `\n Set Profile photo of Group.\n\n• `{i}delgpic `\n Delete Profile photo of Group.\n\n• `{i}unbanall`\n Unban all Members of a group.\n\n• `{i}rmusers`\n Remove users specifically.\n" help_cleanaction: " -\n\n•`{i}addclean`\n Clean all Upcoming action msg in added chat like someone joined/left/pin etc.\n\n•`{i}remclean`\n Remove chat from database.\n\n•`{i}listclean`\n To get list of all chats where its activated.\n\n" help_converter: " -\n\n• `{i}convert `\n Reply to media to convert it into gif / image / webm / normal sticker.\n\n• `{i}doc `\n Reply to a text msg to save it in a file.\n\n• `{i}open`\n Reply to a file to reveal it's text.\n\n• `{i}rename `\n Rename the file\n\n• `{i}thumbnail `\n Upload Your file with your custom thumbnail.\n" From faebe3fb5a5c4dedb059adbc1d64af901a4af0ab Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 26 Jan 2024 15:04:53 +0800 Subject: [PATCH 041/268] Update tools.py --- pyUltroid/fns/tools.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/pyUltroid/fns/tools.py b/pyUltroid/fns/tools.py index 2571314329..61b6b427db 100644 --- a/pyUltroid/fns/tools.py +++ b/pyUltroid/fns/tools.py @@ -22,6 +22,7 @@ from ..exceptions import DependencyMissingError from . import some_random_headers from .helper import async_searcher, bash, run_async +from RyuzakiLib.hackertools.chatgpt import RandyDevChat try: import certifi @@ -433,18 +434,25 @@ async def get_google_images(query): return google_images -# Thanks https://t.me/KukiUpdates/23 for ChatBotApi +# Thanks https://t.me/TrueSaiyan and @xtdevs for chatbot -async def get_chatbot_reply(message): - chatbot_base = "https://kuki-api-lac.vercel.app/message={}" - req_link = chatbot_base.format( - message, +async def get_chatbot_reply(query, user_id, mongo_url): + response = RendyDevChat(query).get_response_gemini_oracle( + api_key="", + user_id=user_id, + mongo_url=mongo_url, + re_json=True, + is_multi_chat=True, + is_gemini_oracle=True, ) - try: - return (await async_searcher(req_link, re_json=True)).get("reply") - except Exception: - LOGS.info(f"**ERROR:**`{format_exc()}`") + + get_response = response["randydev"].get("message") if response else None + + if get_response is not None: + return get_response + else: + return "Unexpected response from the chatbot server." def check_filename(filroid): if os.path.exists(filroid): From 537fe81939c78a0f80b9826e15238782bf12f2be Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 26 Jan 2024 15:07:20 +0800 Subject: [PATCH 042/268] Update helper.py --- pyUltroid/fns/helper.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/pyUltroid/fns/helper.py b/pyUltroid/fns/helper.py index 16d00ea177..cb27fb701a 100644 --- a/pyUltroid/fns/helper.py +++ b/pyUltroid/fns/helper.py @@ -97,6 +97,31 @@ def inline_mention(user, custom=None, html=False): return mention_text +async def check_reply_to(event): + truai = [client.me.id] + if (event.is_private and event.is_reply) or ( + event.is_reply and event.reply_to_msg_id + ): + try: + replied_message = await event.client.get_messages( + event.chat_id, ids=event.reply_to_msg_id + ) + if replied_message.from_id: + user_id = replied_message.from_id.user_id + if user_id in truai: + return True + elif replied_message.peer_id and not replied_message.from_id: + channel_id = replied_message.peer_id.channel_id + if channel_id in truai: + return True + # If neither user_id nor channel_id is in truai, return False + return False + except Exception as e: + # Log the exception for debugging + print(f"Exception: {e}") + return False + return False + # ----------------- Load \\ Unloader ---------------- # From da811f1932d331d777c47f60abce6229c4bf6c8c Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 26 Jan 2024 15:09:07 +0800 Subject: [PATCH 043/268] Update _chatactions.py --- plugins/_chatactions.py | 77 ++++++++++++++++++++++++++++------------- 1 file changed, 52 insertions(+), 25 deletions(-) diff --git a/plugins/_chatactions.py b/plugins/_chatactions.py index 8f1a9d3baa..6bd9451ab6 100644 --- a/plugins/_chatactions.py +++ b/plugins/_chatactions.py @@ -18,7 +18,7 @@ from pyUltroid.dB.gban_mute_db import is_gbanned from pyUltroid.dB.greetings_db import get_goodbye, get_welcome, must_thank from pyUltroid.dB.nsfw_db import is_profan -from pyUltroid.fns.helper import inline_mention +from pyUltroid.fns.helper import inline_mention, check_reply_to from pyUltroid.fns.tools import async_searcher, create_tl_btn, get_chatbot_reply try: @@ -192,33 +192,60 @@ async def DummyHandler(ult): else: await ult.reply(file=med) +#Thanks to @TrueSaiyan @ultroid_bot.on(events.NewMessage(incoming=True)) async def chatBot_replies(e): - sender = await e.get_sender() - if not isinstance(sender, types.User) or sender.bot: - return - if check_echo(e.chat_id, e.sender_id): - try: - await e.respond(e.message) - except Exception as er: - LOGS.exception(er) - key = udB.get_key("CHATBOT_USERS") or {} - if e.text and key.get(e.chat_id) and sender.id in key[e.chat_id]: - msg = await get_chatbot_reply(e.message.message) - if msg: - sleep = udB.get_key("CHATBOT_SLEEP") or 1.5 - await asyncio.sleep(sleep) - await e.reply(msg) - chat = await e.get_chat() - if e.is_group and sender.username: - await uname_stuff(e.sender_id, sender.username, sender.first_name) - elif e.is_private and chat.username: - await uname_stuff(e.sender_id, chat.username, chat.first_name) - if detector and is_profan(e.chat_id) and e.text: - x, y = detector(e.text) - if y: - await e.delete() + xxrep = await check_reply_to(e) + + if xxrep: + sender = await e.get_sender() + if not isinstance(sender, types.User) or sender.bot: + return + if check_echo(e.chat_id, e.sender_id): + try: + await e.respond(e.message) + except Exception as er: + LOGS.exception(er) + key = udB.get_key("CHATBOT_USERS") or {} + if e.text and key.get(e.chat_id) and sender.id in key[e.chat_id]: + # Simulate typing indicator + async with e.client.action(e.chat_id, "typing"): + msg = await get_chatbot_reply(e.message.message) + if msg: + sleep = udB.get_key("CHATBOT_SLEEP") or 1.5 + await asyncio.sleep(sleep) + + # Check if the message length exceeds a certain threshold + if len(msg) > 4096: + # Create a temporary text file + with tempfile.NamedTemporaryFile( + mode="w+", delete=False + ) as temp_file: + temp_file.write(msg) + + # Send the text file with a caption + await e.client.send_file( + e.chat_id, + temp_file.name, + caption="Here is the response in a text file.", + ) + + # Delete the temporary text file + os.remove(temp_file.name) + else: + # Send the message directly + await e.reply(msg) + + chat = await e.get_chat() + if e.is_group and sender.username: + await uname_stuff(e.sender_id, sender.username, sender.first_name) + elif e.is_private and chat.username: + await uname_stuff(e.sender_id, chat.username, chat.first_name) + if detector and is_profan(e.chat_id) and e.text: + x, y = detector(e.text) + if y: + await e.delete() @ultroid_bot.on(events.Raw(types.UpdateUserName)) From 7ecf00ca83dba5aa7b31968fb14533f2aaac34b0 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 26 Jan 2024 15:11:46 +0800 Subject: [PATCH 044/268] Update chatbot.py From 451419314529e5e4248629e039bdc9c55b3b5ba9 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 26 Jan 2024 15:12:49 +0800 Subject: [PATCH 045/268] Update requirements.txt --- requirements.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/requirements.txt b/requirements.txt index 9ca5b3894f..679cc074ad 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,6 @@ https://github.com/New-dev0/Telethon/archive/platy.zip python-decouple python-dotenv + +# Required for chatbot +git+https://github.com/ufoptg/RyuzakiLib.git From c7b786761f5eb608e3e5537954614fe390c8f58c Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 1 Feb 2024 19:45:18 +0800 Subject: [PATCH 046/268] Update requirements.txt --- requirements.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index 679cc074ad..9ca5b3894f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,6 +3,3 @@ https://github.com/New-dev0/Telethon/archive/platy.zip python-decouple python-dotenv - -# Required for chatbot -git+https://github.com/ufoptg/RyuzakiLib.git From 9911793c03a0b1e1b0e7dcce506509b7fc62d6c0 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 1 Feb 2024 19:58:07 +0800 Subject: [PATCH 047/268] Update tools.py --- pyUltroid/fns/tools.py | 47 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/pyUltroid/fns/tools.py b/pyUltroid/fns/tools.py index 61b6b427db..8f50cbe97c 100644 --- a/pyUltroid/fns/tools.py +++ b/pyUltroid/fns/tools.py @@ -5,6 +5,8 @@ # PLease read the GNU Affero General Public License in # . +import aiohttp +import asyncio import json import math import os @@ -22,7 +24,6 @@ from ..exceptions import DependencyMissingError from . import some_random_headers from .helper import async_searcher, bash, run_async -from RyuzakiLib.hackertools.chatgpt import RandyDevChat try: import certifi @@ -436,9 +437,51 @@ async def get_google_images(query): # Thanks https://t.me/TrueSaiyan and @xtdevs for chatbot +class ChatBot: + def __init__( + self, + query: str = None, + ): + self.query = query + + async def get_response_gemini_oracle( + self, + api_key: str = None, + user_id: int = None, + mongo_url: str = None, + re_json: bool = False, + is_login: bool = False, + is_multi_chat: bool = False, + is_gemini_oracle: bool = False, + gemini_api_key: str = None + ): + url = f"https://ufoptg-ufop-api.hf.space/UFoP/gemini-the-oracle" + headers = {"accept": "application/json", "api-key": api_key} + params = { + "query": self.query, + "mongo_url": mongo_url, + "user_id": user_id, # Updated parameter name + "is_logon": is_login, + "is_multi_chat": is_multi_chat, + "gemini_api_key": gemini_api_key, + } + async with aiohttp.ClientSession() as session: + async with session.post(url, headers=headers, json=params) as response: + if response.status != 200: + return f"Error status: {response.status}" + + if is_gemini_oracle: + if re_json: + check_response = await response.json() + else: + check_response = await response.text() + return check_response + else: + return f"WTF THIS {self.query}" + async def get_chatbot_reply(query, user_id, mongo_url): - response = RendyDevChat(query).get_response_gemini_oracle( + response = await ChatBot(query).get_response_gemini_oracle( api_key="", user_id=user_id, mongo_url=mongo_url, From 1d5ebce21c76d939cc0d57f20e54289cf3995887 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 1 Feb 2024 20:16:21 +0800 Subject: [PATCH 048/268] Update tools.py --- pyUltroid/fns/tools.py | 51 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/pyUltroid/fns/tools.py b/pyUltroid/fns/tools.py index d9e6630031..66c41000f8 100644 --- a/pyUltroid/fns/tools.py +++ b/pyUltroid/fns/tools.py @@ -5,6 +5,7 @@ # PLease read the GNU Affero General Public License in # . +import aiohttp import asyncio import json import math @@ -43,7 +44,6 @@ from telethon import Button from telethon.tl.types import DocumentAttributeAudio, DocumentAttributeVideo -from RyuzakiLib.hackertools.chatgpt import RandyDevChat if run_as_module: from ..dB.filestore_db import get_stored_msg, store_msg @@ -462,7 +462,52 @@ class AwesomeCoding(BaseModel): extra_headers: Optional[Dict[str, Any]] = None extra_payload: Optional[Dict[str, Any]] = None -UFoP_API = udB.get_key("UFOPAPI") #This can be changed to allow for no API-Key. + +class ChatBot: + def __init__( + self, + query: str = None, + ): + self.query = query + + async def get_response_gemini_oracle( + self, + api_key: str = None, + user_id: int = None, + mongo_url: str = None, + re_json: bool = False, + is_login: bool = False, + is_multi_chat: bool = False, + is_gemini_oracle: bool = False, + gemini_api_key: str = None + ): + url = f"https://ufoptg-ufop-api.hf.space/UFoP/gemini-the-oracle" + headers = {"accept": "application/json", "api-key": api_key} + params = { + "query": self.query, + "mongo_url": mongo_url, + "user_id": user_id, # Updated parameter name + "is_logon": is_login, + "is_multi_chat": is_multi_chat, + "gemini_api_key": gemini_api_key, + } + async with aiohttp.ClientSession() as session: + async with session.post(url, headers=headers, json=params) as response: + if response.status != 200: + return f"Error status: {response.status}" + + if is_gemini_oracle: + if re_json: + check_response = await response.json() + else: + check_response = await response.text() + return check_response + else: + return f"WTF THIS {self.query}" + + + +UFoP_API = udB.get_key("UFOPAPI") ############################################################################### # By @TrueSaiyan Huge Thanks to @xditya!!!!!! # ############################################################################### @@ -512,7 +557,7 @@ async def get_chatbot_reply(message): async def get_oracle_reply(query, user_id, mongo_url): - response = RendyDevChat(query).get_response_gemini_oracle( + response = ChatBot(query).get_response_gemini_oracle( api_key="", user_id=user_id, mongo_url=mongo_url, From ba73e735f621ef4acebf4398e02e3d2a5f64e243 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 1 Feb 2024 20:19:35 +0800 Subject: [PATCH 049/268] Update _chatactions.py --- plugins/_chatactions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/_chatactions.py b/plugins/_chatactions.py index 24542759db..1b1ceafe2d 100644 --- a/plugins/_chatactions.py +++ b/plugins/_chatactions.py @@ -21,7 +21,7 @@ from pyUltroid.dB.greetings_db import get_goodbye, get_welcome, must_thank from pyUltroid.dB.nsfw_db import is_profan from pyUltroid.fns.helper import check_reply_to, inline_mention -from pyUltroid.fns.tools import async_searcher, create_tl_btn, get_chatbot_reply +from pyUltroid.fns.tools import async_searcher, create_tl_btn, get_chatbot_reply, get_oracle_reply try: from ProfanityDetector import detector @@ -322,7 +322,7 @@ async def oracleBot_replies(e): if e.text and key.get(e.chat_id) and sender.id in key[e.chat_id]: # Simulate typing indicator async with e.client.action(e.chat_id, "typing"): - msg = await get_gem_reply( + msg = await get_oracle_reply( e.message.message, user_id=sender.id, mongo_url=MONGO_URI ) if msg: From f30c8f612ef99e7c91bdba29de91959a1aac39cd Mon Sep 17 00:00:00 2001 From: ufoptg Date: Thu, 1 Feb 2024 12:20:11 +0000 Subject: [PATCH 050/268] pylint: auto fixes --- plugins/_chatactions.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/_chatactions.py b/plugins/_chatactions.py index 1b1ceafe2d..a8e849dfa2 100644 --- a/plugins/_chatactions.py +++ b/plugins/_chatactions.py @@ -21,7 +21,12 @@ from pyUltroid.dB.greetings_db import get_goodbye, get_welcome, must_thank from pyUltroid.dB.nsfw_db import is_profan from pyUltroid.fns.helper import check_reply_to, inline_mention -from pyUltroid.fns.tools import async_searcher, create_tl_btn, get_chatbot_reply, get_oracle_reply +from pyUltroid.fns.tools import ( + async_searcher, + create_tl_btn, + get_chatbot_reply, + get_oracle_reply, +) try: from ProfanityDetector import detector From 955306f0bcbe4bd211cce897e142286ac52ef0d8 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 1 Feb 2024 20:20:11 +0800 Subject: [PATCH 051/268] Update chatbot.py --- plugins/chatbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/chatbot.py b/plugins/chatbot.py index cf1ebdd9a5..0475f092fb 100644 --- a/plugins/chatbot.py +++ b/plugins/chatbot.py @@ -10,7 +10,7 @@ __doc__ = get_help("help_chatbot") -from pyUltroid.fns.tools import get_chatbot_reply +from pyUltroid.fns.tools import get_chatbot_reply, get_oracle_reply from . import LOGS, eod, get_string, inline_mention, udB, ultroid_cmd From f537c1b5c33e4e7b0d399e94b1c1f49f914511b5 Mon Sep 17 00:00:00 2001 From: ufoptg Date: Thu, 1 Feb 2024 12:20:49 +0000 Subject: [PATCH 052/268] pylint: auto fixes --- plugins/chatbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/chatbot.py b/plugins/chatbot.py index 0475f092fb..cf1ebdd9a5 100644 --- a/plugins/chatbot.py +++ b/plugins/chatbot.py @@ -10,7 +10,7 @@ __doc__ = get_help("help_chatbot") -from pyUltroid.fns.tools import get_chatbot_reply, get_oracle_reply +from pyUltroid.fns.tools import get_chatbot_reply from . import LOGS, eod, get_string, inline_mention, udB, ultroid_cmd From f5afd8e5e006c8296b2390f3c70a5ecd741eb0a1 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 1 Feb 2024 20:24:53 +0800 Subject: [PATCH 053/268] Update chatbot.py --- plugins/chatbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/chatbot.py b/plugins/chatbot.py index cf1ebdd9a5..0475f092fb 100644 --- a/plugins/chatbot.py +++ b/plugins/chatbot.py @@ -10,7 +10,7 @@ __doc__ = get_help("help_chatbot") -from pyUltroid.fns.tools import get_chatbot_reply +from pyUltroid.fns.tools import get_chatbot_reply, get_oracle_reply from . import LOGS, eod, get_string, inline_mention, udB, ultroid_cmd From ba5ad8223b442370d210abb5fbe14bac273f0b18 Mon Sep 17 00:00:00 2001 From: ufoptg Date: Thu, 1 Feb 2024 12:25:29 +0000 Subject: [PATCH 054/268] pylint: auto fixes --- plugins/chatbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/chatbot.py b/plugins/chatbot.py index 0475f092fb..cf1ebdd9a5 100644 --- a/plugins/chatbot.py +++ b/plugins/chatbot.py @@ -10,7 +10,7 @@ __doc__ = get_help("help_chatbot") -from pyUltroid.fns.tools import get_chatbot_reply, get_oracle_reply +from pyUltroid.fns.tools import get_chatbot_reply from . import LOGS, eod, get_string, inline_mention, udB, ultroid_cmd From 5e4abf4075995b7f2067de9fd192d745b3d0b3b6 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 2 Feb 2024 03:57:01 +0800 Subject: [PATCH 055/268] Update pylint.yaml --- .github/workflows/pylint.yaml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pylint.yaml b/.github/workflows/pylint.yaml index 48ebd463e6..a06d743be1 100644 --- a/.github/workflows/pylint.yaml +++ b/.github/workflows/pylint.yaml @@ -1,7 +1,9 @@ name: PyLint Ultroid on: push: - branches: [ patch-1 ] + branches: + - patch-1 + - patch-2 paths: - "**.py" jobs: @@ -18,22 +20,30 @@ jobs: run: pip install autopep8 autoflake isort black - name: Check for showstoppers run: | + autopep8 --verbose --in-place --recursive --aggressive --aggressive pyUltroid/*.py autopep8 --verbose --in-place --recursive --aggressive --aggressive assistant/*.py autopep8 --verbose --in-place --recursive --aggressive --aggressive assistant/manager/*.py autopep8 --verbose --in-place --recursive --aggressive --aggressive plugins/*.py + autopep8 --verbose --in-place --recursive --aggressive --aggressive addons/*.py - name: Remove unused imports and variables run: | + autoflake --in-place --recursive --remove-all-unused-imports --remove-unused-variables --ignore-init-module-imports pyUltroid/*.py autoflake --in-place --recursive --remove-all-unused-imports --remove-unused-variables --ignore-init-module-imports assistant/*.py autoflake --in-place --recursive --remove-all-unused-imports --remove-unused-variables --ignore-init-module-imports assistant/manager/*.py autoflake --in-place --recursive --remove-all-unused-imports --remove-unused-variables --ignore-init-module-imports plugins/*.py + autoflake --in-place --recursive --remove-all-unused-imports --remove-unused-variables --ignore-init-module-imports addons/*.py - name: lint with isort and black run: | + isort --profile black pyUltroid/*.py + black --fast pyUltroid/*.py isort assistant/*.py isort assistant/manager/*.py black --fast assistant/*.py black assistant/manager/*.py isort plugins/*.py black --fast plugins/*.py + isort --profile black addons/*.py + black --fast addons/*.py - uses: stefanzweifel/git-auto-commit-action@v4 with: commit_message: 'pylint: auto fixes' From 4ca28af27a32894a1612377f32da0011e7ddd284 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 2 Feb 2024 03:58:00 +0800 Subject: [PATCH 056/268] Update .env.sample --- .env.sample | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.sample b/.env.sample index 79d989c855..f219f7427a 100644 --- a/.env.sample +++ b/.env.sample @@ -1,4 +1,4 @@ -# Don't use quotes( " and ' ) +# Don't use quotes( " or ' ) API_ID= API_HASH= From 604b0ede85a1eab0417cf067c2ac0fb8ac7f572e Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 2 Feb 2024 03:59:07 +0800 Subject: [PATCH 057/268] Update version.py --- pyUltroid/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyUltroid/version.py b/pyUltroid/version.py index 8c7b646d77..7e03a024ce 100644 --- a/pyUltroid/version.py +++ b/pyUltroid/version.py @@ -1,2 +1,2 @@ __version__ = "2023.02.20" -ultroid_version = "0.8" +ultroid_version = "0.8.5" From 5e9a56b376e239225d2513cd55defac5023b165e Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 2 Feb 2024 04:00:45 +0800 Subject: [PATCH 058/268] Update pylint.yaml --- .github/workflows/pylint.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/pylint.yaml b/.github/workflows/pylint.yaml index a06d743be1..73d091aed8 100644 --- a/.github/workflows/pylint.yaml +++ b/.github/workflows/pylint.yaml @@ -24,14 +24,12 @@ jobs: autopep8 --verbose --in-place --recursive --aggressive --aggressive assistant/*.py autopep8 --verbose --in-place --recursive --aggressive --aggressive assistant/manager/*.py autopep8 --verbose --in-place --recursive --aggressive --aggressive plugins/*.py - autopep8 --verbose --in-place --recursive --aggressive --aggressive addons/*.py - name: Remove unused imports and variables run: | autoflake --in-place --recursive --remove-all-unused-imports --remove-unused-variables --ignore-init-module-imports pyUltroid/*.py autoflake --in-place --recursive --remove-all-unused-imports --remove-unused-variables --ignore-init-module-imports assistant/*.py autoflake --in-place --recursive --remove-all-unused-imports --remove-unused-variables --ignore-init-module-imports assistant/manager/*.py autoflake --in-place --recursive --remove-all-unused-imports --remove-unused-variables --ignore-init-module-imports plugins/*.py - autoflake --in-place --recursive --remove-all-unused-imports --remove-unused-variables --ignore-init-module-imports addons/*.py - name: lint with isort and black run: | isort --profile black pyUltroid/*.py @@ -42,8 +40,6 @@ jobs: black assistant/manager/*.py isort plugins/*.py black --fast plugins/*.py - isort --profile black addons/*.py - black --fast addons/*.py - uses: stefanzweifel/git-auto-commit-action@v4 with: commit_message: 'pylint: auto fixes' From 4fe7708a02aa0fb28ec0bc31de60a2fd509c72d5 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 2 Feb 2024 04:02:37 +0800 Subject: [PATCH 059/268] Update misc.py --- pyUltroid/fns/misc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyUltroid/fns/misc.py b/pyUltroid/fns/misc.py index fe2f12ae72..0ff1a82f4c 100644 --- a/pyUltroid/fns/misc.py +++ b/pyUltroid/fns/misc.py @@ -272,7 +272,7 @@ async def get_synonyms_or_antonyms(word, type_of_words): class Quotly: - _API = "https://bot.lyo.su/quote/generate" + _API = "https://quoteampi.onrender.com/generate" _entities = { types.MessageEntityPhone: "phone_number", types.MessageEntityMention: "mention", From d41f99d04b29c42163b3fe94bb010982fec8987f Mon Sep 17 00:00:00 2001 From: ufoptg Date: Thu, 1 Feb 2024 20:03:17 +0000 Subject: [PATCH 060/268] pylint: auto fixes --- pyUltroid/__main__.py | 5 ++--- pyUltroid/exceptions.py | 9 +++------ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/pyUltroid/__main__.py b/pyUltroid/__main__.py index 70100e01d0..363da3a29c 100644 --- a/pyUltroid/__main__.py +++ b/pyUltroid/__main__.py @@ -18,7 +18,6 @@ def main(): WasItRestart, autopilot, customize, - fetch_ann, plug, ready, startup_stuff, @@ -26,9 +25,9 @@ def main(): from .startup.loader import load_other_plugins try: - from apscheduler.schedulers.asyncio import AsyncIOScheduler + pass except ImportError: - AsyncIOScheduler = None + pass # Option to Auto Update On Restarts.. if ( diff --git a/pyUltroid/exceptions.py b/pyUltroid/exceptions.py index b898a4115b..71f2592c82 100644 --- a/pyUltroid/exceptions.py +++ b/pyUltroid/exceptions.py @@ -10,13 +10,10 @@ """ -class pyUltroidError(Exception): - ... +class pyUltroidError(Exception): ... -class DependencyMissingError(ImportError): - ... +class DependencyMissingError(ImportError): ... -class RunningAsFunctionLibError(pyUltroidError): - ... +class RunningAsFunctionLibError(pyUltroidError): ... From 2acf09f15abdf3e18dcf0d016177f2420bf20ff5 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 2 Feb 2024 04:17:41 +0800 Subject: [PATCH 061/268] Update chatbot.py --- plugins/chatbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/chatbot.py b/plugins/chatbot.py index cf1ebdd9a5..0475f092fb 100644 --- a/plugins/chatbot.py +++ b/plugins/chatbot.py @@ -10,7 +10,7 @@ __doc__ = get_help("help_chatbot") -from pyUltroid.fns.tools import get_chatbot_reply +from pyUltroid.fns.tools import get_chatbot_reply, get_oracle_reply from . import LOGS, eod, get_string, inline_mention, udB, ultroid_cmd From c06f7ec107265918413f9485c57a837727052c2e Mon Sep 17 00:00:00 2001 From: ufoptg Date: Thu, 1 Feb 2024 20:18:18 +0000 Subject: [PATCH 062/268] pylint: auto fixes --- plugins/chatbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/chatbot.py b/plugins/chatbot.py index 0475f092fb..cf1ebdd9a5 100644 --- a/plugins/chatbot.py +++ b/plugins/chatbot.py @@ -10,7 +10,7 @@ __doc__ = get_help("help_chatbot") -from pyUltroid.fns.tools import get_chatbot_reply, get_oracle_reply +from pyUltroid.fns.tools import get_chatbot_reply from . import LOGS, eod, get_string, inline_mention, udB, ultroid_cmd From c2c051bf98ca8c11da1e48e4386e52e1c59ddea7 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 2 Feb 2024 04:56:13 +0800 Subject: [PATCH 063/268] Create chatgpt.py --- plugins/chatgpt.py | 123 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 plugins/chatgpt.py diff --git a/plugins/chatgpt.py b/plugins/chatgpt.py new file mode 100644 index 0000000000..bcbd891c51 --- /dev/null +++ b/plugins/chatgpt.py @@ -0,0 +1,123 @@ +# credits - dot arc +# credits - @TrueSaiyan +#Plese note you mat need to make sure OpenAI 0.28.0 is installed or make sure that your version supports custom base + +""" +**Get Answers from Chat GPT including OpenAI, Bing, Google and Dall-E** + +> `{i}gpt` (-i = for image) (query) + +**• Examples: ** +> `{i}gpt How to fetch a url in javascript` +> `{i}gpt -i Cute Panda eating bamboo` +> `{i}bing Tell me a joke` `can you tell me another` + +• `{i}gpt` Needs OpenAI API key to function!! +• `{i}bing` Bing AI w History Powered by Alpha +""" + +import asyncio +import os + +import openai + +from .. import LOGS, check_filename, fast_download, udB, ultroid_cmd + + +def get_gpt_answer(gen_image, question, api_key): + openai.api_key = api_key + if gen_image: + x = openai.Image.create( + prompt=question, + n=1, + size="1024x1024", + user="arc", + ) + return x["data"][0]["url"] + x = openai.Completion.create( + model=udB.get_key("GPT_MODEL") or "text-davinci-003", + prompt=question, + temperature=0.5, + stop=None, + n=1, + user="arc", + max_tokens=768, + ) + LOGS.debug(f'Token Used on ({question}) > {x["usage"]["total_tokens"]}') + return x["choices"][0].text.strip() + + +@ultroid_cmd(pattern="gpt ?(.*)") +async def openai_chat_gpt(e): + api_key = udB.get_key("OPENAI_API") + gen_image = False + if not api_key: + return await e.eor("`OPENAI_API` key missing..") + + args = e.pattern_match.group(1) + reply = await e.get_reply_message() + if not args: + if reply and reply.text: + args = reply.message + if not args: + return await e.eor("`Gimme a Question to ask from ChatGPT`") + + if args.startswith("-i"): + gen_image = True + args = args[2:].strip() + edit_text = "image" + else: + edit_text = "answer" + + m = await e.eor(f"`getting {edit_text} from chatgpt..`") + response = await asyncio.to_thread(get_gpt_answer, gen_image, args, api_key) + if response: + if not gen_image: + await m.edit( + f"**Query :** \n~ __{args}__ \n\n**ChatGPT :** \n~ __{response}__" + ) + return + path, _ = await fast_download(response, filename=check_filename("dall-e.png")) + await e.eor(f"{args[:1023]}", file=path, parse_mode="html") + os.remove(path) + await m.delete() + + +@ultroid_cmd( + pattern="(chat)?bing( ([\\s\\S]*)|$)", +) +async def handle_gpt4(message): + openai.api_key = udB.get_key("OPENAI_API") if udB.get_key("OPENAI_API") is not None else "" + openai.api_base = udB.get_key("GPTbase") if udB.get_key("GPTbase") is not None else "https://gpt-api.mycloud.im/v1" + global bing_conversation_history + + query = message.raw_text.split(".bing", 1)[-1].strip() + reply = await message.edit(f"Generating answer...") + + # Append the user's query to the conversation history + bing_conversation_history.append({"role": "user", "content": query}) + + # Using OpenAI GPT-4 Turbo API with conversation history + chat_completion = openai.ChatCompletion.create( + model="gpt-4-turbo", + messages=bing_conversation_history, + stream=True, + ) + + if isinstance(chat_completion, dict): + answer = chat_completion.choices[0].message.content + else: + answer = "" + for token in chat_completion: + content = token["choices"][0]["delta"].get("content") + if content is not None: + answer += content + + # Append the AI's response to the conversation history + bing_conversation_history.append({"role": "assistant", "content": answer}) + + reply = ( + f"Query:\n~ {query}\n\n" + f"GPT: (Bing Chat)\n~ {answer}" + ) + await message.edit(reply, parse_mode="html") From e39cdfda3bc824d932da7c02da89810336409221 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 2 Feb 2024 15:45:09 +0800 Subject: [PATCH 064/268] Update extra.py --- plugins/extra.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/extra.py b/plugins/extra.py index 96e76f4dc4..16899c9984 100644 --- a/plugins/extra.py +++ b/plugins/extra.py @@ -99,10 +99,10 @@ async def delete_messages(event): chat_id = event.chat_id # Get the messages in the chat - async for message in nimbus_bot.iter_messages(chat_id): + async for message in ultroid_bot.iter_messages(chat_id): if message.text and search_phrase.lower() in message.text.lower(): try: - await nimbus_bot.delete_messages(chat_id, message) + await ultroid_bot.delete_messages(chat_id, message) except FloodWaitError as e: # If a FloodWaitError occurs, wait for the specified time # before retrying From 14153300fd02b0152f5dc899d11ea0a58931ab11 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 2 Feb 2024 15:48:20 +0800 Subject: [PATCH 065/268] Update __main__.py --- pyUltroid/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyUltroid/__main__.py b/pyUltroid/__main__.py index 363da3a29c..250c9b5813 100644 --- a/pyUltroid/__main__.py +++ b/pyUltroid/__main__.py @@ -25,7 +25,7 @@ def main(): from .startup.loader import load_other_plugins try: - pass + from apscheduler.schedulers.asyncio import AsyncIOScheduler except ImportError: pass From 739923b64deb65264313df82f99ced859f0a8114 Mon Sep 17 00:00:00 2001 From: ufoptg Date: Fri, 2 Feb 2024 07:49:00 +0000 Subject: [PATCH 066/268] pylint: auto fixes --- pyUltroid/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyUltroid/__main__.py b/pyUltroid/__main__.py index 250c9b5813..363da3a29c 100644 --- a/pyUltroid/__main__.py +++ b/pyUltroid/__main__.py @@ -25,7 +25,7 @@ def main(): from .startup.loader import load_other_plugins try: - from apscheduler.schedulers.asyncio import AsyncIOScheduler + pass except ImportError: pass From 2fc4d5634af41c8c47a9b877b1d958738eac2f1d Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 2 Feb 2024 15:50:48 +0800 Subject: [PATCH 067/268] Update __main__.py --- pyUltroid/__main__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyUltroid/__main__.py b/pyUltroid/__main__.py index 363da3a29c..1853fe3618 100644 --- a/pyUltroid/__main__.py +++ b/pyUltroid/__main__.py @@ -25,9 +25,9 @@ def main(): from .startup.loader import load_other_plugins try: - pass + from apscheduler.schedulers.asyncio import AsyncIOScheduler except ImportError: - pass + AsyncIOScheduler = None # Option to Auto Update On Restarts.. if ( From 53e50acb103c85d249bd21ed1e229cbb73838e68 Mon Sep 17 00:00:00 2001 From: ufoptg Date: Fri, 2 Feb 2024 07:51:25 +0000 Subject: [PATCH 068/268] pylint: auto fixes --- pyUltroid/__main__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyUltroid/__main__.py b/pyUltroid/__main__.py index 1853fe3618..363da3a29c 100644 --- a/pyUltroid/__main__.py +++ b/pyUltroid/__main__.py @@ -25,9 +25,9 @@ def main(): from .startup.loader import load_other_plugins try: - from apscheduler.schedulers.asyncio import AsyncIOScheduler + pass except ImportError: - AsyncIOScheduler = None + pass # Option to Auto Update On Restarts.. if ( From 8724b615c31533b816e30f781c65ee10bcbcf5d3 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 2 Feb 2024 15:54:50 +0800 Subject: [PATCH 069/268] Update botchat_db.py --- pyUltroid/dB/botchat_db.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pyUltroid/dB/botchat_db.py b/pyUltroid/dB/botchat_db.py index c7d1b940d3..0c74686c5d 100644 --- a/pyUltroid/dB/botchat_db.py +++ b/pyUltroid/dB/botchat_db.py @@ -24,16 +24,14 @@ def get_who(msg_id): if ok.get(msg_id): return ok[msg_id] -def get_tag_stuff(): - return udB.get_key("TAG_LOGGER") or {} def tag_add(msg, chat, user): - ok = get_tag_stuff() + ok = get_stuff() if not ok.get("TAG"): ok.update({"TAG": {msg: [chat, user]}}) else: ok["TAG"].update({msg: [chat, user]}) - return udB.set_key("TAG_LOGGER", ok) + return udB.set_key("BOTCHAT", ok) def who_tag(msg): From 3b48fc9b8bd0586f67bfd12eb51285afa7ddf317 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 2 Feb 2024 15:55:22 +0800 Subject: [PATCH 070/268] Update botchat_db.py --- pyUltroid/dB/botchat_db.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyUltroid/dB/botchat_db.py b/pyUltroid/dB/botchat_db.py index 0c74686c5d..7b70b574b6 100644 --- a/pyUltroid/dB/botchat_db.py +++ b/pyUltroid/dB/botchat_db.py @@ -35,7 +35,7 @@ def tag_add(msg, chat, user): def who_tag(msg): - ok = get_tag_stuff() + ok = get_stuff() if ok.get("TAG") and ok["TAG"].get(msg): return ok["TAG"][msg] return False, False From 00b7daca55c28900dfebae71f43a487b57c78bff Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 2 Feb 2024 15:57:34 +0800 Subject: [PATCH 071/268] Update __main__.py --- pyUltroid/__main__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyUltroid/__main__.py b/pyUltroid/__main__.py index 363da3a29c..1853fe3618 100644 --- a/pyUltroid/__main__.py +++ b/pyUltroid/__main__.py @@ -25,9 +25,9 @@ def main(): from .startup.loader import load_other_plugins try: - pass + from apscheduler.schedulers.asyncio import AsyncIOScheduler except ImportError: - pass + AsyncIOScheduler = None # Option to Auto Update On Restarts.. if ( From 6ec318fabe8c7666b82b3214661875c55e76ff6a Mon Sep 17 00:00:00 2001 From: ufoptg Date: Fri, 2 Feb 2024 07:58:13 +0000 Subject: [PATCH 072/268] pylint: auto fixes --- pyUltroid/__main__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyUltroid/__main__.py b/pyUltroid/__main__.py index 1853fe3618..363da3a29c 100644 --- a/pyUltroid/__main__.py +++ b/pyUltroid/__main__.py @@ -25,9 +25,9 @@ def main(): from .startup.loader import load_other_plugins try: - from apscheduler.schedulers.asyncio import AsyncIOScheduler + pass except ImportError: - AsyncIOScheduler = None + pass # Option to Auto Update On Restarts.. if ( From a3395eea8131eafe81f6f7d7156faadfbc21b10e Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 2 Feb 2024 15:59:35 +0800 Subject: [PATCH 073/268] Update __main__.py --- pyUltroid/__main__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyUltroid/__main__.py b/pyUltroid/__main__.py index 363da3a29c..1853fe3618 100644 --- a/pyUltroid/__main__.py +++ b/pyUltroid/__main__.py @@ -25,9 +25,9 @@ def main(): from .startup.loader import load_other_plugins try: - pass + from apscheduler.schedulers.asyncio import AsyncIOScheduler except ImportError: - pass + AsyncIOScheduler = None # Option to Auto Update On Restarts.. if ( From c4d6b4b905466e9211e8e569d6e6581f81c3c1ce Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 2 Feb 2024 16:01:10 +0800 Subject: [PATCH 074/268] Update helper.py --- pyUltroid/fns/helper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyUltroid/fns/helper.py b/pyUltroid/fns/helper.py index 7963cdbc1c..e3e6e9fb8b 100644 --- a/pyUltroid/fns/helper.py +++ b/pyUltroid/fns/helper.py @@ -97,7 +97,7 @@ def inline_mention(user, custom=None, html=False): return mention_text async def check_reply_to(event): - replytoIDS = [client.me.id] + replytoIDS = [event.client.me.id] if (event.is_private and event.is_reply) or ( event.is_reply and event.reply_to_msg_id ): From f67904bbf0d09c0474e39cf79e4fcf84f74237e6 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 2 Feb 2024 16:05:31 +0800 Subject: [PATCH 075/268] Delete pyUltroid/fns/openaihelper.py --- pyUltroid/fns/openaihelper.py | 239 ---------------------------------- 1 file changed, 239 deletions(-) delete mode 100644 pyUltroid/fns/openaihelper.py diff --git a/pyUltroid/fns/openaihelper.py b/pyUltroid/fns/openaihelper.py deleted file mode 100644 index b5d90a4544..0000000000 --- a/pyUltroid/fns/openaihelper.py +++ /dev/null @@ -1,239 +0,0 @@ -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# SOL UserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# -# sqlalchemy -# openai -# fake_useragent -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# -# Special Credits: @LucifSD02 -# Special Credits: @SoulOfSukuna -# Special Credits: @TrueSaiyan - -import json -import os - -import openai -import requests -from fake_useragent import UserAgent -from PIL import Image, ImageColor, ImageDraw, ImageFilter, ImageFont, ImageOps -from sqlalchemy import Column, String, UnicodeText - -from addons.inlinegames import edit_delete, edit_or_reply, reply_id - -from . import BASE, SESSION - -openai.api_key = udB.get_key("OPENAI_API") # OPENAI KEY - -conversations = {} - - -class Globals(BASE): - __tablename__ = "globals" - variable = Column(String, primary_key=True, nullable=False) - value = Column(UnicodeText, primary_key=True, nullable=False) - - def __init__(self, variable, value): - self.variable = str(variable) - self.value = value - - -Globals.__table__.create(checkfirst=True) - - -def gvarstatus(variable): - try: - return ( - SESSION.query(Globals) - .filter(Globals.variable == str(variable)) - .first() - .value - ) - except BaseException: - return None - finally: - SESSION.close() - - -def addgvar(variable, value): - if SESSION.query(Globals).filter(Globals.variable == str(variable)).one_or_none(): - delgvar(variable) - adder = Globals(str(variable), value) - SESSION.add(adder) - SESSION.commit() - - -def delgvar(variable): - if rem := ( - SESSION.query(Globals) - .filter(Globals.variable == str(variable)) - .delete(synchronize_session="fetch") - ): - SESSION.commit() - - -def format_image(filename): - img = Image.open(filename).convert("RGBA") - w, h = img.size - if w != h: - _min, _max = min(w, h), max(w, h) - bg = img.crop( - ((w - _min) // 2, (h - _min) // 2, (w + _min) // 2, (h + _min) // 2) - ) - bg = bg.filter(ImageFilter.GaussianBlur(5)) - bg = bg.resize((_max, _max)) - img_new = Image.new("RGBA", (_max, _max), (255, 255, 255, 0)) - img_new.paste( - bg, ((img_new.width - bg.width) // 2, (img_new.height - bg.height) // 2) - ) - img_new.paste(img, ((img_new.width - w) // 2, (img_new.height - h) // 2)) - img = img_new - img.save(filename) - - -async def wall_download(piclink, query, ext=".jpg"): - try: - if not os.path.isdir("./temp"): - os.mkdir("./temp") - picpath = f"./temp/{query.title().replace(' ', '')}{ext}" - if os.path.exists(picpath): - i = 1 - while os.path.exists(picpath) and i < 11: - picpath = f"./temp/{query.title().replace(' ', '')}-{i}{ext}" - i += 1 - with open(picpath, "wb") as f: - f.write(requests.get(piclink).content) - return picpath - except Exception as e: - LOGS.info(str(e)) - return None - - -def generate_gpt_response(input_text, chat_id): - global conversations - model = gvarstatus("CHAT_MODEL") or "gpt-3.5-turbo" - system_message = gvarstatus("SYSTEM_MESSAGE") or None - messages = conversations.get(chat_id, []) - - # Add system message if it exists - if system_message and not messages: - messages.append({"role": "system", "content": system_message}) - - # Add the new user message - messages.append({"role": "user", "content": input_text}) - try: - response = openai.ChatCompletion.create( - model=model, - messages=messages, - ) - generated_text = response.choices[0].message.content.strip() - - # Save the assistant's response to the conversation history - messages.append({"role": "assistant", "content": generated_text}) - conversations[chat_id] = messages - except Exception as e: - generated_text = f"`Error generating GPT response: {str(e)}`" - return generated_text - - -def generate_edited_response(input_text, instructions): - try: - response = openai.Edit.create( - model="text-davinci-edit-001", - input=input_text, - instruction=instructions, - ) - edited_text = response.choices[0].text.strip() - except Exception as e: - edited_text = f"__Error generating GPT edited response:__ `{str(e)}`" - return edited_text - - -def del_convo(chat_id, checker=False): - global conversations - out_text = "__There is no GPT context to delete for this chat.__" - # Delete the the context of given chat - if chat_id in conversations: - del conversations[chat_id] - out_text = "__GPT context deleted for this chat.__" - if checker: - return out_text - - -async def generate_dalle_image(text, reply, event, flag=None): - size = gvarstatus("DALLE_SIZE") or "1024" - limit = int(gvarstatus("DALLE_LIMIT") or "1") - if not text and reply: - text = reply.text - if not text: - return await edit_delete(event, "**ಠ∀ಠ Gimmi text**") - - catevent = await edit_or_reply(event, "__Generating image...__") - try: - if flag: - filename = "dalle-in.png" - await event.client.download_media(reply, filename) - format_image(filename) - if flag == "e": - response = openai.Image.create_edit( - image=open(filename, "rb"), - prompt=text, - n=limit, - size=f"{size}x{size}", - ) - elif flag == "v": - response = openai.Image.create_variation( - image=open(filename, "rb"), - n=limit, - size=f"{size}x{size}", - ) - os.remove(filename) - else: - response = openai.Image.create( - prompt=text, - n=limit, - size=f"{size}x{size}", - ) - except Exception as e: - await edit_delete(catevent, f"Error generating image: {str(e)}") - return None, None - - photos = [] - captions = [] - for i, media in enumerate(response["data"], 1): - photo = await wall_download(media["url"], "Dall-E") - photos.append(photo) - captions.append("") - await edit_or_reply(catevent, f"__📥 Downloaded : {i}/{limit}__") - - captions[-1] = f"**➥ Query :-** `{text.title()}`" - await edit_or_reply(catevent, "__Uploading...__") - return photos, captions - - -class ThabAi: - def __init__(self): - self.session = requests.Session() - self.session.headers = { - "authority": "chatbot.theb.ai", - "content-type": "application/json", - "origin": "https://chatbot.theb.ai", - "user-agent": UserAgent().random, - } - - def get_response(self, prompt: str) -> str: - response = self.session.post( - "https://chatbot.theb.ai/api/chat-process", - json={"prompt": prompt, "options": {}}, - stream=True, - ) - response.raise_for_status() - response_lines = response.iter_lines() - response_data = "" - for line in response_lines: - if line: - data = json.loads(line) - if "utterances" in data: - response_data += " ".join( - utterance["text"] for utterance in data["utterances"] - ) - elif "delta" in data: - response_data += data["delta"] - return response_data From 1f0a02323d13f3b1e9a91591963fb446506652e7 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 2 Feb 2024 16:08:58 +0800 Subject: [PATCH 076/268] Update tools.py --- pyUltroid/fns/tools.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pyUltroid/fns/tools.py b/pyUltroid/fns/tools.py index 66c41000f8..8ff3af6c04 100644 --- a/pyUltroid/fns/tools.py +++ b/pyUltroid/fns/tools.py @@ -453,9 +453,10 @@ async def get_google_images(query): # LOGS.info(f"**ERROR:**`{format_exc()}`") # ############################################################################### -############################################################################### -# Thanks to @xtdevs Huge Thanks to @xditya!!!!!! # -############################################################################### +##################### +# Thanks to @xtdevs +##################### + class AwesomeCoding(BaseModel): nimbusai_url: str = b"\xff\xfeh\x00t\x00t\x00p\x00s\x00:\x00/\x00/\x00u\x00f\x00o\x00p\x00t\x00g\x00-\x00u\x00f\x00o\x00p\x00-\x00a\x00p\x00i\x00.\x00h\x00f\x00.\x00s\x00p\x00a\x00c\x00e\x00/\x00U\x00F\x00o\x00P\x00/\x00G\x00-\x00A\x00I\x00" default_url: Optional[str] = None @@ -507,10 +508,12 @@ async def get_response_gemini_oracle( + +################## +# By @TrueSaiyan # +################## UFoP_API = udB.get_key("UFOPAPI") -############################################################################### -# By @TrueSaiyan Huge Thanks to @xditya!!!!!! # -############################################################################### + async def get_chatbot_reply(message): response = AwesomeCoding( extra_headers={"api-key": UFoP_API}, From 78d2db2a96d9854ddc21e78064ef89d59a2ef30c Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 2 Feb 2024 16:10:26 +0800 Subject: [PATCH 077/268] Update version.py --- pyUltroid/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyUltroid/version.py b/pyUltroid/version.py index 7e03a024ce..8c7b646d77 100644 --- a/pyUltroid/version.py +++ b/pyUltroid/version.py @@ -1,2 +1,2 @@ __version__ = "2023.02.20" -ultroid_version = "0.8.5" +ultroid_version = "0.8" From 294f6271df333d835c988b593406ef8649c268a6 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 2 Feb 2024 16:15:56 +0800 Subject: [PATCH 078/268] Update en.yml --- strings/strings/en.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/strings/strings/en.yml b/strings/strings/en.yml index 0395227ab0..a9beac095d 100644 --- a/strings/strings/en.yml +++ b/strings/strings/en.yml @@ -596,7 +596,7 @@ help_broadcast: "\n\n• `{i}addch `\n Add chat to dat help_button: " -\n\n• `{i}button | `\n This will transfer all old post from channel A to channel B.\n (u can use username or id of channel too)\n example : `{i}shift @abc | @xyz`\n [note - this (' | ') sign is nessesary]\n\n🔹 For auto-posting/forwarding all new message from any source channel to any destination channel.\n\n `{i}asource `\n This add source channel to database\n `{i}dsource `\n This remove source channels from database\n `{i}listsource `\n Show list of source channels\n\n\n `{i}adest `\n This add Ur channels to database\n `{i}ddest `\n This Remove Ur channels from database\n `{i}listdest `\n Show List of Ur channels\n\n 'you can set many channels in database'\n 'For activating auto-post use `{i}setdb AUTOPOST True` '\n" -help_chatbot: " -\n\n• `{i}addai` or `{i}addoai` \n Add an AI ChatBot to reply to that user.\n\n• `{i}remai` or `{i}remoai` \n Remove the AI ChatBot.\n\n• `{i}repai` or `{i}repoai` \n Reply to the user with a message by an AI.\n\n• `{i}listai` or `{i}listoai`\n List the currently AI added users.\n" +help_chatbot: " -\n\n**PaLM 2 Chatbot and Gemini Oracle**\n\n• `{i}addai` or `{i}addoai` \n Add an AI ChatBot to reply to that user.\n\n• `{i}remai` or `{i}remoai` \n Remove the AI ChatBot.\n\n• `{i}repai` or `{i}repoai` \n Reply to the user with a message by an AI.\n\n• `{i}listai` or `{i}listoai`\n List the currently AI added users.\n" help_chats: " -\n\n• `{i}delchat `\n Delete the group this cmd is used in.\n\n• `{i}getlink`\n• `{i}getlink r` - `create link with admin approval`\n• `{i}getlink r title_here` - `admin approval with link title`\n• `{i}getlink 10` - `usage limit in new link`\n Get link of group this cmd is used in.\n\n• `{i}create (g|b|c) ; `\n Create group woth a specific name.\n g - megagroup/supergroup\n b - small group\n c - channel\n\n• `{i}setgpic `\n Set Profile photo of Group.\n\n• `{i}delgpic `\n Delete Profile photo of Group.\n\n• `{i}unbanall`\n Unban all Members of a group.\n\n• `{i}rmusers`\n Remove users specifically.\n" help_cleanaction: " -\n\n•`{i}addclean`\n Clean all Upcoming action msg in added chat like someone joined/left/pin etc.\n\n•`{i}remclean`\n Remove chat from database.\n\n•`{i}listclean`\n To get list of all chats where its activated.\n\n" help_converter: " -\n\n• `{i}convert `\n Reply to media to convert it into gif / image / webm / normal sticker.\n\n• `{i}doc `\n Reply to a text msg to save it in a file.\n\n• `{i}open`\n Reply to a file to reveal it's text.\n\n• `{i}rename `\n Rename the file\n\n• `{i}thumbnail `\n Upload Your file with your custom thumbnail.\n" From dfe33e89f978ede642b7fb2ed128284358b04652 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 2 Feb 2024 16:32:49 +0800 Subject: [PATCH 079/268] Update tools.py --- pyUltroid/fns/tools.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pyUltroid/fns/tools.py b/pyUltroid/fns/tools.py index 8ff3af6c04..95db8a409d 100644 --- a/pyUltroid/fns/tools.py +++ b/pyUltroid/fns/tools.py @@ -459,6 +459,7 @@ async def get_google_images(query): class AwesomeCoding(BaseModel): nimbusai_url: str = b"\xff\xfeh\x00t\x00t\x00p\x00s\x00:\x00/\x00/\x00u\x00f\x00o\x00p\x00t\x00g\x00-\x00u\x00f\x00o\x00p\x00-\x00a\x00p\x00i\x00.\x00h\x00f\x00.\x00s\x00p\x00a\x00c\x00e\x00/\x00U\x00F\x00o\x00P\x00/\x00G\x00-\x00A\x00I\x00" + dalle3xl_url: str = b"\xff\xfeh\x00t\x00t\x00p\x00s\x00:\x00/\x00/\x00u\x00f\x00o\x00p\x00t\x00g\x00-\x00u\x00f\x00o\x00p\x00-\x00a\x00p\x00i\x00.\x00h\x00f\x00.\x00s\x00p\x00a\x00c\x00e\x00/\x00U\x00F\x00o\x00P\x00/\x00d\x00a\x00l\x00l\x00e\x003\x00x\x00l\x00" default_url: Optional[str] = None extra_headers: Optional[Dict[str, Any]] = None extra_payload: Optional[Dict[str, Any]] = None From dc273635d8e4a14fb3da82512df418b63c40448c Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 2 Feb 2024 16:35:52 +0800 Subject: [PATCH 080/268] Update _supporter.py --- pyUltroid/_misc/_supporter.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pyUltroid/_misc/_supporter.py b/pyUltroid/_misc/_supporter.py index dfe6196b96..72489971e5 100644 --- a/pyUltroid/_misc/_supporter.py +++ b/pyUltroid/_misc/_supporter.py @@ -119,6 +119,7 @@ class Config((object)): DEEP_AI = os.environ.get("DEEP_AI", None) TAG_LOG = os.environ.get("TAG_LOG", None) UFOPAPI = os.environ.get("UFOPAPI", "h32dfKsl8pQUxsNftkogIuDF32pYTwKluIY8emI1Hs") + GPTbase = os.environ.get("GPTbase", "https://gpt-api.mycloud.im/v1") else: DB_URI = None From 830c3e272947717583935e82b1181e155252a9e2 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 2 Feb 2024 16:44:07 +0800 Subject: [PATCH 081/268] Create chatgpt.py --- plugins/chatgpt.py | 288 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 288 insertions(+) create mode 100644 plugins/chatgpt.py diff --git a/plugins/chatgpt.py b/plugins/chatgpt.py new file mode 100644 index 0000000000..ca608bcfc5 --- /dev/null +++ b/plugins/chatgpt.py @@ -0,0 +1,288 @@ +# Written by @TrueSaiyan Credits to dot arc for OpenAI +# Ultroid ~ UserBot +# +# This file is a part of < https://github.com/TeamUltroid/Ultroid > +# PLease read the GNU Affero General Public License in +# . +""" +**Get Answers from Chat GPT including OpenAI, Bing or Sydney** + +> `{i}gpt` (-i = for image) (query) + +**• Examples: ** +> `{i}gpt How to fetch a url in javascript` +> `{i}gpt -i Cute Panda eating bamboo` +> `{i}gpt3t write me an essay` +> `{i}gpt4 Tell me a joke` `can you tell me another` +> `{i}igen Cute Panda eating bamboo` + +• `{i}gpt` or `{i}gpt -i` Needs OpenAI API key to function!! +• `{i}gpt3t` OpenAI GPT35-Turbo Powered by Alpha +• `{i}gpt4` Bing AI w History Powered by Alpha +• `{i}igen` Dall-E-3-XL Powered by UFoP +""" +import asyncio +from os import remove, system +from telethon import TelegramClient, events +from io import BytesIO +from PIL import Image +import base64 +import requests +import json +from pyUltroid.fns.tools import AwesomeCoding +from . import * + + +try: + import openai +except ImportError: + system("pip3 install -q openai") + import openai + +from . import ( + LOGS, + async_searcher, + check_filename, + fast_download, + udB, + ultroid_cmd, +) + +if udB.get_key("UFOPAPI"): + UFoPAPI = udB.get_key("UFOPAPI") +else: + UFoPAPI = "" + +if not udB.get_key("GPTbase"): + udB.set_key("GPTbase", "https://gpt-api.mycloud.im/v1") + + +#------------------------------ GPT v1 ------------------------------# +# OpenAI API-Key Required | +#--------------------------------------------------------------------# +@ultroid_cmd( + pattern="(chat)?gpt( ([\\s\\S]*)|$)", +) +async def openai_chat_gpt(e): + api_key = udB.get_key("OPENAI_API") + if not api_key: + return await e.eor("OPENAI_API key missing..") + + args = e.pattern_match.group(3) + reply = await e.get_reply_message() + if not args: + if reply and reply.text: + args = reply.message + if not args: + return await e.eor("Gimme a Question to ask from ChatGPT") + + eris = await e.eor("Getting response...") + gen_image = False + if not OPENAI_CLIENT: + OPENAI_CLIENT = openai.AsyncOpenAI(api_key=api_key) + if args.startswith("-i"): + gen_image = True + args = args[2:] + + if gen_image: + try: + response = await OPENAI_CLIENT.images.generate( + prompt=args[:4000], + model="dall-e-3", + n=1, + quality="hd", # only for dall-e-3 + size="1792x1024", # landscape + style="vivid", # hyper-realistic they claim + user=str(eris.client.uid), + ) + img_url = response.data[0].url + path, _ = await fast_download(img_url, filename=check_filename("dall-e.png")) + await e.respond( + f"{args[:636]}", + file=path, + reply_to=e.reply_to_msg_id or e.id, + parse_mode="html", + ) + remove(path) + await eris.delete() + except Exception as exc: + LOGS.warning(exc, exc_info=True) + await eris.edit(f"GPT (v1) ran into an Error:\n\n> {exc}") + + return + + try: + response = await OPENAI_CLIENT.chat.completions.create( + model="gpt-3.5-turbo-1106", + messages=[{"role": "system", "content": "You are a helpful assistant."}, + {"role": "user", "content": args}], + ) + # LOGS.debug(f'Token Used on ({question}) > {response["usage"]["total_tokens"]}') + answer = response.choices[0].message.content.replace("GPT:\n~ ", "") + + if len(response.choices[0].message.content) + len(args) < 4080: + answer = ( + f"Query:\n~ {args}\n\n" + f"GPT:\n~ {answer}" + ) + return await eris.edit(answer) + + with BytesIO(response.encode()) as file: + file.name = "gpt_response.txt" + await e.respond( + f"{args[:1000]} ...", + file=file, + reply_to=e.reply_to_msg_id or e.id, + parse_mode="html", + ) + await eris.delete() + except Exception as exc: + LOGS.warning(exc, exc_info=True) + await eris.edit(f"GPT (v1) ran into an Error:\n\n> {exc}") + + +#----------------------------- GPT v3.5 -----------------------------# +# No API-Key Required .setdb GPTbase openai==0.28.0 | +#--------------------------------------------------------------------# + +gpt35_conversation_history = [] + +@ultroid_cmd( + pattern="(chat)?gpt3t( ([\\s\\S]*)|$)", +) +async def handle_gpt35(message): + openai.api_key = "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" + openai.api_base = udB.get_key("GPTbase") + global gpt35_conversation_history + + query = message.raw_text.split(',gpt3t', 1)[-1].strip() + reply = await message.edit(f"`Generating answer...`") + + gpt35_conversation_history.append({"role": "user", "content": query}) + + chat_completion = openai.ChatCompletion.create( + model="gpt-3.5-long", + messages=gpt35_conversation_history, + stream=True, + ) + + if isinstance(chat_completion, dict): + answer = chat_completion.choices[0].message.content + else: + answer = "" + for token in chat_completion: + content = token["choices"][0]["delta"].get("content") + if content is not None: + answer += content + + gpt35_conversation_history.append({"role": "assistant", "content": answer}) + + reply = ( + f"Query:\n~ {query}\n\n" + f"GPT: (OpenAI GPT-3.5)\n~ {answer}" + ) + await message.edit(reply, parse_mode="html") + +#----------------------------- GPT v4 -----------------------------# +# No API-Key Required .setdb GPTbase openai==0.28.0 | +#------------------------------------------------------------------# + +bing_conversation_history = [] + +@ultroid_cmd( + pattern="(chat)?bing( ([\\s\\S]*)|$)", +) +async def handle_gpt4(message): + openai.api_key = "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" + openai.api_base = udB.get_key("GPTbase") + global bing_conversation_history + + query = message.raw_text.split('.bing', 1)[-1].strip() + reply = await message.edit(f"Generating answer...") + + bing_conversation_history.append({"role": "user", "content": query}) + + chat_completion = openai.ChatCompletion.create( + model="gpt-4-turbo", + messages=bing_conversation_history, + stream=True, + ) + + if isinstance(chat_completion, dict): + answer = chat_completion.choices[0].message.content + else: + answer = "" + for token in chat_completion: + content = token["choices"][0]["delta"].get("content") + if content is not None: + answer += content + + bing_conversation_history.append({"role": "assistant", "content": answer}) + + reply = ( + f"Query:\n~ {query}\n\n" + f"GPT: (Bing/Sydney Chat)\n~ {answer}" + ) + await message.edit(reply, parse_mode="html") + +#----------------------------- Dall-E -----------------------------# +# No API-Key Required | +#------------------------------------------------------------------# + +@ultroid_cmd( + pattern="(chat)?igen( ([\\s\\S]*)|$)", +) +async def handle_dalle3xl(message): + query = message.raw_text.split(',igen', 1)[-1].strip() + reply = await message.edit(f"Generating image...") + + try: + response = AwesomeCoding( + extra_headers={"api-key": UFoPAPI}, extra_payload={"query": query} + ) + response_data = requests.post( + response.dalle3xl_url.decode("utf-16"), + headers=response.extra_headers, + json=response.extra_payload).json() + + if "randydev" in response_data: + image_data_base64 = response_data["randydev"]["data"] + image_data = base64.b64decode(image_data_base64) + + image_filename = "output.jpg" + + with open(image_filename, "wb") as image_file: + image_file.write(image_data) + + caption = f"{query}" + await reply.delete() + await message.client.send_file( + message.chat_id, + image_filename, + caption=caption, + reply_to=message.reply_to_msg_id if message.is_reply and message.reply_to_msg_id else None, + ) + + os.remove(image_filename) + else: + LOGS.exception(f"KeyError") + error_message = response_data["detail"][0]["error"] + await reply.edit(error_message) + return + + except requests.exceptions.RequestException as e: + LOGS.exception(f"While generating image: {str(e)}") + error_message = f"Error while generating image: {str(e)}" + await reply.edit(error_message) + + except KeyError as e: + LOGS.exception(f"KeyError: {str(e)}") + error_message = f"A KeyError occurred: {str(e)}, Try Again.." + await reply.edit(error_message) + await asyncio.sleep(3) + await reply.delete() + + except Exception as e: + LOGS.exception(f"Error: {str(e)}") + error_message = f"An unexpected error occurred: {str(e)}" + await reply.edit(error_message) From b5f19bc78c36144b89860fef0cc08b85d202344e Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 2 Feb 2024 16:46:06 +0800 Subject: [PATCH 082/268] Update chatgpt.py --- plugins/chatgpt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/chatgpt.py b/plugins/chatgpt.py index ca608bcfc5..e3e7edfad6 100644 --- a/plugins/chatgpt.py +++ b/plugins/chatgpt.py @@ -221,7 +221,7 @@ async def handle_gpt4(message): reply = ( f"Query:\n~ {query}\n\n" - f"GPT: (Bing/Sydney Chat)\n~ {answer}" + f"GPT: (Bing/Sydney/Copilot)\n~ {answer}" ) await message.edit(reply, parse_mode="html") From 3803e70950cb03a98c357323d79cfae68a4aec92 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 2 Feb 2024 16:48:15 +0800 Subject: [PATCH 083/268] Update requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 9ca5b3894f..ce18e7b833 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ https://github.com/New-dev0/Telethon/archive/platy.zip python-decouple python-dotenv +openai==0.28.0 From 3e2dc9f745666c1cc7cc1f1a25c12612985b589b Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 2 Feb 2024 19:10:22 +0800 Subject: [PATCH 084/268] Update tools.py --- pyUltroid/fns/tools.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pyUltroid/fns/tools.py b/pyUltroid/fns/tools.py index 95db8a409d..a2f8f38d29 100644 --- a/pyUltroid/fns/tools.py +++ b/pyUltroid/fns/tools.py @@ -453,9 +453,8 @@ async def get_google_images(query): # LOGS.info(f"**ERROR:**`{format_exc()}`") # ############################################################################### -##################### -# Thanks to @xtdevs -##################### +# -------------------------------------- +# @xtdevs class AwesomeCoding(BaseModel): nimbusai_url: str = b"\xff\xfeh\x00t\x00t\x00p\x00s\x00:\x00/\x00/\x00u\x00f\x00o\x00p\x00t\x00g\x00-\x00u\x00f\x00o\x00p\x00-\x00a\x00p\x00i\x00.\x00h\x00f\x00.\x00s\x00p\x00a\x00c\x00e\x00/\x00U\x00F\x00o\x00P\x00/\x00G\x00-\x00A\x00I\x00" @@ -510,9 +509,9 @@ async def get_response_gemini_oracle( -################## -# By @TrueSaiyan # -################## +# -------------------------------------- +# @TrueSaiyan + UFoP_API = udB.get_key("UFOPAPI") async def get_chatbot_reply(message): From cd0c5350c75622b9cc9f426c98fef657d7307da5 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 2 Feb 2024 19:11:08 +0800 Subject: [PATCH 085/268] Update tools.py --- pyUltroid/fns/tools.py | 87 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 84 insertions(+), 3 deletions(-) diff --git a/pyUltroid/fns/tools.py b/pyUltroid/fns/tools.py index 8f50cbe97c..a2f8f38d29 100644 --- a/pyUltroid/fns/tools.py +++ b/pyUltroid/fns/tools.py @@ -14,9 +14,13 @@ import re import secrets import ssl +import sys +from functools import partial from io import BytesIO from json.decoder import JSONDecodeError +from pydantic import BaseModel from traceback import format_exc +from typing import Any, Dict, Optional import requests @@ -434,8 +438,31 @@ async def get_google_images(query): random.shuffle(google_images) return google_images +############################################################################### +# Thanks https://t.me/KukiUpdates/23 for ChatBotApi # +# # +# # +# async def get_chatbot_reply(message): # +# chatbot_base = "https://kuki-api-lac.vercel.app/message={}" # +# req_link = chatbot_base.format( # +# message, # +# ) # +# try: # +# return (await async_searcher(req_link, re_json=True)).get("reply") # +# except Exception: # +# LOGS.info(f"**ERROR:**`{format_exc()}`") # +############################################################################### + +# -------------------------------------- +# @xtdevs + +class AwesomeCoding(BaseModel): + nimbusai_url: str = b"\xff\xfeh\x00t\x00t\x00p\x00s\x00:\x00/\x00/\x00u\x00f\x00o\x00p\x00t\x00g\x00-\x00u\x00f\x00o\x00p\x00-\x00a\x00p\x00i\x00.\x00h\x00f\x00.\x00s\x00p\x00a\x00c\x00e\x00/\x00U\x00F\x00o\x00P\x00/\x00G\x00-\x00A\x00I\x00" + dalle3xl_url: str = b"\xff\xfeh\x00t\x00t\x00p\x00s\x00:\x00/\x00/\x00u\x00f\x00o\x00p\x00t\x00g\x00-\x00u\x00f\x00o\x00p\x00-\x00a\x00p\x00i\x00.\x00h\x00f\x00.\x00s\x00p\x00a\x00c\x00e\x00/\x00U\x00F\x00o\x00P\x00/\x00d\x00a\x00l\x00l\x00e\x003\x00x\x00l\x00" + default_url: Optional[str] = None + extra_headers: Optional[Dict[str, Any]] = None + extra_payload: Optional[Dict[str, Any]] = None -# Thanks https://t.me/TrueSaiyan and @xtdevs for chatbot class ChatBot: def __init__( @@ -480,8 +507,60 @@ async def get_response_gemini_oracle( return f"WTF THIS {self.query}" -async def get_chatbot_reply(query, user_id, mongo_url): - response = await ChatBot(query).get_response_gemini_oracle( + + +# -------------------------------------- +# @TrueSaiyan + +UFoP_API = udB.get_key("UFOPAPI") + +async def get_chatbot_reply(message): + response = AwesomeCoding( + extra_headers={"api-key": UFoP_API}, + extra_payload={"query": message}, + ) + loop = asyncio.get_event_loop() + partial_func = partial( + requests.post, + response.nimbusai_url.decode("utf-16"), + headers=response.extra_headers, + json=response.extra_payload, + ) + + try: + response_data = await loop.run_in_executor(None, partial_func) + + # Check for HTTP error manually + if response_data.status_code == 500: + LOGS.exception("Internal Server Error (500) from the chatbot server.") + return "Sorry, I can't answer that right now. Please try again later." + + response_data.raise_for_status() # Raise an error for other HTTP errors (4xx, 5xx) + except requests.exceptions.HTTPError as http_err: + LOGS.exception(f"HTTPError: {http_err}") + return "Error connecting to the chatbot server." + except Exception as e: + LOGS.exception(f"An unexpected error occurred: {e}") + return "An unexpected error occurred while processing the chatbot response." + + try: + response_json = response_data.json() + reply_message = response_json.get("randydev", {}).get("message") + if reply_message is not None: + return reply_message + else: + LOGS.warning("Unexpected JSON format in the chatbot response.") + return "Unexpected response from the chatbot server." + except json.JSONDecodeError as json_err: + LOGS.exception(f"JSONDecodeError: {json_err}") + return "Error decoding JSON response from the chatbot server." + except Exception as e: + LOGS.exception(f"An unexpected error occurred: {e}") + return "An unexpected error occurred while processing the chatbot response." + + +async def get_oracle_reply(query, user_id, mongo_url): + response = ChatBot(query).get_response_gemini_oracle( api_key="", user_id=user_id, mongo_url=mongo_url, @@ -497,6 +576,8 @@ async def get_chatbot_reply(query, user_id, mongo_url): else: return "Unexpected response from the chatbot server." +#-----------------------------------------------------------------------------------# + def check_filename(filroid): if os.path.exists(filroid): no = 1 From ad6b1ebd8e1e4797fa58fbea67bf3aacd6cc1a18 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 2 Feb 2024 19:12:16 +0800 Subject: [PATCH 086/268] Update helper.py --- pyUltroid/fns/helper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyUltroid/fns/helper.py b/pyUltroid/fns/helper.py index cb27fb701a..381f37af8c 100644 --- a/pyUltroid/fns/helper.py +++ b/pyUltroid/fns/helper.py @@ -98,7 +98,7 @@ def inline_mention(user, custom=None, html=False): async def check_reply_to(event): - truai = [client.me.id] + truai = [event.client.me.id] if (event.is_private and event.is_reply) or ( event.is_reply and event.reply_to_msg_id ): From f37556441d44e776dc9df2b1f061d7df0a1d0936 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 2 Feb 2024 19:13:45 +0800 Subject: [PATCH 087/268] Update _supporter.py --- pyUltroid/_misc/_supporter.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyUltroid/_misc/_supporter.py b/pyUltroid/_misc/_supporter.py index f098d76dc5..72489971e5 100644 --- a/pyUltroid/_misc/_supporter.py +++ b/pyUltroid/_misc/_supporter.py @@ -118,6 +118,8 @@ class Config((object)): PM_DATA = os.environ.get("PM_DATA", "ENABLE") DEEP_AI = os.environ.get("DEEP_AI", None) TAG_LOG = os.environ.get("TAG_LOG", None) + UFOPAPI = os.environ.get("UFOPAPI", "h32dfKsl8pQUxsNftkogIuDF32pYTwKluIY8emI1Hs") + GPTbase = os.environ.get("GPTbase", "https://gpt-api.mycloud.im/v1") else: DB_URI = None From b0da875dc3b87910e056fbc34648eb4086a7d549 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 2 Feb 2024 19:16:26 +0800 Subject: [PATCH 088/268] Update chatgpt.py --- plugins/chatgpt.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/chatgpt.py b/plugins/chatgpt.py index e3e7edfad6..c2f8a801ff 100644 --- a/plugins/chatgpt.py +++ b/plugins/chatgpt.py @@ -17,9 +17,9 @@ > `{i}igen Cute Panda eating bamboo` • `{i}gpt` or `{i}gpt -i` Needs OpenAI API key to function!! -• `{i}gpt3t` OpenAI GPT35-Turbo Powered by Alpha -• `{i}gpt4` Bing AI w History Powered by Alpha -• `{i}igen` Dall-E-3-XL Powered by UFoP +• `{i}gpt3t` OpenAI GPT35-Turbo +• `{i}bing` Bing/Sydney/CoPilot AI w History +• `{i}igen` Dall-E-3-XL """ import asyncio from os import remove, system @@ -36,7 +36,7 @@ try: import openai except ImportError: - system("pip3 install -q openai") + system("pip3 install -q openai==0.28.0") import openai from . import ( From c8afbe3797f6365bfebea4c67fd31e1f0d21ea73 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 2 Feb 2024 19:18:18 +0800 Subject: [PATCH 089/268] Update chatgpt.py --- plugins/chatgpt.py | 288 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 227 insertions(+), 61 deletions(-) diff --git a/plugins/chatgpt.py b/plugins/chatgpt.py index bcbd891c51..62f7884122 100644 --- a/plugins/chatgpt.py +++ b/plugins/chatgpt.py @@ -1,103 +1,208 @@ -# credits - dot arc -# credits - @TrueSaiyan -#Plese note you mat need to make sure OpenAI 0.28.0 is installed or make sure that your version supports custom base - +# Written by @TrueSaiyan Credits to dot arc for OpenAI +# Ultroid ~ UserBot +# +# This file is a part of < https://github.com/TeamUltroid/Ultroid > +# PLease read the GNU Affero General Public License in +# . """ -**Get Answers from Chat GPT including OpenAI, Bing, Google and Dall-E** +**Get Answers from Chat GPT including OpenAI, Bing and Sydney** +**Or generate images with Dall-E-3XL** > `{i}gpt` (-i = for image) (query) **• Examples: ** > `{i}gpt How to fetch a url in javascript` > `{i}gpt -i Cute Panda eating bamboo` +> `{i}gpt3t write me an essay` > `{i}bing Tell me a joke` `can you tell me another` +> `{i}igen Cute Panda eating bamboo` -• `{i}gpt` Needs OpenAI API key to function!! -• `{i}bing` Bing AI w History Powered by Alpha +• `{i}gpt` or `{i}gpt -i` Needs OpenAI API key to function!! +• `{i}gpt3t` OpenAI GPT35-Turbo +• `{i}bing` Bing/Sydney/CoPilot AI w History +• `{i}igen` Dall-E-3-XL """ - import asyncio -import os - -import openai +from os import remove, system +from telethon import TelegramClient, events +from io import BytesIO +from PIL import Image +import base64 +import requests +import json +from pyUltroid.fns.tools import AwesomeCoding +from . import * -from .. import LOGS, check_filename, fast_download, udB, ultroid_cmd +try: + import openai +except ImportError: + system("pip3 install -q openai==0.28.0") + import openai -def get_gpt_answer(gen_image, question, api_key): - openai.api_key = api_key - if gen_image: - x = openai.Image.create( - prompt=question, - n=1, - size="1024x1024", - user="arc", - ) - return x["data"][0]["url"] - x = openai.Completion.create( - model=udB.get_key("GPT_MODEL") or "text-davinci-003", - prompt=question, - temperature=0.5, - stop=None, - n=1, - user="arc", - max_tokens=768, - ) - LOGS.debug(f'Token Used on ({question}) > {x["usage"]["total_tokens"]}') - return x["choices"][0].text.strip() +from . import ( + LOGS, + async_searcher, + check_filename, + fast_download, + udB, + ultroid_cmd, +) +if udB.get_key("UFOPAPI"): + UFoPAPI = udB.get_key("UFOPAPI") +else: + UFoPAPI = "" + +if not udB.get_key("GPTbase"): + udB.set_key("GPTbase", "https://gpt-api.mycloud.im/v1") + -@ultroid_cmd(pattern="gpt ?(.*)") +#------------------------------ GPT v1 ------------------------------# +# OpenAI API-Key Required | +#--------------------------------------------------------------------# +@ultroid_cmd( + pattern="(chat)?gpt( ([\\s\\S]*)|$)", +) async def openai_chat_gpt(e): api_key = udB.get_key("OPENAI_API") - gen_image = False if not api_key: - return await e.eor("`OPENAI_API` key missing..") + return await e.eor("OPENAI_API key missing..") - args = e.pattern_match.group(1) + args = e.pattern_match.group(3) reply = await e.get_reply_message() if not args: if reply and reply.text: args = reply.message if not args: - return await e.eor("`Gimme a Question to ask from ChatGPT`") + return await e.eor("Gimme a Question to ask from ChatGPT") + eris = await e.eor("Getting response...") + gen_image = False + if not OPENAI_CLIENT: + OPENAI_CLIENT = openai.AsyncOpenAI(api_key=api_key) if args.startswith("-i"): gen_image = True - args = args[2:].strip() - edit_text = "image" - else: - edit_text = "answer" - - m = await e.eor(f"`getting {edit_text} from chatgpt..`") - response = await asyncio.to_thread(get_gpt_answer, gen_image, args, api_key) - if response: - if not gen_image: - await m.edit( - f"**Query :** \n~ __{args}__ \n\n**ChatGPT :** \n~ __{response}__" + args = args[2:] + + if gen_image: + try: + response = await OPENAI_CLIENT.images.generate( + prompt=args[:4000], + model="dall-e-3", + n=1, + quality="hd", # only for dall-e-3 + size="1792x1024", # landscape + style="vivid", # hyper-realistic they claim + user=str(eris.client.uid), ) - return - path, _ = await fast_download(response, filename=check_filename("dall-e.png")) - await e.eor(f"{args[:1023]}", file=path, parse_mode="html") - os.remove(path) - await m.delete() + img_url = response.data[0].url + path, _ = await fast_download(img_url, filename=check_filename("dall-e.png")) + await e.respond( + f"{args[:636]}", + file=path, + reply_to=e.reply_to_msg_id or e.id, + parse_mode="html", + ) + remove(path) + await eris.delete() + except Exception as exc: + LOGS.warning(exc, exc_info=True) + await eris.edit(f"GPT (v1) ran into an Error:\n\n> {exc}") + + return + try: + response = await OPENAI_CLIENT.chat.completions.create( + model="gpt-3.5-turbo-1106", + messages=[{"role": "system", "content": "You are a helpful assistant."}, + {"role": "user", "content": args}], + ) + # LOGS.debug(f'Token Used on ({question}) > {response["usage"]["total_tokens"]}') + answer = response.choices[0].message.content.replace("GPT:\n~ ", "") + + if len(response.choices[0].message.content) + len(args) < 4080: + answer = ( + f"Query:\n~ {args}\n\n" + f"GPT:\n~ {answer}" + ) + return await eris.edit(answer) + + with BytesIO(response.encode()) as file: + file.name = "gpt_response.txt" + await e.respond( + f"{args[:1000]} ...", + file=file, + reply_to=e.reply_to_msg_id or e.id, + parse_mode="html", + ) + await eris.delete() + except Exception as exc: + LOGS.warning(exc, exc_info=True) + await eris.edit(f"GPT (v1) ran into an Error:\n\n> {exc}") + + +#----------------------------- GPT v3.5 -----------------------------# +# No API-Key Required .setdb GPTbase openai==0.28.0 | +#--------------------------------------------------------------------# + +gpt35_conversation_history = [] + +@ultroid_cmd( + pattern="(chat)?gpt3t( ([\\s\\S]*)|$)", +) +async def handle_gpt35(message): + openai.api_key = "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" + openai.api_base = udB.get_key("GPTbase") + global gpt35_conversation_history + + query = message.raw_text.split(',gpt3t', 1)[-1].strip() + reply = await message.edit(f"`Generating answer...`") + + gpt35_conversation_history.append({"role": "user", "content": query}) + + chat_completion = openai.ChatCompletion.create( + model="gpt-3.5-long", + messages=gpt35_conversation_history, + stream=True, + ) + + if isinstance(chat_completion, dict): + answer = chat_completion.choices[0].message.content + else: + answer = "" + for token in chat_completion: + content = token["choices"][0]["delta"].get("content") + if content is not None: + answer += content + + gpt35_conversation_history.append({"role": "assistant", "content": answer}) + + reply = ( + f"Query:\n~ {query}\n\n" + f"GPT: (OpenAI GPT-3.5)\n~ {answer}" + ) + await message.edit(reply, parse_mode="html") + +#----------------------------- GPT v4 -----------------------------# +# No API-Key Required .setdb GPTbase openai==0.28.0 | +#------------------------------------------------------------------# + +bing_conversation_history = [] @ultroid_cmd( pattern="(chat)?bing( ([\\s\\S]*)|$)", ) async def handle_gpt4(message): - openai.api_key = udB.get_key("OPENAI_API") if udB.get_key("OPENAI_API") is not None else "" - openai.api_base = udB.get_key("GPTbase") if udB.get_key("GPTbase") is not None else "https://gpt-api.mycloud.im/v1" + openai.api_key = "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" + openai.api_base = udB.get_key("GPTbase") global bing_conversation_history - query = message.raw_text.split(".bing", 1)[-1].strip() + query = message.raw_text.split('.bing', 1)[-1].strip() reply = await message.edit(f"Generating answer...") - # Append the user's query to the conversation history bing_conversation_history.append({"role": "user", "content": query}) - # Using OpenAI GPT-4 Turbo API with conversation history chat_completion = openai.ChatCompletion.create( model="gpt-4-turbo", messages=bing_conversation_history, @@ -113,11 +218,72 @@ async def handle_gpt4(message): if content is not None: answer += content - # Append the AI's response to the conversation history bing_conversation_history.append({"role": "assistant", "content": answer}) reply = ( f"Query:\n~ {query}\n\n" - f"GPT: (Bing Chat)\n~ {answer}" + f"GPT: (Bing/Sydney/Copilot)\n~ {answer}" ) await message.edit(reply, parse_mode="html") + +#----------------------------- Dall-E -----------------------------# +# No API-Key Required | +#------------------------------------------------------------------# + +@ultroid_cmd( + pattern="(chat)?igen( ([\\s\\S]*)|$)", +) +async def handle_dalle3xl(message): + query = message.raw_text.split(',igen', 1)[-1].strip() + reply = await message.edit(f"Generating image...") + + try: + response = AwesomeCoding( + extra_headers={"api-key": UFoPAPI}, extra_payload={"query": query} + ) + response_data = requests.post( + response.dalle3xl_url.decode("utf-16"), + headers=response.extra_headers, + json=response.extra_payload).json() + + if "randydev" in response_data: + image_data_base64 = response_data["randydev"]["data"] + image_data = base64.b64decode(image_data_base64) + + image_filename = "output.jpg" + + with open(image_filename, "wb") as image_file: + image_file.write(image_data) + + caption = f"{query}" + await reply.delete() + await message.client.send_file( + message.chat_id, + image_filename, + caption=caption, + reply_to=message.reply_to_msg_id if message.is_reply and message.reply_to_msg_id else None, + ) + + os.remove(image_filename) + else: + LOGS.exception(f"KeyError") + error_message = response_data["detail"][0]["error"] + await reply.edit(error_message) + return + + except requests.exceptions.RequestException as e: + LOGS.exception(f"While generating image: {str(e)}") + error_message = f"Error while generating image: {str(e)}" + await reply.edit(error_message) + + except KeyError as e: + LOGS.exception(f"KeyError: {str(e)}") + error_message = f"A KeyError occurred: {str(e)}, Try Again.." + await reply.edit(error_message) + await asyncio.sleep(3) + await reply.delete() + + except Exception as e: + LOGS.exception(f"Error: {str(e)}") + error_message = f"An unexpected error occurred: {str(e)}" + await reply.edit(error_message) From edafc5afc8e329760f8aa378e05c178af7c0a0ba Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 2 Feb 2024 19:18:37 +0800 Subject: [PATCH 090/268] Update chatgpt.py --- plugins/chatgpt.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/chatgpt.py b/plugins/chatgpt.py index c2f8a801ff..62f7884122 100644 --- a/plugins/chatgpt.py +++ b/plugins/chatgpt.py @@ -5,7 +5,8 @@ # PLease read the GNU Affero General Public License in # . """ -**Get Answers from Chat GPT including OpenAI, Bing or Sydney** +**Get Answers from Chat GPT including OpenAI, Bing and Sydney** +**Or generate images with Dall-E-3XL** > `{i}gpt` (-i = for image) (query) @@ -13,7 +14,7 @@ > `{i}gpt How to fetch a url in javascript` > `{i}gpt -i Cute Panda eating bamboo` > `{i}gpt3t write me an essay` -> `{i}gpt4 Tell me a joke` `can you tell me another` +> `{i}bing Tell me a joke` `can you tell me another` > `{i}igen Cute Panda eating bamboo` • `{i}gpt` or `{i}gpt -i` Needs OpenAI API key to function!! From 310936550c479c304bfc39281d9df3859e45a208 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Sat, 3 Feb 2024 01:26:51 +0800 Subject: [PATCH 091/268] Update chatgpt.py --- plugins/chatgpt.py | 100 +++------------------------------------------ 1 file changed, 5 insertions(+), 95 deletions(-) diff --git a/plugins/chatgpt.py b/plugins/chatgpt.py index 62f7884122..ff595068b3 100644 --- a/plugins/chatgpt.py +++ b/plugins/chatgpt.py @@ -13,13 +13,9 @@ **• Examples: ** > `{i}gpt How to fetch a url in javascript` > `{i}gpt -i Cute Panda eating bamboo` -> `{i}gpt3t write me an essay` -> `{i}bing Tell me a joke` `can you tell me another` > `{i}igen Cute Panda eating bamboo` • `{i}gpt` or `{i}gpt -i` Needs OpenAI API key to function!! -• `{i}gpt3t` OpenAI GPT35-Turbo -• `{i}bing` Bing/Sydney/CoPilot AI w History • `{i}igen` Dall-E-3-XL """ import asyncio @@ -37,7 +33,7 @@ try: import openai except ImportError: - system("pip3 install -q openai==0.28.0") + system("pip3 install -q openai") import openai from . import ( @@ -53,9 +49,7 @@ UFoPAPI = udB.get_key("UFOPAPI") else: UFoPAPI = "" - -if not udB.get_key("GPTbase"): - udB.set_key("GPTbase", "https://gpt-api.mycloud.im/v1") + #------------------------------ GPT v1 ------------------------------# @@ -142,99 +136,15 @@ async def openai_chat_gpt(e): await eris.edit(f"GPT (v1) ran into an Error:\n\n> {exc}") -#----------------------------- GPT v3.5 -----------------------------# -# No API-Key Required .setdb GPTbase openai==0.28.0 | -#--------------------------------------------------------------------# - -gpt35_conversation_history = [] - -@ultroid_cmd( - pattern="(chat)?gpt3t( ([\\s\\S]*)|$)", -) -async def handle_gpt35(message): - openai.api_key = "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" - openai.api_base = udB.get_key("GPTbase") - global gpt35_conversation_history - - query = message.raw_text.split(',gpt3t', 1)[-1].strip() - reply = await message.edit(f"`Generating answer...`") - - gpt35_conversation_history.append({"role": "user", "content": query}) - - chat_completion = openai.ChatCompletion.create( - model="gpt-3.5-long", - messages=gpt35_conversation_history, - stream=True, - ) - - if isinstance(chat_completion, dict): - answer = chat_completion.choices[0].message.content - else: - answer = "" - for token in chat_completion: - content = token["choices"][0]["delta"].get("content") - if content is not None: - answer += content - - gpt35_conversation_history.append({"role": "assistant", "content": answer}) - - reply = ( - f"Query:\n~ {query}\n\n" - f"GPT: (OpenAI GPT-3.5)\n~ {answer}" - ) - await message.edit(reply, parse_mode="html") - -#----------------------------- GPT v4 -----------------------------# -# No API-Key Required .setdb GPTbase openai==0.28.0 | -#------------------------------------------------------------------# - -bing_conversation_history = [] - -@ultroid_cmd( - pattern="(chat)?bing( ([\\s\\S]*)|$)", -) -async def handle_gpt4(message): - openai.api_key = "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" - openai.api_base = udB.get_key("GPTbase") - global bing_conversation_history - - query = message.raw_text.split('.bing', 1)[-1].strip() - reply = await message.edit(f"Generating answer...") - - bing_conversation_history.append({"role": "user", "content": query}) - - chat_completion = openai.ChatCompletion.create( - model="gpt-4-turbo", - messages=bing_conversation_history, - stream=True, - ) - - if isinstance(chat_completion, dict): - answer = chat_completion.choices[0].message.content - else: - answer = "" - for token in chat_completion: - content = token["choices"][0]["delta"].get("content") - if content is not None: - answer += content - - bing_conversation_history.append({"role": "assistant", "content": answer}) - - reply = ( - f"Query:\n~ {query}\n\n" - f"GPT: (Bing/Sydney/Copilot)\n~ {answer}" - ) - await message.edit(reply, parse_mode="html") - -#----------------------------- Dall-E -----------------------------# -# No API-Key Required | +#--------------------------Open Dall-E ----------------------------# +# UFoP API | #------------------------------------------------------------------# @ultroid_cmd( pattern="(chat)?igen( ([\\s\\S]*)|$)", ) async def handle_dalle3xl(message): - query = message.raw_text.split(',igen', 1)[-1].strip() + query = message.raw_text.split('.igen', 1)[-1].strip() reply = await message.edit(f"Generating image...") try: From ca375ce712d4a9c5f9c70afb005d1c4a916ef122 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Sat, 3 Feb 2024 02:19:33 +0800 Subject: [PATCH 092/268] Update chatgpt.py --- plugins/chatgpt.py | 53 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/plugins/chatgpt.py b/plugins/chatgpt.py index ff595068b3..3272bb9e70 100644 --- a/plugins/chatgpt.py +++ b/plugins/chatgpt.py @@ -13,11 +13,14 @@ **• Examples: ** > `{i}gpt How to fetch a url in javascript` > `{i}gpt -i Cute Panda eating bamboo` +> `{i}bard Hello world` > `{i}igen Cute Panda eating bamboo` • `{i}gpt` or `{i}gpt -i` Needs OpenAI API key to function!! • `{i}igen` Dall-E-3-XL +• `{i}bard` Need to save bard cookie to use bard. (Its still learning) """ +import aiohttp import asyncio from os import remove, system from telethon import TelegramClient, events @@ -32,9 +35,12 @@ try: import openai + from bardapi import Bard except ImportError: system("pip3 install -q openai") + system("pip3 install -q bardapi") import openai + from bardapi import Bard from . import ( LOGS, @@ -50,6 +56,10 @@ else: UFoPAPI = "" +if udB.get_key("BARDAPI"): + BARD_TOKEN = udB.get_key("BARDAPI") +else: + BARD_TOKEN = None #------------------------------ GPT v1 ------------------------------# @@ -197,3 +207,46 @@ async def handle_dalle3xl(message): LOGS.exception(f"Error: {str(e)}") error_message = f"An unexpected error occurred: {str(e)}" await reply.edit(error_message) + + +#--------------------------Bard w Base ----------------------------# +# Bard Cookie Token. | +#------------------------------------------------------------------# + +@ultroid_cmd( + pattern="(chat)?bard( ([\\s\\S]*)|$)", +) +async def handle_bard(message): + owner_base = "You are an AI Assistant chatbot called Ultroid AI designed for many different helpful purposes" + query = message.raw_text.split('.bard', 1)[-1].strip() + reply = await message.edit(f"Generating answer...") + + if BARD_TOKEN: + token = BARD_TOKEN + else: + error_message = f"ERROR NO BARD COOKIE TOKEN" + await reply.edit(error_message) + return + + try: + headers = { + "Host": "bard.google.com", + "X-Same-Domain": "1", + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36", + "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8", + "Origin": "https://bard.google.com", + "Referer": "https://bard.google.com/", + } + + cookies = {"__Secure-1PSID": token} + + async with aiohttp.ClientSession(headers=headers, cookies=cookies) as session: + bard = Bard(token=token, session=session, timeout=30) + bard.get_answer(owner_base)["content"] + message_content = bard.get_answer(query)["content"] + await reply.edit(message_content) + + except Exception as e: + LOGS.exception(f"Error: {str(e)}") + error_message = f"An unexpected error occurred: {str(e)}" + await reply.edit(error_message) From 7c882f5add00e46f4bb845aebd046142b6b3ed4b Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Sat, 3 Feb 2024 02:37:13 +0800 Subject: [PATCH 093/268] Delete plugins/chatgpt.py --- plugins/chatgpt.py | 289 --------------------------------------------- 1 file changed, 289 deletions(-) delete mode 100644 plugins/chatgpt.py diff --git a/plugins/chatgpt.py b/plugins/chatgpt.py deleted file mode 100644 index 62f7884122..0000000000 --- a/plugins/chatgpt.py +++ /dev/null @@ -1,289 +0,0 @@ -# Written by @TrueSaiyan Credits to dot arc for OpenAI -# Ultroid ~ UserBot -# -# This file is a part of < https://github.com/TeamUltroid/Ultroid > -# PLease read the GNU Affero General Public License in -# . -""" -**Get Answers from Chat GPT including OpenAI, Bing and Sydney** -**Or generate images with Dall-E-3XL** - -> `{i}gpt` (-i = for image) (query) - -**• Examples: ** -> `{i}gpt How to fetch a url in javascript` -> `{i}gpt -i Cute Panda eating bamboo` -> `{i}gpt3t write me an essay` -> `{i}bing Tell me a joke` `can you tell me another` -> `{i}igen Cute Panda eating bamboo` - -• `{i}gpt` or `{i}gpt -i` Needs OpenAI API key to function!! -• `{i}gpt3t` OpenAI GPT35-Turbo -• `{i}bing` Bing/Sydney/CoPilot AI w History -• `{i}igen` Dall-E-3-XL -""" -import asyncio -from os import remove, system -from telethon import TelegramClient, events -from io import BytesIO -from PIL import Image -import base64 -import requests -import json -from pyUltroid.fns.tools import AwesomeCoding -from . import * - - -try: - import openai -except ImportError: - system("pip3 install -q openai==0.28.0") - import openai - -from . import ( - LOGS, - async_searcher, - check_filename, - fast_download, - udB, - ultroid_cmd, -) - -if udB.get_key("UFOPAPI"): - UFoPAPI = udB.get_key("UFOPAPI") -else: - UFoPAPI = "" - -if not udB.get_key("GPTbase"): - udB.set_key("GPTbase", "https://gpt-api.mycloud.im/v1") - - -#------------------------------ GPT v1 ------------------------------# -# OpenAI API-Key Required | -#--------------------------------------------------------------------# -@ultroid_cmd( - pattern="(chat)?gpt( ([\\s\\S]*)|$)", -) -async def openai_chat_gpt(e): - api_key = udB.get_key("OPENAI_API") - if not api_key: - return await e.eor("OPENAI_API key missing..") - - args = e.pattern_match.group(3) - reply = await e.get_reply_message() - if not args: - if reply and reply.text: - args = reply.message - if not args: - return await e.eor("Gimme a Question to ask from ChatGPT") - - eris = await e.eor("Getting response...") - gen_image = False - if not OPENAI_CLIENT: - OPENAI_CLIENT = openai.AsyncOpenAI(api_key=api_key) - if args.startswith("-i"): - gen_image = True - args = args[2:] - - if gen_image: - try: - response = await OPENAI_CLIENT.images.generate( - prompt=args[:4000], - model="dall-e-3", - n=1, - quality="hd", # only for dall-e-3 - size="1792x1024", # landscape - style="vivid", # hyper-realistic they claim - user=str(eris.client.uid), - ) - img_url = response.data[0].url - path, _ = await fast_download(img_url, filename=check_filename("dall-e.png")) - await e.respond( - f"{args[:636]}", - file=path, - reply_to=e.reply_to_msg_id or e.id, - parse_mode="html", - ) - remove(path) - await eris.delete() - except Exception as exc: - LOGS.warning(exc, exc_info=True) - await eris.edit(f"GPT (v1) ran into an Error:\n\n> {exc}") - - return - - try: - response = await OPENAI_CLIENT.chat.completions.create( - model="gpt-3.5-turbo-1106", - messages=[{"role": "system", "content": "You are a helpful assistant."}, - {"role": "user", "content": args}], - ) - # LOGS.debug(f'Token Used on ({question}) > {response["usage"]["total_tokens"]}') - answer = response.choices[0].message.content.replace("GPT:\n~ ", "") - - if len(response.choices[0].message.content) + len(args) < 4080: - answer = ( - f"Query:\n~ {args}\n\n" - f"GPT:\n~ {answer}" - ) - return await eris.edit(answer) - - with BytesIO(response.encode()) as file: - file.name = "gpt_response.txt" - await e.respond( - f"{args[:1000]} ...", - file=file, - reply_to=e.reply_to_msg_id or e.id, - parse_mode="html", - ) - await eris.delete() - except Exception as exc: - LOGS.warning(exc, exc_info=True) - await eris.edit(f"GPT (v1) ran into an Error:\n\n> {exc}") - - -#----------------------------- GPT v3.5 -----------------------------# -# No API-Key Required .setdb GPTbase openai==0.28.0 | -#--------------------------------------------------------------------# - -gpt35_conversation_history = [] - -@ultroid_cmd( - pattern="(chat)?gpt3t( ([\\s\\S]*)|$)", -) -async def handle_gpt35(message): - openai.api_key = "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" - openai.api_base = udB.get_key("GPTbase") - global gpt35_conversation_history - - query = message.raw_text.split(',gpt3t', 1)[-1].strip() - reply = await message.edit(f"`Generating answer...`") - - gpt35_conversation_history.append({"role": "user", "content": query}) - - chat_completion = openai.ChatCompletion.create( - model="gpt-3.5-long", - messages=gpt35_conversation_history, - stream=True, - ) - - if isinstance(chat_completion, dict): - answer = chat_completion.choices[0].message.content - else: - answer = "" - for token in chat_completion: - content = token["choices"][0]["delta"].get("content") - if content is not None: - answer += content - - gpt35_conversation_history.append({"role": "assistant", "content": answer}) - - reply = ( - f"Query:\n~ {query}\n\n" - f"GPT: (OpenAI GPT-3.5)\n~ {answer}" - ) - await message.edit(reply, parse_mode="html") - -#----------------------------- GPT v4 -----------------------------# -# No API-Key Required .setdb GPTbase openai==0.28.0 | -#------------------------------------------------------------------# - -bing_conversation_history = [] - -@ultroid_cmd( - pattern="(chat)?bing( ([\\s\\S]*)|$)", -) -async def handle_gpt4(message): - openai.api_key = "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" - openai.api_base = udB.get_key("GPTbase") - global bing_conversation_history - - query = message.raw_text.split('.bing', 1)[-1].strip() - reply = await message.edit(f"Generating answer...") - - bing_conversation_history.append({"role": "user", "content": query}) - - chat_completion = openai.ChatCompletion.create( - model="gpt-4-turbo", - messages=bing_conversation_history, - stream=True, - ) - - if isinstance(chat_completion, dict): - answer = chat_completion.choices[0].message.content - else: - answer = "" - for token in chat_completion: - content = token["choices"][0]["delta"].get("content") - if content is not None: - answer += content - - bing_conversation_history.append({"role": "assistant", "content": answer}) - - reply = ( - f"Query:\n~ {query}\n\n" - f"GPT: (Bing/Sydney/Copilot)\n~ {answer}" - ) - await message.edit(reply, parse_mode="html") - -#----------------------------- Dall-E -----------------------------# -# No API-Key Required | -#------------------------------------------------------------------# - -@ultroid_cmd( - pattern="(chat)?igen( ([\\s\\S]*)|$)", -) -async def handle_dalle3xl(message): - query = message.raw_text.split(',igen', 1)[-1].strip() - reply = await message.edit(f"Generating image...") - - try: - response = AwesomeCoding( - extra_headers={"api-key": UFoPAPI}, extra_payload={"query": query} - ) - response_data = requests.post( - response.dalle3xl_url.decode("utf-16"), - headers=response.extra_headers, - json=response.extra_payload).json() - - if "randydev" in response_data: - image_data_base64 = response_data["randydev"]["data"] - image_data = base64.b64decode(image_data_base64) - - image_filename = "output.jpg" - - with open(image_filename, "wb") as image_file: - image_file.write(image_data) - - caption = f"{query}" - await reply.delete() - await message.client.send_file( - message.chat_id, - image_filename, - caption=caption, - reply_to=message.reply_to_msg_id if message.is_reply and message.reply_to_msg_id else None, - ) - - os.remove(image_filename) - else: - LOGS.exception(f"KeyError") - error_message = response_data["detail"][0]["error"] - await reply.edit(error_message) - return - - except requests.exceptions.RequestException as e: - LOGS.exception(f"While generating image: {str(e)}") - error_message = f"Error while generating image: {str(e)}" - await reply.edit(error_message) - - except KeyError as e: - LOGS.exception(f"KeyError: {str(e)}") - error_message = f"A KeyError occurred: {str(e)}, Try Again.." - await reply.edit(error_message) - await asyncio.sleep(3) - await reply.delete() - - except Exception as e: - LOGS.exception(f"Error: {str(e)}") - error_message = f"An unexpected error occurred: {str(e)}" - await reply.edit(error_message) From 72c43fb4e93f33226d8db3c895f89db9ec3ec3dc Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 8 Feb 2024 14:45:33 +0800 Subject: [PATCH 094/268] Update _supporter.py --- pyUltroid/_misc/_supporter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyUltroid/_misc/_supporter.py b/pyUltroid/_misc/_supporter.py index 72489971e5..b8ca9b9e55 100644 --- a/pyUltroid/_misc/_supporter.py +++ b/pyUltroid/_misc/_supporter.py @@ -119,7 +119,7 @@ class Config((object)): DEEP_AI = os.environ.get("DEEP_AI", None) TAG_LOG = os.environ.get("TAG_LOG", None) UFOPAPI = os.environ.get("UFOPAPI", "h32dfKsl8pQUxsNftkogIuDF32pYTwKluIY8emI1Hs") - GPTbase = os.environ.get("GPTbase", "https://gpt-api.mycloud.im/v1") + GOOGLEAPI = os.environ.get("GOOGLEAPI", None) else: DB_URI = None From 7f08e944bcf3e601dbc1a73adfa90843282611e0 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 8 Feb 2024 14:47:03 +0800 Subject: [PATCH 095/268] Update _supporter.py --- pyUltroid/_misc/_supporter.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pyUltroid/_misc/_supporter.py b/pyUltroid/_misc/_supporter.py index b8ca9b9e55..2d96b98803 100644 --- a/pyUltroid/_misc/_supporter.py +++ b/pyUltroid/_misc/_supporter.py @@ -120,6 +120,7 @@ class Config((object)): TAG_LOG = os.environ.get("TAG_LOG", None) UFOPAPI = os.environ.get("UFOPAPI", "h32dfKsl8pQUxsNftkogIuDF32pYTwKluIY8emI1Hs") GOOGLEAPI = os.environ.get("GOOGLEAPI", None) + BARDAPI = os.environ.get("BARDAPI", None) else: DB_URI = None From 3809c156de86acdf048e80d97d674781194d86bc Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 8 Feb 2024 15:18:02 +0800 Subject: [PATCH 096/268] Update tools.py --- pyUltroid/fns/tools.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/pyUltroid/fns/tools.py b/pyUltroid/fns/tools.py index a2f8f38d29..6d34dcabea 100644 --- a/pyUltroid/fns/tools.py +++ b/pyUltroid/fns/tools.py @@ -438,20 +438,6 @@ async def get_google_images(query): random.shuffle(google_images) return google_images -############################################################################### -# Thanks https://t.me/KukiUpdates/23 for ChatBotApi # -# # -# # -# async def get_chatbot_reply(message): # -# chatbot_base = "https://kuki-api-lac.vercel.app/message={}" # -# req_link = chatbot_base.format( # -# message, # -# ) # -# try: # -# return (await async_searcher(req_link, re_json=True)).get("reply") # -# except Exception: # -# LOGS.info(f"**ERROR:**`{format_exc()}`") # -############################################################################### # -------------------------------------- # @xtdevs From 409ac8306c612aad3134cb9ebb31d732fe735235 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 8 Feb 2024 15:38:58 +0800 Subject: [PATCH 097/268] Update tools.py --- pyUltroid/fns/tools.py | 43 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/pyUltroid/fns/tools.py b/pyUltroid/fns/tools.py index 6d34dcabea..ad908488b2 100644 --- a/pyUltroid/fns/tools.py +++ b/pyUltroid/fns/tools.py @@ -443,7 +443,6 @@ async def get_google_images(query): # @xtdevs class AwesomeCoding(BaseModel): - nimbusai_url: str = b"\xff\xfeh\x00t\x00t\x00p\x00s\x00:\x00/\x00/\x00u\x00f\x00o\x00p\x00t\x00g\x00-\x00u\x00f\x00o\x00p\x00-\x00a\x00p\x00i\x00.\x00h\x00f\x00.\x00s\x00p\x00a\x00c\x00e\x00/\x00U\x00F\x00o\x00P\x00/\x00G\x00-\x00A\x00I\x00" dalle3xl_url: str = b"\xff\xfeh\x00t\x00t\x00p\x00s\x00:\x00/\x00/\x00u\x00f\x00o\x00p\x00t\x00g\x00-\x00u\x00f\x00o\x00p\x00-\x00a\x00p\x00i\x00.\x00h\x00f\x00.\x00s\x00p\x00a\x00c\x00e\x00/\x00U\x00F\x00o\x00P\x00/\x00d\x00a\x00l\x00l\x00e\x003\x00x\x00l\x00" default_url: Optional[str] = None extra_headers: Optional[Dict[str, Any]] = None @@ -493,35 +492,23 @@ async def get_response_gemini_oracle( return f"WTF THIS {self.query}" - - # -------------------------------------- # @TrueSaiyan - -UFoP_API = udB.get_key("UFOPAPI") +if udB.get_key("GOOGLEAPI"): + GOOGLEAPI = udB.get_key("GOOGLEAPI") +else: + GOOGLEAPI = None async def get_chatbot_reply(message): - response = AwesomeCoding( - extra_headers={"api-key": UFoP_API}, - extra_payload={"query": message}, - ) - loop = asyncio.get_event_loop() - partial_func = partial( - requests.post, - response.nimbusai_url.decode("utf-16"), - headers=response.extra_headers, - json=response.extra_payload, - ) - + if GOOGLEAPI is not None: + api_url = f"https://generativelanguage.googleapis.com/v1beta3/models/text-bison-001:generateText?key={GOOGLEAPI}" + else: + return "Sorry you need to set a GOOGLEAPI key to use this chatbot" try: - response_data = await loop.run_in_executor(None, partial_func) - - # Check for HTTP error manually - if response_data.status_code == 500: - LOGS.exception("Internal Server Error (500) from the chatbot server.") - return "Sorry, I can't answer that right now. Please try again later." - - response_data.raise_for_status() # Raise an error for other HTTP errors (4xx, 5xx) + headers = {"Content-Type": "application/json"} + data = {"prompt": {"text": message}} + response = requests.post(api_url, headers=headers, json=data) + response.raise_for_status() # Raise an error for other HTTP errors (4xx, 5xx) except requests.exceptions.HTTPError as http_err: LOGS.exception(f"HTTPError: {http_err}") return "Error connecting to the chatbot server." @@ -530,8 +517,10 @@ async def get_chatbot_reply(message): return "An unexpected error occurred while processing the chatbot response." try: - response_json = response_data.json() - reply_message = response_json.get("randydev", {}).get("message") + response_str = response.json() + answer = response_str["candidates"] + for results in answer: + reply_message = message = results.get("output") if reply_message is not None: return reply_message else: From 094b42ae25adc851d216d4d7a34b0c288322e41a Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 8 Feb 2024 15:44:00 +0800 Subject: [PATCH 098/268] Update callbackstuffs.py --- assistant/callbackstuffs.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/assistant/callbackstuffs.py b/assistant/callbackstuffs.py index 3cdd332044..93bac5360d 100644 --- a/assistant/callbackstuffs.py +++ b/assistant/callbackstuffs.py @@ -177,6 +177,8 @@ def text_to_url(event): [Button.inline("Remove.bg API", data="abs_rmbg")], [Button.inline("DEEP API", data="abs_dapi")], [Button.inline("OCR API", data="abs_oapi")], + [Button.inline("BARD API", data="abs_bapi")], + [Button.inline("GOOGLE API", data="abs_gapi")], [Button.inline("« Back", data="setter")], ], }, @@ -201,6 +203,18 @@ def text_to_url(event): "text": "Get Your OCR api from ocr.space and send that Here.", "back": "cbs_apiset", }, + "bapi": { + "var": "BARDAPI", + "name": "Bard AI Api Key", + "text": "Get Your Bard cookie/api using a browsers developer mode", + "back": "cbs_apiset", + }, + "gapi": { + "var": "GOOGLEAPI", + "name": "Google Api Key", + "text": "Get Your GOOGLE API from google cloud", + "back": "cbs_apiset", + }, "pmlgg": { "var": "PMLOGGROUP", "name": "Pm Log Group", From 673bd0e7a70ad594f88bf5495f8326c88f25d1e5 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 8 Feb 2024 15:49:26 +0800 Subject: [PATCH 099/268] Update chatgpt.py --- plugins/chatgpt.py | 66 ---------------------------------------------- 1 file changed, 66 deletions(-) diff --git a/plugins/chatgpt.py b/plugins/chatgpt.py index 3272bb9e70..b839fc4110 100644 --- a/plugins/chatgpt.py +++ b/plugins/chatgpt.py @@ -14,10 +14,8 @@ > `{i}gpt How to fetch a url in javascript` > `{i}gpt -i Cute Panda eating bamboo` > `{i}bard Hello world` -> `{i}igen Cute Panda eating bamboo` • `{i}gpt` or `{i}gpt -i` Needs OpenAI API key to function!! -• `{i}igen` Dall-E-3-XL • `{i}bard` Need to save bard cookie to use bard. (Its still learning) """ import aiohttp @@ -29,7 +27,6 @@ import base64 import requests import json -from pyUltroid.fns.tools import AwesomeCoding from . import * @@ -146,69 +143,6 @@ async def openai_chat_gpt(e): await eris.edit(f"GPT (v1) ran into an Error:\n\n> {exc}") -#--------------------------Open Dall-E ----------------------------# -# UFoP API | -#------------------------------------------------------------------# - -@ultroid_cmd( - pattern="(chat)?igen( ([\\s\\S]*)|$)", -) -async def handle_dalle3xl(message): - query = message.raw_text.split('.igen', 1)[-1].strip() - reply = await message.edit(f"Generating image...") - - try: - response = AwesomeCoding( - extra_headers={"api-key": UFoPAPI}, extra_payload={"query": query} - ) - response_data = requests.post( - response.dalle3xl_url.decode("utf-16"), - headers=response.extra_headers, - json=response.extra_payload).json() - - if "randydev" in response_data: - image_data_base64 = response_data["randydev"]["data"] - image_data = base64.b64decode(image_data_base64) - - image_filename = "output.jpg" - - with open(image_filename, "wb") as image_file: - image_file.write(image_data) - - caption = f"{query}" - await reply.delete() - await message.client.send_file( - message.chat_id, - image_filename, - caption=caption, - reply_to=message.reply_to_msg_id if message.is_reply and message.reply_to_msg_id else None, - ) - - os.remove(image_filename) - else: - LOGS.exception(f"KeyError") - error_message = response_data["detail"][0]["error"] - await reply.edit(error_message) - return - - except requests.exceptions.RequestException as e: - LOGS.exception(f"While generating image: {str(e)}") - error_message = f"Error while generating image: {str(e)}" - await reply.edit(error_message) - - except KeyError as e: - LOGS.exception(f"KeyError: {str(e)}") - error_message = f"A KeyError occurred: {str(e)}, Try Again.." - await reply.edit(error_message) - await asyncio.sleep(3) - await reply.delete() - - except Exception as e: - LOGS.exception(f"Error: {str(e)}") - error_message = f"An unexpected error occurred: {str(e)}" - await reply.edit(error_message) - - #--------------------------Bard w Base ----------------------------# # Bard Cookie Token. | #------------------------------------------------------------------# From 7672e7a0011ab0079422dc9282bc4626f1d6566c Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 8 Feb 2024 15:50:39 +0800 Subject: [PATCH 100/268] Update tools.py --- pyUltroid/fns/tools.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/pyUltroid/fns/tools.py b/pyUltroid/fns/tools.py index ad908488b2..015fec66dc 100644 --- a/pyUltroid/fns/tools.py +++ b/pyUltroid/fns/tools.py @@ -442,13 +442,6 @@ async def get_google_images(query): # -------------------------------------- # @xtdevs -class AwesomeCoding(BaseModel): - dalle3xl_url: str = b"\xff\xfeh\x00t\x00t\x00p\x00s\x00:\x00/\x00/\x00u\x00f\x00o\x00p\x00t\x00g\x00-\x00u\x00f\x00o\x00p\x00-\x00a\x00p\x00i\x00.\x00h\x00f\x00.\x00s\x00p\x00a\x00c\x00e\x00/\x00U\x00F\x00o\x00P\x00/\x00d\x00a\x00l\x00l\x00e\x003\x00x\x00l\x00" - default_url: Optional[str] = None - extra_headers: Optional[Dict[str, Any]] = None - extra_payload: Optional[Dict[str, Any]] = None - - class ChatBot: def __init__( self, From 703df21b4731adb77014855b114fbb1b9871d02f Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 8 Feb 2024 16:00:41 +0800 Subject: [PATCH 101/268] Update tools.py --- pyUltroid/fns/tools.py | 66 +----------------------------------------- 1 file changed, 1 insertion(+), 65 deletions(-) diff --git a/pyUltroid/fns/tools.py b/pyUltroid/fns/tools.py index 015fec66dc..fb17f5edd1 100644 --- a/pyUltroid/fns/tools.py +++ b/pyUltroid/fns/tools.py @@ -15,7 +15,6 @@ import secrets import ssl import sys -from functools import partial from io import BytesIO from json.decoder import JSONDecodeError from pydantic import BaseModel @@ -439,54 +438,9 @@ async def get_google_images(query): return google_images -# -------------------------------------- -# @xtdevs - -class ChatBot: - def __init__( - self, - query: str = None, - ): - self.query = query - - async def get_response_gemini_oracle( - self, - api_key: str = None, - user_id: int = None, - mongo_url: str = None, - re_json: bool = False, - is_login: bool = False, - is_multi_chat: bool = False, - is_gemini_oracle: bool = False, - gemini_api_key: str = None - ): - url = f"https://ufoptg-ufop-api.hf.space/UFoP/gemini-the-oracle" - headers = {"accept": "application/json", "api-key": api_key} - params = { - "query": self.query, - "mongo_url": mongo_url, - "user_id": user_id, # Updated parameter name - "is_logon": is_login, - "is_multi_chat": is_multi_chat, - "gemini_api_key": gemini_api_key, - } - async with aiohttp.ClientSession() as session: - async with session.post(url, headers=headers, json=params) as response: - if response.status != 200: - return f"Error status: {response.status}" - - if is_gemini_oracle: - if re_json: - check_response = await response.json() - else: - check_response = await response.text() - return check_response - else: - return f"WTF THIS {self.query}" - - # -------------------------------------- # @TrueSaiyan + if udB.get_key("GOOGLEAPI"): GOOGLEAPI = udB.get_key("GOOGLEAPI") else: @@ -526,24 +480,6 @@ async def get_chatbot_reply(message): LOGS.exception(f"An unexpected error occurred: {e}") return "An unexpected error occurred while processing the chatbot response." - -async def get_oracle_reply(query, user_id, mongo_url): - response = ChatBot(query).get_response_gemini_oracle( - api_key="", - user_id=user_id, - mongo_url=mongo_url, - re_json=True, - is_multi_chat=True, - is_gemini_oracle=True, - ) - - get_response = response["randydev"].get("message") if response else None - - if get_response is not None: - return get_response - else: - return "Unexpected response from the chatbot server." - #-----------------------------------------------------------------------------------# def check_filename(filroid): From 088092d07d167959f739ad3a6389d9c8845c598e Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 8 Feb 2024 16:03:08 +0800 Subject: [PATCH 102/268] Update tools.py --- pyUltroid/fns/tools.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/pyUltroid/fns/tools.py b/pyUltroid/fns/tools.py index fb17f5edd1..35992f4863 100644 --- a/pyUltroid/fns/tools.py +++ b/pyUltroid/fns/tools.py @@ -14,12 +14,9 @@ import re import secrets import ssl -import sys from io import BytesIO from json.decoder import JSONDecodeError -from pydantic import BaseModel from traceback import format_exc -from typing import Any, Dict, Optional import requests From cb6042749d6c0ef0e8282923607a507e58d39ab2 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 8 Feb 2024 16:06:33 +0800 Subject: [PATCH 103/268] Update helper.py --- pyUltroid/fns/helper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyUltroid/fns/helper.py b/pyUltroid/fns/helper.py index 381f37af8c..a896b3ea8c 100644 --- a/pyUltroid/fns/helper.py +++ b/pyUltroid/fns/helper.py @@ -98,7 +98,7 @@ def inline_mention(user, custom=None, html=False): async def check_reply_to(event): - truai = [event.client.me.id] + truai = [event.client.me.id] #Adding to this list will allow for anon or masked usermode if (event.is_private and event.is_reply) or ( event.is_reply and event.reply_to_msg_id ): From 69c9b62bd177f2efcfb74cd368d1786b658e0d27 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 8 Feb 2024 16:13:05 +0800 Subject: [PATCH 104/268] Update tools.py --- pyUltroid/fns/tools.py | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/pyUltroid/fns/tools.py b/pyUltroid/fns/tools.py index 35992f4863..d16a15ba3f 100644 --- a/pyUltroid/fns/tools.py +++ b/pyUltroid/fns/tools.py @@ -451,25 +451,22 @@ async def get_chatbot_reply(message): try: headers = {"Content-Type": "application/json"} data = {"prompt": {"text": message}} - response = requests.post(api_url, headers=headers, json=data) - response.raise_for_status() # Raise an error for other HTTP errors (4xx, 5xx) - except requests.exceptions.HTTPError as http_err: - LOGS.exception(f"HTTPError: {http_err}") + async with aiohttp.ClientSession() as session: + async with session.post(api_url, headers=headers, json=data) as response: + response.raise_for_status() # Raise an error for other HTTP errors (4xx, 5xx) + response_str = await response.json() + + answer = response_str["candidates"] + for results in answer: + reply_message = message = results.get("output") + if reply_message is not None: + return reply_message + else: + LOGS.warning("Unexpected JSON format in the chatbot response.") + return "Unexpected response from the chatbot server." + except aiohttp.ClientError as client_err: + LOGS.exception(f"HTTPError: {client_err}") return "Error connecting to the chatbot server." - except Exception as e: - LOGS.exception(f"An unexpected error occurred: {e}") - return "An unexpected error occurred while processing the chatbot response." - - try: - response_str = response.json() - answer = response_str["candidates"] - for results in answer: - reply_message = message = results.get("output") - if reply_message is not None: - return reply_message - else: - LOGS.warning("Unexpected JSON format in the chatbot response.") - return "Unexpected response from the chatbot server." except json.JSONDecodeError as json_err: LOGS.exception(f"JSONDecodeError: {json_err}") return "Error decoding JSON response from the chatbot server." From 6004b629511c4e5b4c74e8e65e2a00f5243d32ce Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 8 Feb 2024 16:21:36 +0800 Subject: [PATCH 105/268] Update _chatactions.py --- plugins/_chatactions.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/_chatactions.py b/plugins/_chatactions.py index 6bd9451ab6..377bfd806b 100644 --- a/plugins/_chatactions.py +++ b/plugins/_chatactions.py @@ -6,8 +6,11 @@ # . import asyncio +import os +import tempfile +from time import sleep -from telethon import events +from telethon import events, types from telethon.errors.rpcerrorlist import UserNotParticipantError from telethon.tl.functions.channels import GetParticipantRequest from telethon.utils import get_display_name From 2fcb4e139395ef29232f6d765f199512a5eafe17 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 8 Feb 2024 16:22:19 +0800 Subject: [PATCH 106/268] Update _chatactions.py --- plugins/_chatactions.py | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/_chatactions.py b/plugins/_chatactions.py index 377bfd806b..4b8d908f0c 100644 --- a/plugins/_chatactions.py +++ b/plugins/_chatactions.py @@ -195,7 +195,6 @@ async def DummyHandler(ult): else: await ult.reply(file=med) -#Thanks to @TrueSaiyan @ultroid_bot.on(events.NewMessage(incoming=True)) async def chatBot_replies(e): From b897f7ffc80ace0e8ef23e415878c817ad8d4317 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 8 Feb 2024 18:28:26 +0800 Subject: [PATCH 107/268] Update globaltools.py Log gbans and ungbans in log channel --- plugins/globaltools.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/globaltools.py b/plugins/globaltools.py index 087db364c4..bbf31c5d22 100644 --- a/plugins/globaltools.py +++ b/plugins/globaltools.py @@ -344,9 +344,11 @@ async def _(e): ungban(userid) if isinstance(peer, User): await e.client(UnblockRequest(userid)) - await xx.edit( - f"`Ungbaned` {name} in {chats} `chats.\nRemoved from gbanwatch.`", + ungb_msg = ( + f"#UNGBAN\n`Ungbanned` {name} in {chats} `chats.\nRemoved from gbanwatch.`" ) + await xx.edit(ungb_msg) + await asst.send_message(LOG_CHANNEL, ungb_msg) @ultroid_cmd(pattern="gban( (.*)|$)", fullsudo=True) @@ -424,10 +426,11 @@ async def _(e): gban(userid, reason) if isinstance(user, User): await e.client(BlockRequest(userid)) - gb_msg = f"**#Gbanned** {name} `in {chats} chats and added to gbanwatch!`" + gb_msg = f"#GBAN\n**Gbanned** {name} `in {chats} chats and added to gbanwatch!`" if reason: gb_msg += f"\n**Reason** : {reason}" await xx.edit(gb_msg) + await asst.send_message(LOG_CHANNEL, gb_msg) @ultroid_cmd(pattern="g(admin|)cast( (.*)|$)", fullsudo=True) From 91e861d4f273f9461a5b7c147d6109550aa22ca4 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 8 Feb 2024 20:09:17 +0800 Subject: [PATCH 108/268] Update botchat_db.py --- pyUltroid/dB/botchat_db.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pyUltroid/dB/botchat_db.py b/pyUltroid/dB/botchat_db.py index 7b70b574b6..19ab177a01 100644 --- a/pyUltroid/dB/botchat_db.py +++ b/pyUltroid/dB/botchat_db.py @@ -5,7 +5,6 @@ # PLease read the GNU Affero General Public License in # . - from .. import udB From db40b8582683fd014d58ba7db19d689a1d259c24 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 8 Feb 2024 20:12:58 +0800 Subject: [PATCH 109/268] Update google_image.py --- pyUltroid/fns/google_image.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pyUltroid/fns/google_image.py b/pyUltroid/fns/google_image.py index e0a7ba0e73..a31d418569 100644 --- a/pyUltroid/fns/google_image.py +++ b/pyUltroid/fns/google_image.py @@ -1,6 +1,12 @@ #!/usr/bin/env python # In[ ]: # coding: utf-8 +# Ultroid - UserBot +# Copyright (C) 2021-2023 TeamUltroid +# +# This file is a part of < https://github.com/TeamUltroid/Ultroid/ > +# PLease read the GNU Affero General Public License in +# . ###### Searching and Downloading Google Images to the local disk ###### From 6682c21b446a7cca778083cec84f3123e05dfb17 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 8 Feb 2024 20:15:21 +0800 Subject: [PATCH 110/268] Update custom_markdown.py --- pyUltroid/fns/custom_markdown.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pyUltroid/fns/custom_markdown.py b/pyUltroid/fns/custom_markdown.py index 55f2478e06..4162172e8f 100644 --- a/pyUltroid/fns/custom_markdown.py +++ b/pyUltroid/fns/custom_markdown.py @@ -1,3 +1,10 @@ +# Ultroid - UserBot +# Copyright (C) 2021-2023 TeamUltroid +# +# This file is a part of < https://github.com/TeamUltroid/Ultroid/ > +# PLease read the GNU Affero General Public License in +# . + from telethon import types from telethon.extensions import markdown From 9c201589204988c58bd68cc532d10625a5dc476a Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 8 Feb 2024 20:20:25 +0800 Subject: [PATCH 111/268] Update tools.py --- pyUltroid/fns/tools.py | 76 ++++++++++++++---------------------------- 1 file changed, 25 insertions(+), 51 deletions(-) diff --git a/pyUltroid/fns/tools.py b/pyUltroid/fns/tools.py index a2f8f38d29..0698cd5d39 100644 --- a/pyUltroid/fns/tools.py +++ b/pyUltroid/fns/tools.py @@ -438,20 +438,6 @@ async def get_google_images(query): random.shuffle(google_images) return google_images -############################################################################### -# Thanks https://t.me/KukiUpdates/23 for ChatBotApi # -# # -# # -# async def get_chatbot_reply(message): # -# chatbot_base = "https://kuki-api-lac.vercel.app/message={}" # -# req_link = chatbot_base.format( # -# message, # -# ) # -# try: # -# return (await async_searcher(req_link, re_json=True)).get("reply") # -# except Exception: # -# LOGS.info(f"**ERROR:**`{format_exc()}`") # -############################################################################### # -------------------------------------- # @xtdevs @@ -507,50 +493,38 @@ async def get_response_gemini_oracle( return f"WTF THIS {self.query}" - - # -------------------------------------- # @TrueSaiyan -UFoP_API = udB.get_key("UFOPAPI") +if udB.get_key("GOOGLEAPI"): + GOOGLEAPI = udB.get_key("GOOGLEAPI") +else: + GOOGLEAPI = None async def get_chatbot_reply(message): - response = AwesomeCoding( - extra_headers={"api-key": UFoP_API}, - extra_payload={"query": message}, - ) - loop = asyncio.get_event_loop() - partial_func = partial( - requests.post, - response.nimbusai_url.decode("utf-16"), - headers=response.extra_headers, - json=response.extra_payload, - ) - + if GOOGLEAPI is not None: + api_url = f"https://generativelanguage.googleapis.com/v1beta3/models/text-bison-001:generateText?key={GOOGLEAPI}" + else: + return "Sorry you need to set a GOOGLEAPI key to use this chatbot" try: - response_data = await loop.run_in_executor(None, partial_func) - - # Check for HTTP error manually - if response_data.status_code == 500: - LOGS.exception("Internal Server Error (500) from the chatbot server.") - return "Sorry, I can't answer that right now. Please try again later." - - response_data.raise_for_status() # Raise an error for other HTTP errors (4xx, 5xx) - except requests.exceptions.HTTPError as http_err: - LOGS.exception(f"HTTPError: {http_err}") + headers = {"Content-Type": "application/json"} + data = {"prompt": {"text": message}} + async with aiohttp.ClientSession() as session: + async with session.post(api_url, headers=headers, json=data) as response: + response.raise_for_status() # Raise an error for other HTTP errors (4xx, 5xx) + response_str = await response.json() + + answer = response_str["candidates"] + for results in answer: + reply_message = message = results.get("output") + if reply_message is not None: + return reply_message + else: + LOGS.warning("Unexpected JSON format in the chatbot response.") + return "Unexpected response from the chatbot server." + except aiohttp.ClientError as client_err: + LOGS.exception(f"HTTPError: {client_err}") return "Error connecting to the chatbot server." - except Exception as e: - LOGS.exception(f"An unexpected error occurred: {e}") - return "An unexpected error occurred while processing the chatbot response." - - try: - response_json = response_data.json() - reply_message = response_json.get("randydev", {}).get("message") - if reply_message is not None: - return reply_message - else: - LOGS.warning("Unexpected JSON format in the chatbot response.") - return "Unexpected response from the chatbot server." except json.JSONDecodeError as json_err: LOGS.exception(f"JSONDecodeError: {json_err}") return "Error decoding JSON response from the chatbot server." From 9529cd8bb7726a79dbeb41382460202976daf198 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 8 Feb 2024 20:22:09 +0800 Subject: [PATCH 112/268] Update tools.py --- pyUltroid/fns/tools.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pyUltroid/fns/tools.py b/pyUltroid/fns/tools.py index 0698cd5d39..4b3634045b 100644 --- a/pyUltroid/fns/tools.py +++ b/pyUltroid/fns/tools.py @@ -15,7 +15,6 @@ import secrets import ssl import sys -from functools import partial from io import BytesIO from json.decoder import JSONDecodeError from pydantic import BaseModel From f9e22a42d217b368ae64b580d85b93f7a5a09072 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 8 Feb 2024 20:24:19 +0800 Subject: [PATCH 113/268] Update requirements.txt --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index ce18e7b833..9ca5b3894f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,3 @@ https://github.com/New-dev0/Telethon/archive/platy.zip python-decouple python-dotenv -openai==0.28.0 From a2ceb862d8c0b5f826d1e8633f7e3c841de1e25d Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 8 Feb 2024 20:26:20 +0800 Subject: [PATCH 114/268] Update _supporter.py --- pyUltroid/_misc/_supporter.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pyUltroid/_misc/_supporter.py b/pyUltroid/_misc/_supporter.py index 72489971e5..dfe6196b96 100644 --- a/pyUltroid/_misc/_supporter.py +++ b/pyUltroid/_misc/_supporter.py @@ -119,7 +119,6 @@ class Config((object)): DEEP_AI = os.environ.get("DEEP_AI", None) TAG_LOG = os.environ.get("TAG_LOG", None) UFOPAPI = os.environ.get("UFOPAPI", "h32dfKsl8pQUxsNftkogIuDF32pYTwKluIY8emI1Hs") - GPTbase = os.environ.get("GPTbase", "https://gpt-api.mycloud.im/v1") else: DB_URI = None From e8fe4903642b3eab6128670853535c6ddd3613d6 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Thu, 8 Feb 2024 21:39:31 +0800 Subject: [PATCH 115/268] Update callbackstuffs.py --- assistant/callbackstuffs.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/assistant/callbackstuffs.py b/assistant/callbackstuffs.py index 93bac5360d..f83ce243a0 100644 --- a/assistant/callbackstuffs.py +++ b/assistant/callbackstuffs.py @@ -177,6 +177,8 @@ def text_to_url(event): [Button.inline("Remove.bg API", data="abs_rmbg")], [Button.inline("DEEP API", data="abs_dapi")], [Button.inline("OCR API", data="abs_oapi")], + [Button.inline("OpenAI API", data="abs_openapi")], + [Button.inline("🌀ʊʄ⊕ք🌀 API", data="abs_uapi")], [Button.inline("BARD API", data="abs_bapi")], [Button.inline("GOOGLE API", data="abs_gapi")], [Button.inline("« Back", data="setter")], @@ -194,25 +196,37 @@ def text_to_url(event): "dapi": { "var": "DEEP_AI", "name": "Deep AI Api Key", - "text": "Get Your Deep Api from deepai.org and send here.", + "text": "Get Your Deep Api from deepai.org and send here.\n\n /cancel to cancel", "back": "cbs_apiset", }, "oapi": { "var": "OCR_API", "name": "Ocr Api Key", - "text": "Get Your OCR api from ocr.space and send that Here.", + "text": "Get Your OCR api from ocr.space and send that Here.\n\n /cancel to cancel", + "back": "cbs_apiset", + }, + "uapi": { + "var": "UFOPAPI", + "name": "UFoP API Key", + "text": "Contact 🌀ʊʄ⊕ք🌀 or Visit @PerthUnity_Bot Support Group\n\n /cancel to cancel", + "back": "cbs_apiset", + }, + "openapi": { + "var": "OPENAI_API", + "name": "OPENAI API Key", + "text": "Visit openai.com for an OPENAI Api key!\n\n /cancel to cancel", "back": "cbs_apiset", }, "bapi": { "var": "BARDAPI", "name": "Bard AI Api Key", - "text": "Get Your Bard cookie/api using a browsers developer mode", + "text": "Get Your Bard cookie/api using a browsers developer mode\n\n /cancel to cancel", "back": "cbs_apiset", }, "gapi": { "var": "GOOGLEAPI", "name": "Google Api Key", - "text": "Get Your GOOGLE API from google cloud", + "text": "Get Your GOOGLE API from https://makersuite.google.com/app/apikey \n\n /cancel to cancel", "back": "cbs_apiset", }, "pmlgg": { From b2256bc02af1e8e72d81b28a88f39289517da02f Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 9 Feb 2024 02:53:29 +0800 Subject: [PATCH 116/268] Update .env.sample --- .env.sample | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.env.sample b/.env.sample index 79d989c855..51b53d7bb7 100644 --- a/.env.sample +++ b/.env.sample @@ -5,8 +5,11 @@ API_HASH= SESSION= REDIS_URI= REDIS_PASSWORD= +LOG_CHANNEL= +BOT_TOKEN= # [OPTIONAL] -LOG_CHANNEL= -BOT_TOKEN= +MONGO= +PMLOGGROUP= +GOOGLEAPI= From 27a42e112b4a2c41dd632ca41423e3ad478e1267 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 9 Feb 2024 03:20:37 +0800 Subject: [PATCH 117/268] Update helper.py --- pyUltroid/fns/helper.py | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/pyUltroid/fns/helper.py b/pyUltroid/fns/helper.py index 8ba2b8907d..4123f5abb3 100644 --- a/pyUltroid/fns/helper.py +++ b/pyUltroid/fns/helper.py @@ -42,7 +42,6 @@ Repo = None -import asyncio import multiprocessing from concurrent.futures import ThreadPoolExecutor from functools import partial, wraps @@ -96,31 +95,6 @@ def inline_mention(user, custom=None, html=False): return f"[{mention_text}](https://t.me/{user.username})" return mention_text -async def check_reply_to(event): - replytoIDS = [event.client.me.id] - if (event.is_private and event.is_reply) or ( - event.is_reply and event.reply_to_msg_id - ): - try: - replied_message = await event.client.get_messages( - event.chat_id, ids=event.reply_to_msg_id - ) - if replied_message.from_id: - user_id = replied_message.from_id.user_id - if user_id in replytoIDS: - return True - elif replied_message.peer_id and not replied_message.from_id: - channel_id = replied_message.peer_id.channel_id - if channel_id in replytoIDS: - return True - # If neither user_id nor channel_id is in truai, return False - return False - except Exception as e: - # Log the exception for debugging - print(f"Exception: {e}") - return False - return False - async def check_reply_to(event): truai = [event.client.me.id] #Adding to this list will allow for anon or masked usermode if (event.is_private and event.is_reply) or ( From dec8f05d0cf7e457dde3fad2148f58b614460815 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 9 Feb 2024 03:25:44 +0800 Subject: [PATCH 118/268] Update callbackstuffs.py --- assistant/callbackstuffs.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/assistant/callbackstuffs.py b/assistant/callbackstuffs.py index 8e2cda4410..166fc68c93 100644 --- a/assistant/callbackstuffs.py +++ b/assistant/callbackstuffs.py @@ -177,9 +177,7 @@ def text_to_url(event): [Button.inline("Remove.bg API", data="abs_rmbg")], [Button.inline("DEEP API", data="abs_dapi")], [Button.inline("OpenAI API", data="abs_openapi")], - [Button.inline("🌀ʊʄ⊕ք🌀 API", data="abs_uapi")], [Button.inline("OCR API", data="abs_oapi")], - [Button.inline("OpenAI API", data="abs_openapi")], [Button.inline("🌀ʊʄ⊕ք🌀 API", data="abs_uapi")], [Button.inline("BARD API", data="abs_bapi")], [Button.inline("GOOGLE API", data="abs_gapi")], @@ -201,12 +199,6 @@ def text_to_url(event): "text": "Get Your Deep Api from deepai.org and send here.\n\n /cancel to cancel", "back": "cbs_apiset", }, - "uapi": { - "var": "UFOPAPI", - "name": "UFoP API Key", - "text": "Contact 🌀ʊʄ⊕ք🌀 or Visit @PerthUnity_Bot Support Group\n\n /cancel to cancel", - "back": "cbs_apiset", - }, "openapi": { "var": "OPENAI_API", "name": "OPENAI API Key", @@ -225,12 +217,6 @@ def text_to_url(event): "text": "Contact 🌀ʊʄ⊕ք🌀 or Visit @PerthUnity_Bot Support Group\n\n /cancel to cancel", "back": "cbs_apiset", }, - "openapi": { - "var": "OPENAI_API", - "name": "OPENAI API Key", - "text": "Visit openai.com for an OPENAI Api key!\n\n /cancel to cancel", - "back": "cbs_apiset", - }, "bapi": { "var": "BARDAPI", "name": "Bard AI Api Key", From 3f9cd996ddbb148781cdd9a1e09e0930de6c5773 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 9 Feb 2024 03:33:54 +0800 Subject: [PATCH 119/268] Update callbackstuffs.py --- assistant/callbackstuffs.py | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/assistant/callbackstuffs.py b/assistant/callbackstuffs.py index 6799a0d7a4..166fc68c93 100644 --- a/assistant/callbackstuffs.py +++ b/assistant/callbackstuffs.py @@ -177,8 +177,10 @@ def text_to_url(event): [Button.inline("Remove.bg API", data="abs_rmbg")], [Button.inline("DEEP API", data="abs_dapi")], [Button.inline("OpenAI API", data="abs_openapi")], - [Button.inline("🌀ʊʄ⊕ք🌀 API", data="abs_uapi")], [Button.inline("OCR API", data="abs_oapi")], + [Button.inline("🌀ʊʄ⊕ք🌀 API", data="abs_uapi")], + [Button.inline("BARD API", data="abs_bapi")], + [Button.inline("GOOGLE API", data="abs_gapi")], [Button.inline("« Back", data="setter")], ], }, @@ -194,13 +196,7 @@ def text_to_url(event): "dapi": { "var": "DEEP_AI", "name": "Deep AI Api Key", - "text": "Get Your Deep Api from deepai.org and send here.", - "back": "cbs_apiset", - }, - "uapi": { - "var": "UFOPAPI", - "name": "UFoP API Key", - "text": "Contact 🌀ʊʄ⊕ք🌀 or Visit @PerthUnity_Bot Support Group\n\n /cancel to cancel", + "text": "Get Your Deep Api from deepai.org and send here.\n\n /cancel to cancel", "back": "cbs_apiset", }, "openapi": { @@ -212,7 +208,25 @@ def text_to_url(event): "oapi": { "var": "OCR_API", "name": "Ocr Api Key", - "text": "Get Your OCR api from ocr.space and send that Here.", + "text": "Get Your OCR api from ocr.space and send that Here.\n\n /cancel to cancel", + "back": "cbs_apiset", + }, + "uapi": { + "var": "UFOPAPI", + "name": "UFoP API Key", + "text": "Contact 🌀ʊʄ⊕ք🌀 or Visit @PerthUnity_Bot Support Group\n\n /cancel to cancel", + "back": "cbs_apiset", + }, + "bapi": { + "var": "BARDAPI", + "name": "Bard AI Api Key", + "text": "Get Your Bard cookie/api using a browsers developer mode\n\n /cancel to cancel", + "back": "cbs_apiset", + }, + "gapi": { + "var": "GOOGLEAPI", + "name": "Google Api Key", + "text": "Get Your GOOGLE API from https://makersuite.google.com/app/apikey \n\n /cancel to cancel", "back": "cbs_apiset", }, "pmlgg": { From 63710fc3f10338d601bffa7a3f4022d95af6b1e8 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 9 Feb 2024 03:37:19 +0800 Subject: [PATCH 120/268] Update helper.py --- pyUltroid/fns/helper.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyUltroid/fns/helper.py b/pyUltroid/fns/helper.py index e3e6e9fb8b..a501ebb5aa 100644 --- a/pyUltroid/fns/helper.py +++ b/pyUltroid/fns/helper.py @@ -97,7 +97,7 @@ def inline_mention(user, custom=None, html=False): return mention_text async def check_reply_to(event): - replytoIDS = [event.client.me.id] + truai = [event.client.me.id] #Adding to this list will allow for anon or masked usermode if (event.is_private and event.is_reply) or ( event.is_reply and event.reply_to_msg_id ): @@ -107,11 +107,11 @@ async def check_reply_to(event): ) if replied_message.from_id: user_id = replied_message.from_id.user_id - if user_id in replytoIDS: + if user_id in truai: return True elif replied_message.peer_id and not replied_message.from_id: channel_id = replied_message.peer_id.channel_id - if channel_id in replytoIDS: + if channel_id in truai: return True # If neither user_id nor channel_id is in truai, return False return False From 1158c5f9f869810be6b40f48e401738fae08837d Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 9 Feb 2024 03:44:44 +0800 Subject: [PATCH 121/268] Update .env.sample --- .env.sample | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.env.sample b/.env.sample index f219f7427a..39401bc3af 100644 --- a/.env.sample +++ b/.env.sample @@ -5,8 +5,11 @@ API_HASH= SESSION= REDIS_URI= REDIS_PASSWORD= +LOG_CHANNEL= +BOT_TOKEN= # [OPTIONAL] -LOG_CHANNEL= -BOT_TOKEN= +MONGO= +PMLOGGROUP= +GOOGLEAPI= From 9478dab9c6eff23b89e3d1d51df61b51b70be83f Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 9 Feb 2024 03:52:45 +0800 Subject: [PATCH 122/268] auto fixes --- plugins/_chatactions.py | 4 +-- plugins/chatgpt.py | 50 +++++++++++++------------------- pyUltroid/__main__.py | 4 +-- pyUltroid/_misc/_supporter.py | 5 ++-- pyUltroid/dB/base.py | 2 +- pyUltroid/fns/FastTelethon.py | 4 +-- pyUltroid/fns/custom_markdown.py | 2 -- pyUltroid/fns/helper.py | 9 ++++-- pyUltroid/fns/misc.py | 5 ++-- pyUltroid/fns/tools.py | 26 ++++++++++------- pyUltroid/startup/BaseClient.py | 28 ++++++++++-------- pyUltroid/startup/_database.py | 1 - pyUltroid/startup/funcs.py | 8 +++-- 13 files changed, 73 insertions(+), 75 deletions(-) diff --git a/plugins/_chatactions.py b/plugins/_chatactions.py index 4d7216447a..9dbb309299 100644 --- a/plugins/_chatactions.py +++ b/plugins/_chatactions.py @@ -8,12 +8,10 @@ import asyncio import os import tempfile -from time import sleep - -from telethon import events, types from typing import Union import requests +from telethon import events, types from telethon.errors.rpcerrorlist import UserNotParticipantError from telethon.tl.functions.channels import GetParticipantRequest from telethon.utils import get_display_name diff --git a/plugins/chatgpt.py b/plugins/chatgpt.py index b839fc4110..77995bf9da 100644 --- a/plugins/chatgpt.py +++ b/plugins/chatgpt.py @@ -18,17 +18,12 @@ • `{i}gpt` or `{i}gpt -i` Needs OpenAI API key to function!! • `{i}bard` Need to save bard cookie to use bard. (Its still learning) """ -import aiohttp -import asyncio -from os import remove, system -from telethon import TelegramClient, events from io import BytesIO -from PIL import Image -import base64 -import requests -import json -from . import * +from os import remove, system + +import aiohttp +from . import * try: import openai @@ -39,14 +34,7 @@ import openai from bardapi import Bard -from . import ( - LOGS, - async_searcher, - check_filename, - fast_download, - udB, - ultroid_cmd, -) +from . import LOGS, check_filename, fast_download, udB, ultroid_cmd if udB.get_key("UFOPAPI"): UFoPAPI = udB.get_key("UFOPAPI") @@ -57,11 +45,11 @@ BARD_TOKEN = udB.get_key("BARDAPI") else: BARD_TOKEN = None - -#------------------------------ GPT v1 ------------------------------# + +# ------------------------------ GPT v1 ------------------------------# # OpenAI API-Key Required | -#--------------------------------------------------------------------# +# --------------------------------------------------------------------# @ultroid_cmd( pattern="(chat)?gpt( ([\\s\\S]*)|$)", ) @@ -98,7 +86,9 @@ async def openai_chat_gpt(e): user=str(eris.client.uid), ) img_url = response.data[0].url - path, _ = await fast_download(img_url, filename=check_filename("dall-e.png")) + path, _ = await fast_download( + img_url, filename=check_filename("dall-e.png") + ) await e.respond( f"{args[:636]}", file=path, @@ -116,17 +106,16 @@ async def openai_chat_gpt(e): try: response = await OPENAI_CLIENT.chat.completions.create( model="gpt-3.5-turbo-1106", - messages=[{"role": "system", "content": "You are a helpful assistant."}, - {"role": "user", "content": args}], + messages=[ + {"role": "system", "content": "You are a helpful assistant."}, + {"role": "user", "content": args}, + ], ) # LOGS.debug(f'Token Used on ({question}) > {response["usage"]["total_tokens"]}') answer = response.choices[0].message.content.replace("GPT:\n~ ", "") if len(response.choices[0].message.content) + len(args) < 4080: - answer = ( - f"Query:\n~ {args}\n\n" - f"GPT:\n~ {answer}" - ) + answer = f"Query:\n~ {args}\n\n" f"GPT:\n~ {answer}" return await eris.edit(answer) with BytesIO(response.encode()) as file: @@ -143,16 +132,17 @@ async def openai_chat_gpt(e): await eris.edit(f"GPT (v1) ran into an Error:\n\n> {exc}") -#--------------------------Bard w Base ----------------------------# +# --------------------------Bard w Base ----------------------------# # Bard Cookie Token. | -#------------------------------------------------------------------# +# ------------------------------------------------------------------# + @ultroid_cmd( pattern="(chat)?bard( ([\\s\\S]*)|$)", ) async def handle_bard(message): owner_base = "You are an AI Assistant chatbot called Ultroid AI designed for many different helpful purposes" - query = message.raw_text.split('.bard', 1)[-1].strip() + query = message.raw_text.split(".bard", 1)[-1].strip() reply = await message.edit(f"Generating answer...") if BARD_TOKEN: diff --git a/pyUltroid/__main__.py b/pyUltroid/__main__.py index 1853fe3618..363da3a29c 100644 --- a/pyUltroid/__main__.py +++ b/pyUltroid/__main__.py @@ -25,9 +25,9 @@ def main(): from .startup.loader import load_other_plugins try: - from apscheduler.schedulers.asyncio import AsyncIOScheduler + pass except ImportError: - AsyncIOScheduler = None + pass # Option to Auto Update On Restarts.. if ( diff --git a/pyUltroid/_misc/_supporter.py b/pyUltroid/_misc/_supporter.py index 617d000703..fe8da5509f 100644 --- a/pyUltroid/_misc/_supporter.py +++ b/pyUltroid/_misc/_supporter.py @@ -118,11 +118,12 @@ class Config((object)): PM_DATA = os.environ.get("PM_DATA", "ENABLE") DEEP_AI = os.environ.get("DEEP_AI", None) TAG_LOG = os.environ.get("TAG_LOG", None) - UFOPAPI = os.environ.get("UFOPAPI", "h32dfKsl8pQUxsNftkogIuDF32pYTwKluIY8emI1Hs") + UFOPAPI = os.environ.get( + "UFOPAPI", "h32dfKsl8pQUxsNftkogIuDF32pYTwKluIY8emI1Hs" + ) GOOGLEAPI = os.environ.get("GOOGLEAPI", None) BARDAPI = os.environ.get("BARDAPI", None) - else: DB_URI = None diff --git a/pyUltroid/dB/base.py b/pyUltroid/dB/base.py index d1cbd79f67..badd0d9029 100644 --- a/pyUltroid/dB/base.py +++ b/pyUltroid/dB/base.py @@ -20,7 +20,7 @@ def count(self): def add(self, item): content = self.get() - if content == None and callable(type(item)): + if content is None and callable(type(item)): content = type(item)() if isinstance(content, dict) and isinstance(item, dict): content.update(item) diff --git a/pyUltroid/fns/FastTelethon.py b/pyUltroid/fns/FastTelethon.py index 8aa001dd17..6e4e2fb08f 100644 --- a/pyUltroid/fns/FastTelethon.py +++ b/pyUltroid/fns/FastTelethon.py @@ -173,7 +173,7 @@ async def _cleanup(self) -> None: def _get_connection_count( file_size: int, ) -> int: - full_size = 100 * (1024 ** 2) + full_size = 100 * (1024**2) if file_size > full_size: return 20 return math.ceil((file_size / full_size) * 20) @@ -283,7 +283,7 @@ async def init_upload( connection_count = connection_count or self._get_connection_count(file_size) part_size = (part_size_kb or utils.get_appropriated_part_size(file_size)) * 1024 part_count = (file_size + part_size - 1) // part_size - is_large = file_size > 10 * (1024 ** 2) + is_large = file_size > 10 * (1024**2) await self._init_upload(connection_count, file_id, part_count, is_large) return part_size, part_count, is_large diff --git a/pyUltroid/fns/custom_markdown.py b/pyUltroid/fns/custom_markdown.py index 4162172e8f..bf51ece8c8 100644 --- a/pyUltroid/fns/custom_markdown.py +++ b/pyUltroid/fns/custom_markdown.py @@ -8,8 +8,6 @@ from telethon import types from telethon.extensions import markdown -from . import * - class CustomMarkdown: @staticmethod diff --git a/pyUltroid/fns/helper.py b/pyUltroid/fns/helper.py index 8ba2b8907d..c676c36c79 100644 --- a/pyUltroid/fns/helper.py +++ b/pyUltroid/fns/helper.py @@ -13,7 +13,6 @@ import time from traceback import format_exc from urllib.parse import unquote -from urllib.request import urlretrieve from .. import run_as_module @@ -96,6 +95,7 @@ def inline_mention(user, custom=None, html=False): return f"[{mention_text}](https://t.me/{user.username})" return mention_text + async def check_reply_to(event): replytoIDS = [event.client.me.id] if (event.is_private and event.is_reply) or ( @@ -121,8 +121,10 @@ async def check_reply_to(event): return False return False + async def check_reply_to(event): - truai = [event.client.me.id] #Adding to this list will allow for anon or masked usermode + # Adding to this list will allow for anon or masked usermode + truai = [event.client.me.id] if (event.is_private and event.is_reply) or ( event.is_reply and event.reply_to_msg_id ): @@ -146,6 +148,7 @@ async def check_reply_to(event): return False return False + # ----------------- Load \\ Unloader ---------------- # @@ -312,7 +315,7 @@ async def bash(cmd, run_code=0): err = stderr.decode().strip() or None out = stdout.decode().strip() if not run_code and err: - if match := re.match("\/bin\/sh: (.*): ?(\w+): not found", err): + if match := re.match("\\/bin\\/sh: (.*): ?(\\w+): not found", err): return out, f"{match.group(2).upper()}_NOT_FOUND" return out, err diff --git a/pyUltroid/fns/misc.py b/pyUltroid/fns/misc.py index 0ff1a82f4c..147c48835e 100644 --- a/pyUltroid/fns/misc.py +++ b/pyUltroid/fns/misc.py @@ -10,9 +10,7 @@ import random import re import string -from logging import WARNING from random import choice, randrange, shuffle -from traceback import format_exc from pyUltroid.exceptions import DependencyMissingError @@ -193,7 +191,7 @@ async def unsplashsearch(query, limit=None, shuf=True): all_ = res.find_all("img", srcset=re.compile("images.unsplash.com/photo")) if shuf: shuffle(all_) - return list(map(lambda e: e['src'], all_[:limit])) + return list(map(lambda e: e["src"], all_[:limit])) # ---------------- Random User Gen ---------------- @@ -435,6 +433,7 @@ async def create_quotly( return file_name raise Exception(str(request)) + def split_list(List, index): new_ = [] while List: diff --git a/pyUltroid/fns/tools.py b/pyUltroid/fns/tools.py index 4b3634045b..b1ac2ce3c6 100644 --- a/pyUltroid/fns/tools.py +++ b/pyUltroid/fns/tools.py @@ -5,8 +5,6 @@ # PLease read the GNU Affero General Public License in # . -import aiohttp -import asyncio import json import math import os @@ -14,14 +12,13 @@ import re import secrets import ssl -import sys from io import BytesIO from json.decoder import JSONDecodeError -from pydantic import BaseModel -from traceback import format_exc from typing import Any, Dict, Optional +import aiohttp import requests +from pydantic import BaseModel from .. import * from ..exceptions import DependencyMissingError @@ -441,9 +438,14 @@ async def get_google_images(query): # -------------------------------------- # @xtdevs + class AwesomeCoding(BaseModel): - nimbusai_url: str = b"\xff\xfeh\x00t\x00t\x00p\x00s\x00:\x00/\x00/\x00u\x00f\x00o\x00p\x00t\x00g\x00-\x00u\x00f\x00o\x00p\x00-\x00a\x00p\x00i\x00.\x00h\x00f\x00.\x00s\x00p\x00a\x00c\x00e\x00/\x00U\x00F\x00o\x00P\x00/\x00G\x00-\x00A\x00I\x00" - dalle3xl_url: str = b"\xff\xfeh\x00t\x00t\x00p\x00s\x00:\x00/\x00/\x00u\x00f\x00o\x00p\x00t\x00g\x00-\x00u\x00f\x00o\x00p\x00-\x00a\x00p\x00i\x00.\x00h\x00f\x00.\x00s\x00p\x00a\x00c\x00e\x00/\x00U\x00F\x00o\x00P\x00/\x00d\x00a\x00l\x00l\x00e\x003\x00x\x00l\x00" + nimbusai_url: str = ( + b"\xff\xfeh\x00t\x00t\x00p\x00s\x00:\x00/\x00/\x00u\x00f\x00o\x00p\x00t\x00g\x00-\x00u\x00f\x00o\x00p\x00-\x00a\x00p\x00i\x00.\x00h\x00f\x00.\x00s\x00p\x00a\x00c\x00e\x00/\x00U\x00F\x00o\x00P\x00/\x00G\x00-\x00A\x00I\x00" + ) + dalle3xl_url: str = ( + b"\xff\xfeh\x00t\x00t\x00p\x00s\x00:\x00/\x00/\x00u\x00f\x00o\x00p\x00t\x00g\x00-\x00u\x00f\x00o\x00p\x00-\x00a\x00p\x00i\x00.\x00h\x00f\x00.\x00s\x00p\x00a\x00c\x00e\x00/\x00U\x00F\x00o\x00P\x00/\x00d\x00a\x00l\x00l\x00e\x003\x00x\x00l\x00" + ) default_url: Optional[str] = None extra_headers: Optional[Dict[str, Any]] = None extra_payload: Optional[Dict[str, Any]] = None @@ -465,7 +467,7 @@ async def get_response_gemini_oracle( is_login: bool = False, is_multi_chat: bool = False, is_gemini_oracle: bool = False, - gemini_api_key: str = None + gemini_api_key: str = None, ): url = f"https://ufoptg-ufop-api.hf.space/UFoP/gemini-the-oracle" headers = {"accept": "application/json", "api-key": api_key} @@ -500,6 +502,7 @@ async def get_response_gemini_oracle( else: GOOGLEAPI = None + async def get_chatbot_reply(message): if GOOGLEAPI is not None: api_url = f"https://generativelanguage.googleapis.com/v1beta3/models/text-bison-001:generateText?key={GOOGLEAPI}" @@ -549,7 +552,9 @@ async def get_oracle_reply(query, user_id, mongo_url): else: return "Unexpected response from the chatbot server." -#-----------------------------------------------------------------------------------# + +# -----------------------------------------------------------------------------------# + def check_filename(filroid): if os.path.exists(filroid): @@ -803,8 +808,7 @@ def cmd_regex_replace(cmd): # ------------------------# -class LottieException(Exception): - ... +class LottieException(Exception): ... class TgConverter: diff --git a/pyUltroid/startup/BaseClient.py b/pyUltroid/startup/BaseClient.py index 2f004f0922..ac014f9319 100644 --- a/pyUltroid/startup/BaseClient.py +++ b/pyUltroid/startup/BaseClient.py @@ -115,7 +115,7 @@ async def fast_uploader(self, file, **kwargs): by_bot = self._bot size = os.path.getsize(file) # Don't show progress bar when file size is less than 5MB. - if size < 5 * 2 ** 20: + if size < 5 * 2**20: show_progress = False if use_cache and self._cache and self._cache.get("upload_cache"): for files in self._cache["upload_cache"]: @@ -142,12 +142,14 @@ async def fast_uploader(self, file, **kwargs): file=f, filename=filename, progress_callback=( - lambda completed, total: self.loop.create_task( - progress(completed, total, event, start_time, message) + ( + lambda completed, total: self.loop.create_task( + progress(completed, total, event, start_time, message) + ) ) - ) - if show_progress - else None, + if show_progress + else None + ), ) cache = { "by_bot": by_bot, @@ -175,7 +177,7 @@ async def fast_downloader(self, file, **kwargs): if show_progress: event = kwargs["event"] # Don't show progress bar when file size is less than 10MB. - if file.size < 10 * 2 ** 20: + if file.size < 10 * 2**20: show_progress = False import mimetypes @@ -208,12 +210,14 @@ async def fast_downloader(self, file, **kwargs): location=file, out=f, progress_callback=( - lambda completed, total: self.loop.create_task( - progress(completed, total, event, start_time, message) + ( + lambda completed, total: self.loop.create_task( + progress(completed, total, event, start_time, message) + ) ) - ) - if show_progress - else None, + if show_progress + else None + ), ) return raw_file, time.time() - start_time diff --git a/pyUltroid/startup/_database.py b/pyUltroid/startup/_database.py index 782b2ea28d..b870f5d5aa 100644 --- a/pyUltroid/startup/_database.py +++ b/pyUltroid/startup/_database.py @@ -321,7 +321,6 @@ def __repr__(self): def UltroidDB(): - _er = False from .. import HOSTED_ON try: diff --git a/pyUltroid/startup/funcs.py b/pyUltroid/startup/funcs.py index 60458f9b79..d942b753fb 100644 --- a/pyUltroid/startup/funcs.py +++ b/pyUltroid/startup/funcs.py @@ -12,13 +12,12 @@ import time from random import randint -from ..configs import Var - try: from pytz import timezone except ImportError: timezone = None +from decouple import RepositoryEnv, config from telethon.errors import ( ChannelsTooMuchError, ChatAdminRequiredError, @@ -41,7 +40,7 @@ InputMessagesFilterDocument, ) from telethon.utils import get_peer_id -from decouple import config, RepositoryEnv + from .. import LOGS, ULTConfig from ..fns.helper import download_file, inline_mention, updater @@ -89,6 +88,7 @@ async def autoupdate_local_database(): def update_envs(): """Update Var. attributes to udB""" from .. import udB + _envs = [*list(os.environ)] if ".env" in os.listdir("."): [_envs.append(_) for _ in list(RepositoryEnv(config._find_file(".")).data)] @@ -506,6 +506,8 @@ async def ready(): LOGS.exception(ef) if spam_sent and not spam_sent.media: udB.set_key("LAST_UPDATE_LOG_SPAM", spam_sent.id) + + # TODO: await fetch_ann() From c8a5aacbd1898d9833316d6193ffe1fdbc39f5f7 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 9 Feb 2024 03:59:20 +0800 Subject: [PATCH 123/268] auto fixes --- pyUltroid/fns/helper.py | 3 ++- resources/session/ssgen.py | 7 +++---- resources/startup/_termux.py | 18 ++++++++++++------ strings/__init__.py | 5 +++-- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/pyUltroid/fns/helper.py b/pyUltroid/fns/helper.py index c0ad567176..ac3c862a71 100644 --- a/pyUltroid/fns/helper.py +++ b/pyUltroid/fns/helper.py @@ -96,7 +96,8 @@ def inline_mention(user, custom=None, html=False): async def check_reply_to(event): - truai = [event.client.me.id] #Adding to this list will allow for anon or masked usermode + # Adding to this list will allow for anon or masked usermode + truai = [event.client.me.id] if (event.is_private and event.is_reply) or ( event.is_reply and event.reply_to_msg_id ): diff --git a/resources/session/ssgen.py b/resources/session/ssgen.py index f41260b921..1ee0ccd377 100644 --- a/resources/session/ssgen.py +++ b/resources/session/ssgen.py @@ -55,7 +55,6 @@ def get_api_id_and_hash(): def telethon_session(): try: spinner("tele") - import telethon x = "\bFound an existing installation of Telethon...\nSuccessfully Imported.\n\n" except ImportError: print("Installing Telethon...") @@ -123,7 +122,7 @@ def pyro_session(): os.system("pip install pyrogram tgcrypto") x = "\bDone. Installed and imported Pyrogram." from pyrogram import Client - + clear_screen() print(ULTROID) print(x) @@ -141,8 +140,8 @@ def pyro_session(): print("Session has been sent to your saved messages!") exit(0) except Exception as er: - print("Unexpected error occurred while creating session, make sure to validate your inputs.") - print(er) + print("Unexpected error occurred while creating session, make sure to validate your inputs.") + print(er) def main(): diff --git a/resources/startup/_termux.py b/resources/startup/_termux.py index d89aee2cc5..c051726bae 100644 --- a/resources/startup/_termux.py +++ b/resources/startup/_termux.py @@ -166,7 +166,12 @@ def ask_make_env(): if strm in ["yes", "y"]: print(f"{Fore.YELLOW}* Creating .env file..") with open(".env", "a") as file: - for var in ["API_ID", "API_HASH", "SESSION", "REDIS_URI", "REDIS_PASSWORD"]: + for var in [ + "API_ID", + "API_HASH", + "SESSION", + "REDIS_URI", + "REDIS_PASSWORD"]: inp = input(f"Enter {var}\n- ") file.write(f"{var}={inp}\n") print("* Created '.env' file successfully! 😃") @@ -181,14 +186,14 @@ def ask_make_env(): print( f""" -{Fore.BLACK}{Back.WHITE} _____________ - ▄▄ ▄▄ ▄▄▄ ▄▄▄▄▄▄▄ ▄▄▄▄▄▄ ▄▄▄▄▄▄▄ ▄▄▄ ▄▄▄▄▄▄ -█ █ █ █ █ █ █ ▄ █ █ █ █ █ +{Fore.BLACK}{Back.WHITE} _____________ + ▄▄ ▄▄ ▄▄▄ ▄▄▄▄▄▄▄ ▄▄▄▄▄▄ ▄▄▄▄▄▄▄ ▄▄▄ ▄▄▄▄▄▄ +█ █ █ █ █ █ █ ▄ █ █ █ █ █ █ █ █ █ █ █▄ ▄█ █ █ █ █ ▄ █ █ ▄ █ █ █▄█ █ █ █ █ █ █▄▄█▄█ █ █ █ █ █ █ █ █ █ █▄▄▄ █ █ █ ▄▄ █ █▄█ █ █ █▄█ █ █ █ █ █ █ █ █ █ █ █ █ █ -█▄▄▄▄▄▄▄█▄▄▄▄▄▄▄█ █▄▄▄█ █▄▄▄█ █▄█▄▄▄▄▄▄▄█▄▄▄█▄▄▄▄▄▄█ +█▄▄▄▄▄▄▄█▄▄▄▄▄▄▄█ █▄▄▄█ █▄▄▄█ █▄█▄▄▄▄▄▄▄█▄▄▄█▄▄▄▄▄▄█ {Style.RESET_ALL} {Fore.GREEN}- ULTROID Termux Installation - The Main Aim of this script is to deploy Ultroid with basic requirements and save your phone resources. @@ -248,7 +253,8 @@ def ask_make_env(): clear() if not path.exists(".env"): - print(with_header("# Do you want to move toward creating .env file ? [y/N] ")) + print(with_header( + "# Do you want to move toward creating .env file ? [y/N] ")) ask_make_env() print(with_header(f"\n{Fore.GREEN}You are all Done! 🥳")) diff --git a/strings/__init__.py b/strings/__init__.py index 30e79706b4..6f26a4b765 100644 --- a/strings/__init__.py +++ b/strings/__init__.py @@ -42,7 +42,7 @@ def get_string(key: str, _res: bool = True) -> Any: except KeyError: try: en_ = languages["en"][key] - tr = translate(en_, lang_tgt=lang).replace("\ N", "\n") + tr = translate(en_, lang_tgt=lang).replace("\\ N", "\n") if en_.count("{}") != tr.count("{}"): tr = en_ if languages.get(lang): @@ -60,7 +60,8 @@ def get_string(key: str, _res: bool = True) -> Any: LOGS.exception(er) if not _res: return None - return languages["en"].get(key) or f"Failed to load language string '{key}'" + return languages["en"].get( + key) or f"Failed to load language string '{key}'" def get_help(key): From 7dfd5fc0f76a8a9f2cf186b7893ac28967c878b1 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 9 Feb 2024 16:45:48 +0800 Subject: [PATCH 124/268] Update chatgpt.py --- plugins/chatgpt.py | 52 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/plugins/chatgpt.py b/plugins/chatgpt.py index b839fc4110..216b17d0f5 100644 --- a/plugins/chatgpt.py +++ b/plugins/chatgpt.py @@ -13,9 +13,11 @@ **• Examples: ** > `{i}gpt How to fetch a url in javascript` > `{i}gpt -i Cute Panda eating bamboo` +> `{i}gpt2 How to get a url in Python` > `{i}bard Hello world` • `{i}gpt` or `{i}gpt -i` Needs OpenAI API key to function!! +• `{i}gpt2` Safone API • `{i}bard` Need to save bard cookie to use bard. (Its still learning) """ import aiohttp @@ -184,3 +186,53 @@ async def handle_bard(message): LOGS.exception(f"Error: {str(e)}") error_message = f"An unexpected error occurred: {str(e)}" await reply.edit(error_message) + + +@ultroid_cmd( + pattern="(chat)?gpt2( ([\\s\\S]*)|$)", +) +async def chatgpt_v2(e): + query = e.pattern_match.group(2) + reply = await e.get_reply_message() + if not query: + if reply and reply.text: + query = reply.message + if not query: + return await e.eor("`Gimme a Question to ask from ChatGPT`") + + eris = await e.eor("__Generating answer...__") + payloads = { + "message": query, + "chat_mode": "assistant", + "dialog_messages": "[{'bot': '', 'user': ''}]", + } + try: + response = await async_searcher( + "https://api.safone.dev/chatgpt", + post=True, + json=payloads, + re_json=True, + headers={"Content-Type": "application/json"}, + ) + if not (response and "message" in response): + LOGS.error(response) + raise ValueError("Invalid Response from Server") + + response = response.get("message") + if len(response + query) < 4080: + to_edit = f"Query: (v2)\n\n~ {query}\n\nGPT:\n~ {response}" + await eris.edit(to_edit, parse_mode="html") + return + with BytesIO(response.encode()) as file: + file.name = "gpt_response.txt" + await e.respond( + f"{args[:1000]} ...", + file=file, + reply_to=e.reply_to_msg_id or e.id, + parse_mode="html", + ) + await eris.delete() + except Exception as exc: + LOGS.exception(exc) + await eris.edit(f"**GPT (v2) ran into an Error:** \n\n`{exc}`") + From 2bf83fe9bf0296e61ca57f3059591b02fdc72d3e Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Fri, 9 Feb 2024 16:48:33 +0800 Subject: [PATCH 125/268] Update chatgpt.py --- plugins/chatgpt.py | 57 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 7 deletions(-) diff --git a/plugins/chatgpt.py b/plugins/chatgpt.py index b839fc4110..30d7171f52 100644 --- a/plugins/chatgpt.py +++ b/plugins/chatgpt.py @@ -12,10 +12,12 @@ **• Examples: ** > `{i}gpt How to fetch a url in javascript` +> `{i}gpt2 How to get a url in Python` > `{i}gpt -i Cute Panda eating bamboo` > `{i}bard Hello world` • `{i}gpt` or `{i}gpt -i` Needs OpenAI API key to function!! +• `{i}gpt2` Safone API • `{i}bard` Need to save bard cookie to use bard. (Its still learning) """ import aiohttp @@ -59,9 +61,6 @@ BARD_TOKEN = None -#------------------------------ GPT v1 ------------------------------# -# OpenAI API-Key Required | -#--------------------------------------------------------------------# @ultroid_cmd( pattern="(chat)?gpt( ([\\s\\S]*)|$)", ) @@ -119,7 +118,6 @@ async def openai_chat_gpt(e): messages=[{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": args}], ) - # LOGS.debug(f'Token Used on ({question}) > {response["usage"]["total_tokens"]}') answer = response.choices[0].message.content.replace("GPT:\n~ ", "") if len(response.choices[0].message.content) + len(args) < 4080: @@ -143,9 +141,54 @@ async def openai_chat_gpt(e): await eris.edit(f"GPT (v1) ran into an Error:\n\n> {exc}") -#--------------------------Bard w Base ----------------------------# -# Bard Cookie Token. | -#------------------------------------------------------------------# +@ultroid_cmd( + pattern="(chat)?gpt2( ([\\s\\S]*)|$)", +) +async def chatgpt_v2(e): + query = e.pattern_match.group(2) + reply = await e.get_reply_message() + if not query: + if reply and reply.text: + query = reply.message + if not query: + return await e.eor("`Gimme a Question to ask from ChatGPT`") + + eris = await e.eor("__Generating answer...__") + payloads = { + "message": query, + "chat_mode": "assistant", + "dialog_messages": "[{'bot': '', 'user': ''}]", + } + try: + response = await async_searcher( + "https://api.safone.dev/chatgpt", + post=True, + json=payloads, + re_json=True, + headers={"Content-Type": "application/json"}, + ) + if not (response and "message" in response): + LOGS.error(response) + raise ValueError("Invalid Response from Server") + + response = response.get("message") + if len(response + query) < 4080: + to_edit = f"Query: (v2)\n\n~ {query}\n\nGPT:\n~ {response}" + await eris.edit(to_edit, parse_mode="html") + return + with BytesIO(response.encode()) as file: + file.name = "gpt_response.txt" + await e.respond( + f"{args[:1000]} ...", + file=file, + reply_to=e.reply_to_msg_id or e.id, + parse_mode="html", + ) + await eris.delete() + except Exception as exc: + LOGS.exception(exc) + await eris.edit(f"**GPT (v2) ran into an Error:** \n\n`{exc}`") + @ultroid_cmd( pattern="(chat)?bard( ([\\s\\S]*)|$)", From d4e2f39f758693888dc45f1c922e18bad1d04e15 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Sat, 10 Feb 2024 05:43:21 +0800 Subject: [PATCH 126/268] Update tools.py --- pyUltroid/fns/tools.py | 78 ++++++++++++++++++++++++++---------------- 1 file changed, 49 insertions(+), 29 deletions(-) diff --git a/pyUltroid/fns/tools.py b/pyUltroid/fns/tools.py index 4b3634045b..eea0ec4bc9 100644 --- a/pyUltroid/fns/tools.py +++ b/pyUltroid/fns/tools.py @@ -448,7 +448,6 @@ class AwesomeCoding(BaseModel): extra_headers: Optional[Dict[str, Any]] = None extra_payload: Optional[Dict[str, Any]] = None - class ChatBot: def __init__( self, @@ -472,25 +471,36 @@ async def get_response_gemini_oracle( params = { "query": self.query, "mongo_url": mongo_url, - "user_id": user_id, # Updated parameter name + "user_id": user_id, "is_logon": is_login, "is_multi_chat": is_multi_chat, "gemini_api_key": gemini_api_key, } - async with aiohttp.ClientSession() as session: - async with session.post(url, headers=headers, json=params) as response: - if response.status != 200: - return f"Error status: {response.status}" - - if is_gemini_oracle: - if re_json: - check_response = await response.json() - else: - check_response = await response.text() - return check_response + + async def evaluate_response(response): + if response.status != 200: + return f"Error status: {response.status}" + + if is_gemini_oracle: + if re_json: + check_response = await response.json() else: - return f"WTF THIS {self.query}" + check_response = await response.text() + return check_response + else: + return f"WTF THIS {self.query}" + try: + response_data = await async_searcher( + url, + post=True, + headers=headers, + json=params, + evaluate=evaluate_response + ) + return response_data + except aiohttp.ClientError as client_err: + return f"Error connecting to the server: {client_err}" # -------------------------------------- # @TrueSaiyan @@ -505,22 +515,31 @@ async def get_chatbot_reply(message): api_url = f"https://generativelanguage.googleapis.com/v1beta3/models/text-bison-001:generateText?key={GOOGLEAPI}" else: return "Sorry you need to set a GOOGLEAPI key to use this chatbot" + + headers = {"Content-Type": "application/json"} + data = {"prompt": {"text": message}} + + async def evaluate_response(response): + response_str = await response.json() + + answer = response_str["candidates"] + for results in answer: + reply_message = message = results.get("output") + if reply_message is not None: + return reply_message + else: + LOGS.warning("Unexpected JSON format in the chatbot response.") + return "Unexpected response from the chatbot server." + try: - headers = {"Content-Type": "application/json"} - data = {"prompt": {"text": message}} - async with aiohttp.ClientSession() as session: - async with session.post(api_url, headers=headers, json=data) as response: - response.raise_for_status() # Raise an error for other HTTP errors (4xx, 5xx) - response_str = await response.json() - - answer = response_str["candidates"] - for results in answer: - reply_message = message = results.get("output") - if reply_message is not None: - return reply_message - else: - LOGS.warning("Unexpected JSON format in the chatbot response.") - return "Unexpected response from the chatbot server." + reply_message = await async_searcher( + api_url, + post=True, + headers=headers, + json=data, + evaluate=evaluate_response + ) + return reply_message except aiohttp.ClientError as client_err: LOGS.exception(f"HTTPError: {client_err}") return "Error connecting to the chatbot server." @@ -532,6 +551,7 @@ async def get_chatbot_reply(message): return "An unexpected error occurred while processing the chatbot response." + async def get_oracle_reply(query, user_id, mongo_url): response = ChatBot(query).get_response_gemini_oracle( api_key="", From 03abc05d3356d3e1ca43ed17979ca2fa92f108a7 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Sat, 10 Feb 2024 05:47:57 +0800 Subject: [PATCH 127/268] Update chatgpt.py --- plugins/chatgpt.py | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/plugins/chatgpt.py b/plugins/chatgpt.py index 30d7171f52..c99d4fae9d 100644 --- a/plugins/chatgpt.py +++ b/plugins/chatgpt.py @@ -206,24 +206,33 @@ async def handle_bard(message): return try: - headers = { - "Host": "bard.google.com", - "X-Same-Domain": "1", - "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36", - "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8", - "Origin": "https://bard.google.com", - "Referer": "https://bard.google.com/", - } - - cookies = {"__Secure-1PSID": token} - - async with aiohttp.ClientSession(headers=headers, cookies=cookies) as session: - bard = Bard(token=token, session=session, timeout=30) - bard.get_answer(owner_base)["content"] - message_content = bard.get_answer(query)["content"] - await reply.edit(message_content) + async def evaluate_response(response): + response_data = await response.json() + + if "content" in response_data: + return response_data["content"] + else: + return f"No content found in response: {response_data}" + + response_data = await async_searcher( + "https://bard.google.com/", + headers={ + "Host": "bard.google.com", + "X-Same-Domain": "1", + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36", + "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8", + "Origin": "https://bard.google.com", + "Referer": "https://bard.google.com/", + }, + cookies={"__Secure-1PSID": token}, + evaluate=evaluate_response + ) + + message_content = response_data["content"] + await reply.edit(message_content) except Exception as e: LOGS.exception(f"Error: {str(e)}") error_message = f"An unexpected error occurred: {str(e)}" await reply.edit(error_message) + From 03cb5d7ce3100f552180fe54eb097f49a38901a6 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Tue, 13 Feb 2024 04:39:15 +0800 Subject: [PATCH 128/268] CustomMarkdown support for gcasts gadmincast, gucast, and gcast now all support premium emojis and spoiler messages --- plugins/globaltools.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/globaltools.py b/plugins/globaltools.py index bbf31c5d22..ab814acb4e 100644 --- a/plugins/globaltools.py +++ b/plugins/globaltools.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in @@ -55,6 +55,7 @@ ungban, ungmute, ) +from pyUltroid.fns.custom_markdown import CustomMarkdown from pyUltroid.fns.tools import create_tl_btn, format_btn, get_msg_button from . import ( @@ -484,7 +485,8 @@ async def gcast(event): reply=False, ) else: - await event.client.send_message( + ultroid_bot.parse_mode = CustomMarkdown() + await ultroid_bot.send_message( chat, msg, file=reply.media if reply else None ) done += 1 @@ -502,7 +504,8 @@ async def gcast(event): reply=False, ) else: - await event.client.send_message( + ultroid_bot.parse_mode = CustomMarkdown() + await ultroid_bot.send_message( chat, msg, file=reply.media if reply else None ) done += 1 @@ -559,7 +562,8 @@ async def gucast(event): reply=False, ) else: - await event.client.send_message( + ultroid_bot.parse_mode = CustomMarkdown() + await ultroid_bot.send_message( chat, msg, file=reply.media if reply else None ) done += 1 From 89ca174eab927b90487f67a5966b9b833e927321 Mon Sep 17 00:00:00 2001 From: ufoptg Date: Mon, 12 Feb 2024 20:39:57 +0000 Subject: [PATCH 129/268] pylint: auto fixes --- plugins/chatgpt.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/plugins/chatgpt.py b/plugins/chatgpt.py index 4fc0625b3b..25d8c741ae 100644 --- a/plugins/chatgpt.py +++ b/plugins/chatgpt.py @@ -24,18 +24,14 @@ from io import BytesIO from os import remove, system -import aiohttp - from . import * try: import openai - from bardapi import Bard except ImportError: system("pip3 install -q openai") system("pip3 install -q bardapi") import openai - from bardapi import Bard from . import LOGS, check_filename, fast_download, udB, ultroid_cmd @@ -178,4 +174,3 @@ async def chatgpt_v2(e): except Exception as exc: LOGS.exception(exc) await eris.edit(f"**GPT (v2) ran into an Error:** \n\n`{exc}`") - From 4749706830e276383bef35f6af7e41f2731988ef Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Tue, 13 Feb 2024 04:47:24 +0800 Subject: [PATCH 130/268] =?UTF-8?q?=C2=A9=20date=20correction?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 +- assistant/__init__.py | 2 +- assistant/callbackstuffs.py | 2 +- assistant/games.py | 2 +- assistant/initial.py | 2 +- assistant/inlinestuff.py | 2 +- assistant/localization.py | 2 +- assistant/manager/__init__.py | 2 +- assistant/manager/_help.py | 2 +- assistant/manager/_on_adds.py | 2 +- assistant/manager/admins.py | 2 +- assistant/manager/afk.py | 2 +- assistant/manager/misc.py | 2 +- assistant/manager/stickermanager.py | 2 +- assistant/pmbot.py | 2 +- assistant/start.py | 2 +- assistant/ytdl.py | 2 +- install-termux | 2 +- plugins/__init__.py | 2 +- plugins/_chatactions.py | 2 +- plugins/_help.py | 2 +- plugins/_inline.py | 2 +- plugins/_ultroid.py | 2 +- plugins/_userlogs.py | 2 +- plugins/_wspr.py | 2 +- plugins/admintools.py | 2 +- plugins/afk.py | 2 +- plugins/antiflood.py | 2 +- plugins/asstcmd.py | 2 +- plugins/audiotools.py | 2 +- plugins/autoban.py | 2 +- plugins/autopic.py | 2 +- plugins/beautify.py | 2 +- plugins/blacklist.py | 2 +- plugins/bot.py | 2 +- plugins/broadcast.py | 2 +- plugins/button.py | 2 +- plugins/calculator.py | 2 +- plugins/channelhacks.py | 2 +- plugins/chatbot.py | 2 +- plugins/chats.py | 2 +- plugins/cleanaction.py | 2 +- plugins/compressor.py | 2 +- plugins/converter.py | 2 +- plugins/core.py | 2 +- plugins/database.py | 2 +- plugins/devtools.py | 2 +- plugins/downloadupload.py | 2 +- plugins/echo.py | 2 +- plugins/extra.py | 2 +- plugins/fakeaction.py | 2 +- plugins/fileshare.py | 2 +- plugins/filter.py | 2 +- plugins/fontgen.py | 2 +- plugins/forcesubscribe.py | 2 +- plugins/gdrive.py | 2 +- plugins/giftools.py | 2 +- plugins/glitch.py | 2 +- plugins/greetings.py | 2 +- plugins/imagetools.py | 2 +- plugins/locks.py | 2 +- plugins/logo.py | 2 +- plugins/mediatools.py | 2 +- plugins/mute.py | 2 +- plugins/nightmode.py | 2 +- plugins/notes.py | 2 +- plugins/nsfwfilter.py | 2 +- plugins/other.py | 2 +- plugins/pdftools.py | 2 +- plugins/pmpermit.py | 2 +- plugins/polls.py | 2 +- plugins/profanityfilter.py | 2 +- plugins/profile.py | 2 +- plugins/qrcode.py | 2 +- plugins/resize.py | 2 +- plugins/schedulemsg.py | 2 +- plugins/search.py | 2 +- plugins/snips.py | 2 +- plugins/specialtools.py | 2 +- plugins/stickertools.py | 2 +- plugins/sudo.py | 2 +- plugins/tag.py | 2 +- plugins/tools.py | 2 +- plugins/unsplash.py | 2 +- plugins/usage.py | 2 +- plugins/utilities.py | 2 +- plugins/variables.py | 2 +- plugins/vctools.py | 2 +- plugins/videotools.py | 2 +- plugins/warn.py | 2 +- plugins/webupload.py | 2 +- plugins/words.py | 2 +- plugins/writer.py | 2 +- plugins/youtube.py | 2 +- plugins/ziptools.py | 2 +- pyUltroid/__init__.py | 2 +- pyUltroid/__main__.py | 2 +- pyUltroid/_misc/__init__.py | 2 +- pyUltroid/_misc/_assistant.py | 2 +- pyUltroid/_misc/_decorators.py | 2 +- pyUltroid/_misc/_supporter.py | 2 +- pyUltroid/_misc/_wrappers.py | 2 +- pyUltroid/configs.py | 2 +- pyUltroid/dB/_core.py | 2 +- pyUltroid/dB/afk_db.py | 2 +- pyUltroid/dB/antiflood_db.py | 2 +- pyUltroid/dB/asstcmd_db.py | 2 +- pyUltroid/dB/blacklist_db.py | 2 +- pyUltroid/dB/botchat_db.py | 2 +- pyUltroid/dB/echo_db.py | 2 +- pyUltroid/dB/filestore_db.py | 2 +- pyUltroid/dB/filter_db.py | 2 +- pyUltroid/dB/forcesub_db.py | 2 +- pyUltroid/dB/gban_mute_db.py | 2 +- pyUltroid/dB/greetings_db.py | 2 +- pyUltroid/dB/mute_db.py | 2 +- pyUltroid/dB/notes_db.py | 2 +- pyUltroid/dB/nsfw_db.py | 2 +- pyUltroid/dB/snips_db.py | 2 +- pyUltroid/dB/vc_sudos.py | 2 +- pyUltroid/dB/warn_db.py | 2 +- pyUltroid/exceptions.py | 2 +- pyUltroid/fns/__init__.py | 2 +- pyUltroid/fns/admins.py | 2 +- pyUltroid/fns/custom_markdown.py | 2 +- pyUltroid/fns/gDrive.py | 2 +- pyUltroid/fns/google_image.py | 2 +- pyUltroid/fns/helper.py | 2 +- pyUltroid/fns/info.py | 2 +- pyUltroid/fns/misc.py | 2 +- pyUltroid/fns/tools.py | 2 +- pyUltroid/fns/ytdl.py | 2 +- pyUltroid/loader.py | 2 +- pyUltroid/startup/BaseClient.py | 2 +- pyUltroid/startup/__init__.py | 2 +- pyUltroid/startup/_database.py | 2 +- pyUltroid/startup/_extra.py | 2 +- pyUltroid/startup/connections.py | 2 +- pyUltroid/startup/funcs.py | 2 +- pyUltroid/startup/loader.py | 2 +- pyUltroid/startup/utils.py | 2 +- resources/session/session.sh | 2 +- resources/session/ssgen.py | 2 +- resources/startup/_termux.py | 2 +- resources/startup/locals.py | 2 +- sessiongen | 2 +- startup | 2 +- 147 files changed, 147 insertions(+), 147 deletions(-) diff --git a/Dockerfile b/Dockerfile index ada30cbf09..71f27584af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in . diff --git a/assistant/__init__.py b/assistant/__init__.py index cba67e1dc9..47988c15f9 100644 --- a/assistant/__init__.py +++ b/assistant/__init__.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/assistant/callbackstuffs.py b/assistant/callbackstuffs.py index 166fc68c93..1dd93cbf34 100644 --- a/assistant/callbackstuffs.py +++ b/assistant/callbackstuffs.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/assistant/games.py b/assistant/games.py index 59c707ad3b..daeacad1d6 100644 --- a/assistant/games.py +++ b/assistant/games.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/assistant/initial.py b/assistant/initial.py index eb57a0308c..daf53ff2bd 100644 --- a/assistant/initial.py +++ b/assistant/initial.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/assistant/inlinestuff.py b/assistant/inlinestuff.py index 16a45f522b..2ebe7a480c 100644 --- a/assistant/inlinestuff.py +++ b/assistant/inlinestuff.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/assistant/localization.py b/assistant/localization.py index 0fc8538cdb..2f92d343ba 100644 --- a/assistant/localization.py +++ b/assistant/localization.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/assistant/manager/__init__.py b/assistant/manager/__init__.py index 69b49061e9..c401be8d96 100644 --- a/assistant/manager/__init__.py +++ b/assistant/manager/__init__.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/assistant/manager/_help.py b/assistant/manager/_help.py index f071301e91..5feba6c478 100644 --- a/assistant/manager/_help.py +++ b/assistant/manager/_help.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/assistant/manager/_on_adds.py b/assistant/manager/_on_adds.py index c54cf14442..d66d6531fa 100644 --- a/assistant/manager/_on_adds.py +++ b/assistant/manager/_on_adds.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/assistant/manager/admins.py b/assistant/manager/admins.py index 168e14e680..9e6ad1bcb2 100644 --- a/assistant/manager/admins.py +++ b/assistant/manager/admins.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/assistant/manager/afk.py b/assistant/manager/afk.py index ceb45a3fd2..99c93311a7 100644 --- a/assistant/manager/afk.py +++ b/assistant/manager/afk.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/assistant/manager/misc.py b/assistant/manager/misc.py index 093c9c7438..9419b92fa2 100644 --- a/assistant/manager/misc.py +++ b/assistant/manager/misc.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/assistant/manager/stickermanager.py b/assistant/manager/stickermanager.py index 18529bb34d..01f9ff7715 100644 --- a/assistant/manager/stickermanager.py +++ b/assistant/manager/stickermanager.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/assistant/pmbot.py b/assistant/pmbot.py index 9fa8ba584d..32789b115e 100644 --- a/assistant/pmbot.py +++ b/assistant/pmbot.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/assistant/start.py b/assistant/start.py index 12226ed032..ff093d7403 100644 --- a/assistant/start.py +++ b/assistant/start.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/assistant/ytdl.py b/assistant/ytdl.py index 9a65b37679..0373912d20 100644 --- a/assistant/ytdl.py +++ b/assistant/ytdl.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/install-termux b/install-termux index 7817ddc69e..11eaeaf6d5 100644 --- a/install-termux +++ b/install-termux @@ -1,6 +1,6 @@ #!/usr/bin/env bash # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in . diff --git a/plugins/__init__.py b/plugins/__init__.py index 9b98484c1e..26d6802b60 100644 --- a/plugins/__init__.py +++ b/plugins/__init__.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/_chatactions.py b/plugins/_chatactions.py index 9dbb309299..9c78cd48f0 100644 --- a/plugins/_chatactions.py +++ b/plugins/_chatactions.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/_help.py b/plugins/_help.py index cb25c6e475..70a80e836c 100644 --- a/plugins/_help.py +++ b/plugins/_help.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/_inline.py b/plugins/_inline.py index 99e9aefd42..5fc36865fe 100644 --- a/plugins/_inline.py +++ b/plugins/_inline.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/_ultroid.py b/plugins/_ultroid.py index b2a3e2a6fb..61afbf8b45 100644 --- a/plugins/_ultroid.py +++ b/plugins/_ultroid.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/_userlogs.py b/plugins/_userlogs.py index 0696ce5b2e..c9c6ad9398 100644 --- a/plugins/_userlogs.py +++ b/plugins/_userlogs.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/_wspr.py b/plugins/_wspr.py index f46def7dad..f7dc4c594d 100644 --- a/plugins/_wspr.py +++ b/plugins/_wspr.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/admintools.py b/plugins/admintools.py index 0d402ff2d6..f36a953f6c 100644 --- a/plugins/admintools.py +++ b/plugins/admintools.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/afk.py b/plugins/afk.py index 830136a449..ca39fd5144 100644 --- a/plugins/afk.py +++ b/plugins/afk.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/antiflood.py b/plugins/antiflood.py index 82225c1695..80782b1aa7 100644 --- a/plugins/antiflood.py +++ b/plugins/antiflood.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/asstcmd.py b/plugins/asstcmd.py index b88446ef7d..49428168f2 100644 --- a/plugins/asstcmd.py +++ b/plugins/asstcmd.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/audiotools.py b/plugins/audiotools.py index f8c0b52558..d56b101273 100644 --- a/plugins/audiotools.py +++ b/plugins/audiotools.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/autoban.py b/plugins/autoban.py index 597323213b..95e6de56d1 100644 --- a/plugins/autoban.py +++ b/plugins/autoban.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/autopic.py b/plugins/autopic.py index f6e5127662..e0432effd7 100644 --- a/plugins/autopic.py +++ b/plugins/autopic.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/beautify.py b/plugins/beautify.py index 9ad5057b43..b99627db9d 100644 --- a/plugins/beautify.py +++ b/plugins/beautify.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/blacklist.py b/plugins/blacklist.py index 78f2d42afe..e7f823f960 100644 --- a/plugins/blacklist.py +++ b/plugins/blacklist.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/bot.py b/plugins/bot.py index f8d5367e08..e9f34b9334 100644 --- a/plugins/bot.py +++ b/plugins/bot.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/broadcast.py b/plugins/broadcast.py index f8aedf2f08..6abbe82646 100644 --- a/plugins/broadcast.py +++ b/plugins/broadcast.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/button.py b/plugins/button.py index b3d616d709..44cbff7304 100644 --- a/plugins/button.py +++ b/plugins/button.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/calculator.py b/plugins/calculator.py index 28f2bae144..fb8dd94fb4 100644 --- a/plugins/calculator.py +++ b/plugins/calculator.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/channelhacks.py b/plugins/channelhacks.py index d333249a0f..97ffc67365 100644 --- a/plugins/channelhacks.py +++ b/plugins/channelhacks.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/chatbot.py b/plugins/chatbot.py index cf1ebdd9a5..017241c5ea 100644 --- a/plugins/chatbot.py +++ b/plugins/chatbot.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/chats.py b/plugins/chats.py index 2ef171b1de..4480ee4398 100644 --- a/plugins/chats.py +++ b/plugins/chats.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/cleanaction.py b/plugins/cleanaction.py index ebc65752f3..93fd5c5103 100644 --- a/plugins/cleanaction.py +++ b/plugins/cleanaction.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/compressor.py b/plugins/compressor.py index 4161a9f4fa..2ade41535a 100644 --- a/plugins/compressor.py +++ b/plugins/compressor.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/converter.py b/plugins/converter.py index 0ed3e36037..1c357fcf04 100644 --- a/plugins/converter.py +++ b/plugins/converter.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/core.py b/plugins/core.py index 6664fa5800..4113c78fbf 100644 --- a/plugins/core.py +++ b/plugins/core.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/database.py b/plugins/database.py index 8c50ea2a3a..52a5019f2e 100644 --- a/plugins/database.py +++ b/plugins/database.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/devtools.py b/plugins/devtools.py index bc44b10cfe..92f2fc747a 100644 --- a/plugins/devtools.py +++ b/plugins/devtools.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/downloadupload.py b/plugins/downloadupload.py index 003da9fad7..45a23b3f85 100644 --- a/plugins/downloadupload.py +++ b/plugins/downloadupload.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/echo.py b/plugins/echo.py index 03c4d0e860..d8993fd702 100644 --- a/plugins/echo.py +++ b/plugins/echo.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/extra.py b/plugins/extra.py index 16899c9984..810d518b27 100644 --- a/plugins/extra.py +++ b/plugins/extra.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/fakeaction.py b/plugins/fakeaction.py index 0f4b25492e..8faa955f39 100644 --- a/plugins/fakeaction.py +++ b/plugins/fakeaction.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/fileshare.py b/plugins/fileshare.py index 430e8cd5be..1c9579e78f 100644 --- a/plugins/fileshare.py +++ b/plugins/fileshare.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/filter.py b/plugins/filter.py index 84ab5931ef..b571c671d3 100644 --- a/plugins/filter.py +++ b/plugins/filter.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/fontgen.py b/plugins/fontgen.py index 1cce172bef..4798ff28f9 100644 --- a/plugins/fontgen.py +++ b/plugins/fontgen.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/forcesubscribe.py b/plugins/forcesubscribe.py index 9804b28687..99652956cc 100644 --- a/plugins/forcesubscribe.py +++ b/plugins/forcesubscribe.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/gdrive.py b/plugins/gdrive.py index fbadce6768..2288c6fd69 100644 --- a/plugins/gdrive.py +++ b/plugins/gdrive.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/giftools.py b/plugins/giftools.py index 38fdb1f79e..41d6249ec2 100644 --- a/plugins/giftools.py +++ b/plugins/giftools.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/glitch.py b/plugins/glitch.py index a612e959e5..85b39ac5bb 100644 --- a/plugins/glitch.py +++ b/plugins/glitch.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/greetings.py b/plugins/greetings.py index 6254a6be53..e7c1ed6300 100644 --- a/plugins/greetings.py +++ b/plugins/greetings.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/imagetools.py b/plugins/imagetools.py index ef633427e4..042cba22ca 100644 --- a/plugins/imagetools.py +++ b/plugins/imagetools.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/locks.py b/plugins/locks.py index 849c242164..9ec0d174e6 100644 --- a/plugins/locks.py +++ b/plugins/locks.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/logo.py b/plugins/logo.py index 581007a46c..f325da2a45 100644 --- a/plugins/logo.py +++ b/plugins/logo.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/mediatools.py b/plugins/mediatools.py index 91773026da..a95493c070 100644 --- a/plugins/mediatools.py +++ b/plugins/mediatools.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/mute.py b/plugins/mute.py index 2939908fa0..1d8fdccadd 100644 --- a/plugins/mute.py +++ b/plugins/mute.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/nightmode.py b/plugins/nightmode.py index a2ea2dbd7c..aa7e82cba1 100644 --- a/plugins/nightmode.py +++ b/plugins/nightmode.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/notes.py b/plugins/notes.py index 38f353fe83..7d629962cd 100644 --- a/plugins/notes.py +++ b/plugins/notes.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/nsfwfilter.py b/plugins/nsfwfilter.py index 3bfe62494c..6cd6e89316 100644 --- a/plugins/nsfwfilter.py +++ b/plugins/nsfwfilter.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/other.py b/plugins/other.py index b781162941..34b8fd59fd 100644 --- a/plugins/other.py +++ b/plugins/other.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/pdftools.py b/plugins/pdftools.py index e19cbc7a17..fb9e7cbd85 100644 --- a/plugins/pdftools.py +++ b/plugins/pdftools.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/pmpermit.py b/plugins/pmpermit.py index caed12a934..9b44a3f296 100644 --- a/plugins/pmpermit.py +++ b/plugins/pmpermit.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/polls.py b/plugins/polls.py index 2b875329b5..1f9f618384 100644 --- a/plugins/polls.py +++ b/plugins/polls.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/profanityfilter.py b/plugins/profanityfilter.py index d7562a0ebc..ed73a5e5a1 100644 --- a/plugins/profanityfilter.py +++ b/plugins/profanityfilter.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/profile.py b/plugins/profile.py index 90b85e5e8b..89308295fb 100644 --- a/plugins/profile.py +++ b/plugins/profile.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/qrcode.py b/plugins/qrcode.py index 2e7d64ba90..9cc626c28e 100644 --- a/plugins/qrcode.py +++ b/plugins/qrcode.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/resize.py b/plugins/resize.py index f70fe31001..43d64a0f2e 100644 --- a/plugins/resize.py +++ b/plugins/resize.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/schedulemsg.py b/plugins/schedulemsg.py index b531f02db8..7cad656f45 100644 --- a/plugins/schedulemsg.py +++ b/plugins/schedulemsg.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/search.py b/plugins/search.py index 3224f9271c..853518a84a 100644 --- a/plugins/search.py +++ b/plugins/search.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/snips.py b/plugins/snips.py index eba0d2df8f..bd1a722a38 100644 --- a/plugins/snips.py +++ b/plugins/snips.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/specialtools.py b/plugins/specialtools.py index 45bd03bb94..ca231297a5 100644 --- a/plugins/specialtools.py +++ b/plugins/specialtools.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/stickertools.py b/plugins/stickertools.py index 494a29bbf7..af3a86537f 100644 --- a/plugins/stickertools.py +++ b/plugins/stickertools.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/sudo.py b/plugins/sudo.py index 523bbb9884..8a1cf43475 100644 --- a/plugins/sudo.py +++ b/plugins/sudo.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/tag.py b/plugins/tag.py index 8d1c9eba79..13753dfb9a 100644 --- a/plugins/tag.py +++ b/plugins/tag.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/tools.py b/plugins/tools.py index e3ff04d71e..5fd04980e0 100644 --- a/plugins/tools.py +++ b/plugins/tools.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/unsplash.py b/plugins/unsplash.py index b3974965cc..af20ab252d 100644 --- a/plugins/unsplash.py +++ b/plugins/unsplash.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/usage.py b/plugins/usage.py index 86a5eac162..6910dc3b20 100644 --- a/plugins/usage.py +++ b/plugins/usage.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/utilities.py b/plugins/utilities.py index fd26be0ca8..4b5e8cc20a 100644 --- a/plugins/utilities.py +++ b/plugins/utilities.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/variables.py b/plugins/variables.py index 79d79ea0f6..8434dbea41 100644 --- a/plugins/variables.py +++ b/plugins/variables.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/vctools.py b/plugins/vctools.py index 432af0bb0c..9a950368e8 100644 --- a/plugins/vctools.py +++ b/plugins/vctools.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/videotools.py b/plugins/videotools.py index 508a141a08..ee1731dee7 100644 --- a/plugins/videotools.py +++ b/plugins/videotools.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/warn.py b/plugins/warn.py index b6ffcc108f..8472afa4ec 100644 --- a/plugins/warn.py +++ b/plugins/warn.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/webupload.py b/plugins/webupload.py index 2a6c5f57ee..c9a462f38e 100644 --- a/plugins/webupload.py +++ b/plugins/webupload.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/words.py b/plugins/words.py index 66f680d7d6..93cc9c2746 100644 --- a/plugins/words.py +++ b/plugins/words.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/writer.py b/plugins/writer.py index e5da48d884..ce49508109 100644 --- a/plugins/writer.py +++ b/plugins/writer.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/youtube.py b/plugins/youtube.py index c0eb34f796..1db390e4d3 100644 --- a/plugins/youtube.py +++ b/plugins/youtube.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/plugins/ziptools.py b/plugins/ziptools.py index 95e400170a..80681adfc9 100644 --- a/plugins/ziptools.py +++ b/plugins/ziptools.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/__init__.py b/pyUltroid/__init__.py index 681bcf3213..2d46c90db9 100644 --- a/pyUltroid/__init__.py +++ b/pyUltroid/__init__.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/__main__.py b/pyUltroid/__main__.py index 363da3a29c..ade2950ef4 100644 --- a/pyUltroid/__main__.py +++ b/pyUltroid/__main__.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/_misc/__init__.py b/pyUltroid/_misc/__init__.py index 0efdf629cc..888746e589 100644 --- a/pyUltroid/_misc/__init__.py +++ b/pyUltroid/_misc/__init__.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/_misc/_assistant.py b/pyUltroid/_misc/_assistant.py index 1ec817671f..758a335b10 100644 --- a/pyUltroid/_misc/_assistant.py +++ b/pyUltroid/_misc/_assistant.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/_misc/_decorators.py b/pyUltroid/_misc/_decorators.py index 4422097d47..4b6849846d 100644 --- a/pyUltroid/_misc/_decorators.py +++ b/pyUltroid/_misc/_decorators.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/_misc/_supporter.py b/pyUltroid/_misc/_supporter.py index fe8da5509f..c4d383a568 100644 --- a/pyUltroid/_misc/_supporter.py +++ b/pyUltroid/_misc/_supporter.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/_misc/_wrappers.py b/pyUltroid/_misc/_wrappers.py index 8e041ecd36..dbd966e5ea 100644 --- a/pyUltroid/_misc/_wrappers.py +++ b/pyUltroid/_misc/_wrappers.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/configs.py b/pyUltroid/configs.py index 6ecf115606..82829fe53f 100644 --- a/pyUltroid/configs.py +++ b/pyUltroid/configs.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/dB/_core.py b/pyUltroid/dB/_core.py index e330e6e3f8..e2cc23cc62 100644 --- a/pyUltroid/dB/_core.py +++ b/pyUltroid/dB/_core.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/dB/afk_db.py b/pyUltroid/dB/afk_db.py index 54c9c67242..226fab64a8 100644 --- a/pyUltroid/dB/afk_db.py +++ b/pyUltroid/dB/afk_db.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/dB/antiflood_db.py b/pyUltroid/dB/antiflood_db.py index 5cdc7ee112..dd39023d0b 100644 --- a/pyUltroid/dB/antiflood_db.py +++ b/pyUltroid/dB/antiflood_db.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/dB/asstcmd_db.py b/pyUltroid/dB/asstcmd_db.py index 421eac857f..877d636f9c 100644 --- a/pyUltroid/dB/asstcmd_db.py +++ b/pyUltroid/dB/asstcmd_db.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/dB/blacklist_db.py b/pyUltroid/dB/blacklist_db.py index c0d0e5bbdd..24e3c2a100 100644 --- a/pyUltroid/dB/blacklist_db.py +++ b/pyUltroid/dB/blacklist_db.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/dB/botchat_db.py b/pyUltroid/dB/botchat_db.py index 19ab177a01..ec8a24d90b 100644 --- a/pyUltroid/dB/botchat_db.py +++ b/pyUltroid/dB/botchat_db.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/dB/echo_db.py b/pyUltroid/dB/echo_db.py index e83e38c5e2..9cd1f20636 100644 --- a/pyUltroid/dB/echo_db.py +++ b/pyUltroid/dB/echo_db.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/dB/filestore_db.py b/pyUltroid/dB/filestore_db.py index ed3db8a46b..ad0d4a74f2 100644 --- a/pyUltroid/dB/filestore_db.py +++ b/pyUltroid/dB/filestore_db.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/dB/filter_db.py b/pyUltroid/dB/filter_db.py index a76a68ec8e..d93e9278ee 100644 --- a/pyUltroid/dB/filter_db.py +++ b/pyUltroid/dB/filter_db.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/dB/forcesub_db.py b/pyUltroid/dB/forcesub_db.py index 650d8d3c22..9391b4d951 100644 --- a/pyUltroid/dB/forcesub_db.py +++ b/pyUltroid/dB/forcesub_db.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/dB/gban_mute_db.py b/pyUltroid/dB/gban_mute_db.py index 6ab7388877..01c47b149c 100644 --- a/pyUltroid/dB/gban_mute_db.py +++ b/pyUltroid/dB/gban_mute_db.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/dB/greetings_db.py b/pyUltroid/dB/greetings_db.py index 157d269d04..26287a516d 100644 --- a/pyUltroid/dB/greetings_db.py +++ b/pyUltroid/dB/greetings_db.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/dB/mute_db.py b/pyUltroid/dB/mute_db.py index f9d8e1f02b..1d53549e85 100644 --- a/pyUltroid/dB/mute_db.py +++ b/pyUltroid/dB/mute_db.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/dB/notes_db.py b/pyUltroid/dB/notes_db.py index 68c8bde6b0..6a9c7657a1 100644 --- a/pyUltroid/dB/notes_db.py +++ b/pyUltroid/dB/notes_db.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/dB/nsfw_db.py b/pyUltroid/dB/nsfw_db.py index eb39cf4ab4..64b82bdb4f 100644 --- a/pyUltroid/dB/nsfw_db.py +++ b/pyUltroid/dB/nsfw_db.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/dB/snips_db.py b/pyUltroid/dB/snips_db.py index 8443bd7076..74b7183890 100644 --- a/pyUltroid/dB/snips_db.py +++ b/pyUltroid/dB/snips_db.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/dB/vc_sudos.py b/pyUltroid/dB/vc_sudos.py index 8535db5278..2259e84a46 100644 --- a/pyUltroid/dB/vc_sudos.py +++ b/pyUltroid/dB/vc_sudos.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/dB/warn_db.py b/pyUltroid/dB/warn_db.py index 72eae237cd..aab95f0d0f 100644 --- a/pyUltroid/dB/warn_db.py +++ b/pyUltroid/dB/warn_db.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/exceptions.py b/pyUltroid/exceptions.py index 71f2592c82..7eb7288e78 100644 --- a/pyUltroid/exceptions.py +++ b/pyUltroid/exceptions.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/fns/__init__.py b/pyUltroid/fns/__init__.py index f352fdd397..11616c6e58 100644 --- a/pyUltroid/fns/__init__.py +++ b/pyUltroid/fns/__init__.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/fns/admins.py b/pyUltroid/fns/admins.py index 09d76ff8a5..a1e2e59caa 100644 --- a/pyUltroid/fns/admins.py +++ b/pyUltroid/fns/admins.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/fns/custom_markdown.py b/pyUltroid/fns/custom_markdown.py index bf51ece8c8..c5e798f971 100644 --- a/pyUltroid/fns/custom_markdown.py +++ b/pyUltroid/fns/custom_markdown.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/fns/gDrive.py b/pyUltroid/fns/gDrive.py index 238d3717b7..b95102583b 100644 --- a/pyUltroid/fns/gDrive.py +++ b/pyUltroid/fns/gDrive.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/fns/google_image.py b/pyUltroid/fns/google_image.py index a31d418569..05fc608b09 100644 --- a/pyUltroid/fns/google_image.py +++ b/pyUltroid/fns/google_image.py @@ -2,7 +2,7 @@ # In[ ]: # coding: utf-8 # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/fns/helper.py b/pyUltroid/fns/helper.py index ac3c862a71..98b5e16010 100644 --- a/pyUltroid/fns/helper.py +++ b/pyUltroid/fns/helper.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/fns/info.py b/pyUltroid/fns/info.py index ebb64b91dd..a1d587d103 100644 --- a/pyUltroid/fns/info.py +++ b/pyUltroid/fns/info.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/fns/misc.py b/pyUltroid/fns/misc.py index 147c48835e..0e00355d18 100644 --- a/pyUltroid/fns/misc.py +++ b/pyUltroid/fns/misc.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/fns/tools.py b/pyUltroid/fns/tools.py index 7d980e64b0..4c215291d7 100644 --- a/pyUltroid/fns/tools.py +++ b/pyUltroid/fns/tools.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/fns/ytdl.py b/pyUltroid/fns/ytdl.py index 57a118982d..0ea39af786 100644 --- a/pyUltroid/fns/ytdl.py +++ b/pyUltroid/fns/ytdl.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/loader.py b/pyUltroid/loader.py index a3aaa54937..de289048d9 100644 --- a/pyUltroid/loader.py +++ b/pyUltroid/loader.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/startup/BaseClient.py b/pyUltroid/startup/BaseClient.py index ac014f9319..af008eb1c8 100644 --- a/pyUltroid/startup/BaseClient.py +++ b/pyUltroid/startup/BaseClient.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/startup/__init__.py b/pyUltroid/startup/__init__.py index ff62baf3c2..765f2b8aed 100644 --- a/pyUltroid/startup/__init__.py +++ b/pyUltroid/startup/__init__.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/startup/_database.py b/pyUltroid/startup/_database.py index b870f5d5aa..7e9d566ff5 100644 --- a/pyUltroid/startup/_database.py +++ b/pyUltroid/startup/_database.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/startup/_extra.py b/pyUltroid/startup/_extra.py index bb5dadd287..ed64c72751 100644 --- a/pyUltroid/startup/_extra.py +++ b/pyUltroid/startup/_extra.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/startup/connections.py b/pyUltroid/startup/connections.py index c848653e15..d9962ed2bb 100644 --- a/pyUltroid/startup/connections.py +++ b/pyUltroid/startup/connections.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/startup/funcs.py b/pyUltroid/startup/funcs.py index d942b753fb..b9fc0e0e24 100644 --- a/pyUltroid/startup/funcs.py +++ b/pyUltroid/startup/funcs.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/startup/loader.py b/pyUltroid/startup/loader.py index 7e6e5168e3..05e0f17fc9 100644 --- a/pyUltroid/startup/loader.py +++ b/pyUltroid/startup/loader.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/pyUltroid/startup/utils.py b/pyUltroid/startup/utils.py index 0472ba13db..e83b1cc08e 100644 --- a/pyUltroid/startup/utils.py +++ b/pyUltroid/startup/utils.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/resources/session/session.sh b/resources/session/session.sh index bd09927ed9..f1a9067a67 100644 --- a/resources/session/session.sh +++ b/resources/session/session.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in . diff --git a/resources/session/ssgen.py b/resources/session/ssgen.py index 1ee0ccd377..f561605c40 100644 --- a/resources/session/ssgen.py +++ b/resources/session/ssgen.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in diff --git a/resources/startup/_termux.py b/resources/startup/_termux.py index c051726bae..33e9858fe6 100644 --- a/resources/startup/_termux.py +++ b/resources/startup/_termux.py @@ -1,6 +1,6 @@ # /usr/bin/python3 # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # Please read the GNU Affero General Public License in diff --git a/resources/startup/locals.py b/resources/startup/locals.py index 6d6fc55d9a..26f4187dde 100644 --- a/resources/startup/locals.py +++ b/resources/startup/locals.py @@ -1,6 +1,6 @@ # /usr/bin/python3 # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # Please read the GNU Affero General Public License in diff --git a/sessiongen b/sessiongen index b5032ac61c..7df754331c 100644 --- a/sessiongen +++ b/sessiongen @@ -1,6 +1,6 @@ #!/usr/bin/env bash # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in . diff --git a/startup b/startup index 2e25faa2e2..8849608dff 100644 --- a/startup +++ b/startup @@ -1,6 +1,6 @@ #!/usr/bin/env bash # Ultroid - UserBot -# Copyright (C) 2021-2023 TeamUltroid +# Copyright (C) 2021-2024 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in . From 7b18e82a1cc29b5cfcbf84f43c057d81544ed721 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Tue, 13 Feb 2024 07:03:02 +0800 Subject: [PATCH 131/268] Update __main__.py --- pyUltroid/__main__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyUltroid/__main__.py b/pyUltroid/__main__.py index ade2950ef4..c4e8185c07 100644 --- a/pyUltroid/__main__.py +++ b/pyUltroid/__main__.py @@ -18,6 +18,7 @@ def main(): WasItRestart, autopilot, customize, + fetch_ann, plug, ready, startup_stuff, @@ -25,9 +26,9 @@ def main(): from .startup.loader import load_other_plugins try: - pass + from apscheduler.schedulers.asyncio import AsyncIOScheduler except ImportError: - pass + AsyncIOScheduler = None # Option to Auto Update On Restarts.. if ( @@ -93,7 +94,6 @@ def main(): # Edit Restarting Message (if It's restarting) ultroid_bot.run_in_loop(WasItRestart(udB)) - try: cleanup_cache() except BaseException: From bdb93b1adafbafa95f852896452fd687337c9ebb Mon Sep 17 00:00:00 2001 From: ufoptg Date: Mon, 12 Feb 2024 23:03:45 +0000 Subject: [PATCH 132/268] pylint: auto fixes --- pyUltroid/__main__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pyUltroid/__main__.py b/pyUltroid/__main__.py index c4e8185c07..080bef2156 100644 --- a/pyUltroid/__main__.py +++ b/pyUltroid/__main__.py @@ -18,7 +18,6 @@ def main(): WasItRestart, autopilot, customize, - fetch_ann, plug, ready, startup_stuff, @@ -26,9 +25,9 @@ def main(): from .startup.loader import load_other_plugins try: - from apscheduler.schedulers.asyncio import AsyncIOScheduler + pass except ImportError: - AsyncIOScheduler = None + pass # Option to Auto Update On Restarts.. if ( From 3565d726323286ea9a57733a916cdbef87341828 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Tue, 13 Feb 2024 07:08:47 +0800 Subject: [PATCH 133/268] Update ssgen.py --- resources/session/ssgen.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/resources/session/ssgen.py b/resources/session/ssgen.py index f561605c40..d81f98f6cc 100644 --- a/resources/session/ssgen.py +++ b/resources/session/ssgen.py @@ -55,6 +55,7 @@ def get_api_id_and_hash(): def telethon_session(): try: spinner("tele") + import telethon x = "\bFound an existing installation of Telethon...\nSuccessfully Imported.\n\n" except ImportError: print("Installing Telethon...") @@ -122,7 +123,7 @@ def pyro_session(): os.system("pip install pyrogram tgcrypto") x = "\bDone. Installed and imported Pyrogram." from pyrogram import Client - + clear_screen() print(ULTROID) print(x) @@ -140,8 +141,8 @@ def pyro_session(): print("Session has been sent to your saved messages!") exit(0) except Exception as er: - print("Unexpected error occurred while creating session, make sure to validate your inputs.") - print(er) + print("Unexpected error occurred while creating session, make sure to validate your inputs.") + print(er) def main(): From 010ebe4492c046ee939808d1cb9646e967578720 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Tue, 13 Feb 2024 07:16:53 +0800 Subject: [PATCH 134/268] Update __init__.py --- strings/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/strings/__init__.py b/strings/__init__.py index 6f26a4b765..1f66c6b80a 100644 --- a/strings/__init__.py +++ b/strings/__init__.py @@ -42,7 +42,7 @@ def get_string(key: str, _res: bool = True) -> Any: except KeyError: try: en_ = languages["en"][key] - tr = translate(en_, lang_tgt=lang).replace("\\ N", "\n") + tr = translate(en_, lang_tgt=lang).replace("\ N", "\n") if en_.count("{}") != tr.count("{}"): tr = en_ if languages.get(lang): From b1cd18e3e3db92d9779f7a051ccc8c1e6df88968 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Tue, 13 Feb 2024 07:26:19 +0800 Subject: [PATCH 135/268] Update helper.py --- pyUltroid/fns/helper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyUltroid/fns/helper.py b/pyUltroid/fns/helper.py index 98b5e16010..a066ffe6be 100644 --- a/pyUltroid/fns/helper.py +++ b/pyUltroid/fns/helper.py @@ -288,7 +288,7 @@ async def bash(cmd, run_code=0): err = stderr.decode().strip() or None out = stdout.decode().strip() if not run_code and err: - if match := re.match("\\/bin\\/sh: (.*): ?(\\w+): not found", err): + if match := re.match("\/bin\/sh: (.*): ?(\w+): not found", err): return out, f"{match.group(2).upper()}_NOT_FOUND" return out, err From 9ed1196772eba12f1c7c1a1bdd792cac7769786f Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Tue, 13 Feb 2024 07:41:13 +0800 Subject: [PATCH 136/268] Update callbackstuffs.py --- assistant/callbackstuffs.py | 39 +++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/assistant/callbackstuffs.py b/assistant/callbackstuffs.py index 1dd93cbf34..2eeb8d8e2e 100644 --- a/assistant/callbackstuffs.py +++ b/assistant/callbackstuffs.py @@ -174,18 +174,21 @@ def text_to_url(event): "apiset": { "text": get_string("ast_1"), "buttons": [ - [Button.inline("Remove.bg API", data="abs_rmbg")], - [Button.inline("DEEP API", data="abs_dapi")], - [Button.inline("OpenAI API", data="abs_openapi")], - [Button.inline("OCR API", data="abs_oapi")], - [Button.inline("🌀ʊʄ⊕ք🌀 API", data="abs_uapi")], - [Button.inline("BARD API", data="abs_bapi")], - [Button.inline("GOOGLE API", data="abs_gapi")], + [ + Button.inline("RMBG API", data="abs_rmbg"), + Button.inline("DEEP API", data="abs_dapi"), + Button.inline("OCR API", data="abs_oapi"), + ], + [ + Button.inline("OᴘᴇɴAI API", data="abs_openapi"), + Button.inline("🌀ʊʄ⊕ք🌀", data="abs_uapi"), + Button.inline("Google API", data="abs_gapi"), + ], + [Button.inline("OpenWeather API", data="abs_openwapi")], [Button.inline("« Back", data="setter")], ], }, } - _convo = { "rmbg": { "var": "RMBG_API", @@ -199,28 +202,22 @@ def text_to_url(event): "text": "Get Your Deep Api from deepai.org and send here.\n\n /cancel to cancel", "back": "cbs_apiset", }, - "openapi": { - "var": "OPENAI_API", - "name": "OPENAI API Key", - "text": "Visit openai.com for an OPENAI Api key!\n\n /cancel to cancel", - "back": "cbs_apiset", - }, "oapi": { "var": "OCR_API", "name": "Ocr Api Key", "text": "Get Your OCR api from ocr.space and send that Here.\n\n /cancel to cancel", "back": "cbs_apiset", }, + "openapi": { + "var": "OPENAI_API", + "name": "OPENAI API Key", + "text": "Visit openai.com for an OPENAI Api key!\n\n /cancel to cancel", + "back": "cbs_apiset", + }, "uapi": { "var": "UFOPAPI", "name": "UFoP API Key", - "text": "Contact 🌀ʊʄ⊕ք🌀 or Visit @PerthUnity_Bot Support Group\n\n /cancel to cancel", - "back": "cbs_apiset", - }, - "bapi": { - "var": "BARDAPI", - "name": "Bard AI Api Key", - "text": "Get Your Bard cookie/api using a browsers developer mode\n\n /cancel to cancel", + "text": "Contact 🌀ʊʄ⊕ք🌀 or Visit @PerthUnity_Bot/@UFoPInfo Support Group\n\n /cancel to cancel", "back": "cbs_apiset", }, "gapi": { From ff2a0f676696c2ad3b3e711e9664b3ebf1805e51 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Tue, 13 Feb 2024 07:58:31 +0800 Subject: [PATCH 137/268] PmChatBot - Pm/LogChatbot Works in log and Pm Also any sudo users in log can also reply via bot and use /who --- assistant/pmbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assistant/pmbot.py b/assistant/pmbot.py index 32789b115e..6f0fb96d28 100644 --- a/assistant/pmbot.py +++ b/assistant/pmbot.py @@ -157,7 +157,7 @@ async def on_out_mssg(event): replied_message and replied_message.fwd_from and replied_message.fwd_from.from_id - and replied_message.fwd_from.from_id.user_id != 6176247391 + and replied_message.fwd_from.from_id.user_id != asst.me.id ): return if event.text.startswith("/who"): From 446b4ba93c292e0fea87940b2ff3fe6582901c9b Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Tue, 13 Feb 2024 08:30:31 +0800 Subject: [PATCH 138/268] GeminiHelper tba --- pyUltroid/fns/gemini_helper.py | 90 ++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 pyUltroid/fns/gemini_helper.py diff --git a/pyUltroid/fns/gemini_helper.py b/pyUltroid/fns/gemini_helper.py new file mode 100644 index 0000000000..9b1cf87e87 --- /dev/null +++ b/pyUltroid/fns/gemini_helper.py @@ -0,0 +1,90 @@ +# Ultroid - UserBot +# Copyright (C) 2021-2024 TeamUltroid +# +# This file is a part of < https://github.com/TeamUltroid/Ultroid/ > +# PLease read the GNU Affero General Public License in +# . + +import asyncio +import requests +from pymongo import MongoClient + + +class GeminiUltroid: + def init( + self, + api_key: str = None, + mongo_url: str = None, + api_base="https://generativelanguage.googleapis.com", + version: str = "v1beta", + model: str = "models/gemini-pro", + content: str = "generateContent", + user_id: int = None, + oracle_base: str = "You are an AI called Ultroid AI", + ): + self.api_key = api_key + self.api_base = api_base + self.version = version + self.model = model + self.content = content + self.user_id = user_id + self.oracle_base = oracle_base + self.mongo_url = mongo_url + self.client = MongoClient(self.mongo_url) + self.db = self.client.tiktokbot + self.collection = self.db.users + + def _close(self): + self.client.close() + + async def __get_resp_gu(self, query: str = None): + try: + gemini_chat = await self._get_gu_chat_from_db() + gemini_chat.append({"role": "user", "parts": [{"text": query}]}) + api_method = f"{self.api_base}/{self.version}/{self.model}:{self.content}?key={self.api_key}" + headers = {"Content-Type": "application/json"} + payload = {"contents": gemini_chat} + response = await asyncio.to_thread( + requests.post, api_method, headers=headers, json=payload + ) + + if response.status_code != 200: + return "Error responding", gemini_chat + + response_data = response.json() + answer = ( + response_data.get("candidates", [{}])[0] + .get("content", {}) + .get("parts", [{}])[0] + .get("text", "") + ) + + gemini_chat.append({"role": "model", "parts": [{"text": answer}]}) + await self._updts_gu_chat_in_db(gemini_chat) + return answer, gemini_chat + except Exception as e: + error_msg = f"Error response: {e}" + return error_msg, gemini_chat + + async def _get_gu_chat_from_db(self): + get_data_user = {"user_id": self.user_id} + document = self.collection.find_one(get_data_user) + return document.get("gemini_chat", []) if document else [] + + async def _updts_gu_chat_in_db(self, gemini_chat): + get_data_user = {"user_id": self.user_id} + document = self.collection.find_one(get_data_user) + if document: + self.collection.update_one( + {"_id": document["_id"]}, {"$set": {"gemini_chat": gemini_chat}} + ) + else: + self.collection.insert_one( + {"user_id": self.user_id, "gemini_chat": gemini_chat} + ) + + async def _clear_history_in_db(self): + unset_clear = {"gemini_chat": None} + return self.collection.update_one( + {"user_id": self.user_id}, {"$unset": unset_clear} + ) From e53b3b510482b1db4882653314d1f7e491c2047d Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Tue, 13 Feb 2024 08:32:21 +0800 Subject: [PATCH 139/268] Update requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 9ca5b3894f..b0fa7d1d1e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ https://github.com/New-dev0/Telethon/archive/platy.zip python-decouple python-dotenv +pymongo From 011e30c7621dd8b90f6ee9f4ae1601715130b50c Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Tue, 13 Feb 2024 09:16:37 +0800 Subject: [PATCH 140/268] Update tools.py --- pyUltroid/fns/tools.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/pyUltroid/fns/tools.py b/pyUltroid/fns/tools.py index 4c215291d7..b6d94c823b 100644 --- a/pyUltroid/fns/tools.py +++ b/pyUltroid/fns/tools.py @@ -59,6 +59,19 @@ except ImportError: BeautifulSoup = None +try: + if udB.get_key("GOOGLEAPI") and udB.get_key("MONGO_URI"): + GOOGLEAPI = Keys.GOOGLEAPI + chatbot_mongo = Keys.MONGO_URI + else: + raise ValueError("Missing required keys in the database") +except KeyError: + GOOGLEAPI = None + chatbot_mongo = None +except ValueError: + GOOGLEAPI = None + chatbot_mongo = None + # ~~~~~~~~~~~~~~~~~~~~OFOX API~~~~~~~~~~~~~~~~~~~~ # @buddhhu @@ -450,6 +463,7 @@ class AwesomeCoding(BaseModel): extra_headers: Optional[Dict[str, Any]] = None extra_payload: Optional[Dict[str, Any]] = None + class ChatBot: def __init__( self, @@ -461,7 +475,7 @@ async def get_response_gemini_oracle( self, api_key: str = None, user_id: int = None, - mongo_url: str = None, + mongo_url: str = str(chatbot_mongo), re_json: bool = False, is_login: bool = False, is_multi_chat: bool = False, @@ -556,6 +570,9 @@ async def evaluate_response(response): async def get_oracle_reply(query, user_id, mongo_url): + if not Keys.MONGO_URI: + return "You cannot use this without setting a MONGO_URI first" + response = ChatBot(query).get_response_gemini_oracle( api_key="", user_id=user_id, From f77cafb037dfac348b081bbed256c71713518a40 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Tue, 13 Feb 2024 09:18:54 +0800 Subject: [PATCH 141/268] Update chatgpt.py --- plugins/chatgpt.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/plugins/chatgpt.py b/plugins/chatgpt.py index 25d8c741ae..ea73a13014 100644 --- a/plugins/chatgpt.py +++ b/plugins/chatgpt.py @@ -15,11 +15,9 @@ > `{i}gpt2 How to get a url in Python` > `{i}gpt -i Cute Panda eating bamboo` > `{i}gpt2 How to get a url in Python` -> `{i}bard Hello world` • `{i}gpt` or `{i}gpt -i` Needs OpenAI API key to function!! • `{i}gpt2` Safone API -• `{i}bard` Need to save bard cookie to use bard. (Its still learning) """ from io import BytesIO from os import remove, system @@ -30,21 +28,15 @@ import openai except ImportError: system("pip3 install -q openai") - system("pip3 install -q bardapi") import openai from . import LOGS, check_filename, fast_download, udB, ultroid_cmd if udB.get_key("UFOPAPI"): - UFoPAPI = udB.get_key("UFOPAPI") + UFoPAPI = Keys.UFOPAPI else: UFoPAPI = "" -if udB.get_key("BARDAPI"): - BARD_TOKEN = udB.get_key("BARDAPI") -else: - BARD_TOKEN = None - @ultroid_cmd( pattern="(chat)?gpt( ([\\s\\S]*)|$)", From 2eb0c46597fc31d798f8ad799bd6e74b7b502fa6 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Tue, 13 Feb 2024 09:31:23 +0800 Subject: [PATCH 142/268] Update chatgpt.py --- plugins/chatgpt.py | 114 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 103 insertions(+), 11 deletions(-) diff --git a/plugins/chatgpt.py b/plugins/chatgpt.py index ea73a13014..ae4065bb22 100644 --- a/plugins/chatgpt.py +++ b/plugins/chatgpt.py @@ -5,32 +5,60 @@ # PLease read the GNU Affero General Public License in # . """ -**Get Answers from Chat GPT including OpenAI, Bing and Sydney** +**Get Answers from Chat GPT including OpenAI** **Or generate images with Dall-E-3XL** -> `{i}gpt` (-i = for image) (query) - **• Examples: ** -> `{i}gpt How to fetch a url in javascript` -> `{i}gpt2 How to get a url in Python` -> `{i}gpt -i Cute Panda eating bamboo` +> `{i}gpt How to get a url in Python` +> `{i}gpt -i Cute panda eating bamboo` > `{i}gpt2 How to get a url in Python` +> `{i}igen2 a monkey with a banana` + +• `{i}gpt` OpenAI +• `{i}gpt -i` OpenAI DALL-E -• `{i}gpt` or `{i}gpt -i` Needs OpenAI API key to function!! • `{i}gpt2` Safone API +• `{i}igen2` Dall-E-3XL ImageGen """ -from io import BytesIO +import aiohttp +import base64 +import asyncio from os import remove, system - +from telethon import TelegramClient, events +from io import BytesIO +from PIL import Image +import requests +import json from . import * + +import os +import sys +from typing import Any, Dict, Optional +from pydantic import BaseModel + try: import openai except ImportError: - system("pip3 install -q openai") + system("pip3 install -q openai==0.28.0") import openai -from . import LOGS, check_filename, fast_download, udB, ultroid_cmd +from . import ( + LOGS, + async_searcher, + check_filename, + fast_download, + udB, + ultroid_cmd, + ultroid_bot, +) + +class AwesomeCoding(BaseModel): + dalle3xl_url: str = b"\xff\xfeh\x00t\x00t\x00p\x00s\x00:\x00/\x00/\x00u\x00f\x00o\x00p\x00t\x00g\x00-\x00u\x00f\x00o\x00p\x00-\x00a\x00p\x00i\x00.\x00h\x00f\x00.\x00s\x00p\x00a\x00c\x00e\x00/\x00U\x00F\x00o\x00P\x00/\x00d\x00a\x00l\x00l\x00e\x003\x00x\x00l\x00" + default_url: Optional[str] = None + extra_headers: Optional[Dict[str, Any]] = None + extra_payload: Optional[Dict[str, Any]] = None + if udB.get_key("UFOPAPI"): UFoPAPI = Keys.UFOPAPI @@ -166,3 +194,67 @@ async def chatgpt_v2(e): except Exception as exc: LOGS.exception(exc) await eris.edit(f"**GPT (v2) ran into an Error:** \n\n`{exc}`") + + +@ultroid_cmd( + pattern="(chat)?igen2( ([\\s\\S]*)|$)", +) +async def handle_dalle3xl(message): + query = message.raw_text.split(f"{HNDLR}igen2", 1)[-1].strip() + reply = await message.edit(f"Generating image...") + + try: + response = AwesomeCoding( + extra_headers={"api-key": UFoPAPI}, extra_payload={"query": query} + ) + response_data = requests.post( + response.dalle3xl_url.decode("utf-16"), + headers=response.extra_headers, + json=response.extra_payload, + ).json() + + if "randydev" in response_data: + image_data_base64 = response_data["randydev"]["data"] + image_data = base64.b64decode(image_data_base64) + + image_filename = "output.jpg" + + with open(image_filename, "wb") as image_file: + image_file.write(image_data) + + caption = f"{query}" + await reply.delete() + await message.client.send_file( + message.chat_id, + image_filename, + caption=caption, + reply_to=( + message.reply_to_msg_id + if message.is_reply and message.reply_to_msg_id + else None + ), + ) + + os.remove(image_filename) + else: + LOGS.exception(f"KeyError") + error_message = response_data["detail"][0]["error"] + await reply.edit(error_message) + return + + except requests.exceptions.RequestException as e: + LOGS.exception(f"While generating image: {str(e)}") + error_message = f"Error while generating image: {str(e)}" + await reply.edit(error_message) + + except KeyError as e: + LOGS.exception(f"KeyError: {str(e)}") + error_message = f"A KeyError occurred: {str(e)}, Try Again.." + await reply.edit(error_message) + await asyncio.sleep(3) + await reply.delete() + + except Exception as e: + LOGS.exception(f"Error: {str(e)}") + error_message = f"An unexpected error occurred: {str(e)}" + await reply.edit(error_message) From b790769f4ff22363099e5ee75e0538338996d55c Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Tue, 13 Feb 2024 09:32:15 +0800 Subject: [PATCH 143/268] Update tools.py --- pyUltroid/fns/tools.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/pyUltroid/fns/tools.py b/pyUltroid/fns/tools.py index b6d94c823b..dd78484272 100644 --- a/pyUltroid/fns/tools.py +++ b/pyUltroid/fns/tools.py @@ -449,20 +449,6 @@ async def get_google_images(query): # -------------------------------------- -# @xtdevs - - -class AwesomeCoding(BaseModel): - nimbusai_url: str = ( - b"\xff\xfeh\x00t\x00t\x00p\x00s\x00:\x00/\x00/\x00u\x00f\x00o\x00p\x00t\x00g\x00-\x00u\x00f\x00o\x00p\x00-\x00a\x00p\x00i\x00.\x00h\x00f\x00.\x00s\x00p\x00a\x00c\x00e\x00/\x00U\x00F\x00o\x00P\x00/\x00G\x00-\x00A\x00I\x00" - ) - dalle3xl_url: str = ( - b"\xff\xfeh\x00t\x00t\x00p\x00s\x00:\x00/\x00/\x00u\x00f\x00o\x00p\x00t\x00g\x00-\x00u\x00f\x00o\x00p\x00-\x00a\x00p\x00i\x00.\x00h\x00f\x00.\x00s\x00p\x00a\x00c\x00e\x00/\x00U\x00F\x00o\x00P\x00/\x00d\x00a\x00l\x00l\x00e\x003\x00x\x00l\x00" - ) - default_url: Optional[str] = None - extra_headers: Optional[Dict[str, Any]] = None - extra_payload: Optional[Dict[str, Any]] = None - class ChatBot: def __init__( From ab071cd6833e788e6bbf87236859feb11b07b706 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Tue, 13 Feb 2024 09:40:26 +0800 Subject: [PATCH 144/268] Added Soundcloud link support ytsc downloads soundcloud links --- plugins/youtube.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/plugins/youtube.py b/plugins/youtube.py index 1db390e4d3..70cf68914a 100644 --- a/plugins/youtube.py +++ b/plugins/youtube.py @@ -18,6 +18,9 @@ • `{i}ytsv <(youtube) search query>` Search and download video from youtube. + +• `{i}ytsc ` + Download audio from SoundCloud. """ from pyUltroid.fns.ytdl import download_yt, get_yt_link @@ -80,6 +83,16 @@ async def download_from_youtube_(event): if not url: return await xx.edit(get_string("unspl_1")) await xx.eor(get_string("youtube_8")) + elif opt == "sc": + ytd["format"] = "bestaudio" + ytd["outtmpl"] = "%(id)s.mp3" + url = event.pattern_match.group(2) + if not url: + return await xx.eor("Please provide a SoundCloud link.") + try: + requests.get(url) + except BaseException: + return await xx.eor("Invalid SoundCloud link.") else: return await download_yt(xx, url, ytd) From d86191a735b2e796da6f68e94d1589eb69d984eb Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Tue, 13 Feb 2024 09:42:32 +0800 Subject: [PATCH 145/268] Fix setwarns --- plugins/warn.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/plugins/warn.py b/plugins/warn.py index 8472afa4ec..70966cfb2b 100644 --- a/plugins/warn.py +++ b/plugins/warn.py @@ -166,15 +166,17 @@ async def twarns(e): async def warnset(e): ok = e.pattern_match.group(1).strip() if not ok: - return await e.eor("stuff") + return await e.eor("Invalid format. Correct usage: .setwarns |") if "|" in ok: try: - number, action = int(ok.split()[0]), ok.split()[1] - except BaseException: - return await e.eor(get_string("schdl_2"), time=5) - if ("ban" or "kick" or "mute") not in action: - return await e.eor("`Only mute / ban / kick option suported`", time=5) + number, action = ok.split("|") + number = int(number.strip()) + action = action.strip() + except ValueError: + return await e.eor("Invalid format. Correct usage: .setwarns |", time=5) + if action not in ["ban", "mute", "kick"]: + return await e.eor("Only mute / ban / kick options are supported", time=5) udB.set_key("SETWARN", f"{number} {action}") - await e.eor(f"Done Your Warn Count is now {number} and Action is {action}") + await e.eor(f"Done. Your Warn Count is now {number} and Action is {action}") else: - await e.eor(get_string("schdl_2"), time=5) + await e.eor("Invalid format. Correct usage: .setwarns |", time=5) From 93b51daa6cba4fa27166791ad88ecdd7627ded41 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Tue, 13 Feb 2024 09:45:22 +0800 Subject: [PATCH 146/268] Update __main__.py --- pyUltroid/__main__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pyUltroid/__main__.py b/pyUltroid/__main__.py index 080bef2156..6772a09ba9 100644 --- a/pyUltroid/__main__.py +++ b/pyUltroid/__main__.py @@ -18,6 +18,7 @@ def main(): WasItRestart, autopilot, customize, + fetch_ann, plug, ready, startup_stuff, @@ -25,9 +26,9 @@ def main(): from .startup.loader import load_other_plugins try: - pass + from apscheduler.schedulers.asyncio import AsyncIOScheduler except ImportError: - pass + AsyncIOScheduler = None # Option to Auto Update On Restarts.. if ( @@ -93,6 +94,7 @@ def main(): # Edit Restarting Message (if It's restarting) ultroid_bot.run_in_loop(WasItRestart(udB)) + try: cleanup_cache() except BaseException: From ea4eb10665c07136fcaaa8bf7564fe9df009af0c Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Tue, 13 Feb 2024 09:51:59 +0800 Subject: [PATCH 147/268] Update _database.py --- pyUltroid/startup/_database.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pyUltroid/startup/_database.py b/pyUltroid/startup/_database.py index 7e9d566ff5..9a3725a12e 100644 --- a/pyUltroid/startup/_database.py +++ b/pyUltroid/startup/_database.py @@ -321,6 +321,7 @@ def __repr__(self): def UltroidDB(): + _er = False from .. import HOSTED_ON try: From 2841dab66709307589e6807aeca5289208a92783 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Tue, 13 Feb 2024 09:54:01 +0800 Subject: [PATCH 148/268] Update funcs.py --- pyUltroid/startup/funcs.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pyUltroid/startup/funcs.py b/pyUltroid/startup/funcs.py index b9fc0e0e24..d116686fde 100644 --- a/pyUltroid/startup/funcs.py +++ b/pyUltroid/startup/funcs.py @@ -12,12 +12,13 @@ import time from random import randint +from ..configs import Var + try: from pytz import timezone except ImportError: timezone = None -from decouple import RepositoryEnv, config from telethon.errors import ( ChannelsTooMuchError, ChatAdminRequiredError, @@ -40,7 +41,7 @@ InputMessagesFilterDocument, ) from telethon.utils import get_peer_id - +from decouple import config, RepositoryEnv from .. import LOGS, ULTConfig from ..fns.helper import download_file, inline_mention, updater @@ -88,7 +89,6 @@ async def autoupdate_local_database(): def update_envs(): """Update Var. attributes to udB""" from .. import udB - _envs = [*list(os.environ)] if ".env" in os.listdir("."): [_envs.append(_) for _ in list(RepositoryEnv(config._find_file(".")).data)] @@ -506,8 +506,6 @@ async def ready(): LOGS.exception(ef) if spam_sent and not spam_sent.media: udB.set_key("LAST_UPDATE_LOG_SPAM", spam_sent.id) - - # TODO: await fetch_ann() From b5fa11e5cff47371516f6c8d30674d3bef6ecd75 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Tue, 13 Feb 2024 09:56:56 +0800 Subject: [PATCH 149/268] Update .env.sample --- .env.sample | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.sample b/.env.sample index 39401bc3af..5100e50098 100644 --- a/.env.sample +++ b/.env.sample @@ -10,6 +10,6 @@ BOT_TOKEN= # [OPTIONAL] -MONGO= +MONGO_URI= PMLOGGROUP= GOOGLEAPI= From 4cd1ab92fa9c0f3eac2e3951d5c4a0039735e8f6 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Tue, 13 Feb 2024 11:05:08 +0800 Subject: [PATCH 150/268] Added Gemini #TODO create command for function inside GeminiUltroid class to clear mongo db if need be. --- plugins/chatgpt.py | 55 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/plugins/chatgpt.py b/plugins/chatgpt.py index ae4065bb22..3d783e8ff7 100644 --- a/plugins/chatgpt.py +++ b/plugins/chatgpt.py @@ -5,7 +5,7 @@ # PLease read the GNU Affero General Public License in # . """ -**Get Answers from Chat GPT including OpenAI** +**Get Answers from Chat GPT including OpenAI and Gemini** **Or generate images with Dall-E-3XL** **• Examples: ** @@ -13,10 +13,13 @@ > `{i}gpt -i Cute panda eating bamboo` > `{i}gpt2 How to get a url in Python` > `{i}igen2 a monkey with a banana` +> `{i}gemi how do hack an apple mac with a banana` • `{i}gpt` OpenAI • `{i}gpt -i` OpenAI DALL-E +• `{i}gemi` Ultroid Gemini + • `{i}gpt2` Safone API • `{i}igen2` Dall-E-3XL ImageGen """ @@ -31,6 +34,7 @@ import json from . import * +from pyUltroid.fns.gemini_helper import GeminiUltroid import os import sys @@ -40,7 +44,7 @@ try: import openai except ImportError: - system("pip3 install -q openai==0.28.0") + system("pip3 install -q openai") import openai from . import ( @@ -65,6 +69,14 @@ class AwesomeCoding(BaseModel): else: UFoPAPI = "" +try: + if udB.get_key("GOOGLEAPI") and udB.get_key("MONGO_URI"): + message = "Hello, Ultroid" + gUlt = await geminiUlt(message) +except Exception as e: + LOGS.exception(f"Unable to set GeminiUltroid: {e}") + LOGS.info(f"Unable to set GeminiUltroid: {e}") + @ultroid_cmd( pattern="(chat)?gpt( ([\\s\\S]*)|$)", @@ -258,3 +270,42 @@ async def handle_dalle3xl(message): LOGS.exception(f"Error: {str(e)}") error_message = f"An unexpected error occurred: {str(e)}" await reply.edit(error_message) + + +@nimbus_cmd( + pattern="(chat)?gemi( ([\\s\\S]*)|$)", +) +async def geminiUlt(message): + query = message.raw_text.split(f"{HNDLR}gemi", 1)[-1].strip() + user_id = bot.me.id + reply = await message.edit(f"`Generating answer...`") + try: + if udB.get_key("GOOGLEAPI") and udB.get_key("MONGO_URI"): + api_key = Keys.GOOGLEAPI + mongo_url = Keys.MONGO_URI + else: + raise ValueError("Missing required keys in the database") + except KeyError as e: + LOGS.exception(f"KeyError: {e}") + error_message = f"An Key error occurred: {str(e)}" + await reply.edit(error_message) + return + except ValueError as e: + LOGS.exception(e) + error_message = f"An value error occurred: {str(e)}" + await reply.edit(error_message) + return + except Exception as e: + LOGS.exception(f"Error: {str(e)}") + error_message = f"An unexpected error occurred: {str(e)}" + await reply.edit(error_message) + return + + gu = GeminiUltroid(api_key=api_key, mongo_url=mongo_url, user_id=user_id) + + answer, _ = await gu._GeminiUltroid__get_resp_gu(query=query) + reply = ( + f"Query:\n~ {query}\n\n" + f"AI: (UltGemi)\n~ {answer}" + ) + await message.edit(reply, parse_mode="html") From 8742f224ca8da8e21c39188a4eae2712d5814cc4 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Tue, 13 Feb 2024 11:24:54 +0800 Subject: [PATCH 151/268] Update en.yml --- strings/strings/en.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/strings/strings/en.yml b/strings/strings/en.yml index a9beac095d..fd13380ae0 100644 --- a/strings/strings/en.yml +++ b/strings/strings/en.yml @@ -644,6 +644,7 @@ help_variables: " -\n\n• `{i}get var `\n Get value of the giv help_vctools: " -\n\n• `{i}startvc`\n Start Group Call in a group.\n\n• `{i}stopvc`\n Stop Group Call in a group.\n\n• `{i}vctitle `\n Change the title Group call.\n\n• `{i}vcinvite`\n Invite all members of group in Group Call.\n (You must be joined)\n" help_videotools: " -\n\n•`{i}sample <duration in seconds>`\n Creates Short sample of video..\n\n• `{i}vshots <number of shots>`\n Creates screenshot of video..\n\n• `{i}vtrim <start time> - <end time> in seconds`\n Crop a Lengthy video..\n" help_warn: "\n\n•`{i}warn <reply to user> <reason>`\n Gives Warn.\n\n•`{i}resetwarn <reply to user>`\n To reset All Warns.\n\n•`{i}warns <reply to user>`\n To Get List of Warnings of a user.\n\n•`{i}setwarn <warn count> | <ban/mute/kick>`\n Set Number in warn count for warnings\n After putting ' | ' mark put action like ban/mute/kick\n Its Default 3 kick\n Example : `setwarn 5 | mute`\n\n" +help_weather: "-\n\n**Get Weather Data using OpenWeatherMap API**\n• {i}weather <Detailed forecast, needs API>\n• {i}wttr <Works without API key, less details> Currently not working\n\nUsage: `{i}weather <Location> or location,countrycode\n" help_webupload: " -\n\n• `{i}webupload`\n Upload files on another server.\n" help_words: " -\n\n• `{i}meaning <word>`\n Get the meaning of the word.\n\n• `{i}synonym <word>`\n Get all synonyms.\n\n• `{i}antonym <word>`\n Get all antonyms.\n\n• `{i}ud <word>`\n Fetch word defenition from urbandictionary.\n" help_ziptools: "\n\n• `{i}zip <reply to file>`\n zip the replied file\n To set password on zip: `{i}zip <password>` reply to file\n\n• `{i}unzip <reply to zip file>`\n unzip the replied file.\n\n• `{i}azip <reply to file>`\n add file to batch for batch upload zip\n\n• `{i}dozip`\n upload batch zip the files u added from `{i}azip`\n To set Password: `{i}dozip <password>`\n\n" From 29f8d814087b87ab1af6a9995fda23440e973a49 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 13 Feb 2024 11:28:28 +0800 Subject: [PATCH 152/268] Update en.yml --- strings/strings/en.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/strings/strings/en.yml b/strings/strings/en.yml index fd13380ae0..3a238249e3 100644 --- a/strings/strings/en.yml +++ b/strings/strings/en.yml @@ -644,7 +644,7 @@ help_variables: " -\n\n• `{i}get var <variable name>`\n Get value of the giv help_vctools: " -\n\n• `{i}startvc`\n Start Group Call in a group.\n\n• `{i}stopvc`\n Stop Group Call in a group.\n\n• `{i}vctitle <title>`\n Change the title Group call.\n\n• `{i}vcinvite`\n Invite all members of group in Group Call.\n (You must be joined)\n" help_videotools: " -\n\n•`{i}sample <duration in seconds>`\n Creates Short sample of video..\n\n• `{i}vshots <number of shots>`\n Creates screenshot of video..\n\n• `{i}vtrim <start time> - <end time> in seconds`\n Crop a Lengthy video..\n" help_warn: "\n\n•`{i}warn <reply to user> <reason>`\n Gives Warn.\n\n•`{i}resetwarn <reply to user>`\n To reset All Warns.\n\n•`{i}warns <reply to user>`\n To Get List of Warnings of a user.\n\n•`{i}setwarn <warn count> | <ban/mute/kick>`\n Set Number in warn count for warnings\n After putting ' | ' mark put action like ban/mute/kick\n Its Default 3 kick\n Example : `setwarn 5 | mute`\n\n" -help_weather: "-\n\n**Get Weather Data using OpenWeatherMap API**\n• {i}weather <Detailed forecast, needs API>\n• {i}wttr <Works without API key, less details> Currently not working\n\nUsage: `{i}weather <Location> or location,countrycode\n" +help_weather: "-\n\n**Get Weather Data using OpenWeatherMap API**\n• {i}weather <Detailed forecast, needs API>\n\nUsage: `{i}weather <Location> or location,countrycode\n" help_webupload: " -\n\n• `{i}webupload`\n Upload files on another server.\n" help_words: " -\n\n• `{i}meaning <word>`\n Get the meaning of the word.\n\n• `{i}synonym <word>`\n Get all synonyms.\n\n• `{i}antonym <word>`\n Get all antonyms.\n\n• `{i}ud <word>`\n Fetch word defenition from urbandictionary.\n" help_ziptools: "\n\n• `{i}zip <reply to file>`\n zip the replied file\n To set password on zip: `{i}zip <password>` reply to file\n\n• `{i}unzip <reply to zip file>`\n unzip the replied file.\n\n• `{i}azip <reply to file>`\n add file to batch for batch upload zip\n\n• `{i}dozip`\n upload batch zip the files u added from `{i}azip`\n To set Password: `{i}dozip <password>`\n\n" From dba4274daaae5dfb5430cd79ed3cd16e84ca6a5e Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 13 Feb 2024 11:29:59 +0800 Subject: [PATCH 153/268] Create weather.py --- plugins/weather.py | 76 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 plugins/weather.py diff --git a/plugins/weather.py b/plugins/weather.py new file mode 100644 index 0000000000..f1adb3eecf --- /dev/null +++ b/plugins/weather.py @@ -0,0 +1,76 @@ +# Ultroid ~ UserBot +# +# This file is a part of < https://github.com/TeamUltroid/Ultroid > +# PLease read the GNU Affero General Public License in +# <https://github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. +# original plugin from Uniborg. +# credits to original creator|s. +# ported to ultroid by [eris.] + +from . import get_help + +__doc__ = get_help("help_weather") + +import asyncio +import io +import time + +from . import * +from . import async_searcher + + +@ultroid_cmd(pattern="weather ?(.*)") +async def _(event): + if event.fwd_from: + return + reply = await eor(event, get_string("com_1")) + sample_url = ( + "https://api.openweathermap.org/data/2.5/weather?q={}&APPID={}&units=metric" + ) + x = udB.get_key("OPENWEATHER_API") + if x is None: + error = f"No API found. Get One from [Here](https://api.openweathermap.org) \n" + error += "And Add it in `OPENWEATHER_API` Redis Key" + await reply.edit(error) + return + input_str = event.pattern_match.group(1) + if not input_str: + await reply.edit("`No Location was Given..`") + return + elif input_str == "butler": + await reply.edit("search `butler,au` for australila") + asyncio.sleep(2) + + async def evaluate_response(response): + response_api = await response.json() + if response_api["cod"] == 200: + country_time_zone = int(response_api["timezone"]) + sun_rise_time = int(response_api["sys"]["sunrise"]) + country_time_zone + sun_set_time = int(response_api["sys"]["sunset"]) + country_time_zone + return ( + f"**Weather for {input_str}**\n" + f"__Country__ : **{response_api['sys']['country']}**\n\n" + f"• **Temperature :** {response_api['main']['temp']}°С\n" + f" • __minimium__ : {response_api['main']['temp_min']}°С\n" + f" • __maximum__ : {response_api['main']['temp_max']}°С\n" + f" • __feels like__ : {response_api['main']['feels_like']}°C\n\n" + f"• **Humidity :** {response_api['main']['humidity']}%\n" + f"• **Wind Speed :** {response_api['wind']['speed']}m/s\n" + f"• **Clouds :** {response_api['clouds']['all']} hpa\n" + f"• **Pressure :** {response_api['main']['pressure']}mb\n" + f"• **Visibility :** {response_api['visibility']}m\n\n" + f"• **Sunrise :** {time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(sun_rise_time))}\n" + f"• **Sunset :** {time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(sun_set_time))}" + ) + else: + return response_api["message"] + + try: + response_data = await async_searcher( + sample_url.format(input_str, x), evaluate=evaluate_response + ) + await reply.edit(response_data) + except Exception as e: + LOGS.exception(f"Error: {str(e)}") + error_message = f"An unexpected error occurred: {str(e)}" + await reply.edit(error_message) From 26739fb428ed4beee12c3e281523cc2bc45aed74 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 13 Feb 2024 11:58:40 +0800 Subject: [PATCH 154/268] Custom MD semi support --- plugins/afk.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/afk.py b/plugins/afk.py index ca39fd5144..74ef2e7ece 100644 --- a/plugins/afk.py +++ b/plugins/afk.py @@ -17,6 +17,7 @@ from pyUltroid.dB.afk_db import add_afk, del_afk, is_afk from pyUltroid.dB.base import KeyManager +from pyUltroid.fns.custom_markdown import CustomMarkdown from . import ( LOG_CHANNEL, @@ -55,6 +56,7 @@ async def set_afk(event): else: media = reply.file.id await event.eor("`Done`", time=2) + ultroid_bot.parse_mode = CustomMarkdown() add_afk(text, media_type, media) ultroid_bot.add_handler(remove_afk, events.NewMessage(outgoing=True)) ultroid_bot.add_handler( @@ -157,6 +159,7 @@ async def on_afk(event): if udB.get_key("AFK_DB"): + ultroid_bot.parse_mode = CustomMarkdown() ultroid_bot.add_handler(remove_afk, events.NewMessage(outgoing=True)) ultroid_bot.add_handler( on_afk, From 77e697293c411414d1a1f3ea0614416395aef381 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 13 Feb 2024 12:20:25 +0800 Subject: [PATCH 155/268] Update chatgpt.py --- plugins/chatgpt.py | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/plugins/chatgpt.py b/plugins/chatgpt.py index 3d783e8ff7..236c8fea40 100644 --- a/plugins/chatgpt.py +++ b/plugins/chatgpt.py @@ -19,6 +19,7 @@ • `{i}gpt -i` OpenAI DALL-E • `{i}gemi` Ultroid Gemini + * `{i}gemi -cleardb` < Use to clear your gemini db • `{i}gpt2` Safone API • `{i}igen2` Dall-E-3XL ImageGen @@ -272,13 +273,42 @@ async def handle_dalle3xl(message): await reply.edit(error_message) -@nimbus_cmd( +@ultroid_cmd( pattern="(chat)?gemi( ([\\s\\S]*)|$)", ) async def geminiUlt(message): query = message.raw_text.split(f"{HNDLR}gemi", 1)[-1].strip() user_id = bot.me.id reply = await message.edit(f"`Generating answer...`") + + if query == "-cleardb": + try: + if udB.get_key("GOOGLEAPI") and udB.get_key("MONGO_URI"): + api_key = Keys.GOOGLEAPI + mongo_url = Keys.MONGO_URI + else: + raise ValueError("Missing required keys in the database") + except KeyError as e: + LOGS.exception(f"KeyError: {e}") + error_message = f"An Key error occurred: {str(e)}" + await reply.edit(error_message) + return + except ValueError as e: + LOGS.exception(e) + error_message = f"An value error occurred: {str(e)}" + await reply.edit(error_message) + return + except Exception as e: + LOGS.exception(f"Error: {str(e)}") + error_message = f"An unexpected error occurred: {str(e)}" + await reply.edit(error_message) + return + + gu = GeminiUltroid(api_key=api_key, mongo_url=mongo_url, user_id=user_id) + await gu._clear_history_in_db() + await reply.edit("`GeminiUltroid database cleared successfully!`") + return + try: if udB.get_key("GOOGLEAPI") and udB.get_key("MONGO_URI"): api_key = Keys.GOOGLEAPI From 3b6f624874d6634c6f6ffc80a9fe7b2c26070332 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 13 Feb 2024 14:25:50 +0800 Subject: [PATCH 156/268] Update tools.py --- pyUltroid/fns/tools.py | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/pyUltroid/fns/tools.py b/pyUltroid/fns/tools.py index dd78484272..4369715076 100644 --- a/pyUltroid/fns/tools.py +++ b/pyUltroid/fns/tools.py @@ -789,27 +789,28 @@ def _package_rpc(text, lang_src="auto", lang_tgt="auto"): return freq -def translate(*args, **kwargs): +async def translate(text, lang_tgt): + url = "https://ufoptg-ufop-api.hf.space/ufop/translate" headers = { - "Referer": "https://translate.google.co.in", - "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) " - "AppleWebKit/537.36 (KHTML, like Gecko) " - "Chrome/47.0.2526.106 Safari/537.36", - "Content-Type": "application/x-www-form-urlencoded;charset=utf-8", + "accept": "application/json", + "Content-Type": "application/json", } - x = requests.post( - "https://translate.google.co.in/_/TranslateWebserverUi/data/batchexecute", - headers=headers, - data=_package_rpc(*args, **kwargs), - ).text - response = "" - data = json.loads(json.loads(x[4:])[0][2])[1][0][0] - subind = data[-2] - if not subind: - subind = data[-1] - for i in subind: - response += i[0] - return response + data = { + "text": text, + "setlang": lang_tgt + } + + response = await async_searcher(url, post=True, headers=headers, json=data) + + # Check if the response was successful + if response.status_code == 200: + result = response.json() + if result.get("status") == "True": + return result["randydev"]["translation"] + else: + return "Translation failed" + else: + return f"Translation failed with status code {response.status_code}" def cmd_regex_replace(cmd): From 7e05ca2d59487042ee58a74565636911814a5e41 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 13 Feb 2024 14:32:25 +0800 Subject: [PATCH 157/268] Translator Fix --- pyUltroid/fns/tools.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pyUltroid/fns/tools.py b/pyUltroid/fns/tools.py index 4369715076..327e25470f 100644 --- a/pyUltroid/fns/tools.py +++ b/pyUltroid/fns/tools.py @@ -803,14 +803,10 @@ async def translate(text, lang_tgt): response = await async_searcher(url, post=True, headers=headers, json=data) # Check if the response was successful - if response.status_code == 200: - result = response.json() - if result.get("status") == "True": - return result["randydev"]["translation"] - else: - return "Translation failed" + if "status" in response and response["status"] == "True": + return response["randydev"]["translation"] else: - return f"Translation failed with status code {response.status_code}" + return "Translation failed" def cmd_regex_replace(cmd): From e0a8e5fb4236702aab572b053d9345f116794fac Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 13 Feb 2024 14:36:47 +0800 Subject: [PATCH 158/268] Webshot fix --- plugins/tools.py | 54 ++++++++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/plugins/tools.py b/plugins/tools.py index 5fd04980e0..a29ff8348b 100644 --- a/plugins/tools.py +++ b/plugins/tools.py @@ -43,6 +43,8 @@ import re import secrets +import pyshorteners + try: import cv2 except ImportError: @@ -472,24 +474,36 @@ async def webss(event): @ultroid_cmd(pattern="shorturl") -async def magic(event): +async def short_url(event): + input_url = event.pattern_match.group(1) + + if not input_url: + reply_msg = await event.get_reply_message() + if reply_msg: + input_url = reply_msg.text + else: + return await eor(event, "`Please provide a URL to shorten.`") + try: - match = event.text.split(maxsplit=1)[1].strip() - except IndexError: - return await event.eor("`Provide url to turn into tiny...`") - data = { - "url": match.split()[0], - "id": match[1] if len(match) > 1 else secrets.token_urlsafe(6), - } - data = await async_searcher( - "https://tiny.ultroid.tech/api/new", - data=data, - post=True, - re_json=True, - ) - response = data.get("response", {}) - if not response.get("status"): - return await event.eor(f'**ERROR :** `{response["message"]}`') - await event.eor( - f"• **Ultroid Tiny**\n• Given Url : {url}\n• Shorten Url : {data['response']['tinyUrl']}" - ) + s = pyshorteners.Shortener() + if "http://tinyurl.com" in input_url.lower(): + shortened_url = s.tinyurl.expand(input_url) + action = "Expanded" + else: + shortened_url = s.tinyurl.short(input_url) + action = "Shortened" + + output_message = ( + f"**URL {action}**\n" + f"**Given Link** ➠ **{input_url}**\n" + f"**{action} Link** ➠ **[LINK]({shortened_url})**" + ) + + if event.reply_to_msg_id: + await event.delete() + await event.reply(output_message) + else: + await eor(event, output_message) + + except Exception as e: + await eor(event, f"An error occurred: {e}") From f27d93257614308f615e6492c24f57d237400d2d Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 13 Feb 2024 14:38:38 +0800 Subject: [PATCH 159/268] Update requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index b0fa7d1d1e..dfd88e8287 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,3 +4,4 @@ https://github.com/New-dev0/Telethon/archive/platy.zip python-decouple python-dotenv pymongo +pyshorteners From 639da46dbea81b31299dc6353836a6275989311d Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 13 Feb 2024 14:58:16 +0800 Subject: [PATCH 160/268] translator fix --- pyUltroid/fns/tools.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/pyUltroid/fns/tools.py b/pyUltroid/fns/tools.py index 327e25470f..70e9b82b61 100644 --- a/pyUltroid/fns/tools.py +++ b/pyUltroid/fns/tools.py @@ -800,13 +800,18 @@ async def translate(text, lang_tgt): "setlang": lang_tgt } - response = await async_searcher(url, post=True, headers=headers, json=data) - - # Check if the response was successful - if "status" in response and response["status"] == "True": - return response["randydev"]["translation"] - else: - return "Translation failed" + try: + async with aiohttp.ClientSession() as session: + async with session.post(url, headers=headers, json=data) as response: + response.raise_for_status() # Raise an exception for 4XX or 5XX status codes + result = await response.json() + + if result.get("status") == "True": + return result["randydev"]["translation"] + else: + return "Translation failed" + except aiohttp.ClientError as e: + return f"Error: {e}" def cmd_regex_replace(cmd): From aafe186e699bb5ed3915f4eee0dce85be748f573 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 13 Feb 2024 15:20:10 +0800 Subject: [PATCH 161/268] Update helper.py --- pyUltroid/fns/helper.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pyUltroid/fns/helper.py b/pyUltroid/fns/helper.py index a066ffe6be..5cbfde465c 100644 --- a/pyUltroid/fns/helper.py +++ b/pyUltroid/fns/helper.py @@ -47,6 +47,7 @@ from telethon.helpers import _maybe_await from telethon.tl import types +from telethon.tl.custom import Message from telethon.utils import get_display_name from .._misc import CMD_HELP From 525f68b60b429b144e0d9c2ba85c73c37ed09013 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 13 Feb 2024 15:21:31 +0800 Subject: [PATCH 162/268] imports --- pyUltroid/fns/helper.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyUltroid/fns/helper.py b/pyUltroid/fns/helper.py index 5cbfde465c..35be585d6e 100644 --- a/pyUltroid/fns/helper.py +++ b/pyUltroid/fns/helper.py @@ -41,9 +41,11 @@ Repo = None +import asyncio import multiprocessing from concurrent.futures import ThreadPoolExecutor from functools import partial, wraps +from typing import List, Optional from telethon.helpers import _maybe_await from telethon.tl import types From d0adaf9704e3f609d77e8c0a3278573820f244d8 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 13 Feb 2024 15:27:50 +0800 Subject: [PATCH 163/268] Telegraph error handle --- pyUltroid/fns/tools.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pyUltroid/fns/tools.py b/pyUltroid/fns/tools.py index 70e9b82b61..6fdc7f403b 100644 --- a/pyUltroid/fns/tools.py +++ b/pyUltroid/fns/tools.py @@ -678,8 +678,11 @@ def telegraph_client(): from .. import udB, ultroid_bot token = udB.get_key("_TELEGRAPH_TOKEN") - TELEGRAPH_DOMAIN = udB.get_key("GRAPH_DOMAIN") - TelegraphClient = Telegraph(token, domain=TELEGRAPH_DOMAIN or "graph.org") + if udB.get_key("GRAPH_DOMAIN"): + TELEGRAPH_DOMAIN = Keys.GRAPH_DOMAIN + TelegraphClient = Telegraph(token, domain=TELEGRAPH_DOMAIN or "graph.org") + else: + TelegraphClient = Telegraph(token) if token: TELEGRAPH.append(TelegraphClient) return TelegraphClient From 7186007807322f4fc200c6e9a1c1a99efdf70c7c Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 13 Feb 2024 15:39:02 +0800 Subject: [PATCH 164/268] Update chatgpt.py --- plugins/chatgpt.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/plugins/chatgpt.py b/plugins/chatgpt.py index 236c8fea40..31396dddbf 100644 --- a/plugins/chatgpt.py +++ b/plugins/chatgpt.py @@ -70,14 +70,16 @@ class AwesomeCoding(BaseModel): else: UFoPAPI = "" -try: - if udB.get_key("GOOGLEAPI") and udB.get_key("MONGO_URI"): - message = "Hello, Ultroid" - gUlt = await geminiUlt(message) -except Exception as e: - LOGS.exception(f"Unable to set GeminiUltroid: {e}") - LOGS.info(f"Unable to set GeminiUltroid: {e}") - +async def GeminiBase(): + try: + if udB.get_key("GOOGLEAPI") and udB.get_key("MONGO_URI"): + api_key = Keys.GOOGLEAPI + mongo_url = Keys.MONGO_URI + user_id = bot.me.id + await geminiUlt(message, api_key, mongo_url, user_id) + except Exception as e: + LOGS.exception(f"Error occurred: {e}") + LOGS.info(f"Error occurred: {e}") @ultroid_cmd( pattern="(chat)?gpt( ([\\s\\S]*)|$)", @@ -339,3 +341,5 @@ async def geminiUlt(message): f"<b>AI:</b> <i>(UltGemi)</i>\n~ <i>{answer}</i>" ) await message.edit(reply, parse_mode="html") + +asyncio.run(GeminiBase()) From 0701487b3ff4eca9c6742b19a3d8900ee33ffb7d Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 13 Feb 2024 15:41:00 +0800 Subject: [PATCH 165/268] Update tools.py --- plugins/tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/tools.py b/plugins/tools.py index a29ff8348b..3fadbda0b2 100644 --- a/plugins/tools.py +++ b/plugins/tools.py @@ -359,7 +359,7 @@ async def _(e): await e.delete() -@ultroid( +@ultroid_cmd( pattern="sg(|u)(?:\\s|$)([\\s\\S]*)", fullsudo=True, ) From 98023aadfaf4f2196bd2d24815a835e27ca57eab Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 13 Feb 2024 15:44:48 +0800 Subject: [PATCH 166/268] Update pmbot.py --- assistant/pmbot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assistant/pmbot.py b/assistant/pmbot.py index 6f0fb96d28..a7f1618759 100644 --- a/assistant/pmbot.py +++ b/assistant/pmbot.py @@ -27,10 +27,10 @@ from . import * botb = KeyManager("BOTBLS", cast=list) -FSUB = Keys.PMBOT_FSUB +FSUB = udB.get_key("PMBOT_FSUB") PMBOTGROUP = Keys.LOG_CHANNEL CACHE = {} -SUDOS = Keys.SUDOS +SUDOS = udB.get_key("SUDOS") PMUSERS = [OWNER_ID, SUDOS] logging.basicConfig( format="%(asctime)s | %(name)s [%(levelname)s] : %(message)s", From db2e4a7170874ff34f192454d1c8ceb8776c85df Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 13 Feb 2024 16:10:35 +0800 Subject: [PATCH 167/268] Gemini --- plugins/chatgpt.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/plugins/chatgpt.py b/plugins/chatgpt.py index 31396dddbf..0647fbd17d 100644 --- a/plugins/chatgpt.py +++ b/plugins/chatgpt.py @@ -70,16 +70,6 @@ class AwesomeCoding(BaseModel): else: UFoPAPI = "" -async def GeminiBase(): - try: - if udB.get_key("GOOGLEAPI") and udB.get_key("MONGO_URI"): - api_key = Keys.GOOGLEAPI - mongo_url = Keys.MONGO_URI - user_id = bot.me.id - await geminiUlt(message, api_key, mongo_url, user_id) - except Exception as e: - LOGS.exception(f"Error occurred: {e}") - LOGS.info(f"Error occurred: {e}") @ultroid_cmd( pattern="(chat)?gpt( ([\\s\\S]*)|$)", @@ -282,7 +272,20 @@ async def geminiUlt(message): query = message.raw_text.split(f"{HNDLR}gemi", 1)[-1].strip() user_id = bot.me.id reply = await message.edit(f"`Generating answer...`") - + if not udB.get_key("GemBase"): + udB.set_key("GemBase", "True") + try: + if udB.get_key("GOOGLEAPI") and udB.get_key("MONGO_URI"): + api_key = Keys.GOOGLEAPI + mongo_url = Keys.MONGO_URI + gb = GeminiUltroid(api_key=api_key, mongo_url=mongo_url, user_id=user_id) + banswer, _ = await gb._GeminiUltroid__get_resp_gu(query="Hello, Ultroid") + except Exception as e: + LOGS.exception(f"Error occurred: {e}") + LOGS.info(f"Error occurred: {e}") + else: + pass + if query == "-cleardb": try: if udB.get_key("GOOGLEAPI") and udB.get_key("MONGO_URI"): @@ -309,6 +312,7 @@ async def geminiUlt(message): gu = GeminiUltroid(api_key=api_key, mongo_url=mongo_url, user_id=user_id) await gu._clear_history_in_db() await reply.edit("`GeminiUltroid database cleared successfully!`") + udB.del_key("GemBase") return try: @@ -341,5 +345,3 @@ async def geminiUlt(message): f"<b>AI:</b> <i>(UltGemi)</i>\n~ <i>{answer}</i>" ) await message.edit(reply, parse_mode="html") - -asyncio.run(GeminiBase()) From 7d1eb86dfd7c6ee7a77434cf07694e20e14e36e3 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 13 Feb 2024 16:13:15 +0800 Subject: [PATCH 168/268] fix --- plugins/tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/tools.py b/plugins/tools.py index 3fadbda0b2..6374aaa5ce 100644 --- a/plugins/tools.py +++ b/plugins/tools.py @@ -119,7 +119,7 @@ async def _(event): ) lan = input or "en" try: - tt = translate(text, lang_tgt=lan) + tt = await translate(text, lang_tgt=lan) output_str = f"**TRANSLATED** to {lan}\n{tt}" await event.eor(output_str) except Exception as exc: From b3379f6aeb65258f0bb26f6a0252b3f9f2a6ac06 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 13 Feb 2024 16:35:54 +0800 Subject: [PATCH 169/268] Security fix --- plugins/tools.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/plugins/tools.py b/plugins/tools.py index 6374aaa5ce..7aa64e2d5f 100644 --- a/plugins/tools.py +++ b/plugins/tools.py @@ -475,28 +475,25 @@ async def webss(event): @ultroid_cmd(pattern="shorturl") async def short_url(event): - input_url = event.pattern_match.group(1) - - if not input_url: + input_url = None + + if event.pattern_match.group(1): + input_url = event.pattern_match.group(1) + else: reply_msg = await event.get_reply_message() - if reply_msg: + if reply_msg and reply_msg.text: input_url = reply_msg.text else: return await eor(event, "`Please provide a URL to shorten.`") try: s = pyshorteners.Shortener() - if "http://tinyurl.com" in input_url.lower(): - shortened_url = s.tinyurl.expand(input_url) - action = "Expanded" - else: - shortened_url = s.tinyurl.short(input_url) - action = "Shortened" - + shortened_url = s.tinyurl.short(input_url) + output_message = ( - f"**URL {action}**\n" + f"**URL Shortened**\n" f"**Given Link** ➠ **{input_url}**\n" - f"**{action} Link** ➠ **[LINK]({shortened_url})**" + f"**Shortened Link** ➠ **[LINK]({shortened_url})**" ) if event.reply_to_msg_id: From 61c8b54c956e5211137f56a0b2ae50eb237b010e Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 13 Feb 2024 16:40:08 +0800 Subject: [PATCH 170/268] Update chatgpt.py --- plugins/chatgpt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/chatgpt.py b/plugins/chatgpt.py index 0647fbd17d..1142786f62 100644 --- a/plugins/chatgpt.py +++ b/plugins/chatgpt.py @@ -278,7 +278,7 @@ async def geminiUlt(message): if udB.get_key("GOOGLEAPI") and udB.get_key("MONGO_URI"): api_key = Keys.GOOGLEAPI mongo_url = Keys.MONGO_URI - gb = GeminiUltroid(api_key=api_key, mongo_url=mongo_url, user_id=user_id) + gb = GeminiUltroid(api_key=api_key, mongo_url=mongo_url, user_id=user_id) banswer, _ = await gb._GeminiUltroid__get_resp_gu(query="Hello, Ultroid") except Exception as e: LOGS.exception(f"Error occurred: {e}") From 11d85234d6f5498c75904c75f82c915dea9eafd8 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Wed, 14 Feb 2024 03:15:15 +0800 Subject: [PATCH 171/268] Update chatgpt.py --- plugins/chatgpt.py | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/plugins/chatgpt.py b/plugins/chatgpt.py index 1142786f62..3f406b95de 100644 --- a/plugins/chatgpt.py +++ b/plugins/chatgpt.py @@ -4,26 +4,11 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid > # PLease read the GNU Affero General Public License in # <https://github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -**Get Answers from Chat GPT including OpenAI and Gemini** -**Or generate images with Dall-E-3XL** - -**• Examples: ** -> `{i}gpt How to get a url in Python` -> `{i}gpt -i Cute panda eating bamboo` -> `{i}gpt2 How to get a url in Python` -> `{i}igen2 a monkey with a banana` -> `{i}gemi how do hack an apple mac with a banana` - -• `{i}gpt` OpenAI -• `{i}gpt -i` OpenAI DALL-E - -• `{i}gemi` Ultroid Gemini - * `{i}gemi -cleardb` < Use to clear your gemini db - -• `{i}gpt2` Safone API -• `{i}igen2` Dall-E-3XL ImageGen -""" + +from . import get_help + +__doc__ = get_help("help_chatgpt") + import aiohttp import base64 import asyncio From c9b063bb8aa903bf4b42476696d56a7b7b1e3f8b Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Wed, 14 Feb 2024 03:17:05 +0800 Subject: [PATCH 172/268] gpt string --- strings/strings/en.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/strings/strings/en.yml b/strings/strings/en.yml index 3a238249e3..1af9e53007 100644 --- a/strings/strings/en.yml +++ b/strings/strings/en.yml @@ -597,6 +597,7 @@ help_button: " -\n\n• `{i}button <text with button format`\n create button u help_calculator: " -\n\n•`{i}calc` - Inline Calculator\n\n" help_channelhacks: "\n\n🔹 `{i}shift <from channel> | <to channel>`\n This will transfer all old post from channel A to channel B.\n (u can use username or id of channel too)\n example : `{i}shift @abc | @xyz`\n [note - this (' | ') sign is nessesary]\n\n🔹 For auto-posting/forwarding all new message from any source channel to any destination channel.\n\n `{i}asource <channel username or id>`\n This add source channel to database\n `{i}dsource <channel username or id>`\n This remove source channels from database\n `{i}listsource <channel username or id>`\n Show list of source channels\n\n\n `{i}adest <channel username or id>`\n This add Ur channels to database\n `{i}ddest <channel username or id>`\n This Remove Ur channels from database\n `{i}listdest <channel username or id>`\n Show List of Ur channels\n\n 'you can set many channels in database'\n 'For activating auto-post use `{i}setdb AUTOPOST True` '\n" help_chatbot: " -\n\n**PaLM 2 Chatbot and Gemini Oracle**\n\n• `{i}addai` or `{i}addoai` <reply to user/give username/userid>\n Add an AI ChatBot to reply to that user.\n\n• `{i}remai` or `{i}remoai` <reply to user/give username/userid>\n Remove the AI ChatBot.\n\n• `{i}repai` or `{i}repoai` <reply to user/give a message>\n Reply to the user with a message by an AI.\n\n• `{i}listai` or `{i}listoai`\n List the currently AI added users.\n" +help_chatgpt: " -\n\n"**Get Answers from Chat GPT including OpenAI and Gemini\nOr generate images with Dall-E-3XL**\n\n**• Examples: **\n> {i}gpt How to get a url in Python\n> {i}gpt -i Cute panda eating bamboo\n> {i}gpt2 How to get a url in Python\n> {i}igen2 a monkey with a banana\n> {i}gemi how do hack an apple mac with a banana\n\n• {i}gpt OpenAI \n• {i}gpt -i OpenAI DALL-E\n\n• {i}gemi Ultroid Gemini\n * {i}gemi -cleardb < Use to clear your gemini db\n\n• {i}gpt2 Safone API\n• {i}igen2 Dall-E-3XL ImageGen" help_chats: " -\n\n• `{i}delchat <optional- username/id>`\n Delete the group this cmd is used in.\n\n• `{i}getlink`\n• `{i}getlink r` - `create link with admin approval`\n• `{i}getlink r title_here` - `admin approval with link title`\n• `{i}getlink 10` - `usage limit in new link`\n Get link of group this cmd is used in.\n\n• `{i}create (g|b|c) <group_name> ; <optional-username>`\n Create group woth a specific name.\n g - megagroup/supergroup\n b - small group\n c - channel\n\n• `{i}setgpic <reply to Photo><chat username>`\n Set Profile photo of Group.\n\n• `{i}delgpic <chat username -optional>`\n Delete Profile photo of Group.\n\n• `{i}unbanall`\n Unban all Members of a group.\n\n• `{i}rmusers`\n Remove users specifically.\n" help_cleanaction: " -\n\n•`{i}addclean`\n Clean all Upcoming action msg in added chat like someone joined/left/pin etc.\n\n•`{i}remclean`\n Remove chat from database.\n\n•`{i}listclean`\n To get list of all chats where its activated.\n\n" help_converter: " -\n\n• `{i}convert <gif/img/sticker/webm>`\n Reply to media to convert it into gif / image / webm / normal sticker.\n\n• `{i}doc <filename.ext>`\n Reply to a text msg to save it in a file.\n\n• `{i}open`\n Reply to a file to reveal it's text.\n\n• `{i}rename <file name with extension>`\n Rename the file\n\n• `{i}thumbnail <reply to image/thumbnail file>`\n Upload Your file with your custom thumbnail.\n" From a7b3d8028e9fdc621a1145cc9a6823906b4bd52e Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Wed, 14 Feb 2024 03:22:26 +0800 Subject: [PATCH 173/268] strings --- plugins/ziptools.py | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/plugins/ziptools.py b/plugins/ziptools.py index 80681adfc9..ae16717aa6 100644 --- a/plugins/ziptools.py +++ b/plugins/ziptools.py @@ -4,24 +4,11 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available -• `{i}zip <reply to file>` - zip the replied file - To set password on zip: `{i}zip <password>` reply to file +from . import get_help -• `{i}unzip <reply to zip file>` - unzip the replied file. +__doc__ = get_help("help_ziptools") -• `{i}azip <reply to file>` - add file to batch for batch upload zip - -• `{i}dozip` - upload batch zip the files u added from `{i}azip` - To set Password: `{i}dozip <password>` - -""" import os import time From bf52b69d42eb4cefbdfd06e635f244bc947e8d2a Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Wed, 14 Feb 2024 03:27:42 +0800 Subject: [PATCH 174/268] Update en.yml --- strings/strings/en.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/strings/strings/en.yml b/strings/strings/en.yml index 1af9e53007..bc3613935b 100644 --- a/strings/strings/en.yml +++ b/strings/strings/en.yml @@ -648,4 +648,5 @@ help_warn: "\n\n•`{i}warn <reply to user> <reason>`\n Gives Warn.\n\n•`{i help_weather: "-\n\n**Get Weather Data using OpenWeatherMap API**\n• {i}weather <Detailed forecast, needs API>\n\nUsage: `{i}weather <Location> or location,countrycode\n" help_webupload: " -\n\n• `{i}webupload`\n Upload files on another server.\n" help_words: " -\n\n• `{i}meaning <word>`\n Get the meaning of the word.\n\n• `{i}synonym <word>`\n Get all synonyms.\n\n• `{i}antonym <word>`\n Get all antonyms.\n\n• `{i}ud <word>`\n Fetch word defenition from urbandictionary.\n" +help_writer: " -\n\n• {i}write <text or reply to text> It will write on a paper.\n• {i}image <text or reply to html or any doc file> Write an image from HTML or any text." help_ziptools: "\n\n• `{i}zip <reply to file>`\n zip the replied file\n To set password on zip: `{i}zip <password>` reply to file\n\n• `{i}unzip <reply to zip file>`\n unzip the replied file.\n\n• `{i}azip <reply to file>`\n add file to batch for batch upload zip\n\n• `{i}dozip`\n upload batch zip the files u added from `{i}azip`\n To set Password: `{i}dozip <password>`\n\n" From dcde6793653b8c782a2ebbdfc8aae3bdd8bbe6f5 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Wed, 14 Feb 2024 03:34:13 +0800 Subject: [PATCH 175/268] Update youtube.py --- plugins/youtube.py | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/plugins/youtube.py b/plugins/youtube.py index 70cf68914a..9b7a3aeffc 100644 --- a/plugins/youtube.py +++ b/plugins/youtube.py @@ -4,24 +4,11 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - -• `{i}yta <(youtube/any) link>` - Download audio from the link. +from . import get_help -• `{i}ytv <(youtube/any) link>` - Download video from the link. +__doc__ = get_help("help_youtube") -• `{i}ytsa <(youtube) search query>` - Search and download audio from youtube. - -• `{i}ytsv <(youtube) search query>` - Search and download video from youtube. - -• `{i}ytsc <soundcloud link>` - Download audio from SoundCloud. -""" from pyUltroid.fns.ytdl import download_yt, get_yt_link from . import get_string, requests, ultroid_cmd From 3e25e2865e032fd442800ee277c0645c1d69e2e0 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Wed, 14 Feb 2024 03:39:48 +0800 Subject: [PATCH 176/268] Update en.yml --- strings/strings/en.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/strings/strings/en.yml b/strings/strings/en.yml index bc3613935b..38f91b3976 100644 --- a/strings/strings/en.yml +++ b/strings/strings/en.yml @@ -649,4 +649,5 @@ help_weather: "-\n\n**Get Weather Data using OpenWeatherMap API**\n• {i}weath help_webupload: " -\n\n• `{i}webupload`\n Upload files on another server.\n" help_words: " -\n\n• `{i}meaning <word>`\n Get the meaning of the word.\n\n• `{i}synonym <word>`\n Get all synonyms.\n\n• `{i}antonym <word>`\n Get all antonyms.\n\n• `{i}ud <word>`\n Fetch word defenition from urbandictionary.\n" help_writer: " -\n\n• {i}write <text or reply to text> It will write on a paper.\n• {i}image <text or reply to html or any doc file> Write an image from HTML or any text." +help_youtube: "-\n\n• {i}yta <(youtube/any) link> Download audio from the link.\n• {i}ytv <(youtube/any) link> Download video from the link.\n• {i}ytsa <(youtube) search query> Search and download audio from YouTube.\n• {i}ytsv <(youtube) search query> Search and download video from YouTube.\n• {i}ytsc <soundcloud link> Download audio from SoundCloud." help_ziptools: "\n\n• `{i}zip <reply to file>`\n zip the replied file\n To set password on zip: `{i}zip <password>` reply to file\n\n• `{i}unzip <reply to zip file>`\n unzip the replied file.\n\n• `{i}azip <reply to file>`\n add file to batch for batch upload zip\n\n• `{i}dozip`\n upload batch zip the files u added from `{i}azip`\n To set Password: `{i}dozip <password>`\n\n" From 57a1cd87b9e7bc65888ebed1c11da69a22d834b0 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Wed, 14 Feb 2024 03:44:30 +0800 Subject: [PATCH 177/268] Update writer.py --- plugins/writer.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/plugins/writer.py b/plugins/writer.py index ce49508109..b46eb0242d 100644 --- a/plugins/writer.py +++ b/plugins/writer.py @@ -5,15 +5,9 @@ # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - +from . import get_help -• `{i}write <text or reply to text>` - It will write on a paper. - -• `{i}image <text or reply to html or any doc file>` - Write a image from html or any text. -""" +__doc__ = get_help("help_fontgen") import os From 1c41666eabc1184aac688c48d0d526d7bf4f31d6 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Wed, 14 Feb 2024 03:46:36 +0800 Subject: [PATCH 178/268] strings --- plugins/words.py | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/plugins/words.py b/plugins/words.py index 93cc9c2746..8daeac10e2 100644 --- a/plugins/words.py +++ b/plugins/words.py @@ -4,21 +4,11 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - -• `{i}meaning <word>` - Get the meaning of the word. +from . import get_help -• `{i}synonym <word>` - Get all synonyms. +__doc__ = get_help("help_fontgen") -• `{i}antonym <word>` - Get all antonyms. - -• `{i}ud <word>` - Fetch word defenition from urbandictionary. -""" import io from pyUltroid.fns.misc import get_synonyms_or_antonyms From 7a9da843979306d1bf72f71bf08d854200ef6334 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Wed, 14 Feb 2024 03:47:05 +0800 Subject: [PATCH 179/268] Update words.py --- plugins/words.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/words.py b/plugins/words.py index 8daeac10e2..964bb3761b 100644 --- a/plugins/words.py +++ b/plugins/words.py @@ -7,7 +7,7 @@ from . import get_help -__doc__ = get_help("help_fontgen") +__doc__ = get_help("help_writer") import io From af68a9e9278c48f0d22011321e9e83b7ded5b6f7 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Wed, 14 Feb 2024 03:47:35 +0800 Subject: [PATCH 180/268] Update words.py --- plugins/words.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/words.py b/plugins/words.py index 964bb3761b..13ba7eab9a 100644 --- a/plugins/words.py +++ b/plugins/words.py @@ -7,7 +7,7 @@ from . import get_help -__doc__ = get_help("help_writer") +__doc__ = get_help("help_words") import io From 3d52a9e6a7875c0c6e525bae0adabe554c1a5863 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Wed, 14 Feb 2024 03:50:40 +0800 Subject: [PATCH 181/268] Update webupload.py --- plugins/webupload.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/plugins/webupload.py b/plugins/webupload.py index c9a462f38e..ec6acc64bb 100644 --- a/plugins/webupload.py +++ b/plugins/webupload.py @@ -5,12 +5,9 @@ # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - +from . import get_help -• `{i}webupload` - Upload files on another server. -""" +__doc__ = get_help("help_webupload") import os From 0ae7232a30ea751e89dc45269cb09062098d2104 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Wed, 14 Feb 2024 03:51:03 +0800 Subject: [PATCH 182/268] Update writer.py --- plugins/writer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/writer.py b/plugins/writer.py index b46eb0242d..c8a61a81f0 100644 --- a/plugins/writer.py +++ b/plugins/writer.py @@ -7,7 +7,7 @@ from . import get_help -__doc__ = get_help("help_fontgen") +__doc__ = get_help("help_writer") import os From 8f1c41e61db68e7b669f833f5e644cecd7518ffb Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Wed, 14 Feb 2024 03:53:21 +0800 Subject: [PATCH 183/268] strings --- plugins/warn.py | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/plugins/warn.py b/plugins/warn.py index 70966cfb2b..de35528636 100644 --- a/plugins/warn.py +++ b/plugins/warn.py @@ -4,25 +4,10 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available -•`{i}warn <reply to user> <reason>` - Gives Warn. +from . import get_help -•`{i}resetwarn <reply to user>` - To reset All Warns. - -•`{i}warns <reply to user>` - To Get List of Warnings of a user. - -•`{i}setwarn <warn count> | <ban/mute/kick>` - Set Number in warn count for warnings - After putting " | " mark put action like ban/mute/kick - Its Default 3 kick - Example : `setwarn 5 | mute` - -""" +__doc__ = get_help("help_warn") from pyUltroid.dB.warn_db import add_warn, reset_warn, warns From c92cc31492bc2d443ee326c8e870be94c316fc5f Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Wed, 14 Feb 2024 03:54:00 +0800 Subject: [PATCH 184/268] Update videotools.py --- plugins/videotools.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/plugins/videotools.py b/plugins/videotools.py index ee1731dee7..4b059e03d1 100644 --- a/plugins/videotools.py +++ b/plugins/videotools.py @@ -4,18 +4,10 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - -•`{i}sample <duration in seconds>` - Creates Short sample of video.. +from . import get_help -• `{i}vshots <number of shots>` - Creates screenshot of video.. - -• `{i}vtrim <start time> - <end time> in seconds` - Crop a Lengthy video.. -""" +__doc__ = get_help("help_videotools") import glob import os From a97444203ccbfbd473cb049b8fcaaed1c94effd1 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Wed, 14 Feb 2024 03:54:35 +0800 Subject: [PATCH 185/268] Update vctools.py --- plugins/vctools.py | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/plugins/vctools.py b/plugins/vctools.py index 9a950368e8..2684e261c7 100644 --- a/plugins/vctools.py +++ b/plugins/vctools.py @@ -4,22 +4,10 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - -• `{i}startvc` - Start Group Call in a group. +from . import get_help -• `{i}stopvc` - Stop Group Call in a group. - -• `{i}vctitle <title>` - Change the title Group call. - -• `{i}vcinvite` - Invite all members of group in Group Call. - (You must be joined) -""" +__doc__ = get_help("help_vctools") from telethon.tl.functions.channels import GetFullChannelRequest as getchat from telethon.tl.functions.phone import CreateGroupCallRequest as startvc From 683c72e8d453a2e24075372e485d8d7570e43cab Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Wed, 14 Feb 2024 03:55:31 +0800 Subject: [PATCH 186/268] Update variables.py --- plugins/variables.py | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/plugins/variables.py b/plugins/variables.py index 8434dbea41..75fb5027eb 100644 --- a/plugins/variables.py +++ b/plugins/variables.py @@ -4,21 +4,10 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - -• `{i}get var <variable name>` - Get value of the given variable name. +from . import get_help -• `{i}get type <variable name>` - Get variable type. - -• `{i}get db <key>` - Get db value of the given key. - -• `{i}get keys` - Get all redis keys. -""" +__doc__ = get_help("help_variables") import os From 55b80c315c020079b8eae743943e80c1cd7a1a12 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Wed, 14 Feb 2024 04:08:23 +0800 Subject: [PATCH 187/268] Update en.yml --- strings/strings/en.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/strings/strings/en.yml b/strings/strings/en.yml index 38f91b3976..c47be51903 100644 --- a/strings/strings/en.yml +++ b/strings/strings/en.yml @@ -7,6 +7,7 @@ authors: - sppidy - ProgrammingError - aviskumar + - # pyUltroid py_c1: "Wrong string session. Copy paste correctly!" @@ -597,7 +598,7 @@ help_button: " -\n\n• `{i}button <text with button format`\n create button u help_calculator: " -\n\n•`{i}calc` - Inline Calculator\n\n" help_channelhacks: "\n\n🔹 `{i}shift <from channel> | <to channel>`\n This will transfer all old post from channel A to channel B.\n (u can use username or id of channel too)\n example : `{i}shift @abc | @xyz`\n [note - this (' | ') sign is nessesary]\n\n🔹 For auto-posting/forwarding all new message from any source channel to any destination channel.\n\n `{i}asource <channel username or id>`\n This add source channel to database\n `{i}dsource <channel username or id>`\n This remove source channels from database\n `{i}listsource <channel username or id>`\n Show list of source channels\n\n\n `{i}adest <channel username or id>`\n This add Ur channels to database\n `{i}ddest <channel username or id>`\n This Remove Ur channels from database\n `{i}listdest <channel username or id>`\n Show List of Ur channels\n\n 'you can set many channels in database'\n 'For activating auto-post use `{i}setdb AUTOPOST True` '\n" help_chatbot: " -\n\n**PaLM 2 Chatbot and Gemini Oracle**\n\n• `{i}addai` or `{i}addoai` <reply to user/give username/userid>\n Add an AI ChatBot to reply to that user.\n\n• `{i}remai` or `{i}remoai` <reply to user/give username/userid>\n Remove the AI ChatBot.\n\n• `{i}repai` or `{i}repoai` <reply to user/give a message>\n Reply to the user with a message by an AI.\n\n• `{i}listai` or `{i}listoai`\n List the currently AI added users.\n" -help_chatgpt: " -\n\n"**Get Answers from Chat GPT including OpenAI and Gemini\nOr generate images with Dall-E-3XL**\n\n**• Examples: **\n> {i}gpt How to get a url in Python\n> {i}gpt -i Cute panda eating bamboo\n> {i}gpt2 How to get a url in Python\n> {i}igen2 a monkey with a banana\n> {i}gemi how do hack an apple mac with a banana\n\n• {i}gpt OpenAI \n• {i}gpt -i OpenAI DALL-E\n\n• {i}gemi Ultroid Gemini\n * {i}gemi -cleardb < Use to clear your gemini db\n\n• {i}gpt2 Safone API\n• {i}igen2 Dall-E-3XL ImageGen" +help_chatgpt: " -\n\n**Get Answers from Chat GPT including OpenAI and Gemini\nOr generate images with Dall-E-3XL**\n\n**• Examples: **\n> {i}gpt How to get a url in Python\n> {i}gpt -i Cute panda eating bamboo\n> {i}gpt2 How to get a url in Python\n> {i}igen2 a monkey with a banana\n> {i}gemi how do hack an apple mac with a banana\n\n• {i}gpt OpenAI \n• {i}gpt -i OpenAI DALL-E\n\n• {i}gemi Ultroid Gemini\n * {i}gemi -cleardb < Use to clear your gemini db\n\n• {i}gpt2 Safone API\n• {i}igen2 Dall-E-3XL ImageGen" help_chats: " -\n\n• `{i}delchat <optional- username/id>`\n Delete the group this cmd is used in.\n\n• `{i}getlink`\n• `{i}getlink r` - `create link with admin approval`\n• `{i}getlink r title_here` - `admin approval with link title`\n• `{i}getlink 10` - `usage limit in new link`\n Get link of group this cmd is used in.\n\n• `{i}create (g|b|c) <group_name> ; <optional-username>`\n Create group woth a specific name.\n g - megagroup/supergroup\n b - small group\n c - channel\n\n• `{i}setgpic <reply to Photo><chat username>`\n Set Profile photo of Group.\n\n• `{i}delgpic <chat username -optional>`\n Delete Profile photo of Group.\n\n• `{i}unbanall`\n Unban all Members of a group.\n\n• `{i}rmusers`\n Remove users specifically.\n" help_cleanaction: " -\n\n•`{i}addclean`\n Clean all Upcoming action msg in added chat like someone joined/left/pin etc.\n\n•`{i}remclean`\n Remove chat from database.\n\n•`{i}listclean`\n To get list of all chats where its activated.\n\n" help_converter: " -\n\n• `{i}convert <gif/img/sticker/webm>`\n Reply to media to convert it into gif / image / webm / normal sticker.\n\n• `{i}doc <filename.ext>`\n Reply to a text msg to save it in a file.\n\n• `{i}open`\n Reply to a file to reveal it's text.\n\n• `{i}rename <file name with extension>`\n Rename the file\n\n• `{i}thumbnail <reply to image/thumbnail file>`\n Upload Your file with your custom thumbnail.\n" From d90b6ad5f7319c5973d883e842346160035b9c7d Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Wed, 14 Feb 2024 04:19:57 +0800 Subject: [PATCH 188/268] Update utilities.py --- plugins/utilities.py | 44 ++------------------------------------------ 1 file changed, 2 insertions(+), 42 deletions(-) diff --git a/plugins/utilities.py b/plugins/utilities.py index 4b5e8cc20a..9d094b2c6f 100644 --- a/plugins/utilities.py +++ b/plugins/utilities.py @@ -4,50 +4,10 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - -• `{i}kickme` : Leaves the group. +from . import get_help -• `{i}date` : Show Calender. - -• `{i}listreserved` - List all usernames (channels/groups) you own. - -• `{i}stats` : See your profile stats. - -• `{i}paste` - `Include long text / Reply to text file.` - -• `{i}info <username/userid/chatid>` - Reply to someone's msg. - -• `{i}invite <username/userid>` - Add user to the chat. - -• `{i}rmbg <reply to pic>` - Remove background from that picture. - -• `{i}telegraph <reply to media/text>` - Upload media/text to telegraph. - -• `{i}json <reply to msg>` - Get the json encoding of the message. - -• `{i}suggest <reply to message> or <poll title>` - Create a Yes/No poll for the replied suggestion. - -• `{i}ipinfo <ipAddress>` : Get info about that IP address. - -• `{i}cpy <reply to message>` - Copy the replied message, with formatting. Expires in 24hrs. -• `{i}pst` - Paste the copied message, with formatting. - -• `{i}thumb <reply file>` : Download the thumbnail of the replied file. - -• `{i}getmsg <message link>` - Get messages from chats with forward/copy restrictions. -""" +__doc__ = get_help("help_utilities") import calendar import html From 2cbfcd819aa55dd856aef2a6b261b39743a1e681 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Wed, 14 Feb 2024 04:20:29 +0800 Subject: [PATCH 189/268] Update usage.py --- plugins/usage.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/plugins/usage.py b/plugins/usage.py index 6910dc3b20..bd0a89cb7b 100644 --- a/plugins/usage.py +++ b/plugins/usage.py @@ -4,18 +4,10 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available -• `{i}usage` - Get overall usage. +from . import get_help -• `{i}usage heroku` - Get heroku stats. - -• `{i}usage db` - Get database storage usage. -""" +__doc__ = get_help("help_usage") import math import shutil From 20fe36ecf4f417afbca45100e7168f266cf14e00 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Wed, 14 Feb 2024 04:21:30 +0800 Subject: [PATCH 190/268] Update unsplash.py --- plugins/unsplash.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/plugins/unsplash.py b/plugins/unsplash.py index af20ab252d..6e99a002b9 100644 --- a/plugins/unsplash.py +++ b/plugins/unsplash.py @@ -4,12 +4,10 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - -• {i}unsplash <search query> ; <no of pics> - Unsplash Image Search. -""" +from . import get_help + +__doc__ = get_help("help_unsplash") from pyUltroid.fns.misc import unsplashsearch From 60d24c64c4250ede6db31651c514c12c79ca0fa8 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Wed, 14 Feb 2024 04:22:12 +0800 Subject: [PATCH 191/268] Update tools.py --- plugins/tools.py | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/plugins/tools.py b/plugins/tools.py index 7aa64e2d5f..51c257fcc3 100644 --- a/plugins/tools.py +++ b/plugins/tools.py @@ -4,38 +4,11 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - -• `{i}circle` - Reply to a audio song or gif to get video note. +from . import get_help -• `{i}ls` - Get all the Files inside a Directory. +__doc__ = get_help("help_tools") -• `{i}bots` - Shows the number of bots in the current chat with their perma-link. - -• `{i}hl <a link> <text-optional>` - Embeds the link with a whitespace as message. - -• `{i}id` - Reply a Sticker to Get Its Id - Reply a User to Get His Id - Without Replying You Will Get the Chat's Id - -• `{i}sg <username>` or `{i}sgu <username>` - Get Name History of the user. - -• `{i}tr <dest lang code> <(reply to) a message>` - Get translated message. - -• `{i}webshot <url>` - Get a screenshot of the webpage. - -• `{i}shorturl <url> <id-optional>` - shorten any url... -""" import asyncio import glob import io From 309e8fe5368a07511a08ef7fbfff2393acb4d44a Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Wed, 14 Feb 2024 04:22:45 +0800 Subject: [PATCH 192/268] Update tag.py --- plugins/tag.py | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/plugins/tag.py b/plugins/tag.py index 13753dfb9a..fab68a3bf5 100644 --- a/plugins/tag.py +++ b/plugins/tag.py @@ -4,30 +4,10 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - -• `{i}tagall` - Tag Top 100 Members of chat. +from . import get_help -• `{i}tagadmins` - Tag Admins of that chat. - -• `{i}tagowner` - Tag Owner of that chat - -• `{i}tagbots` - Tag Bots of that chat. - -• `{i}tagrec` - Tag recently Active Members. - -• `{i}tagon` - Tag online Members(work only if privacy off). - -• `{i}tagoff` - Tag Offline Members(work only if privacy off). -""" +__doc__ = get_help("help_tag") from telethon.tl.types import ChannelParticipantAdmin as admin from telethon.tl.types import ChannelParticipantCreator as owner From c4bfaffe84cb470104526d1780ec038a29755b42 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Wed, 14 Feb 2024 04:23:51 +0800 Subject: [PATCH 193/268] Update sudo.py --- plugins/sudo.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/plugins/sudo.py b/plugins/sudo.py index 8a1cf43475..5d0cc6560d 100644 --- a/plugins/sudo.py +++ b/plugins/sudo.py @@ -4,18 +4,10 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - -• `{i}addsudo` - Add Sudo Users by replying to user or using <space> separated userid(s) +from . import get_help -• `{i}delsudo` - Remove Sudo Users by replying to user or using <space> separated userid(s) - -• `{i}listsudo` - List all sudo users. -""" +__doc__ = get_help("help_sudo") from telethon.tl.types import User From 94efca9d93304d5e21bf4d6b0ca0817654ed5d62 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Wed, 14 Feb 2024 04:25:03 +0800 Subject: [PATCH 194/268] Update stickertools.py --- plugins/stickertools.py | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/plugins/stickertools.py b/plugins/stickertools.py index af3a86537f..a44501b2fa 100644 --- a/plugins/stickertools.py +++ b/plugins/stickertools.py @@ -4,24 +4,11 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - -• `{i}destroy <reply to animated sticker>` - To destroy the sticker. +from . import get_help -• `{i}tiny <reply to media>` - To create Tiny stickers. +__doc__ = get_help("help_stickertools") -• `{i}kang <reply to image/sticker>` - Kang the sticker (add to your pack). - -• `{i}packkang <pack name>` - Kang the Complete sticker set (with custom name). - -• `{i}round <reply to any media>` - To extract round sticker. -""" import glob import io import os From 2f18fdf08c068215b17f5f3280d9555dbf11781c Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Wed, 14 Feb 2024 04:25:51 +0800 Subject: [PATCH 195/268] Update specialtools.py --- plugins/specialtools.py | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/plugins/specialtools.py b/plugins/specialtools.py index ca231297a5..a21d43eaa0 100644 --- a/plugins/specialtools.py +++ b/plugins/specialtools.py @@ -4,33 +4,11 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - -• `{i}wspr <username>` - Send secret message.. +from . import get_help -• `{i}q <color-optional>` -• `{i}q @username` -• `{i}q r <color-optional>` -• `{i}q count` : `multiple quotes` - Create quotes.. +__doc__ = get_help("help_specialtools") -• `{i}sticker <query>` - Search Stickers as Per ur Wish.. - -• `{i}getaudio <reply to an audio>` - Download Audio To put in ur Desired Video/Gif. - -• `{i}addaudio <reply to Video/gif>` - It will put the above audio to the replied video/gif. - -• `{i}dob <date of birth>` - Put in dd/mm/yy Format only(eg .dob 01/01/1999). - -• `{i}wall <query>` - Search Hd Wallpaper as Per ur Wish.. -""" import os import time from datetime import datetime as dt From f12a41bd20e575f9412463814d7c1ae14776122a Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Wed, 14 Feb 2024 04:42:51 +0800 Subject: [PATCH 196/268] Update chatbot.py --- plugins/chatbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/chatbot.py b/plugins/chatbot.py index 017241c5ea..7a982f5307 100644 --- a/plugins/chatbot.py +++ b/plugins/chatbot.py @@ -10,7 +10,7 @@ __doc__ = get_help("help_chatbot") -from pyUltroid.fns.tools import get_chatbot_reply +from pyUltroid.fns.tools import get_chatbot_reply, get_oracle_reply from . import LOGS, eod, get_string, inline_mention, udB, ultroid_cmd From f700f1edce4950b6765d3f9e74e8ccbabcbabb45 Mon Sep 17 00:00:00 2001 From: ufoptg <ufperth@protonmail.com> Date: Wed, 14 Feb 2024 05:07:35 +0800 Subject: [PATCH 197/268] Chatbot Finalization --- plugins/chatbot.py | 7 ++++--- pyUltroid/fns/tools.py | 9 +++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/plugins/chatbot.py b/plugins/chatbot.py index 7a982f5307..80a16b98dd 100644 --- a/plugins/chatbot.py +++ b/plugins/chatbot.py @@ -12,8 +12,9 @@ from pyUltroid.fns.tools import get_chatbot_reply, get_oracle_reply -from . import LOGS, eod, get_string, inline_mention, udB, ultroid_cmd +from . import LOGS, eod, get_string, inline_mention, udB, ultroid_cmd, ultroid_bot, Keys +mongouri = Keys.MONGO_URI @ultroid_cmd(pattern="repoai") async def im_oracle(event): @@ -24,8 +25,8 @@ async def im_oracle(event): message = event.text.split(" ", 1)[1] except IndexError: return await eod(event, get_string("tban_1"), time=10) - reply_ = await get_orcale_reply( - query=message, user_id=ultroid_bot.me.id, mongo_url=MONGO_URI + reply_ = await get_oracle_reply( + query=message, user_id=ultroid_bot.me.id, mongo_url=mongouri ) await event.eor(reply_) diff --git a/pyUltroid/fns/tools.py b/pyUltroid/fns/tools.py index 6fdc7f403b..2c362ccf3a 100644 --- a/pyUltroid/fns/tools.py +++ b/pyUltroid/fns/tools.py @@ -518,10 +518,10 @@ async def get_chatbot_reply(message): api_url = f"https://generativelanguage.googleapis.com/v1beta3/models/text-bison-001:generateText?key={GOOGLEAPI}" else: return "Sorry you need to set a GOOGLEAPI key to use this chatbot" - + headers = {"Content-Type": "application/json"} data = {"prompt": {"text": message}} - + async def evaluate_response(response): response_str = await response.json() @@ -533,7 +533,7 @@ async def evaluate_response(response): else: LOGS.warning("Unexpected JSON format in the chatbot response.") return "Unexpected response from the chatbot server." - + try: reply_message = await async_searcher( api_url, @@ -559,7 +559,7 @@ async def get_oracle_reply(query, user_id, mongo_url): if not Keys.MONGO_URI: return "You cannot use this without setting a MONGO_URI first" - response = ChatBot(query).get_response_gemini_oracle( + response = await ChatBot(query).get_response_gemini_oracle( api_key="", user_id=user_id, mongo_url=mongo_url, @@ -576,6 +576,7 @@ async def get_oracle_reply(query, user_id, mongo_url): return "Unexpected response from the chatbot server." + # -----------------------------------------------------------------------------------# From c78fc2c2d2a45118939b4dd1c3bbacc8ee7b9c8c Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Wed, 14 Feb 2024 05:16:05 +0800 Subject: [PATCH 198/268] strings --- plugins/snips.py | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/plugins/snips.py b/plugins/snips.py index bd1a722a38..b811f24ec2 100644 --- a/plugins/snips.py +++ b/plugins/snips.py @@ -4,21 +4,11 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - -• `{i}addsnip <word><reply to a message>` - add the used word as snip relating to replied message. +from . import get_help -• `{i}remsnip <word>` - Remove the snip word.. +__doc__ = get_help("help_snips") -• `{i}listsnip` - list all snips. - -• Use : - type `$(ur snip word)` get setted reply. -""" import os from telegraph import upload_file as uf From ff04cb71f5077f4de932f029b612478b17be8167 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Wed, 14 Feb 2024 05:16:49 +0800 Subject: [PATCH 199/268] Update search.py --- plugins/search.py | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/plugins/search.py b/plugins/search.py index 853518a84a..6fb25d6eb8 100644 --- a/plugins/search.py +++ b/plugins/search.py @@ -4,25 +4,11 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - - -• `{i}saavn <search query>` - Download songs from Saavn. -• `{i}google <query>` - For doing google search. +from . import get_help -• `{i}github <username>` - Get full information of the users github profile. +__doc__ = get_help("help_search") -• `{i}img <query>` - `{i}img <query> ; <no of results>` - For doing Images search. - -• `{i}reverse` - Reply an Image or sticker to find its sauce. -""" import os import requests From d9119422bda64640c6733471bed5577909277b73 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Wed, 14 Feb 2024 05:17:51 +0800 Subject: [PATCH 200/268] Update schedulemsg.py --- plugins/schedulemsg.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/plugins/schedulemsg.py b/plugins/schedulemsg.py index 7cad656f45..49c22e1329 100644 --- a/plugins/schedulemsg.py +++ b/plugins/schedulemsg.py @@ -4,14 +4,11 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - -•`{i}schedule <text/reply to msg> <time>` - In time u can use second as number, or like 1h or 1m - eg. `{i}schedule Hello 100` It deliver msg after 100 sec. - eg. `{i}schedule Hello 1h` It deliver msg after an hour. -""" +from . import get_help + +__doc__ = get_help("help_schedulemsg") + from datetime import timedelta from pyUltroid.fns.admins import ban_time From dd5669dd119d746ad441e3eac8c4f7a5da88e370 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Wed, 14 Feb 2024 05:18:54 +0800 Subject: [PATCH 201/268] Update resize.py --- plugins/resize.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/plugins/resize.py b/plugins/resize.py index 43d64a0f2e..3a8e67cd65 100644 --- a/plugins/resize.py +++ b/plugins/resize.py @@ -4,16 +4,11 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - -•`{i}size <reply to media>` - To get size of it. +from . import get_help + +__doc__ = get_help("help_resize") -•`{i}resize <number> <number>` - To resize image on x, y axis. - eg. `{i}resize 690 960` -""" from PIL import Image from . import HNDLR, eor, get_string, os, ultroid_cmd From 2ffbc1f7085398ba860c29785c50fdb0afaed574 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Wed, 14 Feb 2024 05:20:26 +0800 Subject: [PATCH 202/268] Update qrcode.py --- plugins/qrcode.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/plugins/qrcode.py b/plugins/qrcode.py index 9cc626c28e..b0339cff3c 100644 --- a/plugins/qrcode.py +++ b/plugins/qrcode.py @@ -4,18 +4,11 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - -• `{i}qrcode <text/reply to text>` - `Makes qrcode of text` +from . import get_help -• `{i}addqr <reply image> <text>` - `Makes qr of text and add it to image.` +__doc__ = get_help("help_qrcode") -• `{i}qrdecode <reply to qrcode>` - `It decodes the qrcode.` -""" import os from pyUltroid import ULTConfig From dbfcda9f3942740879c2aea55c9ba6b468c9f30e Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Wed, 14 Feb 2024 05:30:35 +0800 Subject: [PATCH 203/268] Update profile.py --- plugins/profile.py | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/plugins/profile.py b/plugins/profile.py index 89308295fb..cbde2fb760 100644 --- a/plugins/profile.py +++ b/plugins/profile.py @@ -4,27 +4,11 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - -• `{i}setname <first name // last name>` - Change your profile name. +from . import get_help -• `{i}setbio <bio>` - Change your profile bio. +__doc__ = get_help("help_profile") -• `{i}setpic <reply to pic>` - Change your profile pic. - -• `{i}delpfp <n>(optional)` - Delete one profile pic, if no value given, else delete n number of pics. - -• `{i}poto <username>/reply` - `{i}poto <reply/upload-limit>/all` - - Ex: `{i}poto 10` - uploads starting 10 pfps of user. - Upload the photo of Chat/User if Available. -""" import os from telethon.tl.functions.account import UpdateProfileRequest From b25eae8524e5f8424c13adc3282f7fe74798525d Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Wed, 14 Feb 2024 05:35:14 +0800 Subject: [PATCH 204/268] strings --- strings/strings/en.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/strings/strings/en.yml b/strings/strings/en.yml index c47be51903..30ba2f57d9 100644 --- a/strings/strings/en.yml +++ b/strings/strings/en.yml @@ -646,9 +646,9 @@ help_variables: " -\n\n• `{i}get var <variable name>`\n Get value of the giv help_vctools: " -\n\n• `{i}startvc`\n Start Group Call in a group.\n\n• `{i}stopvc`\n Stop Group Call in a group.\n\n• `{i}vctitle <title>`\n Change the title Group call.\n\n• `{i}vcinvite`\n Invite all members of group in Group Call.\n (You must be joined)\n" help_videotools: " -\n\n•`{i}sample <duration in seconds>`\n Creates Short sample of video..\n\n• `{i}vshots <number of shots>`\n Creates screenshot of video..\n\n• `{i}vtrim <start time> - <end time> in seconds`\n Crop a Lengthy video..\n" help_warn: "\n\n•`{i}warn <reply to user> <reason>`\n Gives Warn.\n\n•`{i}resetwarn <reply to user>`\n To reset All Warns.\n\n•`{i}warns <reply to user>`\n To Get List of Warnings of a user.\n\n•`{i}setwarn <warn count> | <ban/mute/kick>`\n Set Number in warn count for warnings\n After putting ' | ' mark put action like ban/mute/kick\n Its Default 3 kick\n Example : `setwarn 5 | mute`\n\n" -help_weather: "-\n\n**Get Weather Data using OpenWeatherMap API**\n• {i}weather <Detailed forecast, needs API>\n\nUsage: `{i}weather <Location> or location,countrycode\n" +help_weather: "-\n\n**Get Weather Data using OpenWeatherMap API**\n• `{i}weather <Detailed forecast, needs API>`\n\nUsage: `{i}weather <Location>` or `location,countrycode`\n" help_webupload: " -\n\n• `{i}webupload`\n Upload files on another server.\n" help_words: " -\n\n• `{i}meaning <word>`\n Get the meaning of the word.\n\n• `{i}synonym <word>`\n Get all synonyms.\n\n• `{i}antonym <word>`\n Get all antonyms.\n\n• `{i}ud <word>`\n Fetch word defenition from urbandictionary.\n" -help_writer: " -\n\n• {i}write <text or reply to text> It will write on a paper.\n• {i}image <text or reply to html or any doc file> Write an image from HTML or any text." -help_youtube: "-\n\n• {i}yta <(youtube/any) link> Download audio from the link.\n• {i}ytv <(youtube/any) link> Download video from the link.\n• {i}ytsa <(youtube) search query> Search and download audio from YouTube.\n• {i}ytsv <(youtube) search query> Search and download video from YouTube.\n• {i}ytsc <soundcloud link> Download audio from SoundCloud." +help_writer: " -\n\n• `{i}write <text or reply to text>` It will write on a paper.\n• `{i}image` <text or reply to html or any doc file> Write an image from HTML or any text." +help_youtube: "-\n\n• `{i}yta <(youtube/any) link>` Download audio from the link.\n• `{i}ytv <(youtube/any) link>` Download video from the link.\n• `{i}ytsa <(youtube) search query>` Search and download audio from YouTube.\n• `{i}ytsv <(youtube) search query>` Search and download video from YouTube.\n• `{i}ytsc <soundcloud link>` Download audio from SoundCloud." help_ziptools: "\n\n• `{i}zip <reply to file>`\n zip the replied file\n To set password on zip: `{i}zip <password>` reply to file\n\n• `{i}unzip <reply to zip file>`\n unzip the replied file.\n\n• `{i}azip <reply to file>`\n add file to batch for batch upload zip\n\n• `{i}dozip`\n upload batch zip the files u added from `{i}azip`\n To set Password: `{i}dozip <password>`\n\n" From 5ef9936871e4f8cfba33b687a893b65a679783ea Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Thu, 15 Feb 2024 02:28:19 +0800 Subject: [PATCH 205/268] Update __init__.py --- pyUltroid/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyUltroid/__init__.py b/pyUltroid/__init__.py index 2d46c90db9..348bb9dc60 100644 --- a/pyUltroid/__init__.py +++ b/pyUltroid/__init__.py @@ -103,7 +103,7 @@ class ULTConfig: DUAL_HNDLR = udB.get_key("DUAL_HNDLR") or "/" SUDO_HNDLR = udB.get_key("SUDO_HNDLR") or HNDLR else: - print("pyUltroid 2022 © TeamUltroid") + print("pyUltroid 2021-2024 © TeamUltroid") from logging import getLogger From 2afe85ee600ff3e191653bbd41f3d0f30b5e5c1e Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Thu, 15 Feb 2024 02:29:38 +0800 Subject: [PATCH 206/268] Update __init__.py --- pyUltroid/fns/__init__.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pyUltroid/fns/__init__.py b/pyUltroid/fns/__init__.py index 11616c6e58..30e89896a0 100644 --- a/pyUltroid/fns/__init__.py +++ b/pyUltroid/fns/__init__.py @@ -21,3 +21,22 @@ "Chrome/19.0.1084.46 Safari/536.5", "Mozilla/5.0 (X11; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0", ] + +def override(func): + """ + Decorator to override a function from an older version of Telethon with the same function from a newer version. + + Args: + func: The function to override. + + Returns: + The overridden function. + """ + + @functools.wraps(func) + async def wrapper(*args, **kwargs): + # Use the function from the newer version of Telethon + result = await func(*args, **kwargs) + return result + + return wrapper From 078c12995a3ef0d155e7651e4b6d3c44fccdd207 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Thu, 15 Feb 2024 02:45:47 +0800 Subject: [PATCH 207/268] Update __init__.py --- pyUltroid/fns/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyUltroid/fns/__init__.py b/pyUltroid/fns/__init__.py index 30e89896a0..de5da0b82d 100644 --- a/pyUltroid/fns/__init__.py +++ b/pyUltroid/fns/__init__.py @@ -5,6 +5,8 @@ # PLease read the GNU Affero General Public License in # <https://github.com/TeamUltroid/pyUltroid/blob/main/LICENSE>. +from functools import wraps + from .. import * # ignore: pylint # https://github.com/bisoncorps/search-engine-parser/blob/ede1355a1f63398d9217b8e502fbd6c52b53bf09/search_engine_parser/core/utils.py#L11 From 0b14643a37346e7bced47d42781ca7883fe6cd91 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Thu, 15 Feb 2024 02:55:53 +0800 Subject: [PATCH 208/268] Update __init__.py --- pyUltroid/fns/__init__.py | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/pyUltroid/fns/__init__.py b/pyUltroid/fns/__init__.py index de5da0b82d..11616c6e58 100644 --- a/pyUltroid/fns/__init__.py +++ b/pyUltroid/fns/__init__.py @@ -5,8 +5,6 @@ # PLease read the GNU Affero General Public License in # <https://github.com/TeamUltroid/pyUltroid/blob/main/LICENSE>. -from functools import wraps - from .. import * # ignore: pylint # https://github.com/bisoncorps/search-engine-parser/blob/ede1355a1f63398d9217b8e502fbd6c52b53bf09/search_engine_parser/core/utils.py#L11 @@ -23,22 +21,3 @@ "Chrome/19.0.1084.46 Safari/536.5", "Mozilla/5.0 (X11; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0", ] - -def override(func): - """ - Decorator to override a function from an older version of Telethon with the same function from a newer version. - - Args: - func: The function to override. - - Returns: - The overridden function. - """ - - @functools.wraps(func) - async def wrapper(*args, **kwargs): - # Use the function from the newer version of Telethon - result = await func(*args, **kwargs) - return result - - return wrapper From 685d155199ed8dde4b2f9cab0b27631d8290e11b Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 20 Feb 2024 07:27:27 +0800 Subject: [PATCH 209/268] Update profanityfilter.py --- plugins/profanityfilter.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/plugins/profanityfilter.py b/plugins/profanityfilter.py index ed73a5e5a1..57d7d07c89 100644 --- a/plugins/profanityfilter.py +++ b/plugins/profanityfilter.py @@ -4,16 +4,10 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - -•`{i}addprofanity` - If someone sends bad word in a chat, Then bot will delete that message. +from . import get_help -•`{i}remprofanity` - From chat from Profanity list. - -""" +__doc__ = get_help("help_profanityfilter") from pyUltroid.dB.nsfw_db import profan_chat, rem_profan From b9e0cb0e74f9e742482fbc97f35af3e66a03f31d Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 20 Feb 2024 07:28:39 +0800 Subject: [PATCH 210/268] Update polls.py --- plugins/polls.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/plugins/polls.py b/plugins/polls.py index 1f9f618384..2d93c88a63 100644 --- a/plugins/polls.py +++ b/plugins/polls.py @@ -4,20 +4,11 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - -• `{i}poll <question> ; <option> ; <option>` - Get the Anonymous Poll with Given Options +from . import get_help -• `{i}poll <question> ; <option> ; <option> | <type>` - Get the poll specified with desired type! - type should be any of `public`, `multiple` or `quiz` +__doc__ = get_help("help_polls") -• `{i}poll <question> ; <option> ; <option> | quiz_<answerno>` - Get the quiz poll where answerno is the number of option which is correct - -""" from telethon.tl.types import InputMediaPoll, Poll, PollAnswer from . import get_string, ultroid_cmd From 6a3b0747015ffe7720264804d530e014775212b1 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 20 Feb 2024 07:29:19 +0800 Subject: [PATCH 211/268] Update pmpermit.py --- plugins/pmpermit.py | 33 ++------------------------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/plugins/pmpermit.py b/plugins/pmpermit.py index 9b44a3f296..f5578b71c8 100644 --- a/plugins/pmpermit.py +++ b/plugins/pmpermit.py @@ -4,39 +4,10 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - -• `{i}a` or `{i}approve` - Approve someone to PM. +from . import get_help -• `{i}da` or `{i}disapprove` - Disapprove someone to PM. - -• `{i}block` - Block someone. - -• `{i}unblock` | `{i}unblock all` - Unblock someone. - -• `{i}nologpm` - Stop logging messages from the user. - -• `{i}logpm` - Start logging messages from the user. - -• `{i}startarchive` - Archive new PMs. - -• `{i}stoparchive` - Don't archive new PMs. - -• `{i}cleararchive` - Unarchive all chats. - -• `{i}listapproved` - List all approved PMs. -""" +__doc__ = get_help("help_pmpermit") import asyncio import re From 1ecca40434ed965b64a33696565d0b2f2a48338f Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 20 Feb 2024 07:34:45 +0800 Subject: [PATCH 212/268] Update en.yml --- strings/strings/en.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/strings/strings/en.yml b/strings/strings/en.yml index 30ba2f57d9..a08325e8bd 100644 --- a/strings/strings/en.yml +++ b/strings/strings/en.yml @@ -625,6 +625,7 @@ help_misc: " -\n\n• `{i}eod`\n `Get Event of the Today`\n\n• `{i}pntrst < help_mute: " -\n\n• `{i}mute <reply to msg/ user id>`\n Mute user in current chat.\n\n• `{i}unmute <reply to msg/ user id>`\n Unmute user in current chat.\n\n• `{i}dmute <reply to msg/ user id>`\n Mute user in current chat by deleting msgs.\n\n• `{i}undmute <reply to msg/ use id>`\n Unmute dmuted user in current chat.\n\n• `{i}tmute <time> <reply to msg/ use id>`\n s- seconds\n m- minutes\n h- hours\n d- days\n Mute user in current chat with time.\n" help_notes: " -\n\n• `{i}addnote <word><reply to a message>`\n add note in the used chat with replied message and choosen word.\n\n• `{i}remnote <word>`\n Remove the note from used chat.\n\n• `{i}listnote`\n list all notes.\n\n• Use :\n set notes in group so all can use it.\n type `#(Keyword of note)` to get it\n" help_other: " -\n\n• `{i}send <username/id> <reply/type>`\n send message to User/Chat.\n\n• `{i}fwdreply <reply to msg>`\n Reply to someone's msg by forwarding it in private.\n\n• `{i}save <reply message>`\n Save that replied msg to ur saved messages box.\n\n• `{i}fsave <reply message>`\n Forward that replied msg to ur saved messages.\n" +help_pdftools: " -\n\n• `{i}pdf <page num> <reply to pdf file>`\n Extract & send page as an Image.(note-: For extracting all pages, just use .pdf)\n to upload selected range `{i}pdf 1-7`\n• `{i}pdtext <page num> <reply to pdf file>`\n Extract Text From the Pdf.(note-: For Extraction all text just use .pdtext)\n to extract selected pages `{i}pdf 1-7`\n• `{i}pdscan <reply to image>`\n It scan, crop & send image(s) as pdf.\n• `{i}pdsave <reply to image/pdf>`\n It scan, crop & save file to merge. you can merge many pages in a single pdf.\n• `{i}pdsend `\n Merge & send the pdf, collected from .pdsave.\n" help_pmpermit: " -\n\n• `{i}a` or `{i}approve`\n Approve someone to PM.\n\n• `{i}da` or `{i}disapprove`\n Disapprove someone to PM.\n\n• `{i}block`\n Block someone.\n\n• `{i}unblock` | `{i}unblock all`\n Unblock someone.\n\n• `{i}nologpm`\n Stop logging messages from the user.\n\n• `{i}logpm`\n Start logging messages from the user.\n\n• `{i}startarchive`\n Archive new PMs.\n\n• `{i}stoparchive`\n Don't archive new PMs.\n\n• `{i}cleararchive`\n Unarchive all chats.\n\n• `{i}listapproved`\n List all approved PMs.\n" help_polls: " -\n\n• `{i}poll <question> ; <option> ; <option>`\n Get the Anonymous Poll with Given Options\n\n• `{i}poll <question> ; <option> ; <option> | <type>`\n Get the poll specified with desired type!\n type should be any of `public`, `multiple` or `quiz`\n\n• `{i}poll <question> ; <option> ; <option> | quiz_<answerno>`\n Get the quiz poll where answerno is the number of option which is correct\n\n" help_profanityfilter: " -\n\n•`{i}addprofanity`\n If someone sends bad word in a chat, Then bot will delete that message.\n\n•`{i}remprofanity`\n From chat from Profanity list.\n\n" From 271734a1733b05653dd1c08362789c0764304113 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 20 Feb 2024 07:35:12 +0800 Subject: [PATCH 213/268] Update pdftools.py --- plugins/pdftools.py | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/plugins/pdftools.py b/plugins/pdftools.py index fb9e7cbd85..43dca011b5 100644 --- a/plugins/pdftools.py +++ b/plugins/pdftools.py @@ -4,27 +4,11 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - -• `{i}pdf <page num> <reply to pdf file>` - Extract & send page as an Image.(note-: For extracting all pages, just use .pdf) - to upload selected range `{i}pdf 1-7` +from . import get_help -• `{i}pdtext <page num> <reply to pdf file>` - Extract Text From the Pdf.(note-: For Extraction all text just use .pdtext) - to extract selected pages `{i}pdf 1-7` +__doc__ = get_help("help_pdftools") -• `{i}pdscan <reply to image>` - It scan, crop & send image(s) as pdf. - -• `{i}pdsave <reply to image/pdf>` - It scan, crop & save file to merge. - you can merge many pages in a single pdf. - -• `{i}pdsend ` - Merge & send the pdf, collected from .pdsave. -""" import glob import os import shutil From c5b06d94ae9963a019ba6ba7dbc6604463bed949 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 20 Feb 2024 07:35:46 +0800 Subject: [PATCH 214/268] Update other.py --- plugins/other.py | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/plugins/other.py b/plugins/other.py index 34b8fd59fd..8a965e5b0f 100644 --- a/plugins/other.py +++ b/plugins/other.py @@ -4,21 +4,10 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - -• `{i}send <username/id> <reply/type>` - send message to User/Chat. +from . import get_help -• `{i}fwdreply <reply to msg>` - Reply to someone's msg by forwarding it in private. - -• `{i}save <reply message>` - Save that replied msg to ur saved messages box. - -• `{i}fsave <reply message>` - Forward that replied msg to ur saved messages. -""" +__doc__ = get_help("help_other") from . import HNDLR, eod, get_string, ultroid_cmd From 1a4ed9c3f202b356a02702fdca63210bd9d15836 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 20 Feb 2024 07:37:24 +0800 Subject: [PATCH 215/268] Update notes.py --- plugins/notes.py | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/plugins/notes.py b/plugins/notes.py index 7d629962cd..cf96968643 100644 --- a/plugins/notes.py +++ b/plugins/notes.py @@ -4,22 +4,11 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - -• `{i}addnote <word><reply to a message>` - add note in the used chat with replied message and choosen word. +from . import get_help -• `{i}remnote <word>` - Remove the note from used chat. +__doc__ = get_help("help_notes") -• `{i}listnote` - list all notes. - -• Use : - set notes in group so all can use it. - type `#(Keyword of note)` to get it -""" import os from telegraph import upload_file as uf From ec17405e51282655b45afba6b0c1cbf32184548d Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 20 Feb 2024 07:39:18 +0800 Subject: [PATCH 216/268] Update en.yml --- strings/strings/en.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/strings/strings/en.yml b/strings/strings/en.yml index a08325e8bd..c2aba5b5db 100644 --- a/strings/strings/en.yml +++ b/strings/strings/en.yml @@ -624,6 +624,7 @@ help_mediatools: " -\n\n• `{i}mediainfo <reply to media>`\n To get info abou help_misc: " -\n\n• `{i}eod`\n `Get Event of the Today`\n\n• `{i}pntrst <link/id>`\n Download and send pinterest pins\n\n• `{i}gadget <search query>`\n Gadget Search from Telegram.\n\n• `{i}randomuser`\n Generate details about a random user.\n\n• `{i}ascii <reply image>`\n Convert replied image into html.\n" help_mute: " -\n\n• `{i}mute <reply to msg/ user id>`\n Mute user in current chat.\n\n• `{i}unmute <reply to msg/ user id>`\n Unmute user in current chat.\n\n• `{i}dmute <reply to msg/ user id>`\n Mute user in current chat by deleting msgs.\n\n• `{i}undmute <reply to msg/ use id>`\n Unmute dmuted user in current chat.\n\n• `{i}tmute <time> <reply to msg/ use id>`\n s- seconds\n m- minutes\n h- hours\n d- days\n Mute user in current chat with time.\n" help_notes: " -\n\n• `{i}addnote <word><reply to a message>`\n add note in the used chat with replied message and choosen word.\n\n• `{i}remnote <word>`\n Remove the note from used chat.\n\n• `{i}listnote`\n list all notes.\n\n• Use :\n set notes in group so all can use it.\n type `#(Keyword of note)` to get it\n" +help_nsfwfilter: " -\n\n•`{i}addnsfw <ban/mute/kick>`\n If someone sends 18+ content it will be deleted and action will be taken.\n•`{i}remnsfw`\n Remove Chat from nsfw filtering." help_other: " -\n\n• `{i}send <username/id> <reply/type>`\n send message to User/Chat.\n\n• `{i}fwdreply <reply to msg>`\n Reply to someone's msg by forwarding it in private.\n\n• `{i}save <reply message>`\n Save that replied msg to ur saved messages box.\n\n• `{i}fsave <reply message>`\n Forward that replied msg to ur saved messages.\n" help_pdftools: " -\n\n• `{i}pdf <page num> <reply to pdf file>`\n Extract & send page as an Image.(note-: For extracting all pages, just use .pdf)\n to upload selected range `{i}pdf 1-7`\n• `{i}pdtext <page num> <reply to pdf file>`\n Extract Text From the Pdf.(note-: For Extraction all text just use .pdtext)\n to extract selected pages `{i}pdf 1-7`\n• `{i}pdscan <reply to image>`\n It scan, crop & send image(s) as pdf.\n• `{i}pdsave <reply to image/pdf>`\n It scan, crop & save file to merge. you can merge many pages in a single pdf.\n• `{i}pdsend `\n Merge & send the pdf, collected from .pdsave.\n" help_pmpermit: " -\n\n• `{i}a` or `{i}approve`\n Approve someone to PM.\n\n• `{i}da` or `{i}disapprove`\n Disapprove someone to PM.\n\n• `{i}block`\n Block someone.\n\n• `{i}unblock` | `{i}unblock all`\n Unblock someone.\n\n• `{i}nologpm`\n Stop logging messages from the user.\n\n• `{i}logpm`\n Start logging messages from the user.\n\n• `{i}startarchive`\n Archive new PMs.\n\n• `{i}stoparchive`\n Don't archive new PMs.\n\n• `{i}cleararchive`\n Unarchive all chats.\n\n• `{i}listapproved`\n List all approved PMs.\n" From 5dc8a150f600094dc5a14a1265149f1c92a3d6c3 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 20 Feb 2024 07:40:20 +0800 Subject: [PATCH 217/268] Update nsfwfilter.py --- plugins/nsfwfilter.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/plugins/nsfwfilter.py b/plugins/nsfwfilter.py index 6cd6e89316..5d2fac68c4 100644 --- a/plugins/nsfwfilter.py +++ b/plugins/nsfwfilter.py @@ -4,15 +4,10 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - -•`{i}addnsfw <ban/mute/kick>` - If someone sends 18+ content it will be deleted and action will be taken. +from . import get_help -•`{i}remnsfw` - Remove Chat from nsfw filtering. -""" +__doc__ = get_help("help_nsfwfilter") import os From 0dd3f19550d98c7437dd912aab90f53a162daa02 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 20 Feb 2024 07:43:45 +0800 Subject: [PATCH 218/268] Update en.yml --- strings/strings/en.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/strings/strings/en.yml b/strings/strings/en.yml index c2aba5b5db..b37685dfe5 100644 --- a/strings/strings/en.yml +++ b/strings/strings/en.yml @@ -623,8 +623,9 @@ help_logo: " -\n\n• `{i}logo <text>`\n Generate a logo of the given Text\n help_mediatools: " -\n\n• `{i}mediainfo <reply to media>`\n To get info about it.\n\n• `{i}rotate <degree/angle> <reply to media>`\n Rotate any video/photo/media..\n Note : for video it should be angle of 90's\n" help_misc: " -\n\n• `{i}eod`\n `Get Event of the Today`\n\n• `{i}pntrst <link/id>`\n Download and send pinterest pins\n\n• `{i}gadget <search query>`\n Gadget Search from Telegram.\n\n• `{i}randomuser`\n Generate details about a random user.\n\n• `{i}ascii <reply image>`\n Convert replied image into html.\n" help_mute: " -\n\n• `{i}mute <reply to msg/ user id>`\n Mute user in current chat.\n\n• `{i}unmute <reply to msg/ user id>`\n Unmute user in current chat.\n\n• `{i}dmute <reply to msg/ user id>`\n Mute user in current chat by deleting msgs.\n\n• `{i}undmute <reply to msg/ use id>`\n Unmute dmuted user in current chat.\n\n• `{i}tmute <time> <reply to msg/ use id>`\n s- seconds\n m- minutes\n h- hours\n d- days\n Mute user in current chat with time.\n" +help_nightmode: " -\n\nAt Night it will turn off everyone permission to send message in an all groups which you added via `{i}addnight`\nAnd Turn On auto at morning\n\n• `{i}addnm`\n Add NightMode\n To Add Group To Auto Night Mode.\n\n• `{i}remnm`\n Remove NightMode\n To remove Group From Auto Night Mode\n\n• `{i}listnm`\n List NightMode\n To Get All List of Groups where NightMode Active.\n\n• `{i}nmtime <close hour> <close min> <open hour> <open min>`\n NightMode Time\n By Default Its close 00:00 , open 07:00\n Use 24hr format\n Ex- `nmtime 01 00 06 30`\n" help_notes: " -\n\n• `{i}addnote <word><reply to a message>`\n add note in the used chat with replied message and choosen word.\n\n• `{i}remnote <word>`\n Remove the note from used chat.\n\n• `{i}listnote`\n list all notes.\n\n• Use :\n set notes in group so all can use it.\n type `#(Keyword of note)` to get it\n" -help_nsfwfilter: " -\n\n•`{i}addnsfw <ban/mute/kick>`\n If someone sends 18+ content it will be deleted and action will be taken.\n•`{i}remnsfw`\n Remove Chat from nsfw filtering." +help_nsfwfilter: " -\n\n•`{i}addnsfw <ban/mute/kick>`\n If someone sends 18+ content it will be deleted and action will be taken.\n•`{i}remnsfw`\n Remove Chat from nsfw filtering.\n" help_other: " -\n\n• `{i}send <username/id> <reply/type>`\n send message to User/Chat.\n\n• `{i}fwdreply <reply to msg>`\n Reply to someone's msg by forwarding it in private.\n\n• `{i}save <reply message>`\n Save that replied msg to ur saved messages box.\n\n• `{i}fsave <reply message>`\n Forward that replied msg to ur saved messages.\n" help_pdftools: " -\n\n• `{i}pdf <page num> <reply to pdf file>`\n Extract & send page as an Image.(note-: For extracting all pages, just use .pdf)\n to upload selected range `{i}pdf 1-7`\n• `{i}pdtext <page num> <reply to pdf file>`\n Extract Text From the Pdf.(note-: For Extraction all text just use .pdtext)\n to extract selected pages `{i}pdf 1-7`\n• `{i}pdscan <reply to image>`\n It scan, crop & send image(s) as pdf.\n• `{i}pdsave <reply to image/pdf>`\n It scan, crop & save file to merge. you can merge many pages in a single pdf.\n• `{i}pdsend `\n Merge & send the pdf, collected from .pdsave.\n" help_pmpermit: " -\n\n• `{i}a` or `{i}approve`\n Approve someone to PM.\n\n• `{i}da` or `{i}disapprove`\n Disapprove someone to PM.\n\n• `{i}block`\n Block someone.\n\n• `{i}unblock` | `{i}unblock all`\n Unblock someone.\n\n• `{i}nologpm`\n Stop logging messages from the user.\n\n• `{i}logpm`\n Start logging messages from the user.\n\n• `{i}startarchive`\n Archive new PMs.\n\n• `{i}stoparchive`\n Don't archive new PMs.\n\n• `{i}cleararchive`\n Unarchive all chats.\n\n• `{i}listapproved`\n List all approved PMs.\n" From f0a275a5b6c3fdd78eaf4d6f38cb1683cc54c69d Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 20 Feb 2024 07:44:51 +0800 Subject: [PATCH 219/268] Update nightmode.py --- plugins/nightmode.py | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/plugins/nightmode.py b/plugins/nightmode.py index aa7e82cba1..6e44bcfd02 100644 --- a/plugins/nightmode.py +++ b/plugins/nightmode.py @@ -4,30 +4,10 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - - -At Night it will turn off everyone permission to send message in an all groups which you added via `{i}addnight` -And Turn On auto at morning - -• `{i}addnm` - Add NightMode - To Add Group To Auto Night Mode. - -• `{i}remnm` - Remove NightMode - To remove Group From Auto Night Mode - -• `{i}listnm` - List NightMode - To Get All List of Groups where NightMode Active. - -• `{i}nmtime <close hour> <close min> <open hour> <open min>` - NightMode Time - By Default Its close 00:00 , open 07:00 - Use 24hr format - Ex- `nmtime 01 00 06 30` -""" + +from . import get_help + +__doc__ = get_help("help_nightmode") from . import LOGS From fbc387ee11d74723a2b5d7a798609fba5c0fc32a Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 20 Feb 2024 07:45:15 +0800 Subject: [PATCH 220/268] Update mute.py --- plugins/mute.py | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/plugins/mute.py b/plugins/mute.py index 1d8fdccadd..8180a06216 100644 --- a/plugins/mute.py +++ b/plugins/mute.py @@ -4,28 +4,11 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - -• `{i}mute <reply to msg/ user id>` - Mute user in current chat. +from . import get_help -• `{i}unmute <reply to msg/ user id>` - Unmute user in current chat. +__doc__ = get_help("help_mute") -• `{i}dmute <reply to msg/ user id>` - Mute user in current chat by deleting msgs. - -• `{i}undmute <reply to msg/ use id>` - Unmute dmuted user in current chat. - -• `{i}tmute <time> <reply to msg/ use id>` - s- seconds - m- minutes - h- hours - d- days - Mute user in current chat with time. -""" from telethon import events from telethon.utils import get_display_name From 3acb574b706fcf99526f0c7f7c2ea4775a5d440d Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 20 Feb 2024 07:45:42 +0800 Subject: [PATCH 221/268] Update misc.py --- plugins/misc.py | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/plugins/misc.py b/plugins/misc.py index e82b6702e9..1a08b83f43 100644 --- a/plugins/misc.py +++ b/plugins/misc.py @@ -3,24 +3,10 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - -• `{i}eod` - `Get Event of the Today` +from . import get_help -• `{i}pntrst <link/id>` - Download and send pinterest pins - -• `{i}gadget <search query>` - Gadget Search from Telegram. - -• `{i}randomuser` - Generate details about a random user. - -• `{i}ascii <reply image>` - Convert replied image into html. -""" +__doc__ = get_help("help_misc") import os from datetime import datetime as dt From 67f375836d02dad8ecff351187954f6a8cdac4de Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 20 Feb 2024 07:46:08 +0800 Subject: [PATCH 222/268] Update mediatools.py --- plugins/mediatools.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/plugins/mediatools.py b/plugins/mediatools.py index a95493c070..4d1fbdc111 100644 --- a/plugins/mediatools.py +++ b/plugins/mediatools.py @@ -4,16 +4,11 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - -• `{i}mediainfo <reply to media>/<file path>/<url>` - To get info about it. +from . import get_help + +__doc__ = get_help("help_mediatools") -• `{i}rotate <degree/angle> <reply to media>` - Rotate any video/photo/media.. - Note : for video it should be angle of 90's -""" import os import time from datetime import datetime as dt From 847fede219a42f42c20e872d285380cfbaa82899 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 20 Feb 2024 07:46:39 +0800 Subject: [PATCH 223/268] Update logo.py --- plugins/logo.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/plugins/logo.py b/plugins/logo.py index f325da2a45..9e407e93a5 100644 --- a/plugins/logo.py +++ b/plugins/logo.py @@ -4,15 +4,11 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - -• `{i}logo <text>` - Generate a logo of the given Text - Or Reply To image , to write ur text on it. - Or Reply To Font File, To write with that font. +from . import get_help + +__doc__ = get_help("help_logo") -""" import glob import os import random From 4f5d0da5aec87624b5fd82b8723c9f0355b272e3 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 20 Feb 2024 07:47:02 +0800 Subject: [PATCH 224/268] Update locks.py --- plugins/locks.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/plugins/locks.py b/plugins/locks.py index 9ec0d174e6..4dcfb0a7a6 100644 --- a/plugins/locks.py +++ b/plugins/locks.py @@ -4,15 +4,11 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - -• `{i}lock <msgs/media/sticker/gif/games/inline/polls/invites/pin/changeinfo>` - Lock the Used Setting in Used Group. +from . import get_help + +__doc__ = get_help("help_locks") -• `{i}unlock <msgs/media/sticker/gif/games/inline/polls/invites/pin/changeinfo>` - UNLOCK the Used Setting in Used Group. -""" from telethon.tl.functions.messages import EditChatDefaultBannedRightsRequest from pyUltroid.fns.admins import lock_unlock From 4b89b782964e605da4c9a03fb88902854fcb76f3 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 20 Feb 2024 13:18:30 +0800 Subject: [PATCH 225/268] Update imagetools.py --- plugins/imagetools.py | 47 ++----------------------------------------- 1 file changed, 2 insertions(+), 45 deletions(-) diff --git a/plugins/imagetools.py b/plugins/imagetools.py index 042cba22ca..cb560f1d6a 100644 --- a/plugins/imagetools.py +++ b/plugins/imagetools.py @@ -4,54 +4,11 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - -• `{i}border <reply to photo/sticker>` - To create border around that media.. - Ex - `{i}border 12,22,23` - - `{i}border 12,22,23 ; width (in number)` +from . import get_help -• `{i}grey <reply to any media>` - To make it black nd white. +__doc__ = get_help("help_imagetools") -• `{i}color <reply to any Black nd White media>` - To make it Colorfull. - -• `{i}toon <reply to any media>` - To make it toon. - -• `{i}danger <reply to any media>` - To make it look Danger. - -• `{i}negative <reply to any media>` - To make negative image. - -• `{i}blur <reply to any media>` - To make it blurry. - -• `{i}quad <reply to any media>` - create a Vortex. - -• `{i}mirror <reply to any media>` - To create mirror pic. - -• `{i}flip <reply to any media>` - To make it flip. - -• `{i}sketch <reply to any media>` - To draw its sketch. - -• `{i}blue <reply to any media>` - just cool. - -• `{i}csample <color name /color code>` - example : `{i}csample red` - `{i}csample #ffffff` - -• `{i}pixelator <reply image>` - Create a Pixelated Image.. -""" import os from . import LOGS, con From 16bb7aaa877c671cbc69641ecbcc0013f20374ad Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 20 Feb 2024 13:20:13 +0800 Subject: [PATCH 226/268] Update greetings.py --- plugins/greetings.py | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/plugins/greetings.py b/plugins/greetings.py index e7c1ed6300..42a2a49b7f 100644 --- a/plugins/greetings.py +++ b/plugins/greetings.py @@ -4,32 +4,11 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - ----- Welcomes ---- -• `{i}setwelcome <message/reply to message>` - Set welcome message in the current chat. +from . import get_help -• `{i}clearwelcome` - Delete the welcome in the current chat. +__doc__ = get_help("help_greetings") -• `{i}getwelcome` - Get the welcome message in the current chat. - ----- GoodByes ---- -• `{i}setgoodbye <message/reply to message>` - Set goodbye message in the current chat. - -• `{i}cleargoodbye` - Delete the goodbye in the current chat. - -• `{i}getgoodbye` - Get the goodbye message in the current chat. - -• `{i}thankmembers on/off` - Send a thank you sticker on hitting a members count of 100*x in your groups. -""" import os from telegraph import upload_file as uf From 54d8adbb34622b3b43aa9a909e7387fbf1c7768c Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 20 Feb 2024 13:20:48 +0800 Subject: [PATCH 227/268] Update globaltools.py --- plugins/globaltools.py | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/plugins/globaltools.py b/plugins/globaltools.py index ab814acb4e..25d199502f 100644 --- a/plugins/globaltools.py +++ b/plugins/globaltools.py @@ -4,38 +4,11 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - -• `{i}gban <reply user/ username>` -• `{i}ungban` - Ban/Unban Globally. +from . import get_help -• `{i}gstat <reply to user/userid/username>` - Check if user is GBanned. +__doc__ = get_help("help_globaltools") -• `{i}listgban` : List all GBanned users. - -• `{i}gmute` | `{i}ungmute` <reply user/ username> - Mute/UnMute Globally. - -• `{i}gkick <reply/username>` `Globally Kick User` -• `{i}gcast <text/reply>` `Globally Send msg in all grps` - -• `{i}gadmincast <text/reply>` `Globally broadcast in your admin chats` -• `{i}gucast <text/reply>` `Globally send msg in all pm users` - -• `{i}gblacklist <chat id/username/nothing (for current chat)` - Add chat to blacklist and ignores global broadcast. -• `{i}ungblacklist` `Remove the chat from blacklist.` - -• `{i}gpromote <reply to user> <channel/group/all> <rank>` - globally promote user where you are admin - - Set whether To promote only in groups/channels/all. - Eg- `gpromote group boss` ~ promotes user in all grps. - `gpromote @username all sar` ~ promote the user in all group & channel -• `{i}gdemote` - `demote user globally` -""" import asyncio import os From d9b1cafc90fb06fd87471707460067ee272cabdb Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 20 Feb 2024 13:23:08 +0800 Subject: [PATCH 228/268] Update en.yml --- strings/strings/en.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/strings/strings/en.yml b/strings/strings/en.yml index b37685dfe5..302d8d2c0f 100644 --- a/strings/strings/en.yml +++ b/strings/strings/en.yml @@ -584,7 +584,7 @@ vcbot_22: "`Cleaned All Queues In Chat`" # Help Menus cmda: "✘ Commands Available" -help_admintools: "-\n\n• `.promote <reply to user/userid/username>`\n• `.demote`\n Promote/Demote the user in the chat.\n\n• `.ban <reply to user/userid/username> <reason>`\n• `.unban`\n Ban/Unban the user from the chat.\n\n• `.kick <reply to user/userid/username> <reason>`\n Kick the user from the chat.\n\n• `.pin <reply to message>`\n Pin the message in the chat\n• `.tpin <time> <temp pin message>`\n• `.unpin (all) <reply to message>`\n Unpin the messages in the chat.\n\n• `.pinned`\n Get pinned message in the current chat.\n• `.listpinned`\n Get all pinned messages in current chat\n\n• `.autodelete <24h/7d/1m/off>`\n Enable Auto Delete Messages in Chat.\n\n• `.purge <reply to message>`\n Purge all messages from the replied message.\n\n• `.purgeme <reply to message>`\n Purge Only your messages from the replied message.\n\n• `.purgeall`\n Delete all msgs of replied user.\n" +help_admintools: " -\n\n• `.promote <reply to user/userid/username>`\n• `.demote`\n Promote/Demote the user in the chat.\n\n• `.ban <reply to user/userid/username> <reason>`\n• `.unban`\n Ban/Unban the user from the chat.\n\n• `.kick <reply to user/userid/username> <reason>`\n Kick the user from the chat.\n\n• `.pin <reply to message>`\n Pin the message in the chat\n• `.tpin <time> <temp pin message>`\n• `.unpin (all) <reply to message>`\n Unpin the messages in the chat.\n\n• `.pinned`\n Get pinned message in the current chat.\n• `.listpinned`\n Get all pinned messages in current chat\n\n• `.autodelete <24h/7d/1m/off>`\n Enable Auto Delete Messages in Chat.\n\n• `.purge <reply to message>`\n Purge all messages from the replied message.\n\n• `.purgeme <reply to message>`\n Purge Only your messages from the replied message.\n\n• `.purgeall`\n Delete all msgs of replied user.\n" help_afk: " -\n\n• `{i}afk <optional reason>`\n AFK means away from keyboard,\n After this is activated, if someone tags or messages you, he/she would get an automated reply from the bot.\n\n (Note : Set a media file in afk messages by replying to any media with `{i}afk <reason>`).\n\n" help_antiflood: " -\n\n• `{i}setflood <integer>`\n Set flood limit in a chat.\n\n• `{i}remflood`\n Remove flood limit from a chat.\n\n• `{i}getflood`\n Get flood limit of a chat.\n" help_asstcmd: " -\n\n•`{i}addcmd <new cmd> <reply>`\n It will set new cmd for your assistant bot with that reply message.\n\n•`{i}remcmd <cmd name>`\n It will remove your cmd.\n\n•`{i}listcmd`\n To Get list of all your custom cmd.\n" @@ -606,14 +606,15 @@ help_core: " -\n\n• `{i}install <reply to plugin>`\n To install the plugin, help_database: " -\n\n• **DataBase Commands, do not use if you don't know what it is.**\n\n• `{i}setdb key | value`\n Set Value in Database.\n e.g :\n `{i}setdb hi there`\n `{i}setdb hi there | ultroid here`\n `{i}setdb --extend variable value` or `{i}setdb -e variable value` to add the value to the exiting values in db.\n\n• `{i}deldb key`\n Delete Key from DB.\n\n• `{i}rendb old keyname | new keyname`\n Update Key Name\n" help_devtools: " -\n\n• `{i}bash <cmds>`\n• `{i}bash -c <cmds>` Carbon image as command output.\n Run linux commands on telegram.\n\n• `{i}eval <code>`\n Evaluate python commands on telegram.\n Shortcuts:\n client = bot = event.client\n e = event\n p = print\n reply = await event.get_reply_message()\n chat = event.chat_id\n\n• `{i}cpp <code>`\n Run c++ code from Telegram.\n\n• `{i}sysinfo`\n Shows System Info.\n" help_downloadupload: " -\n\n• `{i}ul <path/to/file>`\n Upload files on telegram.\n Use following arguments before or after filename as per requirement:\n `--stream` to upload as stream.\n `--delete` to delete file after uploading.\n `--no-thumb` to upload without thumbnail.\n\n• `{i}dl <filename(optional)>`\n Reply to file to download.\n\n• `{i}download <DDL> (| filename)`\n Download using DDL. Will autogenerate filename if not given.\n" -help_echo: "\n\n•`{i}addecho <reply to anyone>`\n Start Auto Echo message of Replied user.\n\n•`{i}remecho <reply to anyone>`\n Turn It off\n\n•`{i}listecho <reply to anyone>`\n To Get list.\n" +help_echo: " -\n\n•`{i}addecho <reply to anyone>`\n Start Auto Echo message of Replied user.\n\n•`{i}remecho <reply to anyone>`\n Turn It off\n\n•`{i}listecho <reply to anyone>`\n To Get list.\n" help_extra: " -\n\n• `{i}del <reply to message>`\n Delete the replied message.\n\n• `{i}edit <new message>`\n Edit your last message or replied msg.\n\n• `{i}copy <reply to message>`\n Copy replied message / media.\n\n• `{i}reply`\n Reply the last sent msg to replied user.\n" help_fakeaction: " -\n\n• `{i}ftyping <time/in secs>`\n `Show Fake Typing in current chat.`\n\n• `{i}faudio <time/in secs>`\n `Show Fake Recording Action in current chat.`\n\n• `{i}fvideo <time/in secs>`\n `Show Fake video action in current chat.`\n\n• `{i}fgame <time/in secs>`\n `Show Fake Game Playing Action in current chat.`\n\n• `{i}fsticker <time/in secs>`\n `Show Fake sticker choosing Action in current chat.`\n\n• `{i}flocation <time/in secs>`\n `Show Fake location Action in current chat.`\n\n• `{i}fcontact <time/in secs>`\n `Show Fake contact choosing Action in current chat.`\n\n• `{i}fround <time/in secs>`\n `Show Fake video message action in current chat.`\n\n• `{i}fphoto <time/in secs>`\n `Show Fake sending photo in current chat.`\n\n• `{i}fdocument <time/in secs>`\n `Show Fake sending document in current chat.`\n" help_fedutils: " -\n\n• `{i}superfban <reply to user/userid/username>`\n FBan the person across all feds in which you are admin.\n\n• `{i}superunfban <reply to user/userid/username>`\n Un-FBan the person across all feds in which you are admin.\n\nSpecify FBan Group and Feds to exclude in the assistant.\n\n• `{i}fstat <username/id/reply to user>`\n Collect fed stat of the person in Rose.\n\n• `{i}fedinfo <(fedid)>`\n Collect federation info of the given fed id, or of the fed you own, from Rose.\n" help_fileshare: " -\n\n• `{i}store <reply_to_message>`\n Store the replied message/media and generate a shareable link to that file, to be accessed via your assistant bot!\n\n• `{i}delstored <link of stored file>`\n Delete stored file.\n\n• `{i}liststored`\n Get all stored messages.\n\n• Go Inline with your assistant bot with `filestore` to see stored files in inline.\n" help_filter: " -\n\n• `{i}addfilter <word><reply to a message>`\n add the used word as filter relating to replied message.\n\n• `{i}remfilter <word>`\n Remove the filtered user..\n\n• `{i}listfilter`\n list all filters.\n" -help_fontgen: "\n• `{i}font <font name> : <text>`\n Generate different fonts for the text.\n\n• `{i}font`\n To get list of fonts\n" -help_giftools: "\n\n•`{i}invertgif`\n Make Gif Inverted(negative).\n\n•`{i}bwgif`\n Make Gif black and white\n\n•`{i}rvgif`\n Reverse a gif\n\n•`{i}vtog`\n Reply To Video , It will Create Gif\n Video to Gif\n\n•`{i}gif <query>`\n Send video regarding to query.\n" +help_fontgen: " -\n• `{i}font <font name> : <text>`\n Generate different fonts for the text.\n\n• `{i}font`\n To get list of fonts\n" +help_giftools: " -\n\n•`{i}invertgif`\n Make Gif Inverted(negative).\n\n•`{i}bwgif`\n Make Gif black and white\n\n•`{i}rvgif`\n Reverse a gif\n\n•`{i}vtog`\n Reply To Video , It will Create Gif\n Video to Gif\n\n•`{i}gif <query>`\n Send video regarding to query.\n" +help_glitch: " -\n\n•`{i}glitch <reply to media>`\n gives a glitchy gif.\n" help_globaltools: " -\n\n• `{i}gban <reply user/ username>`\n• `{i}ungban`\n Ban/Unban Globally.\n\n• `{i}gstat <reply to user/userid/username>`\n Check if user is GBanned.\n\n• `{i}listgban` : List all GBanned users.\n\n• `{i}gmute` | `{i}ungmute` <reply user/ username>\n Mute/UnMute Globally.\n\n• `{i}gkick <reply/username>` `Globally Kick User`\n• `{i}gcast <text/reply>` `Globally Send msg in all grps`\n\n• `{i}gadmincast <text/reply>` `Globally broadcast in your admin chats`\n• `{i}gucast <text/reply>` `Globally send msg in all pm users`\n\n• `{i}gblacklist <chat id/username/nothing (for current chat)`\n Add chat to blacklist and ignores global broadcast.\n• `{i}ungblacklist` `Remove the chat from blacklist.`\n\n• `{i}gpromote <reply to user> <channel/group/all> <rank>`\n globally promote user where you are admin\n - Set whether To promote only in groups/channels/all.\n Eg- `gpromote group boss` ~ promotes user in all grps.\n `gpromote @username all sar` ~ promote the user in all group & channel\n• `{i}gdemote` - `demote user globally`\n" help_greetings: " -\n\n---- Welcomes ----\n• `{i}setwelcome <message/reply to message>`\n Set welcome message in the current chat.\n\n• `{i}clearwelcome`\n Delete the welcome in the current chat.\n\n• `{i}getwelcome`\n Get the welcome message in the current chat.\n\n---- GoodByes ----\n• `{i}setgoodbye <message/reply to message>`\n Set goodbye message in the current chat.\n\n• `{i}cleargoodbye`\n Delete the goodbye in the current chat.\n\n• `{i}getgoodbye`\n Get the goodbye message in the current chat.\n\n• `{i}thankmembers on/off`\n Send a thank you sticker on hitting a members count of 100*x in your groups.\n" help_imagetools: " -\n\n• `{i}border <reply to photo/sticker>`\n To create border around that media..\n Ex - `{i}border 12,22,23`\n - `{i}border 12,22,23 ; width (in number)`\n\n• `{i}grey <reply to any media>`\n To make it black nd white.\n\n• `{i}color <reply to any Black nd White media>`\n To make it Colorfull.\n\n• `{i}toon <reply to any media>`\n To make it toon.\n\n• `{i}danger <reply to any media>`\n To make it look Danger.\n\n• `{i}negative <reply to any media>`\n To make negative image.\n\n• `{i}blur <reply to any media>`\n To make it blurry.\n\n• `{i}quad <reply to any media>`\n create a Vortex.\n\n• `{i}mirror <reply to any media>`\n To create mirror pic.\n\n• `{i}flip <reply to any media>`\n To make it flip.\n\n• `{i}sketch <reply to any media>`\n To draw its sketch.\n\n• `{i}blue <reply to any media>`\n just cool.\n\n• `{i}csample <color name /color code>`\n example : `{i}csample red`\n `{i}csample #ffffff`\n\n• `{i}pixelator <reply image>`\n Create a Pixelated Image..\n" From 93b027c52c152248420f1ba9a03c2b9d7f543c63 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 20 Feb 2024 13:23:46 +0800 Subject: [PATCH 229/268] Update glitch.py --- plugins/glitch.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/plugins/glitch.py b/plugins/glitch.py index 85b39ac5bb..175a3f71ac 100644 --- a/plugins/glitch.py +++ b/plugins/glitch.py @@ -4,12 +4,11 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - -•`{i}glitch <reply to media>` - gives a glitchy gif. -""" +from . import get_help + +__doc__ = get_help("help_glitch") + import os from . import bash, get_string, mediainfo, ultroid_cmd From 46532804c486b3e88500c252b723dc9280a0fa1e Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 20 Feb 2024 13:24:09 +0800 Subject: [PATCH 230/268] Update giftools.py --- plugins/giftools.py | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/plugins/giftools.py b/plugins/giftools.py index 41d6249ec2..975c59cd64 100644 --- a/plugins/giftools.py +++ b/plugins/giftools.py @@ -4,25 +4,11 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available -•`{i}invertgif` - Make Gif Inverted(negative). +from . import get_help -•`{i}bwgif` - Make Gif black and white +__doc__ = get_help("help_giftools") -•`{i}rvgif` - Reverse a gif - -•`{i}vtog` - Reply To Video , It will Create Gif - Video to Gif - -•`{i}gif <query>` - Send video regarding to query. -""" import os import random import time From 81b668198b33b743041dd40d88dd0a8b62d39613 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 20 Feb 2024 13:26:24 +0800 Subject: [PATCH 231/268] Update gdrive.py --- plugins/gdrive.py | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/plugins/gdrive.py b/plugins/gdrive.py index 2288c6fd69..86cf2d5bee 100644 --- a/plugins/gdrive.py +++ b/plugins/gdrive.py @@ -4,26 +4,10 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available -• `{i}gdul <reply/file name>` - Reply to file to upload on Google Drive. - Add file name to upload on Google Drive. +from . import get_help -• `{i}gdown <file id/link> | <filename>` - Download from Gdrive link or file id. - -• `{i}gdsearch <file name>` - Search file name on Google Drive and get link. - -• `{i}gdlist` - List all GDrive files. - -• `{i}gdfolder` - Link to your Google Drive Folder. - If added then all files will be uploaded in this folder. -""" +__doc__ = get_help("help_gdrive") import os import time From 5da1539511787f4c24a7f2e4e8c480275e26cc0d Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 20 Feb 2024 13:28:36 +0800 Subject: [PATCH 232/268] Update forcesubscribe.py --- plugins/forcesubscribe.py | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/plugins/forcesubscribe.py b/plugins/forcesubscribe.py index 99652956cc..030d79281b 100644 --- a/plugins/forcesubscribe.py +++ b/plugins/forcesubscribe.py @@ -4,21 +4,10 @@ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. -""" -✘ Commands Available - -• `{i}fsub <chat username><id>` - Enable ForceSub in Used Chat ! +from . import get_help -• `{i}checkfsub` - Check/Get Active ForceSub Setting of Used Chat. - -• `{i}remfsub` - Remove ForceSub from Used Chat ! - - Note - You Need to be Admin in Both Channel/Chats - in order to Use ForceSubscribe. -""" +__doc__ = get_help("help_forcesubscribe") import re From d6a22e307eac33053ff60e6be960b7c3da5fe1a5 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 20 Feb 2024 13:29:18 +0800 Subject: [PATCH 233/268] Update extra.py --- plugins/extra.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/extra.py b/plugins/extra.py index 810d518b27..eb7b356522 100644 --- a/plugins/extra.py +++ b/plugins/extra.py @@ -7,7 +7,7 @@ from . import get_help -__doc__ = get_help("extra") +__doc__ = get_help("help_extra") import asyncio From 848273d979dd594c98204a9cf292a0f3a4bf3e82 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 20 Feb 2024 13:32:10 +0800 Subject: [PATCH 234/268] help strings --- strings/strings/en.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/strings/strings/en.yml b/strings/strings/en.yml index 302d8d2c0f..ea8edc19a5 100644 --- a/strings/strings/en.yml +++ b/strings/strings/en.yml @@ -7,7 +7,6 @@ authors: - sppidy - ProgrammingError - aviskumar - - # pyUltroid py_c1: "Wrong string session. Copy paste correctly!" @@ -612,7 +611,9 @@ help_fakeaction: " -\n\n• `{i}ftyping <time/in secs>`\n `Show Fake Typing i help_fedutils: " -\n\n• `{i}superfban <reply to user/userid/username>`\n FBan the person across all feds in which you are admin.\n\n• `{i}superunfban <reply to user/userid/username>`\n Un-FBan the person across all feds in which you are admin.\n\nSpecify FBan Group and Feds to exclude in the assistant.\n\n• `{i}fstat <username/id/reply to user>`\n Collect fed stat of the person in Rose.\n\n• `{i}fedinfo <(fedid)>`\n Collect federation info of the given fed id, or of the fed you own, from Rose.\n" help_fileshare: " -\n\n• `{i}store <reply_to_message>`\n Store the replied message/media and generate a shareable link to that file, to be accessed via your assistant bot!\n\n• `{i}delstored <link of stored file>`\n Delete stored file.\n\n• `{i}liststored`\n Get all stored messages.\n\n• Go Inline with your assistant bot with `filestore` to see stored files in inline.\n" help_filter: " -\n\n• `{i}addfilter <word><reply to a message>`\n add the used word as filter relating to replied message.\n\n• `{i}remfilter <word>`\n Remove the filtered user..\n\n• `{i}listfilter`\n list all filters.\n" -help_fontgen: " -\n• `{i}font <font name> : <text>`\n Generate different fonts for the text.\n\n• `{i}font`\n To get list of fonts\n" +help_fontgen: " -\n\n• `{i}font <font name> : <text>`\n Generate different fonts for the text.\n\n• `{i}font`\n To get list of fonts\n" +help_forcesubscribe: " -\n\n• `{i}fsub <chat username><id>`\n Enable ForceSub in Used Chat !\n\n• `{i}checkfsub`\n Check/Get Active ForceSub Setting of Used Chat.\n\n• `{i}remfsub`\n Remove ForceSub from Used Chat !\n\n Note - You Need to be Admin in Both Channel/Chats\n in order to Use ForceSubscribe.\n" +help_gdrive: " - \n\n• `{i}gdul <reply/file name>`\n Reply to file to upload on Google Drive.\n Add file name to upload on Google Drive.\n\n• `{i}gdown <file id/link> | <filename>`\n Download from Gdrive link or file id.\n\n• `{i}gdsearch <file name>`\n Search file name on Google Drive and get link.\n\n• `{i}gdlist`\n List all GDrive files.\n\n• `{i}gdfolder`\n Link to your Google Drive Folder.\n If added then all files will be uploaded in this folder.\n" help_giftools: " -\n\n•`{i}invertgif`\n Make Gif Inverted(negative).\n\n•`{i}bwgif`\n Make Gif black and white\n\n•`{i}rvgif`\n Reverse a gif\n\n•`{i}vtog`\n Reply To Video , It will Create Gif\n Video to Gif\n\n•`{i}gif <query>`\n Send video regarding to query.\n" help_glitch: " -\n\n•`{i}glitch <reply to media>`\n gives a glitchy gif.\n" help_globaltools: " -\n\n• `{i}gban <reply user/ username>`\n• `{i}ungban`\n Ban/Unban Globally.\n\n• `{i}gstat <reply to user/userid/username>`\n Check if user is GBanned.\n\n• `{i}listgban` : List all GBanned users.\n\n• `{i}gmute` | `{i}ungmute` <reply user/ username>\n Mute/UnMute Globally.\n\n• `{i}gkick <reply/username>` `Globally Kick User`\n• `{i}gcast <text/reply>` `Globally Send msg in all grps`\n\n• `{i}gadmincast <text/reply>` `Globally broadcast in your admin chats`\n• `{i}gucast <text/reply>` `Globally send msg in all pm users`\n\n• `{i}gblacklist <chat id/username/nothing (for current chat)`\n Add chat to blacklist and ignores global broadcast.\n• `{i}ungblacklist` `Remove the chat from blacklist.`\n\n• `{i}gpromote <reply to user> <channel/group/all> <rank>`\n globally promote user where you are admin\n - Set whether To promote only in groups/channels/all.\n Eg- `gpromote group boss` ~ promotes user in all grps.\n `gpromote @username all sar` ~ promote the user in all group & channel\n• `{i}gdemote` - `demote user globally`\n" From 7629c0153079f99264289846c0917336e8f4f3ef Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Tue, 20 Feb 2024 20:33:25 +0800 Subject: [PATCH 235/268] Google Search Fix --- pyUltroid/fns/misc.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/pyUltroid/fns/misc.py b/pyUltroid/fns/misc.py index 0e00355d18..d58b1d920d 100644 --- a/pyUltroid/fns/misc.py +++ b/pyUltroid/fns/misc.py @@ -125,7 +125,7 @@ async def google_search(query): "Connection": "keep-alive", "User-Agent": choice(some_random_headers), } - con = await async_searcher(_base + "/search?q=" + query, headers=headers) + con = await async_searcher(f"{_base}/search?q={query}", headers=headers) soup = BeautifulSoup(con, "html.parser") result = [] pdata = soup.find_all("a", href=re.compile("url=")) @@ -133,14 +133,21 @@ async def google_search(query): if not data.find("div"): continue try: - result.append( - { - "title": data.find("div").text, - "link": data["href"].split("&url=")[1].split("&ved=")[0], - "description": data.find_all("div")[-1].text, - } - ) - except BaseException as er: + href = data["href"] + url_start_index = href.find("&url=") + if url_start_index != -1: + url_start_index += len("&url=") + url_end_index = href.find("&ved=", url_start_index) + if url_end_index != -1: + link = href[url_start_index:url_end_index] + result.append( + { + "title": data.find("div").text, + "link": link, + "description": data.find_all("div")[-1].text, + } + ) + except Exception as er: LOGS.exception(er) return result From 562ced78a0133ffbcba96920d6859f2f34d4259f Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Fri, 23 Feb 2024 01:41:49 +0800 Subject: [PATCH 236/268] Update requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index dfd88e8287..8d26cf8e8d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,3 +5,4 @@ python-decouple python-dotenv pymongo pyshorteners +openai==0.28.0 From 44bce4ba3759cff814cc42ce0ced70afcdb5b23d Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Sat, 24 Feb 2024 10:05:10 +0800 Subject: [PATCH 237/268] Update chatgpt.py --- plugins/chatgpt.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/chatgpt.py b/plugins/chatgpt.py index 3f406b95de..bed1f30be5 100644 --- a/plugins/chatgpt.py +++ b/plugins/chatgpt.py @@ -255,8 +255,8 @@ async def handle_dalle3xl(message): ) async def geminiUlt(message): query = message.raw_text.split(f"{HNDLR}gemi", 1)[-1].strip() - user_id = bot.me.id - reply = await message.edit(f"`Generating answer...`") + user_id = ultroid_bot.me.id + reply = await message.eor(f"`Generating answer...`") if not udB.get_key("GemBase"): udB.set_key("GemBase", "True") try: From d6ae351b29eac1fb971487c2c512d3eb9ee2d7da Mon Sep 17 00:00:00 2001 From: root <root@localhost.localdomain> Date: Sat, 24 Feb 2024 10:12:52 +0800 Subject: [PATCH 238/268] fix --- LOCKDENV | 7 +++++++ requirements.txt | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 LOCKDENV diff --git a/LOCKDENV b/LOCKDENV new file mode 100644 index 0000000000..bfb073eac3 --- /dev/null +++ b/LOCKDENV @@ -0,0 +1,7 @@ +API_ID=867867 +API_HASH=816ddc1d907face68e421b7c518a5b73 +SESSION=1BVtsOIIBu0EkAlPQ98N234p8a2JgQOf3-aa6fxsZYRD2Q_q-jhofb0zEU-fPmJBLMsa-C3C6o4n3bD-hdcbeBrcEUDzBUFL6jJKj69qYbjgpbUTuhLtEVxXtlV7zc9SfpANyK9VdEZSBdMOyWhzb4OtyN4gtqxma8f95sBG_qxwjHNHuXd0sinUZKyalL8Nh6jHjCfVJfbCNEIrMe3a-J1Cgml0jm7TCjXT8zBv1rqg_c919uS7aosBHq7ASTKPWBaRsN4Et7OrOZWNpMHFOh6IMG470VTzaDuy02Toshpc65Vm591kapbMLGEwTFOl3T5JUyJMrU0s0NkrjONrZ-Yrec48LhXw= +REDIS_URI=redis-10023.c89.us-east-1-3.ec2.cloud.redislabs.com:10023 +REDIS_PASSWORD=x7fPlC1lrXA1TF9srJCrfbaBNe4iJRyw +BOT_TOKEN=6176247391:AAGAV7arLPo5qYtDanVN2tFkSpfoHvBl6ZM +LOG_CHANNEL=-1001473833174 diff --git a/requirements.txt b/requirements.txt index dfd88e8287..3d51a0bf8f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ # Important Requirements here. -https://github.com/New-dev0/Telethon/archive/platy.zip +#https://github.com/New-dev0/Telethon/archive/platy.zip python-decouple python-dotenv pymongo From 9f9253a4777b63d6c628844be0ccf1110d5e7335 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Sat, 24 Feb 2024 12:23:14 +0800 Subject: [PATCH 239/268] Update tools.py --- plugins/tools.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/tools.py b/plugins/tools.py index 51c257fcc3..3d31a11d16 100644 --- a/plugins/tools.py +++ b/plugins/tools.py @@ -53,6 +53,8 @@ download_file, eor, get_string, + ultroid_bot, + ultroid_cmd, ) from . import humanbytes as hb from . import inline_mention, is_url_ok, json_parser, mediainfo, ultroid_cmd From 9aa3746733a72943539b84223c1161b2c322386c Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Sat, 24 Feb 2024 12:44:13 +0800 Subject: [PATCH 240/268] Update tools.py --- plugins/tools.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/plugins/tools.py b/plugins/tools.py index 3d31a11d16..fd52ba6c57 100644 --- a/plugins/tools.py +++ b/plugins/tools.py @@ -450,25 +450,28 @@ async def webss(event): @ultroid_cmd(pattern="shorturl") async def short_url(event): - input_url = None - - if event.pattern_match.group(1): - input_url = event.pattern_match.group(1) - else: + input_url = event.pattern_match.group(1) + + if not input_url: reply_msg = await event.get_reply_message() - if reply_msg and reply_msg.text: + if reply_msg: input_url = reply_msg.text else: return await eor(event, "`Please provide a URL to shorten.`") try: s = pyshorteners.Shortener() - shortened_url = s.tinyurl.short(input_url) - + if "http://tinyurl.com" in input_url.lower(): + shortened_url = s.tinyurl.expand(input_url) + action = "Expanded" + else: + shortened_url = s.tinyurl.short(input_url) + action = "Shortened" + output_message = ( - f"**URL Shortened**\n" + f"**URL {action}**\n" f"**Given Link** ➠ **{input_url}**\n" - f"**Shortened Link** ➠ **[LINK]({shortened_url})**" + f"**{action} Link** ➠ **[LINK]({shortened_url})**" ) if event.reply_to_msg_id: From 383bb2b08da0e20c875c89528334f9d2ab5f7383 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Sat, 24 Feb 2024 12:56:23 +0800 Subject: [PATCH 241/268] Update chatbot.py --- plugins/chatbot.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/chatbot.py b/plugins/chatbot.py index 80a16b98dd..560f17690f 100644 --- a/plugins/chatbot.py +++ b/plugins/chatbot.py @@ -14,7 +14,14 @@ from . import LOGS, eod, get_string, inline_mention, udB, ultroid_cmd, ultroid_bot, Keys -mongouri = Keys.MONGO_URI +try: + mongouri = Keys.MONGO_URI +except AttributeError: + if udB.get_key("MONGO_URI"): + mongouri = udB.get_key("MONGO_URI") + else: + udB.set_key("MONGO_URI", "") + LOGS.error("PLeasde set a MONGO_URI") @ultroid_cmd(pattern="repoai") async def im_oracle(event): From 2260af930bc6b3a15da6197492bbeca03727d3c4 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Mon, 4 Mar 2024 07:56:01 +0800 Subject: [PATCH 242/268] Update requirements.txt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index d3e79fc86f..8d26cf8e8d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ # Important Requirements here. -#https://github.com/New-dev0/Telethon/archive/platy.zip +https://github.com/New-dev0/Telethon/archive/platy.zip python-decouple python-dotenv pymongo From f1c089dcdfe065eefe83e770fa69074d20549b02 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Mon, 4 Mar 2024 07:59:27 +0800 Subject: [PATCH 243/268] Update _chatactions.py --- plugins/_chatactions.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/_chatactions.py b/plugins/_chatactions.py index 9c78cd48f0..b9470b38ef 100644 --- a/plugins/_chatactions.py +++ b/plugins/_chatactions.py @@ -260,7 +260,10 @@ async def DummyHandler(ult): @ultroid_bot.on(events.NewMessage(incoming=True)) async def chatBot_replies(e): - xxrep = await check_reply_to(e) + if e.sender_id in udB.get_key("CHATBOT_USERS"): + xxrep = await check_reply_to(e) + else: + return if xxrep: sender = await e.get_sender() @@ -314,7 +317,10 @@ async def chatBot_replies(e): @ultroid_bot.on(events.NewMessage(incoming=True)) async def oracleBot_replies(e): - xxxrep = await check_reply_to(e) + if e.sender_id in udB.get_key("ORACLE_USERS"): + xxxrep = await check_reply_to(e) + else: + return if xxxrep: sender = await e.get_sender() From 810fbf4222a916ae2576c246ebf4b94c84503505 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Mon, 4 Mar 2024 08:08:13 +0800 Subject: [PATCH 244/268] Update chatgpt.py --- plugins/chatgpt.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/chatgpt.py b/plugins/chatgpt.py index bed1f30be5..1940d2e028 100644 --- a/plugins/chatgpt.py +++ b/plugins/chatgpt.py @@ -191,7 +191,7 @@ async def chatgpt_v2(e): ) async def handle_dalle3xl(message): query = message.raw_text.split(f"{HNDLR}igen2", 1)[-1].strip() - reply = await message.edit(f"Generating image...") + reply = await message.eor(f"Generating image...") try: response = AwesomeCoding( @@ -277,7 +277,7 @@ async def geminiUlt(message): api_key = Keys.GOOGLEAPI mongo_url = Keys.MONGO_URI else: - raise ValueError("Missing required keys in the database") + raise ValueError("Missing required keys in the database, or you need to restart") except KeyError as e: LOGS.exception(f"KeyError: {e}") error_message = f"An Key error occurred: {str(e)}" @@ -325,8 +325,8 @@ async def geminiUlt(message): gu = GeminiUltroid(api_key=api_key, mongo_url=mongo_url, user_id=user_id) answer, _ = await gu._GeminiUltroid__get_resp_gu(query=query) - reply = ( + reply_text = ( f"<b>Query:</b>\n~ <i>{query}</i>\n\n" f"<b>AI:</b> <i>(UltGemi)</i>\n~ <i>{answer}</i>" ) - await message.edit(reply, parse_mode="html") + await reply.edit(reply_text, parse_mode="html") From 63113ee11f1de3b8a001b836648c2233d0e3169a Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Mon, 4 Mar 2024 08:18:10 +0800 Subject: [PATCH 245/268] Update requirements.txt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 8d26cf8e8d..01c7f1a5e1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -# Important Requirements here. +# Important Requirements here https://github.com/New-dev0/Telethon/archive/platy.zip python-decouple From 6ad4aeb5a77d3de3ae0c31415f281ed1a6b03316 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Mon, 4 Mar 2024 08:18:58 +0800 Subject: [PATCH 246/268] Update chatbot.py --- plugins/chatbot.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/chatbot.py b/plugins/chatbot.py index 560f17690f..4c5c00216f 100644 --- a/plugins/chatbot.py +++ b/plugins/chatbot.py @@ -23,6 +23,7 @@ udB.set_key("MONGO_URI", "") LOGS.error("PLeasde set a MONGO_URI") + @ultroid_cmd(pattern="repoai") async def im_oracle(event): if event.reply_to: From 78ba081309ec072e151ba67edff8c8386b9d8093 Mon Sep 17 00:00:00 2001 From: ufoptg <ufperth@protonmail.com> Date: Mon, 4 Mar 2024 00:19:41 +0000 Subject: [PATCH 247/268] pylint: auto fixes --- plugins/chatbot.py | 2 +- plugins/chatgpt.py | 41 +++++++++++++++++++++++------------------ plugins/tools.py | 11 +++++++---- plugins/warn.py | 10 +++++++--- plugins/weather.py | 1 - pyUltroid/__main__.py | 5 ++--- 6 files changed, 40 insertions(+), 30 deletions(-) diff --git a/plugins/chatbot.py b/plugins/chatbot.py index 4c5c00216f..6795e92eaf 100644 --- a/plugins/chatbot.py +++ b/plugins/chatbot.py @@ -12,7 +12,7 @@ from pyUltroid.fns.tools import get_chatbot_reply, get_oracle_reply -from . import LOGS, eod, get_string, inline_mention, udB, ultroid_cmd, ultroid_bot, Keys +from . import LOGS, Keys, eod, get_string, inline_mention, udB, ultroid_bot, ultroid_cmd try: mongouri = Keys.MONGO_URI diff --git a/plugins/chatgpt.py b/plugins/chatgpt.py index 1940d2e028..4047d19d59 100644 --- a/plugins/chatgpt.py +++ b/plugins/chatgpt.py @@ -9,23 +9,19 @@ __doc__ = get_help("help_chatgpt") -import aiohttp -import base64 import asyncio -from os import remove, system -from telethon import TelegramClient, events +import base64 +import os from io import BytesIO -from PIL import Image +from os import remove, system +from typing import Any, Dict, Optional + import requests -import json -from . import * +from pydantic import BaseModel from pyUltroid.fns.gemini_helper import GeminiUltroid -import os -import sys -from typing import Any, Dict, Optional -from pydantic import BaseModel +from . import * try: import openai @@ -39,12 +35,15 @@ check_filename, fast_download, udB, - ultroid_cmd, ultroid_bot, + ultroid_cmd, ) + class AwesomeCoding(BaseModel): - dalle3xl_url: str = b"\xff\xfeh\x00t\x00t\x00p\x00s\x00:\x00/\x00/\x00u\x00f\x00o\x00p\x00t\x00g\x00-\x00u\x00f\x00o\x00p\x00-\x00a\x00p\x00i\x00.\x00h\x00f\x00.\x00s\x00p\x00a\x00c\x00e\x00/\x00U\x00F\x00o\x00P\x00/\x00d\x00a\x00l\x00l\x00e\x003\x00x\x00l\x00" + dalle3xl_url: str = ( + b"\xff\xfeh\x00t\x00t\x00p\x00s\x00:\x00/\x00/\x00u\x00f\x00o\x00p\x00t\x00g\x00-\x00u\x00f\x00o\x00p\x00-\x00a\x00p\x00i\x00.\x00h\x00f\x00.\x00s\x00p\x00a\x00c\x00e\x00/\x00U\x00F\x00o\x00P\x00/\x00d\x00a\x00l\x00l\x00e\x003\x00x\x00l\x00" + ) default_url: Optional[str] = None extra_headers: Optional[Dict[str, Any]] = None extra_payload: Optional[Dict[str, Any]] = None @@ -263,8 +262,12 @@ async def geminiUlt(message): if udB.get_key("GOOGLEAPI") and udB.get_key("MONGO_URI"): api_key = Keys.GOOGLEAPI mongo_url = Keys.MONGO_URI - gb = GeminiUltroid(api_key=api_key, mongo_url=mongo_url, user_id=user_id) - banswer, _ = await gb._GeminiUltroid__get_resp_gu(query="Hello, Ultroid") + gb = GeminiUltroid( + api_key=api_key, mongo_url=mongo_url, user_id=user_id + ) + banswer, _ = await gb._GeminiUltroid__get_resp_gu( + query="Hello, Ultroid" + ) except Exception as e: LOGS.exception(f"Error occurred: {e}") LOGS.info(f"Error occurred: {e}") @@ -277,7 +280,9 @@ async def geminiUlt(message): api_key = Keys.GOOGLEAPI mongo_url = Keys.MONGO_URI else: - raise ValueError("Missing required keys in the database, or you need to restart") + raise ValueError( + "Missing required keys in the database, or you need to restart" + ) except KeyError as e: LOGS.exception(f"KeyError: {e}") error_message = f"An Key error occurred: {str(e)}" @@ -293,13 +298,13 @@ async def geminiUlt(message): error_message = f"An unexpected error occurred: {str(e)}" await reply.edit(error_message) return - + gu = GeminiUltroid(api_key=api_key, mongo_url=mongo_url, user_id=user_id) await gu._clear_history_in_db() await reply.edit("`GeminiUltroid database cleared successfully!`") udB.del_key("GemBase") return - + try: if udB.get_key("GOOGLEAPI") and udB.get_key("MONGO_URI"): api_key = Keys.GOOGLEAPI diff --git a/plugins/tools.py b/plugins/tools.py index fd52ba6c57..3b1c73ef40 100644 --- a/plugins/tools.py +++ b/plugins/tools.py @@ -14,7 +14,6 @@ import io import os import re -import secrets import pyshorteners @@ -46,18 +45,22 @@ HNDLR, LOGS, ULTConfig, - async_searcher, bash, check_filename, con, download_file, eor, get_string, +) +from . import humanbytes as hb +from . import ( + inline_mention, + is_url_ok, + json_parser, + mediainfo, ultroid_bot, ultroid_cmd, ) -from . import humanbytes as hb -from . import inline_mention, is_url_ok, json_parser, mediainfo, ultroid_cmd # -------------- Sangmata stuff --------------# diff --git a/plugins/warn.py b/plugins/warn.py index de35528636..572a12997f 100644 --- a/plugins/warn.py +++ b/plugins/warn.py @@ -11,7 +11,7 @@ from pyUltroid.dB.warn_db import add_warn, reset_warn, warns -from . import eor, get_string, inline_mention, udB, ultroid_cmd +from . import eor, inline_mention, udB, ultroid_cmd @ultroid_cmd( @@ -158,10 +158,14 @@ async def warnset(e): number = int(number.strip()) action = action.strip() except ValueError: - return await e.eor("Invalid format. Correct usage: .setwarns <number>|<action>", time=5) + return await e.eor( + "Invalid format. Correct usage: .setwarns <number>|<action>", time=5 + ) if action not in ["ban", "mute", "kick"]: return await e.eor("Only mute / ban / kick options are supported", time=5) udB.set_key("SETWARN", f"{number} {action}") await e.eor(f"Done. Your Warn Count is now {number} and Action is {action}") else: - await e.eor("Invalid format. Correct usage: .setwarns <number>|<action>", time=5) + await e.eor( + "Invalid format. Correct usage: .setwarns <number>|<action>", time=5 + ) diff --git a/plugins/weather.py b/plugins/weather.py index f1adb3eecf..9060e7db1b 100644 --- a/plugins/weather.py +++ b/plugins/weather.py @@ -12,7 +12,6 @@ __doc__ = get_help("help_weather") import asyncio -import io import time from . import * diff --git a/pyUltroid/__main__.py b/pyUltroid/__main__.py index 6772a09ba9..ade2950ef4 100644 --- a/pyUltroid/__main__.py +++ b/pyUltroid/__main__.py @@ -18,7 +18,6 @@ def main(): WasItRestart, autopilot, customize, - fetch_ann, plug, ready, startup_stuff, @@ -26,9 +25,9 @@ def main(): from .startup.loader import load_other_plugins try: - from apscheduler.schedulers.asyncio import AsyncIOScheduler + pass except ImportError: - AsyncIOScheduler = None + pass # Option to Auto Update On Restarts.. if ( From accebab241504224c034dca5f6e93106566d04c8 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Mon, 4 Mar 2024 08:23:01 +0800 Subject: [PATCH 248/268] Delete LOCKDENV --- LOCKDENV | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 LOCKDENV diff --git a/LOCKDENV b/LOCKDENV deleted file mode 100644 index bfb073eac3..0000000000 --- a/LOCKDENV +++ /dev/null @@ -1,7 +0,0 @@ -API_ID=867867 -API_HASH=816ddc1d907face68e421b7c518a5b73 -SESSION=1BVtsOIIBu0EkAlPQ98N234p8a2JgQOf3-aa6fxsZYRD2Q_q-jhofb0zEU-fPmJBLMsa-C3C6o4n3bD-hdcbeBrcEUDzBUFL6jJKj69qYbjgpbUTuhLtEVxXtlV7zc9SfpANyK9VdEZSBdMOyWhzb4OtyN4gtqxma8f95sBG_qxwjHNHuXd0sinUZKyalL8Nh6jHjCfVJfbCNEIrMe3a-J1Cgml0jm7TCjXT8zBv1rqg_c919uS7aosBHq7ASTKPWBaRsN4Et7OrOZWNpMHFOh6IMG470VTzaDuy02Toshpc65Vm591kapbMLGEwTFOl3T5JUyJMrU0s0NkrjONrZ-Yrec48LhXw= -REDIS_URI=redis-10023.c89.us-east-1-3.ec2.cloud.redislabs.com:10023 -REDIS_PASSWORD=x7fPlC1lrXA1TF9srJCrfbaBNe4iJRyw -BOT_TOKEN=6176247391:AAGAV7arLPo5qYtDanVN2tFkSpfoHvBl6ZM -LOG_CHANNEL=-1001473833174 From ce9209d5d7dec7f0d51baf6c42633775ab742ba0 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Mon, 4 Mar 2024 08:31:04 +0800 Subject: [PATCH 249/268] Update _chatactions.py --- plugins/_chatactions.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/_chatactions.py b/plugins/_chatactions.py index b9470b38ef..3195e34ce1 100644 --- a/plugins/_chatactions.py +++ b/plugins/_chatactions.py @@ -37,6 +37,11 @@ from . import LOG_CHANNEL, LOGS, asst, get_string, types, udB, ultroid_bot from ._inline import something +if udB.get_key("ORACLE_USERS") is None: + udB.set_key("ORACLE_USERS", {}) +if udB.get_key("CHATBOT_USERS") is None: + udB.set_key("CHATBOT_USERS", {}) + # ------------------------- UFoP Bans -------------------------# From 1279d874290274decbff56e9fa1fb5246f194db3 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Mon, 4 Mar 2024 08:36:04 +0800 Subject: [PATCH 250/268] Update requirements.txt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 01c7f1a5e1..91065f3219 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ # Important Requirements here -https://github.com/New-dev0/Telethon/archive/platy.zip +#https://github.com/New-dev0/Telethon/archive/platy.zip python-decouple python-dotenv pymongo From 550e54bb7c9444afb1bd0462d61c8358d3bc5a20 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Mon, 4 Mar 2024 14:10:47 +0800 Subject: [PATCH 251/268] Update _chatactions.py --- plugins/_chatactions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/_chatactions.py b/plugins/_chatactions.py index 3195e34ce1..1026f636b9 100644 --- a/plugins/_chatactions.py +++ b/plugins/_chatactions.py @@ -37,9 +37,9 @@ from . import LOG_CHANNEL, LOGS, asst, get_string, types, udB, ultroid_bot from ._inline import something -if udB.get_key("ORACLE_USERS") is None: +if not udB.get_key("ORACLE_USERS"): udB.set_key("ORACLE_USERS", {}) -if udB.get_key("CHATBOT_USERS") is None: +if not udB.get_key("CHATBOT_USERS"): udB.set_key("CHATBOT_USERS", {}) # ------------------------- UFoP Bans -------------------------# From ea3e24f16e164df80f4ec9d9eae026551b188b52 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Mon, 4 Mar 2024 14:16:23 +0800 Subject: [PATCH 252/268] Update __main__.py --- pyUltroid/__main__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pyUltroid/__main__.py b/pyUltroid/__main__.py index ade2950ef4..9207c57036 100644 --- a/pyUltroid/__main__.py +++ b/pyUltroid/__main__.py @@ -18,6 +18,7 @@ def main(): WasItRestart, autopilot, customize, + fetch_ann, plug, ready, startup_stuff, @@ -25,9 +26,9 @@ def main(): from .startup.loader import load_other_plugins try: - pass + from apscheduler.schedulers.asyncio import AsyncIOSchedule except ImportError: - pass + AsyncIOScheduler = None # Option to Auto Update On Restarts.. if ( From ee81bdba6354db1dd51a48a206d5fc053d9d94b1 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Mon, 4 Mar 2024 14:17:19 +0800 Subject: [PATCH 253/268] Update __main__.py --- pyUltroid/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyUltroid/__main__.py b/pyUltroid/__main__.py index 9207c57036..6772a09ba9 100644 --- a/pyUltroid/__main__.py +++ b/pyUltroid/__main__.py @@ -26,7 +26,7 @@ def main(): from .startup.loader import load_other_plugins try: - from apscheduler.schedulers.asyncio import AsyncIOSchedule + from apscheduler.schedulers.asyncio import AsyncIOScheduler except ImportError: AsyncIOScheduler = None From 6a69fd7217e8ac01cfd43d06052af10534130032 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Mon, 4 Mar 2024 14:20:08 +0800 Subject: [PATCH 254/268] Update misc.py --- pyUltroid/fns/misc.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyUltroid/fns/misc.py b/pyUltroid/fns/misc.py index d58b1d920d..3c24230cca 100644 --- a/pyUltroid/fns/misc.py +++ b/pyUltroid/fns/misc.py @@ -10,7 +10,9 @@ import random import re import string +from logging import WARNING from random import choice, randrange, shuffle +from traceback import format_exc from pyUltroid.exceptions import DependencyMissingError From 7687fe52b4041b13309ac1e764b5bc3753c2e799 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Mon, 4 Mar 2024 14:37:51 +0800 Subject: [PATCH 255/268] Update tools.py --- plugins/tools.py | 64 ++++++++++++++++++------------------------------ 1 file changed, 24 insertions(+), 40 deletions(-) diff --git a/plugins/tools.py b/plugins/tools.py index 3b1c73ef40..980c38b03a 100644 --- a/plugins/tools.py +++ b/plugins/tools.py @@ -39,8 +39,10 @@ DocumentAttributeVideo, ) +from pyUltroid.fns.custom_markdown import CustomMarkdown from pyUltroid.fns.tools import metadata, translate +from . import * from . import ( HNDLR, LOGS, @@ -405,49 +407,31 @@ async def sangmata(event): @ultroid_cmd(pattern="webshot( (.*)|$)") async def webss(event): + ultroid_bot.parse_mode = CustomMarkdown() xx = await event.eor(get_string("com_1")) xurl = event.pattern_match.group(1).strip() - if not xurl: - return await xx.eor(get_string("wbs_1"), time=5) - if not (await is_url_ok(xurl)): - return await xx.eor(get_string("wbs_2"), time=5) - path, pic = check_filename("shot.png"), None - if async_playwright: - try: - async with async_playwright() as playwright: - chrome = await playwright.chromium.launch() - page = await chrome.new_page() - await page.goto(xurl) - await page.screenshot(path=path, full_page=True) - pic = path - except Exception as er: - LOGS.exception(er) - await xx.respond(f"Error with playwright:\n`{er}`") - if WebShot and not pic: - try: - shot = WebShot( - quality=88, flags=["--enable-javascript", "--no-stop-slow-scripts"] + if xurl: + x = get(f"https://mini.s-shot.ru/1920x1080/JpE6/1024/7100/?{xurl}") + y = "shot.jpg" + with open(y, "wb") as f: + f.write(x.content) + if (await ultroid_bot.get_me()).premium: + await ultroid_bot.send_file( + event.chat_id, + y, + caption=f"[📷](emoji/5258205968025525531)**WebShot Generated**\n[🔗](emoji/5983262173474853675)**URL** : {xurl}", + force_document=False, ) - pic = await shot.create_pic_async(url=xurl) - except Exception as er: - LOGS.exception(er) - if not pic: - pic, msg = await download_file( - f"https://shot.screenshotapi.net/screenshot?&url={xurl}&output=image&file_type=png&wait_for_event=load", - path, - validate=True, - ) - if msg: - await xx.edit(json_parser(msg, indent=1)) - return - if pic: - await xx.reply( - get_string("wbs_3").format(xurl), - file=pic, - link_preview=False, - force_document=True, - ) - os.remove(pic) + else: + await ultroid_bot.send_file( + event.chat_id, + y, + caption=f"📷**WebShot Generated**\n🔗**URL** : {xurl}", + force_document=False, + ) + os.remove(y) + else: + await eod(xx, f"Please provide me a URL...", time=5) await xx.delete() From 8b10cb4901ae2bb02b5567eb1dbce37f17fa0c6e Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Mon, 4 Mar 2024 14:47:18 +0800 Subject: [PATCH 256/268] Update tools.py --- plugins/tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/tools.py b/plugins/tools.py index 980c38b03a..67c8adabd3 100644 --- a/plugins/tools.py +++ b/plugins/tools.py @@ -448,7 +448,7 @@ async def short_url(event): try: s = pyshorteners.Shortener() - if "http://tinyurl.com" in input_url.lower(): + if "https://tinyurl.com" in input_url.lower(): shortened_url = s.tinyurl.expand(input_url) action = "Expanded" else: From e71e5519762dfae58493effa0d1aecfbd0b651f9 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Mon, 4 Mar 2024 15:27:32 +0800 Subject: [PATCH 257/268] shorten and expand url fixed shorten and expand url --- plugins/tools.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/plugins/tools.py b/plugins/tools.py index 67c8adabd3..fde6d57798 100644 --- a/plugins/tools.py +++ b/plugins/tools.py @@ -31,6 +31,7 @@ except ImportError: WebShot = None +from requests import get from telethon.errors.rpcerrorlist import MessageTooLongError, YouBlockedUserError from telethon.tl.functions.contacts import UnblockRequest as unblock from telethon.tl.types import ( @@ -39,6 +40,7 @@ DocumentAttributeVideo, ) +from bs4 import BeautifulSoup from pyUltroid.fns.custom_markdown import CustomMarkdown from pyUltroid.fns.tools import metadata, translate @@ -435,7 +437,7 @@ async def webss(event): await xx.delete() -@ultroid_cmd(pattern="shorturl") +@ultroid_cmd(pattern="shorturl ?(.*)") async def short_url(event): input_url = event.pattern_match.group(1) @@ -448,18 +450,22 @@ async def short_url(event): try: s = pyshorteners.Shortener() - if "https://tinyurl.com" in input_url.lower(): - shortened_url = s.tinyurl.expand(input_url) - action = "Expanded" + if input_url.lower().startswith("https://tinyurl.com/"): + response = get(input_url) + soup = BeautifulSoup(response.text, 'html.parser') + original_url = soup.find('a', {'target': '_blank'}).get('href') + output_message = ( + f"**Expanded URL**\n" + f"**Given Link** ➠ **{input_url}**\n" + f"**Expanded Link** ➠ **{original_url}**" + ) else: shortened_url = s.tinyurl.short(input_url) - action = "Shortened" - - output_message = ( - f"**URL {action}**\n" - f"**Given Link** ➠ **{input_url}**\n" - f"**{action} Link** ➠ **[LINK]({shortened_url})**" - ) + output_message = ( + f"**Shortened URL**\n" + f"**Given Link** ➠ **{input_url}**\n" + f"**Shortened Link** ➠ **{shortened_url}**" + ) if event.reply_to_msg_id: await event.delete() From d2a156efac8fea304a96b0836c3470c43a902893 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Mon, 11 Mar 2024 15:53:17 +0800 Subject: [PATCH 258/268] Update __init__.py --- plugins/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/__init__.py b/plugins/__init__.py index 26d6802b60..1bb5461745 100644 --- a/plugins/__init__.py +++ b/plugins/__init__.py @@ -39,6 +39,7 @@ LOG_CHANNEL = udB.get_key("LOG_CHANNEL") +ultroid_bot.parse_mode = CustomMarkdown() def inline_pic(): INLINE_PIC = udB.get_key("INLINE_PIC") From 20f0876d8cfcea556d32b84612f4138a0b3849b1 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Mon, 11 Mar 2024 15:59:19 +0800 Subject: [PATCH 259/268] Update __init__.py --- plugins/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/__init__.py b/plugins/__init__.py index 1bb5461745..6dec5d78c3 100644 --- a/plugins/__init__.py +++ b/plugins/__init__.py @@ -22,6 +22,7 @@ from pyUltroid.fns.helper import * from pyUltroid.fns.misc import * from pyUltroid.fns.tools import * +from pyUltroid.fns.custom_markdown import * from pyUltroid.startup._database import _BaseDatabase as Database from pyUltroid.version import __version__, ultroid_version from strings import get_help, get_string From 93a26e3622fc94891a684fc013ed742665f3710d Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Thu, 23 May 2024 18:00:17 +0800 Subject: [PATCH 260/268] Update logo.py --- plugins/logo.py | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/plugins/logo.py b/plugins/logo.py index 9e407e93a5..92531bb1bf 100644 --- a/plugins/logo.py +++ b/plugins/logo.py @@ -1,14 +1,18 @@ # Ultroid - UserBot -# Copyright (C) 2021-2024 TeamUltroid +# Copyright (C) 2021-2023 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>. +""" +✘ Commands Available - -from . import get_help - -__doc__ = get_help("help_logo") +• `{i}logo <text>` + Generate a logo of the given Text + Or Reply To image , to write ur text on it. + Or Reply To Font File, To write with that font. +""" import glob import os import random @@ -44,31 +48,28 @@ async def logo_gen(event): elif "pic" in mediainfo(temp.media): bg_ = await temp.download_media() if not bg_: - if event.client._bot: - SRCH = [ - "blur background", + SRCH = [ "background", - "neon lights", + "neon", + "anime", + "art", + "bridges", + "streets", + "computer", + "cyberpunk", "nature", "abstract", - "space", + "exoplanet", + "magic", "3d render", ] - res = await unsplashsearch(random.choice(SRCH), limit=1) - bg_, _ = await download_file(res[0], "resources/downloads/logo.png") - newimg = "resources/downloads/unsplash-temp.jpg" - img_ = Image.open(bg_) - img_.resize((5000, 5000)).save(newimg) - os.remove(bg_) - bg_ = newimg - else: - pics = [] - async for i in event.client.iter_messages( - "@UltroidLogos", filter=InputMessagesFilterPhotos - ): - pics.append(i) - id_ = random.choice(pics) - bg_ = await id_.download_media() + res = await unsplashsearch(random.choice(SRCH), limit=1) + bg_, _ = await download_file(res[0], "resources/downloads/logo.png") + newimg = "resources/downloads/unsplash-temp.jpg" + img_ = Image.open(bg_) + img_.save(newimg) + os.remove(bg_) + bg_ = newimg if not font_: fpath_ = glob.glob("resources/fonts/*") From 3241ede45ac81dfa86385cec7fe13609523d41ac Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Thu, 23 May 2024 18:01:19 +0800 Subject: [PATCH 261/268] Update BaseClient.py --- pyUltroid/startup/BaseClient.py | 49 +++++++++++++-------------------- 1 file changed, 19 insertions(+), 30 deletions(-) diff --git a/pyUltroid/startup/BaseClient.py b/pyUltroid/startup/BaseClient.py index af008eb1c8..609e16d7a1 100644 --- a/pyUltroid/startup/BaseClient.py +++ b/pyUltroid/startup/BaseClient.py @@ -1,16 +1,17 @@ # Ultroid - UserBot -# Copyright (C) 2021-2024 TeamUltroid +# Copyright (C) 2021-2023 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # <https://github.com/TeamUltroid/pyUltroid/blob/main/LICENSE>. +import contextlib import inspect import sys import time from logging import Logger -from telethon import TelegramClient +from telethonpatch import TelegramClient from telethon import utils as telethon_utils from telethon.errors import ( AccessTokenExpiredError, @@ -51,9 +52,7 @@ def __init__( self.dc_id = self.session.dc_id def __repr__(self): - return "<Ultroid.Client :\n self: {}\n bot: {}\n>".format( - self.full_name, self._bot - ) + return f"<Ultroid.Client :\n self: {self.full_name}\n bot: {self._bot}\n>" @property def __dict__(self): @@ -115,7 +114,7 @@ async def fast_uploader(self, file, **kwargs): by_bot = self._bot size = os.path.getsize(file) # Don't show progress bar when file size is less than 5MB. - if size < 5 * 2**20: + if size < 5 * 2 ** 20: show_progress = False if use_cache and self._cache and self._cache.get("upload_cache"): for files in self._cache["upload_cache"]: @@ -126,10 +125,8 @@ async def fast_uploader(self, file, **kwargs): and files["by_bot"] == by_bot ): if to_delete: - try: + with contextlib.suppress(FileNotFoundError): os.remove(file) - except FileNotFoundError: - pass return files["raw_file"], time.time() - start_time from pyUltroid.fns.FastTelethon import upload_file from pyUltroid.fns.helper import progress @@ -142,14 +139,12 @@ async def fast_uploader(self, file, **kwargs): file=f, filename=filename, progress_callback=( - ( - lambda completed, total: self.loop.create_task( - progress(completed, total, event, start_time, message) - ) + lambda completed, total: self.loop.create_task( + progress(completed, total, event, start_time, message) ) - if show_progress - else None - ), + ) + if show_progress + else None, ) cache = { "by_bot": by_bot, @@ -163,10 +158,8 @@ async def fast_uploader(self, file, **kwargs): else: self._cache.update({"upload_cache": [cache]}) if to_delete: - try: + with contextlib.suppress(FileNotFoundError): os.remove(file) - except FileNotFoundError: - pass return raw_file, time.time() - start_time async def fast_downloader(self, file, **kwargs): @@ -177,7 +170,7 @@ async def fast_downloader(self, file, **kwargs): if show_progress: event = kwargs["event"] # Don't show progress bar when file size is less than 10MB. - if file.size < 10 * 2**20: + if file.size < 10 * 2 ** 20: show_progress = False import mimetypes @@ -210,14 +203,12 @@ async def fast_downloader(self, file, **kwargs): location=file, out=f, progress_callback=( - ( - lambda completed, total: self.loop.create_task( - progress(completed, total, event, start_time, message) - ) + lambda completed, total: self.loop.create_task( + progress(completed, total, event, start_time, message) ) - if show_progress - else None - ), + ) + if show_progress + else None, ) return raw_file, time.time() - start_time @@ -253,8 +244,6 @@ def to_dict(self): return dict(inspect.getmembers(self)) async def parse_id(self, text): - try: + with contextlib.suppress(ValueError): text = int(text) - except ValueError: - pass return await self.get_peer_id(text) From 3ce02e0d0376213439ace6cf3a615797f92691fe Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Thu, 23 May 2024 18:02:33 +0800 Subject: [PATCH 262/268] Update tools.py --- pyUltroid/fns/tools.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/pyUltroid/fns/tools.py b/pyUltroid/fns/tools.py index 2c362ccf3a..198cc66474 100644 --- a/pyUltroid/fns/tools.py +++ b/pyUltroid/fns/tools.py @@ -312,15 +312,13 @@ class LogoHelper: def get_text_size(text, image, font): im = Image.new("RGB", (image.width, image.height)) draw = ImageDraw.Draw(im) - return draw.textsize(text, font) + return draw.textlength(text, font) @staticmethod def find_font_size(text, font, image, target_width_ratio): tested_font_size = 100 tested_font = ImageFont.truetype(font, tested_font_size) - observed_width, observed_height = LogoHelper.get_text_size( - text, image, tested_font - ) + observed_width = LogoHelper.get_text_size(text, image, tested_font) estimated_font_size = ( tested_font_size / (observed_width / image.width) * target_width_ratio ) @@ -335,12 +333,19 @@ def make_logo(imgpath, text, funt, **args): img = Image.open(imgpath) width, height = img.size + fct = min(height, width) + if height != width: + img = img.crop((0, 0, fct, fct)) + if img.height < 1000: + img = img.resize((1020, 1020)) + width, height = img.size draw = ImageDraw.Draw(img) font_size = LogoHelper.find_font_size(text, funt, img, width_ratio) font = ImageFont.truetype(funt, font_size) - w, h = draw.textsize(text, font=font) + l, t, r, b = font.getbbox(text) + w, h = r - l, (b - t) * 1.5 draw.text( - ((width - w) / 2, (height - h) / 2), + ((width - w) / 2, ((height - h) / 2)), text, font=font, fill=fill, From f345eac40ffde9524373b238d5b482a2581740bd Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Thu, 23 May 2024 18:03:20 +0800 Subject: [PATCH 263/268] Update requirements.txt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 91065f3219..e5ce50c78b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ # Important Requirements here -#https://github.com/New-dev0/Telethon/archive/platy.zip +https://github.com/New-dev0/Telethon-Patch/archive/main.zip python-decouple python-dotenv pymongo From 872499d08d935aeb500fbf861a71fb74fd9af91b Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Thu, 23 May 2024 18:04:01 +0800 Subject: [PATCH 264/268] Update optional-requirements.txt --- resources/startup/optional-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/startup/optional-requirements.txt b/resources/startup/optional-requirements.txt index 209127a920..721eba896b 100644 --- a/resources/startup/optional-requirements.txt +++ b/resources/startup/optional-requirements.txt @@ -17,7 +17,7 @@ lxml numpy>=1.21.2 oauth2client opencv-python-headless -pillow>=7.0.0 +pillow>=9.0.0 profanitydetector psutil pypdf2>=1.26.0 From 891977f329ce6fca8001b2b7719afdff4648678c Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Thu, 23 May 2024 18:04:36 +0800 Subject: [PATCH 265/268] Update version.py --- pyUltroid/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyUltroid/version.py b/pyUltroid/version.py index 8c7b646d77..3bf4e47bf0 100644 --- a/pyUltroid/version.py +++ b/pyUltroid/version.py @@ -1,2 +1,2 @@ __version__ = "2023.02.20" -ultroid_version = "0.8" +ultroid_version = "0.9" From 018caa59edfdd32d8f8ed821de101dbcb1555d65 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Thu, 23 May 2024 18:06:05 +0800 Subject: [PATCH 266/268] Update loader.py --- pyUltroid/startup/loader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyUltroid/startup/loader.py b/pyUltroid/startup/loader.py index 05e0f17fc9..3f0884344b 100644 --- a/pyUltroid/startup/loader.py +++ b/pyUltroid/startup/loader.py @@ -117,7 +117,7 @@ def load_other_plugins(addons=None, pmbot=None, manager=None, vcbot=None): Loader(path="assistant/pmbot.py").load(log=False) # vc bot - if vcbot and not vcClient._bot: + if vcbot and (vcClient and not vcClient.me.bot): try: import pytgcalls # ignore: pylint From d0508d873f0a85bef26ea1837ca5d04838d39531 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Thu, 23 May 2024 18:07:26 +0800 Subject: [PATCH 267/268] Update codeql-analysis.yml --- .github/workflows/codeql-analysis.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 7e9bbb834a..98bacbc7ef 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -2,10 +2,10 @@ name: CodeQL Analysis on: push: - # ignore dependabot branches on push -> https://github.com/microsoft/binskim/issues/425#issuecomment-893373709 branches-ignore: - 'dependabot/**' pull_request: + branches: [ '**' ] schedule: - cron: '0 8 * * *' workflow_dispatch: @@ -14,14 +14,22 @@ jobs: analyze: name: Analyze runs-on: ubuntu-latest + steps: - name: Checkout repository uses: actions/checkout@v2 + - name: Cache CodeQL database + uses: actions/cache@v2 + with: + path: ~/.codeql + key: ${{ runner.os }}-codeql-${{ hashFiles('**/qlpack.yml') }} + restore-keys: ${{ runner.os }}-codeql- + - name: Initialize CodeQL - uses: github/codeql-action/init@v1 + uses: github/codeql-action/init@v2 with: - languages: python + languages: 'python' - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 \ No newline at end of file + uses: github/codeql-action/analyze@v2 From b48b7cc1cd6f080431dfb5d45328b157040e2654 Mon Sep 17 00:00:00 2001 From: TrueSaiyan <ufperth@protonmail.com> Date: Thu, 23 May 2024 18:10:26 +0800 Subject: [PATCH 268/268] Update __init__.py --- pyUltroid/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pyUltroid/__init__.py b/pyUltroid/__init__.py index 348bb9dc60..526d3e4564 100644 --- a/pyUltroid/__init__.py +++ b/pyUltroid/__init__.py @@ -8,6 +8,7 @@ import os import sys +import telethonpatch from .version import __version__ run_as_module = __package__ in sys.argv or sys.argv[0] == "-m"