From 17cc65c3f8ae310ddd2cef4019bbdc9a6d0d5dc1 Mon Sep 17 00:00:00 2001 From: xtsea <90479255+xtsea@users.noreply.github.com> Date: Thu, 8 Aug 2024 18:10:16 +0700 Subject: [PATCH 001/152] Create api.md --- docs/api.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 docs/api.md diff --git a/docs/api.md b/docs/api.md new file mode 100644 index 00000000..24b0824b --- /dev/null +++ b/docs/api.md @@ -0,0 +1,3 @@ +# API Reference + +::: lumache From 62ce73791584a443349338163347cfb15fb55466 Mon Sep 17 00:00:00 2001 From: xtsea <90479255+xtsea@users.noreply.github.com> Date: Thu, 8 Aug 2024 18:11:12 +0700 Subject: [PATCH 002/152] Create usage.md --- docs/usage.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 docs/usage.md diff --git a/docs/usage.md b/docs/usage.md new file mode 100644 index 00000000..4fc65cfe --- /dev/null +++ b/docs/usage.md @@ -0,0 +1,11 @@ +Usage +===== + +Installation +------------ + +To use Lumache, first install it using pip: + +```console +(.venv) $ pip install RyuzakiLib +``` From 1e440320a04eaf5439c8c14409e4489091b27e74 Mon Sep 17 00:00:00 2001 From: xtsea <90479255+xtsea@users.noreply.github.com> Date: Thu, 8 Aug 2024 18:12:51 +0700 Subject: [PATCH 003/152] Create lumache.py --- lumache.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 lumache.py diff --git a/lumache.py b/lumache.py new file mode 100644 index 00000000..49f0c0ed --- /dev/null +++ b/lumache.py @@ -0,0 +1,34 @@ +""" +Lumache - Python library for cooks and food lovers. + +This is a Python docstring, we can use Markdown syntax here because +our API documentation library understands it (mkdocstrings). + + # Import lumache + import lumache + + # Call its only function + get_random_ingredients(kind=["cheeses"]) + +""" + +__version__ = "0.1.0" + + +class InvalidKindError(Exception): + """Raised if the kind is invalid.""" + + pass + + +def get_random_ingredients(kind=None): + """ + Return a list of random ingredients as strings. + + :param kind: Optional "kind" of ingredients. + :type kind: list[str] or None + :raise lumache.InvalidKindError: If the kind is invalid. + :return: The ingredients list. + :rtype: list[str] + """ + return ["shells", "gorgonzola", "parsley"] From 85985f41d612cd55af8dedeab2eb22dbd2c299cb Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Thu, 8 Aug 2024 22:22:22 +0700 Subject: [PATCH 004/152] _ --- RyuzakiLib/api/youtube.py | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/RyuzakiLib/api/youtube.py b/RyuzakiLib/api/youtube.py index 4106ef21..0886eee0 100644 --- a/RyuzakiLib/api/youtube.py +++ b/RyuzakiLib/api/youtube.py @@ -1,20 +1,14 @@ import asyncio -import json +import uvloop +asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) class Youtube: @staticmethod async def cookies_loads(file_json: str): - if file_json: - try: - with open(file_json, "r") as f: - cookies = json.load(f) - return cookies - except FileNotFoundError: - return [] - except json.JSONDecodeError: - return [] - return [] + with open(file_json, "r") as f: + cookies = json.load(f) + return cookies @staticmethod async def download(file_json: str, url: str, name_txt="youtube_cookies.txt"): @@ -25,9 +19,9 @@ async def download(file_json: str, url: str, name_txt="youtube_cookies.txt"): for cookie in cookies: f.write("\t".join([ cookie.get('domain', ''), - 'TRUE' if cookie.get('hostOnly', False) else 'FALSE', + 'TRUE' if cookie.get('hostOnly', False) else 'TRUE', cookie.get('path', '/'), - 'TRUE' if cookie.get('secure', False) else 'FALSE', + 'TRUE' if cookie.get('secure', False) else 'TRUE', str(int(cookie.get('expirationDate', 0))), cookie.get('name', ''), cookie.get('value', ''), @@ -38,14 +32,8 @@ async def download(file_json: str, url: str, name_txt="youtube_cookies.txt"): cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE ) stdout, stderr = await process.communicate() - e = stderr.decode() - if not e: - e = "No errors" - o = stdout.decode() - if not o: - o = "No output" - - OUTPUT = "" - OUTPUT += f"Output: \n{o}\n" - OUTPUT += f"Errors: \n{e}" + e = stderr.decode() or "No errors" + o = stdout.decode() or "No output" + + OUTPUT = f"Output: \n{o}\nErrors: \n{e}" return OUTPUT From 079bc15ff3585fd8e269bce75ba1d4b4d206c826 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Thu, 8 Aug 2024 22:50:59 +0700 Subject: [PATCH 005/152] Update youtube.py --- RyuzakiLib/api/youtube.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/RyuzakiLib/api/youtube.py b/RyuzakiLib/api/youtube.py index 0886eee0..95b7f751 100644 --- a/RyuzakiLib/api/youtube.py +++ b/RyuzakiLib/api/youtube.py @@ -1,7 +1,4 @@ import asyncio -import uvloop - -asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) class Youtube: @staticmethod From fa1b45f22a93835a05f03c42e65ac16869b0c1a6 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Thu, 8 Aug 2024 22:54:11 +0700 Subject: [PATCH 006/152] _ --- pyproject.toml | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index db4ae5a5..00000000 --- a/pyproject.toml +++ /dev/null @@ -1,8 +0,0 @@ -[build-system] -requires = ["flit_core >=3.2,<4"] -build-backend = "flit_core.buildapi" - -[project] -name = "Randy Wahdin" -authors = [{name = "Randy Wahidin", email = "killerx@randydev.my.id"}] -dynamic = ["version", "description"] From 40efbfd5d8b131076bd2593c382e34842cedcbcd Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Thu, 8 Aug 2024 22:55:05 +0700 Subject: [PATCH 007/152] back eh --- RyuzakiLib/api/youtube.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/RyuzakiLib/api/youtube.py b/RyuzakiLib/api/youtube.py index 95b7f751..0886eee0 100644 --- a/RyuzakiLib/api/youtube.py +++ b/RyuzakiLib/api/youtube.py @@ -1,4 +1,7 @@ import asyncio +import uvloop + +asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) class Youtube: @staticmethod From 1fb070081aa40c06119cfbada0bbca58d7df2d89 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Thu, 8 Aug 2024 22:59:28 +0700 Subject: [PATCH 008/152] _ --- docs/api.md | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/docs/api.md b/docs/api.md index 24b0824b..30a8392e 100644 --- a/docs/api.md +++ b/docs/api.md @@ -1,3 +1,21 @@ -# API Reference +### Faster Downloader +```python +from RyuzakiLib.api.fullstack import FullStackDev -::: lumache +# - Supported jpg, mp4, mp3 + +link_url = "https://example.jpg" + +await FullStackDev.fast(url=link_url, filename="photo.jpg", type_mode="wb") +``` +- Now you've saved it, see for example photo.jpg + +* parameter +- filename="example.mp4" +- type_mode="wb" + +* Do something like example +```python +import RyuzakiLib.api.fullstack as example +print(dir(example)) +``` From 8af78bd2ddf8d57e144fac2c4906962530c88011 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Thu, 8 Aug 2024 23:00:47 +0700 Subject: [PATCH 009/152] _ --- api.md | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 api.md diff --git a/api.md b/api.md deleted file mode 100644 index 30a8392e..00000000 --- a/api.md +++ /dev/null @@ -1,21 +0,0 @@ -### Faster Downloader -```python -from RyuzakiLib.api.fullstack import FullStackDev - -# - Supported jpg, mp4, mp3 - -link_url = "https://example.jpg" - -await FullStackDev.fast(url=link_url, filename="photo.jpg", type_mode="wb") -``` -- Now you've saved it, see for example photo.jpg - -* parameter -- filename="example.mp4" -- type_mode="wb" - -* Do something like example -```python -import RyuzakiLib.api.fullstack as example -print(dir(example)) -``` From f4b3594a535bbadcbd1fd595757ccd112be9ca46 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Thu, 8 Aug 2024 23:01:28 +0700 Subject: [PATCH 010/152] _ --- tiktok_download.md => docs/tiktok_download.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tiktok_download.md => docs/tiktok_download.md (100%) diff --git a/tiktok_download.md b/docs/tiktok_download.md similarity index 100% rename from tiktok_download.md rename to docs/tiktok_download.md From ac5ca8c3e3b91882f306b21d9b96aa95e3df6b47 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Thu, 8 Aug 2024 23:02:05 +0700 Subject: [PATCH 011/152] _ --- database.md => docs/database.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename database.md => docs/database.md (100%) diff --git a/database.md b/docs/database.md similarity index 100% rename from database.md rename to docs/database.md From a5abfabf54f28e62157777e7d88c5719a544c38a Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Thu, 8 Aug 2024 23:02:46 +0700 Subject: [PATCH 012/152] _ --- memes.md => docs/memes.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename memes.md => docs/memes.md (100%) diff --git a/memes.md b/docs/memes.md similarity index 100% rename from memes.md rename to docs/memes.md From 08e043486f8761a9b29bb256b1bc40aa99bdc8a4 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Thu, 8 Aug 2024 23:03:40 +0700 Subject: [PATCH 013/152] _ --- extreme.md => docs/extreme.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename extreme.md => docs/extreme.md (100%) diff --git a/extreme.md b/docs/extreme.md similarity index 100% rename from extreme.md rename to docs/extreme.md From 269f3c7201b0159aba572efb9db2f121bdf8d2fe Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Thu, 8 Aug 2024 23:04:28 +0700 Subject: [PATCH 014/152] _ --- hackertools.md => docs/hackertools.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename hackertools.md => docs/hackertools.md (100%) diff --git a/hackertools.md b/docs/hackertools.md similarity index 100% rename from hackertools.md rename to docs/hackertools.md From 3a5a7e50a2da9d47edd0cf3d0789ef0f8a98bcd2 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Thu, 8 Aug 2024 23:05:11 +0700 Subject: [PATCH 015/152] _ --- openvpn.md => docs/openvpn.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename openvpn.md => docs/openvpn.md (100%) diff --git a/openvpn.md b/docs/openvpn.md similarity index 100% rename from openvpn.md rename to docs/openvpn.md From 28debf3c384e7a857a3d5f816598442a9721e125 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Thu, 8 Aug 2024 23:07:45 +0700 Subject: [PATCH 016/152] _ --- docs/spamwatch.md | 10 ++++++++++ spamwatch.md | 18 ------------------ 2 files changed, 10 insertions(+), 18 deletions(-) create mode 100644 docs/spamwatch.md delete mode 100644 spamwatch.md diff --git a/docs/spamwatch.md b/docs/spamwatch.md new file mode 100644 index 00000000..38b8e8ed --- /dev/null +++ b/docs/spamwatch.md @@ -0,0 +1,10 @@ +### Spamwatch +• Example usage +```python +from RyuzakiLib import SibylBan + +x = SiblyBan.ban(user_id) +xb = SiblyBan.banlist(user_id) +xub = SiblyBan.unban(user_id) +results = SiblyBan.banlist_all() +``` diff --git a/spamwatch.md b/spamwatch.md deleted file mode 100644 index 88788888..00000000 --- a/spamwatch.md +++ /dev/null @@ -1,18 +0,0 @@ -### Spamwatch -• Example usage -```python -from RyuzakiLib.spamwatch.clients import SibylBan - -clients = SibylBan("your_api_key_here") - -message = clients.add_ban(user_id=client.me.id, reason="scammer", is_banned=True) -await message.reply_text(message) - -# Part 2 -showing = clients.get_ban(user_id=client.me.id, banlist=True) -print(showing) - -# Part 3 -results = clients.get_all_banlist() -print(results) -``` From d391e552ce0ac8b0f72a7f5f6a8294672777bf85 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Thu, 8 Aug 2024 23:08:26 +0700 Subject: [PATCH 017/152] _ --- types.md => docs/types.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename types.md => docs/types.md (100%) diff --git a/types.md b/docs/types.md similarity index 100% rename from types.md rename to docs/types.md From 28082442fc0472ca9fdbc30b367f7d69a319d6c5 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Thu, 8 Aug 2024 23:10:51 +0700 Subject: [PATCH 018/152] Create clone.md --- docs/clone.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 docs/clone.md diff --git a/docs/clone.md b/docs/clone.md new file mode 100644 index 00000000..9b51d4af --- /dev/null +++ b/docs/clone.md @@ -0,0 +1,10 @@ +### Profile Clone +• Example usage +```python +from RyuzakiLib import Clone + +message = Clone.clone() # need parameter + +showing = Clone.sclone() # need parameter +print(showing) +``` From 414f8f4f7b793d03a63949af7264c327faa1c9ce Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Thu, 8 Aug 2024 23:11:29 +0700 Subject: [PATCH 019/152] Create telegram.md --- docs/telegram.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 docs/telegram.md diff --git a/docs/telegram.md b/docs/telegram.md new file mode 100644 index 00000000..b6711202 --- /dev/null +++ b/docs/telegram.md @@ -0,0 +1,27 @@ +### Learn Telegram Bot API +```python + +from RyuzakiLib.bot import API + +api = API(bot_token="your_token") + +# supported here +api.send_message() +api.send_photo() +api.send_sticker() +api.send_audio() +api.send_document() +api.forward_message() + +# you can pass +sent_message = api.send_message(chat_id=chat_id, text=text) + +sent_sticker = api.send_sticker(chat_id=chat_id, sticker=sticker) + +# your own developer +urls = api.telegram("SendMessage") +payload = {} +headers = {} +response = requests.post(urls, json=payload, headers=headers) +print(response.text) +``` From 158519a3de2084dec786fc9c93278083f61bf584 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Thu, 8 Aug 2024 23:12:56 +0700 Subject: [PATCH 020/152] Create chatgpt_new.md --- docs/chatgpt_new.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 docs/chatgpt_new.md diff --git a/docs/chatgpt_new.md b/docs/chatgpt_new.md new file mode 100644 index 00000000..f7793a03 --- /dev/null +++ b/docs/chatgpt_new.md @@ -0,0 +1,13 @@ +### Chatgpt New? +* Chatgpt's new features are available here +- parameter + +```python +from RyuzakiLib import RendyDevChat + +results = await RendyDevChat.chat_hacked(latest_model="list-model", list_model_all=True) +print(results) + +response = await RendyDevChat.chat_hacked("hello world") +print(response) +``` From c441b8fa1180101b763f954090cfdea4f7d8cbf5 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Thu, 8 Aug 2024 23:13:47 +0700 Subject: [PATCH 021/152] Create imageai.md --- docs/imageai.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 docs/imageai.md diff --git a/docs/imageai.md b/docs/imageai.md new file mode 100644 index 00000000..2c0c60d3 --- /dev/null +++ b/docs/imageai.md @@ -0,0 +1,10 @@ +### AI image Generator New? +* AI image Generator new features are available here +- parameter +```python +from RyuzakiLib import RendyDevChat + +query = "Cat in a Hat" +response = await RendyDevChat.image_generator(query) +print(response) +``` From 4e0608a6bc8752f45f566ab1302ab4c12944bf7f Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Thu, 8 Aug 2024 23:14:14 +0700 Subject: [PATCH 022/152] Create openai.md --- docs/openai.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 docs/openai.md diff --git a/docs/openai.md b/docs/openai.md new file mode 100644 index 00000000..ce3e1df1 --- /dev/null +++ b/docs/openai.md @@ -0,0 +1,15 @@ +### Continue Conversation +```python +from RyuzakiLib import OpenAI + +api_base = "https://api.example.com/v1" +api_key = "" +query = "hello world" +response = await OpenAI(api_key=api_key, api_base=api_base).chat_message_turbo( + query=query, + model="gpt-4", + is_stream=False +) + +print(response[0]) +``` From 47285eaaa55350f6a9688c5f0ac0b07423625485 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Thu, 8 Aug 2024 23:16:10 +0700 Subject: [PATCH 023/152] Create gemini.md --- docs/gemini.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 docs/gemini.md diff --git a/docs/gemini.md b/docs/gemini.md new file mode 100644 index 00000000..5cabc2db --- /dev/null +++ b/docs/gemini.md @@ -0,0 +1,28 @@ +### Gemini AI New (Free) +- No authorization needed +- Gemini Pro and Gemini Flash (Without RyuzakiLib API keys) +- Multi-Turn Conversation + +```python +from RyuzakiLib import GeminiLatest + +mongo_url = "....." +api_key = "....." +user_id = 0 +geni = GeminiLatest(api_keys=api_key, mongo_url=mongo_url, user_id=user_id) + +# Get response (private in python) +answer, gemini_chat = geni._GeminiLatest__get_response_gemini(query) +print(answer) + +# Get response image to text +from RyuzakiLib import GeminiLatest + +caption = message.reply_to_message.caption +file_path = await message.reply_to_message.download() + +x = GeminiLatest(api_keys="api key here") +response = x.get_response_image(caption, file_path) +print(response) +``` +- Gemini AI New: Get [API key Here](https://makersuite.google.com/app/apikey) from Google Dev From 075526c016bd626f07a72e62e197d75d07650057 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Thu, 8 Aug 2024 23:16:27 +0700 Subject: [PATCH 024/152] Create blackbox.md --- docs/blackbox.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 docs/blackbox.md diff --git a/docs/blackbox.md b/docs/blackbox.md new file mode 100644 index 00000000..72c8b921 --- /dev/null +++ b/docs/blackbox.md @@ -0,0 +1,20 @@ +### Blackbox New AI +```python +from RyuzakiLib import Blackbox +import os + +varname = "DATABASE_URL" + +value = os.environ.get(varname.upper(), None) + +mongo_uri = value +db_name = "tiktokbot" + +blackbox = Blackbox(mongo_uri, db_name) + +user_id = "user666" +query = "What is todays date?" + +results = await blackbox.chat(query, user_id=user_id) +print(results) +``` From 5ca4927721c62ace9301af86fdb1caaed978f5a3 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Thu, 8 Aug 2024 23:16:59 +0700 Subject: [PATCH 025/152] _ --- docs/chatgpt_new.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/chatgpt_new.md b/docs/chatgpt_new.md index f7793a03..b73a1630 100644 --- a/docs/chatgpt_new.md +++ b/docs/chatgpt_new.md @@ -11,3 +11,12 @@ print(results) response = await RendyDevChat.chat_hacked("hello world") print(response) ``` +### BetaRag New (AI) +```python +from RyuzakiLib import BetaRag + +x = BetaRag(token="api key", user_id=0, mongo_url="your mongo") + +response = await x.rag_chat("how to javascript code?") +print(response) +``` From 13fed47f15ea1dca4f45d55aae1b5bcb01907629 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Thu, 8 Aug 2024 23:19:18 +0700 Subject: [PATCH 026/152] _ --- docs/api.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/docs/api.md b/docs/api.md index 30a8392e..2c9b69bd 100644 --- a/docs/api.md +++ b/docs/api.md @@ -1,3 +1,40 @@ +### RyuzakiLib API + +![IMG_20231209_213430_940](https://github.com/TeamKillerX/RyuzakiLib-API/assets/90479255/f26513f7-cdf4-44ee-9a08-f6b27e6b99f7) + +## Authentication +> **Warning** Do not expose the `__Secure-1PSID` +```python +from RyuzakiLib.api.reqs import AsyicXSearcher + +url ="https://randydev-ryuzaki-api.hf.space/ryuzaki/gemini-ai-pro" + +payload = { + "query": "hello world", + "bard_api_key": "cookie token here", + "is_login": True +} + +headers = { + "accept": "application/json", +} + +response = await AsyicXSearcher.search(url, post=True, re_json=True, headers=headers, json=payload) +print(response) +``` + +* `bard_api_key` : (optional) +* `is_login` : default `False` (optional) + +1. Visit https://bard.google.com/ +2. F12 for console +3. Session: Application → Cookies → Copy the value of `__Secure-1PSID` cookie. + +Note that while I referred to `__Secure-1PSID` value as an API key for convenience, it is not an officially provided API key. Cookie value subject to frequent changes. Verify the value again if an error occurs. Most errors occur when an invalid cookie value is entered. + +`bard_api_key={__Secure-1PSID}` + + ### Faster Downloader ```python from RyuzakiLib.api.fullstack import FullStackDev From 47428f8de007593675279e196a9c967026a66969 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Thu, 8 Aug 2024 23:20:54 +0700 Subject: [PATCH 027/152] read docs --- README.md | 283 +----------------------------------------------------- 1 file changed, 1 insertion(+), 282 deletions(-) diff --git a/README.md b/README.md index c5b2d131..311a25ec 100644 --- a/README.md +++ b/README.md @@ -21,287 +21,6 @@ pip3 install git+https://github.com/TeamKillerX/RyuzakiLib ``` -### Import Here -```python -from RyuzakiLib.hackertools.chatgpt import RendyDevChat -from RyuzakiLib.hackertools.github import GithubUsername -from RyuzakiLib.hackertools.rmbg import RemoveBg -from RyuzakiLib.hackertools.reverse import GoogleReverseImage -from RyuzakiLib.hackertools.ipinfo import WhoisIpHacker -from RyuzakiLib.hackertools.ocrapi import OcrApiUrl -from RyuzakiLib.hackertools.prefixes import CustomPrefixes - -# or - -from RyuzakiLib import * -``` - -### Learn Python -```python -import asyncio - -class example_python: - @staticmethod - def hello_world(): - asyncio.sleep(5) - -# examples usage -example_python.hello_world() -``` - -### Spamwatch -• Example usage -```python -from RyuzakiLib import SibylBan - -x = SiblyBan.ban(user_id) -xb = SiblyBan.banlist(user_id) -xub = SiblyBan.unban(user_id) -results = SiblyBan.banlist_all() -``` - -### Profile Clone -• Example usage -```python -from RyuzakiLib import Clone - -message = Clone.clone() # need parameter - -showing = Clone.sclone() # need parameter -print(showing) -``` - -### Learn Telegram Bot API -```python - -from RyuzakiLib.bot import API - -api = API(bot_token="your_token") - -# supported here -api.send_message() -api.send_photo() -api.send_sticker() -api.send_audio() -api.send_document() -api.forward_message() - -# you can pass -sent_message = api.send_message(chat_id=chat_id, text=text) - -sent_sticker = api.send_sticker(chat_id=chat_id, sticker=sticker) - -# your own developer -urls = api.telegram("SendMessage") -payload = {} -headers = {} -response = requests.post(urls, json=payload, headers=headers) -print(response.text) -``` - -### Chatgpt New? -* Chatgpt's new features are available here -- parameter - -```python -from RyuzakiLib import RendyDevChat - -results = await RendyDevChat.chat_hacked(latest_model="list-model", list_model_all=True) -print(results) - -response = await RendyDevChat.chat_hacked("hello world") -print(response) -``` - -### AI image Generator New? -* AI image Generator new features are available here -- parameter -```python -from RyuzakiLib import RendyDevChat - -query = "Cat in a Hat" -response = await RendyDevChat.image_generator(query) -print(response) -``` - -### Continue Conversation -```python -from RyuzakiLib import OpenAI - -api_base = "https://api.example.com/v1" -api_key = "" -query = "hello world" -response = await OpenAI(api_key=api_key, api_base=api_base).chat_message_turbo( - query=query, - model="gpt-4", - is_stream=False -) - -print(response[0]) -``` - -### Example Google Reverse Image -```python -from pyrogram import Client, filters -from pyrogram.types import Message - -from RyuzakiLib import GoogleReverseImage - -url = "https://example/jpg" -apikey = "api key token" -response = GoogleReverseImage(url, apikey) -results = response.get_reverse() -print(results) -``` -### New Features -```python -# Create by @xtdevs -# Prefixes Custom - -from pyrogram import Client, filters -from pyrogram.types import Message - -from RyuzakiLib.hackertools.prefixes import CustomPrefixes -from pymongo import MongoClient - -client = MongoClient("mongodb://localhost:27017/") -db = client["your_database_name"] -collection = db["your_collection_name"] - -db_name = "custom_prefixes" -user_id = message.from_user.id -prefix = [".", "+", "-"] -set_handler = CustomPrefixes(db_name, user_id, prefix, collection, True) # parameter upsert using set True or False -set_handler.add_prefixes() -now_show_prefix = set_handler.get_prefix() -print(now_show_prefix) -``` - -### Gemini AI New (Free) -- No authorization needed -- Gemini Pro and Gemini Flash (Without RyuzakiLib API keys) -- Multi-Turn Conversation - -```python -from RyuzakiLib import GeminiLatest - -mongo_url = "....." -api_key = "....." -user_id = 0 -geni = GeminiLatest(api_keys=api_key, mongo_url=mongo_url, user_id=user_id) - -# Get response (private in python) -answer, gemini_chat = geni._GeminiLatest__get_response_gemini(query) -print(answer) - -# Get response image to text -from RyuzakiLib import GeminiLatest - -caption = message.reply_to_message.caption -file_path = await message.reply_to_message.download() - -x = GeminiLatest(api_keys="api key here") -response = x.get_response_image(caption, file_path) -print(response) -``` - -- Gemini AI New: Get [API key Here](https://makersuite.google.com/app/apikey) from Google Dev - -### Blackbox New AI -```python -from RyuzakiLib import Blackbox -import os - -varname = "DATABASE_URL" - -value = os.environ.get(varname.upper(), None) - -mongo_uri = value -db_name = "tiktokbot" - -blackbox = Blackbox(mongo_uri, db_name) - -user_id = "user666" -query = "What is todays date?" - -results = await blackbox.chat(query, user_id=user_id) -print(results) -``` - -### BetaRag New (AI) -```python -from RyuzakiLib import BetaRag - -x = BetaRag(token="api key", user_id=0, mongo_url="your mongo") - -response = await x.rag_chat("how to javascript code?") -print(response) -``` - -- You can ask support [@KillerXSupport](https://t.me/KillerXSupport) - -### Test your bots -```bash -- git clone https://github.com/TeamKillerX/RyuzakiLib -- cd RyuzakiLib -- pip3 install -r ryuzaki.txt -- nano buildbot/secrets/env.py -- ctrl s + x to save -- bash start.sh -``` - -### RyuzakiLib API - -![IMG_20231209_213430_940](https://github.com/TeamKillerX/RyuzakiLib-API/assets/90479255/f26513f7-cdf4-44ee-9a08-f6b27e6b99f7) - -## Authentication -> **Warning** Do not expose the `__Secure-1PSID` -```python -from RyuzakiLib.api.reqs import AsyicXSearcher - -url ="https://randydev-ryuzaki-api.hf.space/ryuzaki/gemini-ai-pro" - -payload = { - "query": "hello world", - "bard_api_key": "cookie token here", - "is_login": True -} - -headers = { - "accept": "application/json", -} - -response = await AsyicXSearcher.search(url, post=True, re_json=True, headers=headers, json=payload) -print(response) -``` - -* `bard_api_key` : (optional) -* `is_login` : default `False` (optional) - -1. Visit https://bard.google.com/ -2. F12 for console -3. Session: Application → Cookies → Copy the value of `__Secure-1PSID` cookie. - -Note that while I referred to `__Secure-1PSID` value as an API key for convenience, it is not an officially provided API key. Cookie value subject to frequent changes. Verify the value again if an error occurs. Most errors occur when an invalid cookie value is entered. - -`bard_api_key={__Secure-1PSID}` - - -### Tutorial Requests in Python ->Request body schema -* `json=payload` -```python -response = requests.post(url, headers=headers, json=payload).json() -``` - -> Query Parameters -* `params=params` -```python -response = requests.post(url, headers=headers, params=params).json() -``` - -You can find the [`Ryuzaki API`](https://private.randydev.my.id) - * Only Developed by - [@xtdevs](https://t.me/xtdevs) - [@TrueSaiyan](https://t.me/TrueSaiyan) @@ -311,7 +30,7 @@ You can find the [`Ryuzaki API`](https://private.randydev.my.id) * Contact Support: [@xtdevs](https://t.me/xtdevs) ### Troubleshoot -Sometimes errors occur, but we are here to help! This guide covers some of the most common issues we’ve seen and how you can resolve them. However, this guide isn’t meant to be a comprehensive collection of every 🤗 FastAPI issue. For more help with troubleshooting your issue, try: +Sometimes errors occur, but we are here to help! This guide covers some of the most common issues we’ve seen and how you can resolve them. However, this guide isn’t meant to be a comprehensive collection of every 🤗 RyuzakiLib issue. For more help with troubleshooting your issue, try: * [Contact Support](https://t.me/xtdevs) # License From 60ad362804df814204cc3dc3adc96bb4e0ad4c06 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 Aug 2024 16:24:27 +0000 Subject: [PATCH 028/152] Bump pymdown-extensions from 9.5 to 10.0 in /docs Bumps [pymdown-extensions](https://github.com/facelessuser/pymdown-extensions) from 9.5 to 10.0. - [Release notes](https://github.com/facelessuser/pymdown-extensions/releases) - [Commits](https://github.com/facelessuser/pymdown-extensions/compare/9.5...10.0) --- updated-dependencies: - dependency-name: pymdown-extensions dependency-type: indirect ... Signed-off-by: dependabot[bot] --- docs/requirements.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index f6cb652b..c883767d 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -24,7 +24,7 @@ markdown==3.3.7 # mkdocstrings # pymdown-extensions markdown-include==0.6.0 - # via -r docs/requirements.in + # via -r requirements.in markupsafe==2.1.1 # via # jinja2 @@ -33,20 +33,20 @@ mergedeep==1.3.4 # via mkdocs mkdocs==1.3.0 # via - # -r docs/requirements.in + # -r requirements.in # mkdocs-autorefs # mkdocstrings mkdocs-autorefs==0.4.1 # via mkdocstrings mkdocstrings[python]==0.19.0 # via - # -r docs/requirements.in + # -r requirements.in # mkdocstrings-python mkdocstrings-python==0.7.1 # via mkdocstrings packaging==21.3 # via mkdocs -pymdown-extensions==9.5 +pymdown-extensions==10.0 # via mkdocstrings pyparsing==3.0.9 # via packaging @@ -55,6 +55,7 @@ python-dateutil==2.8.2 pyyaml==6.0 # via # mkdocs + # pymdown-extensions # pyyaml-env-tag pyyaml-env-tag==0.1 # via mkdocs From a9b5eece3e9a987dd5f3915521cef75e79236f80 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 8 Aug 2024 16:24:34 +0000 Subject: [PATCH 029/152] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- RyuzakiLib/api/youtube.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RyuzakiLib/api/youtube.py b/RyuzakiLib/api/youtube.py index 0886eee0..4d694b13 100644 --- a/RyuzakiLib/api/youtube.py +++ b/RyuzakiLib/api/youtube.py @@ -1,4 +1,5 @@ import asyncio + import uvloop asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) @@ -34,6 +35,6 @@ async def download(file_json: str, url: str, name_txt="youtube_cookies.txt"): stdout, stderr = await process.communicate() e = stderr.decode() or "No errors" o = stdout.decode() or "No output" - + OUTPUT = f"Output: \n{o}\nErrors: \n{e}" return OUTPUT From 7d9b24efd9552464e34b79a7d694837020c1eecf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 Aug 2024 16:24:52 +0000 Subject: [PATCH 030/152] Bump zipp from 3.8.0 to 3.19.1 in /docs Bumps [zipp](https://github.com/jaraco/zipp) from 3.8.0 to 3.19.1. - [Release notes](https://github.com/jaraco/zipp/releases) - [Changelog](https://github.com/jaraco/zipp/blob/main/NEWS.rst) - [Commits](https://github.com/jaraco/zipp/compare/v3.8.0...v3.19.1) --- updated-dependencies: - dependency-name: zipp dependency-type: indirect ... Signed-off-by: dependabot[bot] --- docs/requirements.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index f6cb652b..86d810e1 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -24,7 +24,7 @@ markdown==3.3.7 # mkdocstrings # pymdown-extensions markdown-include==0.6.0 - # via -r docs/requirements.in + # via -r requirements.in markupsafe==2.1.1 # via # jinja2 @@ -33,14 +33,14 @@ mergedeep==1.3.4 # via mkdocs mkdocs==1.3.0 # via - # -r docs/requirements.in + # -r requirements.in # mkdocs-autorefs # mkdocstrings mkdocs-autorefs==0.4.1 # via mkdocstrings mkdocstrings[python]==0.19.0 # via - # -r docs/requirements.in + # -r requirements.in # mkdocstrings-python mkdocstrings-python==0.7.1 # via mkdocstrings @@ -62,5 +62,5 @@ six==1.16.0 # via python-dateutil watchdog==2.1.9 # via mkdocs -zipp==3.8.0 +zipp==3.19.1 # via importlib-metadata From 4ef168025153555dd91c868c0f6fb0204dff4c8d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 8 Aug 2024 16:24:59 +0000 Subject: [PATCH 031/152] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- RyuzakiLib/api/youtube.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RyuzakiLib/api/youtube.py b/RyuzakiLib/api/youtube.py index 0886eee0..4d694b13 100644 --- a/RyuzakiLib/api/youtube.py +++ b/RyuzakiLib/api/youtube.py @@ -1,4 +1,5 @@ import asyncio + import uvloop asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) @@ -34,6 +35,6 @@ async def download(file_json: str, url: str, name_txt="youtube_cookies.txt"): stdout, stderr = await process.communicate() e = stderr.decode() or "No errors" o = stdout.decode() or "No output" - + OUTPUT = f"Output: \n{o}\nErrors: \n{e}" return OUTPUT From 2e62c5d2e580b5e909fff4b27547270d6bfecc39 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 Aug 2024 16:25:24 +0000 Subject: [PATCH 032/152] Bump jinja2 from 3.1.2 to 3.1.4 in /docs Bumps [jinja2](https://github.com/pallets/jinja) from 3.1.2 to 3.1.4. - [Release notes](https://github.com/pallets/jinja/releases) - [Changelog](https://github.com/pallets/jinja/blob/main/CHANGES.rst) - [Commits](https://github.com/pallets/jinja/compare/3.1.2...3.1.4) --- updated-dependencies: - dependency-name: jinja2 dependency-type: indirect ... Signed-off-by: dependabot[bot] --- docs/requirements.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index f6cb652b..f50ada6b 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -12,7 +12,7 @@ griffe==0.22.0 # via mkdocstrings-python importlib-metadata==4.12.0 # via mkdocs -jinja2==3.1.2 +jinja2==3.1.4 # via # mkdocs # mkdocstrings @@ -24,7 +24,7 @@ markdown==3.3.7 # mkdocstrings # pymdown-extensions markdown-include==0.6.0 - # via -r docs/requirements.in + # via -r requirements.in markupsafe==2.1.1 # via # jinja2 @@ -33,14 +33,14 @@ mergedeep==1.3.4 # via mkdocs mkdocs==1.3.0 # via - # -r docs/requirements.in + # -r requirements.in # mkdocs-autorefs # mkdocstrings mkdocs-autorefs==0.4.1 # via mkdocstrings mkdocstrings[python]==0.19.0 # via - # -r docs/requirements.in + # -r requirements.in # mkdocstrings-python mkdocstrings-python==0.7.1 # via mkdocstrings From a26b54014bc51a384c7c9c4e1fe15bc0630b3f9a Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Thu, 8 Aug 2024 23:33:07 +0700 Subject: [PATCH 033/152] _ --- RyuzakiLib/api/youtube.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RyuzakiLib/api/youtube.py b/RyuzakiLib/api/youtube.py index 4d694b13..22ba7261 100644 --- a/RyuzakiLib/api/youtube.py +++ b/RyuzakiLib/api/youtube.py @@ -1,5 +1,5 @@ import asyncio - +import json import uvloop asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) From e5dbb1534b341a722aae7ee8b3a7722ef763eb85 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Sun, 11 Aug 2024 01:15:43 +0700 Subject: [PATCH 034/152] _ --- RyuzakiLib/api/yohasakura.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RyuzakiLib/api/yohasakura.py b/RyuzakiLib/api/yohasakura.py index f0d10f09..cbb679e0 100644 --- a/RyuzakiLib/api/yohasakura.py +++ b/RyuzakiLib/api/yohasakura.py @@ -2,7 +2,7 @@ class SearchAPI: - def __init__(self, api_key="29db8322f22d425d7023c499610fc2419f8ff44e0bd3f63edd90d2994bf76b49"): + def __init__(self, api_key="6398769dabd9fe0e49bedce0354b40a9b1a69d9594dc9d48c1d8a2a071c51e89"): self.url = "https://randydev-ryuzaki-api.hf.space/ryuzaki" self.api_key = api_key self.headers = {"accept": "application/json", "api-key": self.api_key} From 9ee37a723e772f35b05676147652f2ea31bcf8b1 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Sun, 11 Aug 2024 18:08:10 +0700 Subject: [PATCH 035/152] Update requirements.txt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index d8cd35d5..e1861c3f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -27,6 +27,6 @@ google-generativeai curl_cffi gradio-client gradio -huggingface_hub==0.22.2 +huggingface-hub>=0.23.2 motor nest-asyncio From ed2e6c102585f0f1d60078a5640d4ed7d3d809b5 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Sun, 11 Aug 2024 18:15:31 +0700 Subject: [PATCH 036/152] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index af0dbeb7..310e79db 100644 --- a/setup.py +++ b/setup.py @@ -53,7 +53,7 @@ def read(fname, version=False): "google-generativeai", "gradio-client", "gradio", - "huggingface_hub==0.22.2", + "huggingface-hub>=0.23.2", "motor", ], classifiers=[ From 2bbbfc23de887efb55cf901a47f911b76e1ddc9c Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Mon, 12 Aug 2024 04:09:26 +0700 Subject: [PATCH 037/152] _ --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index e1861c3f..7576bfd3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -18,7 +18,6 @@ typing-extensions typing aiohttp deprecation -ntgcalls>=1.0.2 psutil screeninfo aiofiles From 782ca7df258877e3248ac7f6a456af26171b4c18 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Thu, 15 Aug 2024 20:10:59 +0700 Subject: [PATCH 038/152] _ --- RyuzakiLib/hackertools/flux.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 RyuzakiLib/hackertools/flux.py diff --git a/RyuzakiLib/hackertools/flux.py b/RyuzakiLib/hackertools/flux.py new file mode 100644 index 00000000..9c2f5a37 --- /dev/null +++ b/RyuzakiLib/hackertools/flux.py @@ -0,0 +1,18 @@ +from RyuzakiLib.api.reqs import AsyicXSearcher + +class FluxAi: + @staticmethod + async def schellwithflux(args, auto_enhanger=False, re_content=False): + API_URL = "https://randydev-ryuzaki-api.hf.space/api/v1/akeno/fluxai" + payload = { + "user_id": 1191668125, # Please don't edit here + "args": args, + "auto_enhanger": auto_enhanger + } + response = requests.post(API_URL, json=payload) + if response.status_code != 200: + return None + if re_content: + return response.content + else: + return response.json() From 4ea54ddec83e976772e5c56b87fc1a6ef7af453e Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Thu, 15 Aug 2024 20:14:25 +0700 Subject: [PATCH 039/152] _ --- RyuzakiLib/hackertools/flux.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/RyuzakiLib/hackertools/flux.py b/RyuzakiLib/hackertools/flux.py index 9c2f5a37..f97ba67d 100644 --- a/RyuzakiLib/hackertools/flux.py +++ b/RyuzakiLib/hackertools/flux.py @@ -1,13 +1,14 @@ +import requests from RyuzakiLib.api.reqs import AsyicXSearcher class FluxAi: @staticmethod - async def schellwithflux(args, auto_enhanger=False, re_content=False): + async def schellwithflux(args, auto_enhancer=False, re_content=False): API_URL = "https://randydev-ryuzaki-api.hf.space/api/v1/akeno/fluxai" payload = { "user_id": 1191668125, # Please don't edit here "args": args, - "auto_enhanger": auto_enhanger + "auto_enhancer": auto_enhancer } response = requests.post(API_URL, json=payload) if response.status_code != 200: From 9fcd0e99939ed9936259f56a9b5de2c49be0ca28 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Thu, 15 Aug 2024 20:15:25 +0700 Subject: [PATCH 040/152] _ --- RyuzakiLib/hackertools/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/RyuzakiLib/hackertools/__init__.py b/RyuzakiLib/hackertools/__init__.py index 439f48a6..435b6c6d 100644 --- a/RyuzakiLib/hackertools/__init__.py +++ b/RyuzakiLib/hackertools/__init__.py @@ -11,3 +11,4 @@ from .reverse import * from .rmbg import * from .tiktok import * +from .flux import * From 965eb8f2a21cba5f821894d17288f3145d0b7ad3 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Thu, 15 Aug 2024 20:16:52 +0700 Subject: [PATCH 041/152] _ --- RyuzakiLib/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/RyuzakiLib/__init__.py b/RyuzakiLib/__init__.py index bd115d21..94999ce2 100644 --- a/RyuzakiLib/__init__.py +++ b/RyuzakiLib/__init__.py @@ -51,6 +51,7 @@ from .hackertools.reverse import GoogleReverseImage from .hackertools.rmbg import Background from .hackertools.tiktok import Tiktok +from .hackertools.flux import FluxAi from .mental import * from .profile.user import Clone from .pushdb import * @@ -113,4 +114,5 @@ class AwesomeCoding(BaseModel): "AsyicXSearcher", "SearchAPI", "Jiosaavn", + "FluxAi", ] From 7f206c9f9baefc7544f15b6415c374536462b616 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 15 Aug 2024 13:18:50 +0000 Subject: [PATCH 042/152] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- RyuzakiLib/__init__.py | 2 +- RyuzakiLib/api/youtube.py | 1 + RyuzakiLib/hackertools/__init__.py | 2 +- RyuzakiLib/hackertools/flux.py | 2 ++ 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/RyuzakiLib/__init__.py b/RyuzakiLib/__init__.py index 94999ce2..9e92f5b8 100644 --- a/RyuzakiLib/__init__.py +++ b/RyuzakiLib/__init__.py @@ -41,6 +41,7 @@ from .hackertools.blackbox import Blackbox from .hackertools.chatgpt import RendyDevChat from .hackertools.farfalle import FarFalle +from .hackertools.flux import FluxAi from .hackertools.gemini import GeminiLatest from .hackertools.github import Github from .hackertools.huggingface import FaceAI @@ -51,7 +52,6 @@ from .hackertools.reverse import GoogleReverseImage from .hackertools.rmbg import Background from .hackertools.tiktok import Tiktok -from .hackertools.flux import FluxAi from .mental import * from .profile.user import Clone from .pushdb import * diff --git a/RyuzakiLib/api/youtube.py b/RyuzakiLib/api/youtube.py index 22ba7261..84f627fe 100644 --- a/RyuzakiLib/api/youtube.py +++ b/RyuzakiLib/api/youtube.py @@ -1,5 +1,6 @@ import asyncio import json + import uvloop asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) diff --git a/RyuzakiLib/hackertools/__init__.py b/RyuzakiLib/hackertools/__init__.py index 435b6c6d..8f8c39cf 100644 --- a/RyuzakiLib/hackertools/__init__.py +++ b/RyuzakiLib/hackertools/__init__.py @@ -1,6 +1,7 @@ from .blackbox import * from .chatgpt import * from .farfalle import * +from .flux import * from .gemini import * from .github import * from .huggingface import * @@ -11,4 +12,3 @@ from .reverse import * from .rmbg import * from .tiktok import * -from .flux import * diff --git a/RyuzakiLib/hackertools/flux.py b/RyuzakiLib/hackertools/flux.py index f97ba67d..646bf434 100644 --- a/RyuzakiLib/hackertools/flux.py +++ b/RyuzakiLib/hackertools/flux.py @@ -1,6 +1,8 @@ import requests + from RyuzakiLib.api.reqs import AsyicXSearcher + class FluxAi: @staticmethod async def schellwithflux(args, auto_enhancer=False, re_content=False): From 9fd407b59b18802a82570466e3bb48531c9d42be Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Thu, 15 Aug 2024 20:19:35 +0700 Subject: [PATCH 043/152] Update RyuzakiLib/hackertools/flux.py Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> --- RyuzakiLib/hackertools/flux.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/RyuzakiLib/hackertools/flux.py b/RyuzakiLib/hackertools/flux.py index 646bf434..dd3ba3f3 100644 --- a/RyuzakiLib/hackertools/flux.py +++ b/RyuzakiLib/hackertools/flux.py @@ -13,9 +13,6 @@ async def schellwithflux(args, auto_enhancer=False, re_content=False): "auto_enhancer": auto_enhancer } response = requests.post(API_URL, json=payload) - if response.status_code != 200: - return None - if re_content: - return response.content + return response.content if re_content else response.json() else: return response.json() From d4924582b65630c16d112c043cd2b98cb9d79038 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Thu, 15 Aug 2024 20:23:32 +0700 Subject: [PATCH 044/152] _ --- RyuzakiLib/hackertools/flux.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/RyuzakiLib/hackertools/flux.py b/RyuzakiLib/hackertools/flux.py index dd3ba3f3..cc082335 100644 --- a/RyuzakiLib/hackertools/flux.py +++ b/RyuzakiLib/hackertools/flux.py @@ -14,5 +14,3 @@ async def schellwithflux(args, auto_enhancer=False, re_content=False): } response = requests.post(API_URL, json=payload) return response.content if re_content else response.json() - else: - return response.json() From 4aa0315c89ab5a64ab4a05fc068af00b924f3a16 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Fri, 16 Aug 2024 15:33:49 +0700 Subject: [PATCH 045/152] _ --- RyuzakiLib/hackertools/cloudflare.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 RyuzakiLib/hackertools/cloudflare.py diff --git a/RyuzakiLib/hackertools/cloudflare.py b/RyuzakiLib/hackertools/cloudflare.py new file mode 100644 index 00000000..95059cbd --- /dev/null +++ b/RyuzakiLib/hackertools/cloudflare.py @@ -0,0 +1,17 @@ +from RyuzakiLib.api.reqs import AsyicXSearcher +import requests +from datetime import datetime as dt + +class CloudFlare: + @staticmethod + async def run(prompt, account_id, api_token): + payload = {"messages": prompt} + if account_id and api_token: + API_BASE_URL = f"https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run/@cf/meta/llama-3-8b-instruct" + headers = {"Authorization": f"Bearer {API_TOKEN}"} + response = requests.post(f"{API_BASE_URL}", headers=headers, json=payload) + if response.status_code != 200: + return None + return response.json() + else: + return "Required account_id and api_token" From bca23bc0ce0d07d14d9ff3def99e07122c6e9c45 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Fri, 16 Aug 2024 15:41:45 +0700 Subject: [PATCH 046/152] _ --- RyuzakiLib/hackertools/cloudflare.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/RyuzakiLib/hackertools/cloudflare.py b/RyuzakiLib/hackertools/cloudflare.py index 95059cbd..bd7355d2 100644 --- a/RyuzakiLib/hackertools/cloudflare.py +++ b/RyuzakiLib/hackertools/cloudflare.py @@ -2,16 +2,29 @@ import requests from datetime import datetime as dt +owner_base = f""" +Your name is Randy Dev. A kind and friendly AI assistant that answers in +a short and concise answer. Give short step-by-step reasoning if required. + +- Powered by @xtdevs on telegram +Today is {dt.now():%A %d %B %Y %H:%M} +""" + class CloudFlare: @staticmethod async def run(prompt, account_id, api_token): - payload = {"messages": prompt} + payload = { + "messages": [ + {"role": "system", "content": owner_base}, + {"role": "user", "content": prompt} + ], + } if account_id and api_token: API_BASE_URL = f"https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run/@cf/meta/llama-3-8b-instruct" headers = {"Authorization": f"Bearer {API_TOKEN}"} response = requests.post(f"{API_BASE_URL}", headers=headers, json=payload) if response.status_code != 200: return None - return response.json() + return response.json()["response"] else: return "Required account_id and api_token" From 04ac639dd7894b31f9b887f25017b9ddbe8e130b Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Fri, 16 Aug 2024 15:42:28 +0700 Subject: [PATCH 047/152] _ --- RyuzakiLib/hackertools/cloudflare.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RyuzakiLib/hackertools/cloudflare.py b/RyuzakiLib/hackertools/cloudflare.py index bd7355d2..7e548a4b 100644 --- a/RyuzakiLib/hackertools/cloudflare.py +++ b/RyuzakiLib/hackertools/cloudflare.py @@ -21,7 +21,7 @@ async def run(prompt, account_id, api_token): } if account_id and api_token: API_BASE_URL = f"https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run/@cf/meta/llama-3-8b-instruct" - headers = {"Authorization": f"Bearer {API_TOKEN}"} + headers = {"Authorization": f"Bearer {api_token}"} response = requests.post(f"{API_BASE_URL}", headers=headers, json=payload) if response.status_code != 200: return None From c9d40d7522b8d69669b0f4a8d102442d6a3eb189 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Fri, 16 Aug 2024 15:44:29 +0700 Subject: [PATCH 048/152] _ --- RyuzakiLib/hackertools/cloudflare.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RyuzakiLib/hackertools/cloudflare.py b/RyuzakiLib/hackertools/cloudflare.py index 7e548a4b..15ca8312 100644 --- a/RyuzakiLib/hackertools/cloudflare.py +++ b/RyuzakiLib/hackertools/cloudflare.py @@ -25,6 +25,6 @@ async def run(prompt, account_id, api_token): response = requests.post(f"{API_BASE_URL}", headers=headers, json=payload) if response.status_code != 200: return None - return response.json()["response"] + return response.json()["result"].get("response") else: return "Required account_id and api_token" From bfb72a97c19b13345e76e91150875d236ca30e11 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Fri, 16 Aug 2024 15:45:42 +0700 Subject: [PATCH 049/152] _ --- RyuzakiLib/hackertools/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/RyuzakiLib/hackertools/__init__.py b/RyuzakiLib/hackertools/__init__.py index 8f8c39cf..3192ca93 100644 --- a/RyuzakiLib/hackertools/__init__.py +++ b/RyuzakiLib/hackertools/__init__.py @@ -12,3 +12,4 @@ from .reverse import * from .rmbg import * from .tiktok import * +from .cloudflare import * From 24ea1e49eb77d43e3fd77769db036b4daf318593 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Fri, 16 Aug 2024 15:46:45 +0700 Subject: [PATCH 050/152] _ --- RyuzakiLib/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/RyuzakiLib/__init__.py b/RyuzakiLib/__init__.py index 9e92f5b8..a1085761 100644 --- a/RyuzakiLib/__init__.py +++ b/RyuzakiLib/__init__.py @@ -52,6 +52,7 @@ from .hackertools.reverse import GoogleReverseImage from .hackertools.rmbg import Background from .hackertools.tiktok import Tiktok +from .hackertools.cloudflare import CloudFlare from .mental import * from .profile.user import Clone from .pushdb import * @@ -115,4 +116,5 @@ class AwesomeCoding(BaseModel): "SearchAPI", "Jiosaavn", "FluxAi", + "CloudFlare", ] From 6be93764ae56200ca1734c1e6b4500b3b45689b9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 16 Aug 2024 08:56:33 +0000 Subject: [PATCH 051/152] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- RyuzakiLib/__init__.py | 2 +- RyuzakiLib/hackertools/__init__.py | 2 +- RyuzakiLib/hackertools/cloudflare.py | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/RyuzakiLib/__init__.py b/RyuzakiLib/__init__.py index a1085761..7a3d8056 100644 --- a/RyuzakiLib/__init__.py +++ b/RyuzakiLib/__init__.py @@ -40,6 +40,7 @@ from .extreme.webshot import WebShotUrl from .hackertools.blackbox import Blackbox from .hackertools.chatgpt import RendyDevChat +from .hackertools.cloudflare import CloudFlare from .hackertools.farfalle import FarFalle from .hackertools.flux import FluxAi from .hackertools.gemini import GeminiLatest @@ -52,7 +53,6 @@ from .hackertools.reverse import GoogleReverseImage from .hackertools.rmbg import Background from .hackertools.tiktok import Tiktok -from .hackertools.cloudflare import CloudFlare from .mental import * from .profile.user import Clone from .pushdb import * diff --git a/RyuzakiLib/hackertools/__init__.py b/RyuzakiLib/hackertools/__init__.py index 3192ca93..c9465b46 100644 --- a/RyuzakiLib/hackertools/__init__.py +++ b/RyuzakiLib/hackertools/__init__.py @@ -1,5 +1,6 @@ from .blackbox import * from .chatgpt import * +from .cloudflare import * from .farfalle import * from .flux import * from .gemini import * @@ -12,4 +13,3 @@ from .reverse import * from .rmbg import * from .tiktok import * -from .cloudflare import * diff --git a/RyuzakiLib/hackertools/cloudflare.py b/RyuzakiLib/hackertools/cloudflare.py index 15ca8312..ba56ccd0 100644 --- a/RyuzakiLib/hackertools/cloudflare.py +++ b/RyuzakiLib/hackertools/cloudflare.py @@ -1,7 +1,9 @@ -from RyuzakiLib.api.reqs import AsyicXSearcher -import requests from datetime import datetime as dt +import requests + +from RyuzakiLib.api.reqs import AsyicXSearcher + owner_base = f""" Your name is Randy Dev. A kind and friendly AI assistant that answers in a short and concise answer. Give short step-by-step reasoning if required. From 8688f9cbcd00ad6a8bff1aaea04d867534c36514 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Sat, 17 Aug 2024 18:03:11 +0700 Subject: [PATCH 052/152] _ --- RyuzakiLib/pyrogramMod.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 RyuzakiLib/pyrogramMod.py diff --git a/RyuzakiLib/pyrogramMod.py b/RyuzakiLib/pyrogramMod.py new file mode 100644 index 00000000..85984db7 --- /dev/null +++ b/RyuzakiLib/pyrogramMod.py @@ -0,0 +1,8 @@ +from pyrogram import Client + +class PyorgramMod: + @staticmethod + async def chat_photos(client: Client, user): + if isinstance(client, Client): + async for photo in client.get_chat_photos(user): + return photo From 403ce4fdf360cf44af8a8fb3a00b3e48ae655e52 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Sat, 17 Aug 2024 18:07:47 +0700 Subject: [PATCH 053/152] _ --- RyuzakiLib/pyrogramMod.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/RyuzakiLib/pyrogramMod.py b/RyuzakiLib/pyrogramMod.py index 85984db7..d966c9ae 100644 --- a/RyuzakiLib/pyrogramMod.py +++ b/RyuzakiLib/pyrogramMod.py @@ -2,7 +2,11 @@ class PyorgramMod: @staticmethod - async def chat_photos(client: Client, user): + async def chat_photos(client: Client, user, is_limit: bool = False, set_limit=None): if isinstance(client, Client): - async for photo in client.get_chat_photos(user): - return photo + if is_limit: + async for photo in client.get_chat_photos(chat_id=user): + return photo + else: + async for photo in client.get_chat_photos(chat_id=user, limit=set_limit): + return photo From 39a318183fbc764401e598b3d8ab8f94fdfda46d Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Sat, 17 Aug 2024 18:39:21 +0700 Subject: [PATCH 054/152] _ --- RyuzakiLib/pyrogramMod.py | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/RyuzakiLib/pyrogramMod.py b/RyuzakiLib/pyrogramMod.py index d966c9ae..26c6f25b 100644 --- a/RyuzakiLib/pyrogramMod.py +++ b/RyuzakiLib/pyrogramMod.py @@ -1,12 +1,33 @@ -from pyrogram import Client +from pyrogram import Client, enums class PyorgramMod: @staticmethod - async def chat_photos(client: Client, user, is_limit: bool = False, set_limit=None): - if isinstance(client, Client): - if is_limit: - async for photo in client.get_chat_photos(chat_id=user): - return photo - else: - async for photo in client.get_chat_photos(chat_id=user, limit=set_limit): - return photo + async def chat_photos(client: Client, user, set_limit=None, is_limit: bool = False): + if not isinstance(client, Client): + raise ValueError("Invalid client instance provided") + if is_limit and set_limit: + async for photo in client.get_chat_photos(chat_id=user): + yield photo + else: + async for photo in client.get_chat_photos(chat_id=user, limit=set_limit): + yield photo + + async def chat_members( + client: Client, + chat=None, + query=None, + filter: enums.ChatMembersFilter = None, + is_query: bool = False, + is_filter: bool = False, + ): + if not isinstance(client, Client): + raise ValueError("Invalid client instance provided") + if is_query and query: + async for member in client.get_chat_members(chat_id=chat, query=query): + yield member + elif is_filter and filter: + async for member in client.get_chat_members(chat_id=chat, filter=filter): + yield member + else: + async for member in client.get_chat_members(chat_id=chat): + yield member From 924efcbcdd6f90f49548e183743a4e09af6c4028 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Sat, 17 Aug 2024 18:39:49 +0700 Subject: [PATCH 055/152] _ --- RyuzakiLib/pyrogramMod.py | 1 + 1 file changed, 1 insertion(+) diff --git a/RyuzakiLib/pyrogramMod.py b/RyuzakiLib/pyrogramMod.py index 26c6f25b..e06dbf75 100644 --- a/RyuzakiLib/pyrogramMod.py +++ b/RyuzakiLib/pyrogramMod.py @@ -12,6 +12,7 @@ async def chat_photos(client: Client, user, set_limit=None, is_limit: bool = Fal async for photo in client.get_chat_photos(chat_id=user, limit=set_limit): yield photo + @staticmethod async def chat_members( client: Client, chat=None, From ec1c95a9faaf7cac3069558c6d6c873cf89f4394 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Sat, 17 Aug 2024 18:41:21 +0700 Subject: [PATCH 056/152] _ --- RyuzakiLib/pyrogramMod.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RyuzakiLib/pyrogramMod.py b/RyuzakiLib/pyrogramMod.py index e06dbf75..3c5f8d68 100644 --- a/RyuzakiLib/pyrogramMod.py +++ b/RyuzakiLib/pyrogramMod.py @@ -6,10 +6,10 @@ async def chat_photos(client: Client, user, set_limit=None, is_limit: bool = Fal if not isinstance(client, Client): raise ValueError("Invalid client instance provided") if is_limit and set_limit: - async for photo in client.get_chat_photos(chat_id=user): + async for photo in client.get_chat_photos(chat_id=user, limit=set_limit): yield photo else: - async for photo in client.get_chat_photos(chat_id=user, limit=set_limit): + async for photo in client.get_chat_photos(chat_id=user): yield photo @staticmethod From 78f2f3ced3ed55dc898391dd32ddf3fc2e8c54c1 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Sat, 17 Aug 2024 18:48:49 +0700 Subject: [PATCH 057/152] _ --- RyuzakiLib/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/RyuzakiLib/__init__.py b/RyuzakiLib/__init__.py index 7a3d8056..a08eb467 100644 --- a/RyuzakiLib/__init__.py +++ b/RyuzakiLib/__init__.py @@ -25,6 +25,7 @@ from . import * from .__version__ import __version__ +from .pyrogramMod import PyorgramMod from .api.fullstack import FullStackDev from .api.jiosaavn import Jiosaavn from .api.private import PrivateApiUrl @@ -117,4 +118,5 @@ class AwesomeCoding(BaseModel): "Jiosaavn", "FluxAi", "CloudFlare", + "PyorgramMod", ] From bef9ca784ae5df65ea550a21707539d5d9f3f9f6 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Sat, 17 Aug 2024 18:49:42 +0700 Subject: [PATCH 058/152] _ --- RyuzakiLib/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RyuzakiLib/__init__.py b/RyuzakiLib/__init__.py index a08eb467..dab980bc 100644 --- a/RyuzakiLib/__init__.py +++ b/RyuzakiLib/__init__.py @@ -25,7 +25,7 @@ from . import * from .__version__ import __version__ -from .pyrogramMod import PyorgramMod +from .pyrogramMod import PyrogramMod from .api.fullstack import FullStackDev from .api.jiosaavn import Jiosaavn from .api.private import PrivateApiUrl @@ -118,5 +118,5 @@ class AwesomeCoding(BaseModel): "Jiosaavn", "FluxAi", "CloudFlare", - "PyorgramMod", + "PyrogramMod", ] From 19a6e080c1681165aaefb0905ec03528fef835a5 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Sat, 17 Aug 2024 18:50:10 +0700 Subject: [PATCH 059/152] _ --- RyuzakiLib/pyrogramMod.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RyuzakiLib/pyrogramMod.py b/RyuzakiLib/pyrogramMod.py index 3c5f8d68..006fb045 100644 --- a/RyuzakiLib/pyrogramMod.py +++ b/RyuzakiLib/pyrogramMod.py @@ -1,6 +1,6 @@ from pyrogram import Client, enums -class PyorgramMod: +class PyrogramMod: @staticmethod async def chat_photos(client: Client, user, set_limit=None, is_limit: bool = False): if not isinstance(client, Client): From 48f159ebcba446641e4e8ae3f2108218a06fbf1f Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Sat, 17 Aug 2024 19:03:55 +0700 Subject: [PATCH 060/152] _ --- RyuzakiLib/pyrogramMod.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/RyuzakiLib/pyrogramMod.py b/RyuzakiLib/pyrogramMod.py index 006fb045..10fa1cfc 100644 --- a/RyuzakiLib/pyrogramMod.py +++ b/RyuzakiLib/pyrogramMod.py @@ -5,6 +5,7 @@ class PyrogramMod: async def chat_photos(client: Client, user, set_limit=None, is_limit: bool = False): if not isinstance(client, Client): raise ValueError("Invalid client instance provided") + if is_limit and set_limit: async for photo in client.get_chat_photos(chat_id=user, limit=set_limit): yield photo @@ -21,14 +22,15 @@ async def chat_members( is_query: bool = False, is_filter: bool = False, ): - if not isinstance(client, Client): - raise ValueError("Invalid client instance provided") - if is_query and query: - async for member in client.get_chat_members(chat_id=chat, query=query): - yield member - elif is_filter and filter: - async for member in client.get_chat_members(chat_id=chat, filter=filter): - yield member - else: - async for member in client.get_chat_members(chat_id=chat): - yield member + if not isinstance(client, Client): + raise ValueError("Invalid client instance provided") + + if is_query and query: + async for member in client.get_chat_members(chat_id=chat, query=query): + yield member + elif is_filter and filter: + async for member in client.get_chat_members(chat_id=chat, filter=filter): + yield member + else: + async for member in client.get_chat_members(chat_id=chat): + yield member From 4a832070bc1d0ad38fdc666a5c10a5814235a890 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Sat, 17 Aug 2024 23:51:38 +0700 Subject: [PATCH 061/152] _ --- RyuzakiLib/hackertools/gemini.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RyuzakiLib/hackertools/gemini.py b/RyuzakiLib/hackertools/gemini.py index cd852a7d..268c9637 100644 --- a/RyuzakiLib/hackertools/gemini.py +++ b/RyuzakiLib/hackertools/gemini.py @@ -101,12 +101,12 @@ def __get_response_gemini(self, query: str = None, settings_config: bool = False } model_flash = genai.GenerativeModel( model_name=self.model, + system_instruction="You are a funny. Your name is Randy", generation_config=generation_config, ) gemini_chat = self._get_gemini_chat_from_db() gemini_chat.append({"role": "user", "parts": [{"text": query}]}) chat_session = model_flash.start_chat(history=gemini_chat) - response_data = chat_session.send_message(query) answer = response_data.text gemini_chat.append({"role": "model", "parts": [{"text": answer}]}) From 373426a25623633c84339df6c34e8198fd69c618 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Sun, 18 Aug 2024 00:32:42 +0700 Subject: [PATCH 062/152] add block none works --- RyuzakiLib/hackertools/gemini.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/RyuzakiLib/hackertools/gemini.py b/RyuzakiLib/hackertools/gemini.py index 268c9637..176b1d94 100644 --- a/RyuzakiLib/hackertools/gemini.py +++ b/RyuzakiLib/hackertools/gemini.py @@ -99,10 +99,28 @@ def __get_response_gemini(self, query: str = None, settings_config: bool = False "max_output_tokens": 8192, "response_mime_type": "text/plain", } + safety_settings = [ + { + "category": "HARM_CATEGORY_HARASSMENT", + "threshold": "BLOCK_NONE", + }, + { + "category": "HARM_CATEGORY_HATE_SPEECH", + "threshold": "BLOCK_NONE", + }, + { + "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT", + "threshold": "BLOCK_NONE", + }, + { + "category": "HARM_CATEGORY_DANGEROUS_CONTENT", + "threshold": "BLOCK_NONE", + }, + ] model_flash = genai.GenerativeModel( model_name=self.model, - system_instruction="You are a funny. Your name is Randy", generation_config=generation_config, + safety_settings=safety_settings ) gemini_chat = self._get_gemini_chat_from_db() gemini_chat.append({"role": "user", "parts": [{"text": query}]}) From b2d8a5e7fc392df709168afe6ec7e7139a153ed5 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Sun, 18 Aug 2024 01:11:46 +0700 Subject: [PATCH 063/152] _ --- RyuzakiLib/hackertools/gemini.py | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/RyuzakiLib/hackertools/gemini.py b/RyuzakiLib/hackertools/gemini.py index 176b1d94..e9ed5241 100644 --- a/RyuzakiLib/hackertools/gemini.py +++ b/RyuzakiLib/hackertools/gemini.py @@ -25,7 +25,6 @@ import requests from pymongo import MongoClient - class GeminiLatest: def __init__( self, @@ -99,28 +98,16 @@ def __get_response_gemini(self, query: str = None, settings_config: bool = False "max_output_tokens": 8192, "response_mime_type": "text/plain", } - safety_settings = [ - { - "category": "HARM_CATEGORY_HARASSMENT", - "threshold": "BLOCK_NONE", - }, - { - "category": "HARM_CATEGORY_HATE_SPEECH", - "threshold": "BLOCK_NONE", - }, - { - "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT", - "threshold": "BLOCK_NONE", - }, - { - "category": "HARM_CATEGORY_DANGEROUS_CONTENT", - "threshold": "BLOCK_NONE", - }, - ] model_flash = genai.GenerativeModel( model_name=self.model, generation_config=generation_config, - safety_settings=safety_settings + safety_settings={ + genai.types.HarmCategory.HARM_CATEGORY_HATE_SPEECH: genai.types.HarmBlockThreshold.BLOCK_NONE, + genai.types.HarmCategory.HARM_CATEGORY_HARASSMENT: genai.types.HarmBlockThreshold.BLOCK_NONE, + genai.types.HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: genai.types.HarmBlockThreshold.BLOCK_NONE, + genai.types.HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: genai.types.HarmBlockThreshold.BLOCK_NONE + + } ) gemini_chat = self._get_gemini_chat_from_db() gemini_chat.append({"role": "user", "parts": [{"text": query}]}) From e7b905a8f42fcabac9d9d4a135d99c650888d9c1 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Sun, 18 Aug 2024 01:15:32 +0700 Subject: [PATCH 064/152] _ --- RyuzakiLib/hackertools/gemini.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/RyuzakiLib/hackertools/gemini.py b/RyuzakiLib/hackertools/gemini.py index e9ed5241..9dc963ca 100644 --- a/RyuzakiLib/hackertools/gemini.py +++ b/RyuzakiLib/hackertools/gemini.py @@ -105,8 +105,9 @@ def __get_response_gemini(self, query: str = None, settings_config: bool = False genai.types.HarmCategory.HARM_CATEGORY_HATE_SPEECH: genai.types.HarmBlockThreshold.BLOCK_NONE, genai.types.HarmCategory.HARM_CATEGORY_HARASSMENT: genai.types.HarmBlockThreshold.BLOCK_NONE, genai.types.HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: genai.types.HarmBlockThreshold.BLOCK_NONE, - genai.types.HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: genai.types.HarmBlockThreshold.BLOCK_NONE - + genai.types.HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: genai.types.HarmBlockThreshold.BLOCK_NONE, + genai.types.HarmCategory.HARM_CATEGORY_TOXICITY: genai.types.HarmBlockThreshold.BLOCK_NONE, + genai.types.HarmCategory.HARM_CATEGORY_VIOLENCE: genai.types.HarmBlockThreshold.BLOCK_NONE } ) gemini_chat = self._get_gemini_chat_from_db() From d046c198b87ce8c23bf53bb53bdad335fe1b52d9 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Sun, 18 Aug 2024 01:16:04 +0700 Subject: [PATCH 065/152] _ --- RyuzakiLib/hackertools/gemini.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RyuzakiLib/hackertools/gemini.py b/RyuzakiLib/hackertools/gemini.py index 9dc963ca..e9969211 100644 --- a/RyuzakiLib/hackertools/gemini.py +++ b/RyuzakiLib/hackertools/gemini.py @@ -30,7 +30,7 @@ def __init__( self, api_keys: Optional[str] = None, mongo_url: Optional[str] = None, - model: Optional[str] = "gemini-1.5-flash-latest", + model: Optional[str] = "gemini-1.5-flash", user_id: Optional[int] = None, generation_configs = {} ): From 352b343439f3331f7e4457f3c36f52495dbfefab Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Sun, 18 Aug 2024 01:21:19 +0700 Subject: [PATCH 066/152] _ --- RyuzakiLib/hackertools/gemini.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/RyuzakiLib/hackertools/gemini.py b/RyuzakiLib/hackertools/gemini.py index e9969211..2ec69c92 100644 --- a/RyuzakiLib/hackertools/gemini.py +++ b/RyuzakiLib/hackertools/gemini.py @@ -106,8 +106,6 @@ def __get_response_gemini(self, query: str = None, settings_config: bool = False genai.types.HarmCategory.HARM_CATEGORY_HARASSMENT: genai.types.HarmBlockThreshold.BLOCK_NONE, genai.types.HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: genai.types.HarmBlockThreshold.BLOCK_NONE, genai.types.HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: genai.types.HarmBlockThreshold.BLOCK_NONE, - genai.types.HarmCategory.HARM_CATEGORY_TOXICITY: genai.types.HarmBlockThreshold.BLOCK_NONE, - genai.types.HarmCategory.HARM_CATEGORY_VIOLENCE: genai.types.HarmBlockThreshold.BLOCK_NONE } ) gemini_chat = self._get_gemini_chat_from_db() From ebb28fad10b4f513924f4093033457ea2c217cde Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Tue, 20 Aug 2024 23:18:34 +0700 Subject: [PATCH 067/152] _ --- RyuzakiLib/api/youtube.py | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/RyuzakiLib/api/youtube.py b/RyuzakiLib/api/youtube.py index 84f627fe..e8f4219e 100644 --- a/RyuzakiLib/api/youtube.py +++ b/RyuzakiLib/api/youtube.py @@ -1,11 +1,7 @@ import asyncio import json -import uvloop - -asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) - -class Youtube: +class YoutubeJsonConvert: @staticmethod async def cookies_loads(file_json: str): with open(file_json, "r") as f: @@ -13,7 +9,7 @@ async def cookies_loads(file_json: str): return cookies @staticmethod - async def download(file_json: str, url: str, name_txt="youtube_cookies.txt"): + async def to_cookies(file_json: str, url: str, name_txt="cookies.txt"): with open(name_txt, 'w') as f: f.write("# Netscape HTTP Cookie File\n") f.write("# This is a generated file! Do not edit.\n\n") @@ -28,14 +24,5 @@ async def download(file_json: str, url: str, name_txt="youtube_cookies.txt"): cookie.get('name', ''), cookie.get('value', ''), ]) + "\n") - - cmd = f"yt-dlp --cookies {name_txt} {url}" - process = await asyncio.create_subprocess_shell( - cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE - ) - stdout, stderr = await process.communicate() - e = stderr.decode() or "No errors" - o = stdout.decode() or "No output" - - OUTPUT = f"Output: \n{o}\nErrors: \n{e}" + OUTPUT = "Successful output cookies.txt" return OUTPUT From 8c67a0e9a4ef45335ce3cf066c6fe680799348ac Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Tue, 20 Aug 2024 23:21:03 +0700 Subject: [PATCH 068/152] _ --- RyuzakiLib/api/youtube.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RyuzakiLib/api/youtube.py b/RyuzakiLib/api/youtube.py index e8f4219e..9d7a8b63 100644 --- a/RyuzakiLib/api/youtube.py +++ b/RyuzakiLib/api/youtube.py @@ -9,7 +9,7 @@ async def cookies_loads(file_json: str): return cookies @staticmethod - async def to_cookies(file_json: str, url: str, name_txt="cookies.txt"): + async def to_cookies(file_json: str, name_txt="cookies.txt"): with open(name_txt, 'w') as f: f.write("# Netscape HTTP Cookie File\n") f.write("# This is a generated file! Do not edit.\n\n") From 55ad407690b1d68ec851f4f2cc47877326fd3b77 Mon Sep 17 00:00:00 2001 From: TrueSaiyan Date: Wed, 21 Aug 2024 00:39:52 +0800 Subject: [PATCH 069/152] Update youtube.py --- RyuzakiLib/api/youtube.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RyuzakiLib/api/youtube.py b/RyuzakiLib/api/youtube.py index 9d7a8b63..cba3b9c2 100644 --- a/RyuzakiLib/api/youtube.py +++ b/RyuzakiLib/api/youtube.py @@ -13,7 +13,7 @@ async def to_cookies(file_json: str, name_txt="cookies.txt"): with open(name_txt, 'w') as f: f.write("# Netscape HTTP Cookie File\n") f.write("# This is a generated file! Do not edit.\n\n") - cookies = await Youtube.cookies_loads(file_json) + cookies = await YoutubeJsonConvert.cookies_loads(file_json) for cookie in cookies: f.write("\t".join([ cookie.get('domain', ''), From a4f50f4d702eb50682aa079c524e958b4d03be7d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 20 Aug 2024 16:40:46 +0000 Subject: [PATCH 070/152] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- RyuzakiLib/__init__.py | 2 +- RyuzakiLib/api/youtube.py | 1 + RyuzakiLib/hackertools/gemini.py | 1 + RyuzakiLib/pyrogramMod.py | 5 +++-- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/RyuzakiLib/__init__.py b/RyuzakiLib/__init__.py index dab980bc..7f462b7b 100644 --- a/RyuzakiLib/__init__.py +++ b/RyuzakiLib/__init__.py @@ -25,7 +25,6 @@ from . import * from .__version__ import __version__ -from .pyrogramMod import PyrogramMod from .api.fullstack import FullStackDev from .api.jiosaavn import Jiosaavn from .api.private import PrivateApiUrl @@ -58,6 +57,7 @@ from .profile.user import Clone from .pushdb import * from .py_tgcalls import PyTgCalls +from .pyrogramMod import PyrogramMod from .quote import * from .reminder import * from .spamwatch.clients import SibylBan diff --git a/RyuzakiLib/api/youtube.py b/RyuzakiLib/api/youtube.py index cba3b9c2..9285ef35 100644 --- a/RyuzakiLib/api/youtube.py +++ b/RyuzakiLib/api/youtube.py @@ -1,6 +1,7 @@ import asyncio import json + class YoutubeJsonConvert: @staticmethod async def cookies_loads(file_json: str): diff --git a/RyuzakiLib/hackertools/gemini.py b/RyuzakiLib/hackertools/gemini.py index 2ec69c92..88867609 100644 --- a/RyuzakiLib/hackertools/gemini.py +++ b/RyuzakiLib/hackertools/gemini.py @@ -25,6 +25,7 @@ import requests from pymongo import MongoClient + class GeminiLatest: def __init__( self, diff --git a/RyuzakiLib/pyrogramMod.py b/RyuzakiLib/pyrogramMod.py index 10fa1cfc..7d3231e5 100644 --- a/RyuzakiLib/pyrogramMod.py +++ b/RyuzakiLib/pyrogramMod.py @@ -1,11 +1,12 @@ from pyrogram import Client, enums + class PyrogramMod: @staticmethod async def chat_photos(client: Client, user, set_limit=None, is_limit: bool = False): if not isinstance(client, Client): raise ValueError("Invalid client instance provided") - + if is_limit and set_limit: async for photo in client.get_chat_photos(chat_id=user, limit=set_limit): yield photo @@ -24,7 +25,7 @@ async def chat_members( ): if not isinstance(client, Client): raise ValueError("Invalid client instance provided") - + if is_query and query: async for member in client.get_chat_members(chat_id=chat, query=query): yield member From 9944080fbb00cfff843c496100519a82dde4429d Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Wed, 21 Aug 2024 17:34:34 +0700 Subject: [PATCH 071/152] _ --- RyuzakiLib/methods/__init__.py | 13 --- RyuzakiLib/methods/decorators/__init__.py | 19 --- RyuzakiLib/methods/decorators/nothing | 0 .../decorators/on_closed_voice_chat.py | 18 --- .../decorators/on_group_call_invite.py | 18 --- RyuzakiLib/methods/decorators/on_kicked.py | 18 --- RyuzakiLib/methods/decorators/on_left.py | 18 --- .../decorators/on_participants_change.py | 18 --- .../methods/decorators/on_raw_update.py | 14 --- .../methods/decorators/on_stream_end.py | 18 --- RyuzakiLib/methods/groups/__init__.py | 13 --- .../methods/groups/change_volume_call.py | 30 ----- RyuzakiLib/methods/groups/get_participants.py | 17 --- RyuzakiLib/methods/groups/join_group_call.py | 97 --------------- RyuzakiLib/methods/groups/leave_group_call.py | 54 --------- RyuzakiLib/methods/groups/nothing | 0 RyuzakiLib/methods/nothing | 0 RyuzakiLib/methods/stream/__init__.py | 17 --- RyuzakiLib/methods/stream/change_stream.py | 44 ------- RyuzakiLib/methods/stream/mute_stream.py | 28 ----- RyuzakiLib/methods/stream/nothing | 0 RyuzakiLib/methods/stream/pause_stream.py | 35 ------ RyuzakiLib/methods/stream/played_time.py | 28 ----- RyuzakiLib/methods/stream/resume_stream.py | 35 ------ RyuzakiLib/methods/stream/unmute_stream.py | 28 ----- RyuzakiLib/methods/utilities/__init__.py | 21 ---- RyuzakiLib/methods/utilities/cache_peer.py | 7 -- RyuzakiLib/methods/utilities/call_holder.py | 66 ----------- .../methods/utilities/get_max_voice_chat.py | 10 -- RyuzakiLib/methods/utilities/idle.py | 30 ----- .../methods/utilities/mtproto_handler.py | 110 ------------------ RyuzakiLib/methods/utilities/nothing | 0 RyuzakiLib/methods/utilities/ping.py | 13 --- .../methods/utilities/resolve_chat_id.py | 16 --- RyuzakiLib/methods/utilities/run.py | 8 -- RyuzakiLib/methods/utilities/start.py | 83 ------------- RyuzakiLib/methods/utilities/stream_params.py | 51 -------- 37 files changed, 995 deletions(-) delete mode 100644 RyuzakiLib/methods/__init__.py delete mode 100644 RyuzakiLib/methods/decorators/__init__.py delete mode 100644 RyuzakiLib/methods/decorators/nothing delete mode 100644 RyuzakiLib/methods/decorators/on_closed_voice_chat.py delete mode 100644 RyuzakiLib/methods/decorators/on_group_call_invite.py delete mode 100644 RyuzakiLib/methods/decorators/on_kicked.py delete mode 100644 RyuzakiLib/methods/decorators/on_left.py delete mode 100644 RyuzakiLib/methods/decorators/on_participants_change.py delete mode 100644 RyuzakiLib/methods/decorators/on_raw_update.py delete mode 100644 RyuzakiLib/methods/decorators/on_stream_end.py delete mode 100644 RyuzakiLib/methods/groups/__init__.py delete mode 100644 RyuzakiLib/methods/groups/change_volume_call.py delete mode 100644 RyuzakiLib/methods/groups/get_participants.py delete mode 100644 RyuzakiLib/methods/groups/join_group_call.py delete mode 100644 RyuzakiLib/methods/groups/leave_group_call.py delete mode 100644 RyuzakiLib/methods/groups/nothing delete mode 100644 RyuzakiLib/methods/nothing delete mode 100644 RyuzakiLib/methods/stream/__init__.py delete mode 100644 RyuzakiLib/methods/stream/change_stream.py delete mode 100644 RyuzakiLib/methods/stream/mute_stream.py delete mode 100644 RyuzakiLib/methods/stream/nothing delete mode 100644 RyuzakiLib/methods/stream/pause_stream.py delete mode 100644 RyuzakiLib/methods/stream/played_time.py delete mode 100644 RyuzakiLib/methods/stream/resume_stream.py delete mode 100644 RyuzakiLib/methods/stream/unmute_stream.py delete mode 100644 RyuzakiLib/methods/utilities/__init__.py delete mode 100644 RyuzakiLib/methods/utilities/cache_peer.py delete mode 100644 RyuzakiLib/methods/utilities/call_holder.py delete mode 100644 RyuzakiLib/methods/utilities/get_max_voice_chat.py delete mode 100644 RyuzakiLib/methods/utilities/idle.py delete mode 100644 RyuzakiLib/methods/utilities/mtproto_handler.py delete mode 100644 RyuzakiLib/methods/utilities/nothing delete mode 100644 RyuzakiLib/methods/utilities/ping.py delete mode 100644 RyuzakiLib/methods/utilities/resolve_chat_id.py delete mode 100644 RyuzakiLib/methods/utilities/run.py delete mode 100644 RyuzakiLib/methods/utilities/start.py delete mode 100644 RyuzakiLib/methods/utilities/stream_params.py diff --git a/RyuzakiLib/methods/__init__.py b/RyuzakiLib/methods/__init__.py deleted file mode 100644 index 6207aaa8..00000000 --- a/RyuzakiLib/methods/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -from .decorators import Decorators -from .groups import Groups -from .stream import StreamMethods -from .utilities import Utilities - - -class Methods( - Decorators, - Groups, - StreamMethods, - Utilities, -): - pass diff --git a/RyuzakiLib/methods/decorators/__init__.py b/RyuzakiLib/methods/decorators/__init__.py deleted file mode 100644 index 5fc55ae2..00000000 --- a/RyuzakiLib/methods/decorators/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -from .on_closed_voice_chat import OnClosedVoiceChat -from .on_group_call_invite import OnGroupCallInvite -from .on_kicked import OnKicked -from .on_left import OnLeft -from .on_participants_change import OnParticipantsChange -from .on_raw_update import OnRawUpdate -from .on_stream_end import OnStreamEnd - - -class Decorators( - OnClosedVoiceChat, - OnGroupCallInvite, - OnKicked, - OnLeft, - OnParticipantsChange, - OnRawUpdate, - OnStreamEnd, -): - pass diff --git a/RyuzakiLib/methods/decorators/nothing b/RyuzakiLib/methods/decorators/nothing deleted file mode 100644 index e69de29b..00000000 diff --git a/RyuzakiLib/methods/decorators/on_closed_voice_chat.py b/RyuzakiLib/methods/decorators/on_closed_voice_chat.py deleted file mode 100644 index 602e4460..00000000 --- a/RyuzakiLib/methods/decorators/on_closed_voice_chat.py +++ /dev/null @@ -1,18 +0,0 @@ -from typing import Callable - -from ...scaffold import Scaffold - - -class OnClosedVoiceChat(Scaffold): - def on_closed_voice_chat(self) -> Callable: - method = "CLOSED_HANDLER" - - def decorator(func: Callable) -> Callable: - if self is not None: - self._on_event_update.add_handler( - method, - func, - ) - return func - - return decorator diff --git a/RyuzakiLib/methods/decorators/on_group_call_invite.py b/RyuzakiLib/methods/decorators/on_group_call_invite.py deleted file mode 100644 index d1f9e661..00000000 --- a/RyuzakiLib/methods/decorators/on_group_call_invite.py +++ /dev/null @@ -1,18 +0,0 @@ -from typing import Callable - -from ...scaffold import Scaffold - - -class OnGroupCallInvite(Scaffold): - def on_group_call_invite(self) -> Callable: - method = "INVITE_HANDLER" - - def decorator(func: Callable) -> Callable: - if self is not None: - self._on_event_update.add_handler( - method, - func, - ) - return func - - return decorator diff --git a/RyuzakiLib/methods/decorators/on_kicked.py b/RyuzakiLib/methods/decorators/on_kicked.py deleted file mode 100644 index dacc7df0..00000000 --- a/RyuzakiLib/methods/decorators/on_kicked.py +++ /dev/null @@ -1,18 +0,0 @@ -from typing import Callable - -from ...scaffold import Scaffold - - -class OnKicked(Scaffold): - def on_kicked(self) -> Callable: - method = "KICK_HANDLER" - - def decorator(func: Callable) -> Callable: - if self is not None: - self._on_event_update.add_handler( - method, - func, - ) - return func - - return decorator diff --git a/RyuzakiLib/methods/decorators/on_left.py b/RyuzakiLib/methods/decorators/on_left.py deleted file mode 100644 index f6fb555d..00000000 --- a/RyuzakiLib/methods/decorators/on_left.py +++ /dev/null @@ -1,18 +0,0 @@ -from typing import Callable - -from ...scaffold import Scaffold - - -class OnLeft(Scaffold): - def on_left(self) -> Callable: - method = "LEFT_HANDLER" - - def decorator(func: Callable) -> Callable: - if self is not None: - self._on_event_update.add_handler( - method, - func, - ) - return func - - return decorator diff --git a/RyuzakiLib/methods/decorators/on_participants_change.py b/RyuzakiLib/methods/decorators/on_participants_change.py deleted file mode 100644 index 2a92f38b..00000000 --- a/RyuzakiLib/methods/decorators/on_participants_change.py +++ /dev/null @@ -1,18 +0,0 @@ -from typing import Callable - -from ...scaffold import Scaffold - - -class OnParticipantsChange(Scaffold): - def on_participants_change(self) -> Callable: - method = "PARTICIPANTS_LIST" - - def decorator(func: Callable) -> Callable: - if self is not None: - self._on_event_update.add_handler( - method, - func, - ) - return func - - return decorator diff --git a/RyuzakiLib/methods/decorators/on_raw_update.py b/RyuzakiLib/methods/decorators/on_raw_update.py deleted file mode 100644 index 15eeb356..00000000 --- a/RyuzakiLib/methods/decorators/on_raw_update.py +++ /dev/null @@ -1,14 +0,0 @@ -from typing import Callable - -from deprecation import deprecated - -from ...scaffold import Scaffold - - -class OnRawUpdate(Scaffold): - @deprecated( - deprecated_in="1.0.0.dev1", - details="This method is no longer supported.", - ) - def on_raw_update(self) -> Callable: - pass diff --git a/RyuzakiLib/methods/decorators/on_stream_end.py b/RyuzakiLib/methods/decorators/on_stream_end.py deleted file mode 100644 index 72ff04c3..00000000 --- a/RyuzakiLib/methods/decorators/on_stream_end.py +++ /dev/null @@ -1,18 +0,0 @@ -from typing import Callable - -from ...scaffold import Scaffold - - -class OnStreamEnd(Scaffold): - def on_stream_end(self) -> Callable: - method = "STREAM_END_HANDLER" - - def decorator(func: Callable) -> Callable: - if self is not None: - self._on_event_update.add_handler( - method, - func, - ) - return func - - return decorator diff --git a/RyuzakiLib/methods/groups/__init__.py b/RyuzakiLib/methods/groups/__init__.py deleted file mode 100644 index a22700cb..00000000 --- a/RyuzakiLib/methods/groups/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -from .change_volume_call import ChangeVolumeCall -from .get_participants import GetParticipants -from .join_group_call import JoinGroupCall -from .leave_group_call import LeaveGroupCall - - -class Groups( - ChangeVolumeCall, - GetParticipants, - JoinGroupCall, - LeaveGroupCall, -): - pass diff --git a/RyuzakiLib/methods/groups/change_volume_call.py b/RyuzakiLib/methods/groups/change_volume_call.py deleted file mode 100644 index d3366f5b..00000000 --- a/RyuzakiLib/methods/groups/change_volume_call.py +++ /dev/null @@ -1,30 +0,0 @@ -from typing import Union - -from ...exceptions import ClientNotStarted, NoActiveGroupCall, NoMTProtoClientSet -from ...scaffold import Scaffold - - -class ChangeVolumeCall(Scaffold): - async def change_volume_call( - self, - chat_id: Union[int, str], - volume: int, - ): - if self._app is None: - raise NoMTProtoClientSet() - - if not self._is_running: - raise ClientNotStarted() - - chat_id = await self._resolve_chat_id(chat_id) - chat_call = await self._app.get_full_chat( - chat_id, - ) - if chat_call is None: - raise NoActiveGroupCall() - - await self._app.change_volume( - chat_id, - volume, - self._cache_user_peer.get(chat_id), - ) diff --git a/RyuzakiLib/methods/groups/get_participants.py b/RyuzakiLib/methods/groups/get_participants.py deleted file mode 100644 index 831aecc9..00000000 --- a/RyuzakiLib/methods/groups/get_participants.py +++ /dev/null @@ -1,17 +0,0 @@ -from typing import List, Optional, Union - -from ...scaffold import Scaffold -from ...types.groups.group_call_participant import GroupCallParticipant - - -class GetParticipants(Scaffold): - async def get_participants( - self, - chat_id: Union[int, str], - ) -> Optional[List[GroupCallParticipant]]: - chat_id = await self._resolve_chat_id(chat_id) - await self.get_call(chat_id) - - return await self._app.get_group_call_participants( - chat_id, - ) diff --git a/RyuzakiLib/methods/groups/join_group_call.py b/RyuzakiLib/methods/groups/join_group_call.py deleted file mode 100644 index caac9cd7..00000000 --- a/RyuzakiLib/methods/groups/join_group_call.py +++ /dev/null @@ -1,97 +0,0 @@ -import logging -from typing import Optional, Union - -from ntgcalls import ConnectionError, FileError, InvalidParams - -from ...exceptions import ( - AlreadyJoinedError, - ClientNotStarted, - NoActiveGroupCall, - NoMTProtoClientSet, - TelegramServerError, - UnMuteNeeded, -) -from ...mtproto import BridgedClient -from ...scaffold import Scaffold -from ...to_async import ToAsync -from ...types import JoinedVoiceChat -from ...types.input_stream.stream import Stream -from ..utilities.stream_params import StreamParams - -py_logger = logging.getLogger("ryuzakilib") - - -class JoinGroupCall(Scaffold): - async def join_group_call( - self, - chat_id: Union[int, str], - stream: Optional[Stream] = None, - invite_hash: str = None, - join_as=None, - ): - if join_as is None: - join_as = self._cache_local_peer - - chat_id = await self._resolve_chat_id(chat_id) - self._cache_user_peer.put(chat_id, join_as) - - if self._app is None: - raise NoMTProtoClientSet() - - if not self._is_running: - raise ClientNotStarted() - - chat_call = await self._app.get_full_chat( - chat_id, - ) - if chat_call is None: - raise NoActiveGroupCall() - - media_description = await StreamParams.get_stream_params( - stream, - ) - - try: - call_params: str = await ToAsync( - self._binding.create_call, - chat_id, - media_description, - ) - - result_params = await self._app.join_group_call( - chat_id, - call_params, - invite_hash, - media_description.video is None, - self._cache_user_peer.get(chat_id), - ) - - await ToAsync( - self._binding.connect, - chat_id, - result_params, - ) - - participants = await self._app.get_group_call_participants( - chat_id, - ) - - for x in participants: - if x.user_id == BridgedClient.chat_id( - self._cache_local_peer, - ): - self._need_unmute[chat_id] = x.muted_by_admin - - await self._on_event_update.propagate( - "RAW_UPDATE_HANDLER", - self, - JoinedVoiceChat(chat_id), - ) - except FileError: - raise FileNotFoundError() - except ConnectionError: - raise AlreadyJoinedError() - except InvalidParams: - raise UnMuteNeeded() - except Exception: - raise TelegramServerError() diff --git a/RyuzakiLib/methods/groups/leave_group_call.py b/RyuzakiLib/methods/groups/leave_group_call.py deleted file mode 100644 index 48b780c4..00000000 --- a/RyuzakiLib/methods/groups/leave_group_call.py +++ /dev/null @@ -1,54 +0,0 @@ -from typing import Union - -from ntgcalls import ConnectionError - -from ...exceptions import ( - ClientNotStarted, - NoActiveGroupCall, - NoMTProtoClientSet, - NotInGroupCallError, -) -from ...scaffold import Scaffold -from ...to_async import ToAsync -from ...types import LeftVoiceChat - - -class LeaveGroupCall(Scaffold): - async def leave_group_call( - self, - chat_id: Union[int, str], - ): - if self._app is None: - raise NoMTProtoClientSet() - - if not self._is_running: - raise ClientNotStarted() - - chat_id = await self._resolve_chat_id(chat_id) - chat_call = await self._app.get_full_chat( - chat_id, - ) - - if chat_call is None: - raise NoActiveGroupCall() - - await self._app.leave_group_call( - chat_id, - ) - - try: - await ToAsync( - self._binding.stop, - chat_id, - ) - except ConnectionError: - raise NotInGroupCallError() - - if chat_id in self._need_unmute: - del self._need_unmute[chat_id] - - await self._on_event_update.propagate( - "RAW_UPDATE_HANDLER", - self, - LeftVoiceChat(chat_id), - ) diff --git a/RyuzakiLib/methods/groups/nothing b/RyuzakiLib/methods/groups/nothing deleted file mode 100644 index e69de29b..00000000 diff --git a/RyuzakiLib/methods/nothing b/RyuzakiLib/methods/nothing deleted file mode 100644 index e69de29b..00000000 diff --git a/RyuzakiLib/methods/stream/__init__.py b/RyuzakiLib/methods/stream/__init__.py deleted file mode 100644 index af53f691..00000000 --- a/RyuzakiLib/methods/stream/__init__.py +++ /dev/null @@ -1,17 +0,0 @@ -from .change_stream import ChangeStream -from .mute_stream import MuteStream -from .pause_stream import PauseStream -from .played_time import PlayedTime -from .resume_stream import ResumeStream -from .unmute_stream import UnMuteStream - - -class StreamMethods( - ChangeStream, - MuteStream, - PauseStream, - PlayedTime, - ResumeStream, - UnMuteStream, -): - pass diff --git a/RyuzakiLib/methods/stream/change_stream.py b/RyuzakiLib/methods/stream/change_stream.py deleted file mode 100644 index 960ab6c2..00000000 --- a/RyuzakiLib/methods/stream/change_stream.py +++ /dev/null @@ -1,44 +0,0 @@ -import logging -from typing import Optional, Union - -from ntgcalls import FileError - -from ...exceptions import ClientNotStarted, NoMTProtoClientSet, NotInGroupCallError -from ...scaffold import Scaffold -from ...to_async import ToAsync -from ...types import ChangedStream -from ...types.input_stream.stream import Stream -from ..utilities.stream_params import StreamParams - -py_logger = logging.getLogger("ryuzakilib") - - -class ChangeStream(Scaffold): - async def change_stream( - self, - chat_id: Union[int, str], - stream: Optional[Stream] = None, - ): - if self._app is None: - raise NoMTProtoClientSet() - - if not self._is_running: - raise ClientNotStarted() - - chat_id = await self._resolve_chat_id(chat_id) - try: - await ToAsync( - self._binding.change_stream, - chat_id, - await StreamParams.get_stream_params(stream), - ) - except FileError: - raise FileNotFoundError() - except Exception: - raise NotInGroupCallError() - - await self._on_event_update.propagate( - "RAW_UPDATE_HANDLER", - self, - ChangedStream(chat_id), - ) diff --git a/RyuzakiLib/methods/stream/mute_stream.py b/RyuzakiLib/methods/stream/mute_stream.py deleted file mode 100644 index abce33d0..00000000 --- a/RyuzakiLib/methods/stream/mute_stream.py +++ /dev/null @@ -1,28 +0,0 @@ -from typing import Union - -from ntgcalls import ConnectionError - -from ...exceptions import ClientNotStarted, NoMTProtoClientSet, NotInGroupCallError -from ...scaffold import Scaffold -from ...to_async import ToAsync - - -class MuteStream(Scaffold): - async def mute_stream( - self, - chat_id: Union[int, str], - ): - if self._app is None: - raise NoMTProtoClientSet() - - if not self._is_running: - raise ClientNotStarted() - - chat_id = await self._resolve_chat_id(chat_id) - try: - return await ToAsync( - self._binding.mute, - chat_id, - ) - except ConnectionError: - raise NotInGroupCallError() diff --git a/RyuzakiLib/methods/stream/nothing b/RyuzakiLib/methods/stream/nothing deleted file mode 100644 index e69de29b..00000000 diff --git a/RyuzakiLib/methods/stream/pause_stream.py b/RyuzakiLib/methods/stream/pause_stream.py deleted file mode 100644 index bf9019a8..00000000 --- a/RyuzakiLib/methods/stream/pause_stream.py +++ /dev/null @@ -1,35 +0,0 @@ -from typing import Union - -from ntgcalls import ConnectionError - -from ...exceptions import ClientNotStarted, NoMTProtoClientSet, NotInGroupCallError -from ...scaffold import Scaffold -from ...to_async import ToAsync -from ...types import PausedStream - - -class PauseStream(Scaffold): - async def pause_stream( - self, - chat_id: Union[int, str], - ): - if self._app is None: - raise NoMTProtoClientSet() - - if not self._is_running: - raise ClientNotStarted() - - chat_id = await self._resolve_chat_id(chat_id) - try: - status = await ToAsync( - self._binding.pause, - chat_id, - ) - await self._on_event_update.propagate( - "RAW_UPDATE_HANDLER", - self, - PausedStream(chat_id), - ) - return status - except ConnectionError: - raise NotInGroupCallError() diff --git a/RyuzakiLib/methods/stream/played_time.py b/RyuzakiLib/methods/stream/played_time.py deleted file mode 100644 index c3d7195c..00000000 --- a/RyuzakiLib/methods/stream/played_time.py +++ /dev/null @@ -1,28 +0,0 @@ -from typing import Union - -from ntgcalls import ConnectionError - -from ...exceptions import ClientNotStarted, NoMTProtoClientSet, NotInGroupCallError -from ...scaffold import Scaffold -from ...to_async import ToAsync - - -class PlayedTime(Scaffold): - async def played_time( - self, - chat_id: Union[int, str], - ): - if self._app is None: - raise NoMTProtoClientSet() - - if not self._is_running: - raise ClientNotStarted() - - chat_id = await self._resolve_chat_id(chat_id) - try: - return await ToAsync( - self._binding.time, - chat_id, - ) - except ConnectionError: - raise NotInGroupCallError() diff --git a/RyuzakiLib/methods/stream/resume_stream.py b/RyuzakiLib/methods/stream/resume_stream.py deleted file mode 100644 index df85cf2f..00000000 --- a/RyuzakiLib/methods/stream/resume_stream.py +++ /dev/null @@ -1,35 +0,0 @@ -from typing import Union - -from ntgcalls import ConnectionError - -from ...exceptions import ClientNotStarted, NoMTProtoClientSet, NotInGroupCallError -from ...scaffold import Scaffold -from ...to_async import ToAsync -from ...types import ResumedStream - - -class ResumeStream(Scaffold): - async def resume_stream( - self, - chat_id: Union[int, str], - ): - if self._app is None: - raise NoMTProtoClientSet() - - if not self._is_running: - raise ClientNotStarted() - - chat_id = await self._resolve_chat_id(chat_id) - try: - status = await ToAsync( - self._binding.resume, - chat_id, - ) - await self._on_event_update.propagate( - "RAW_UPDATE_HANDLER", - self, - ResumedStream(chat_id), - ) - return status - except ConnectionError: - raise NotInGroupCallError() diff --git a/RyuzakiLib/methods/stream/unmute_stream.py b/RyuzakiLib/methods/stream/unmute_stream.py deleted file mode 100644 index c284e16d..00000000 --- a/RyuzakiLib/methods/stream/unmute_stream.py +++ /dev/null @@ -1,28 +0,0 @@ -from typing import Union - -from ntgcalls import ConnectionError - -from ...exceptions import ClientNotStarted, NoMTProtoClientSet, NotInGroupCallError -from ...scaffold import Scaffold -from ...to_async import ToAsync - - -class UnMuteStream(Scaffold): - async def unmute_stream( - self, - chat_id: Union[int, str], - ): - if self._app is None: - raise NoMTProtoClientSet() - - if not self._is_running: - raise ClientNotStarted() - - chat_id = await self._resolve_chat_id(chat_id) - try: - return await ToAsync( - self._binding.unmute, - chat_id, - ) - except ConnectionError: - raise NotInGroupCallError() diff --git a/RyuzakiLib/methods/utilities/__init__.py b/RyuzakiLib/methods/utilities/__init__.py deleted file mode 100644 index 7ab1ee03..00000000 --- a/RyuzakiLib/methods/utilities/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -from .cache_peer import CachePeer -from .call_holder import CallHolder -from .get_max_voice_chat import GetMaxVoiceChat -from .mtproto_handler import MTProtoHandler -from .ping import Ping -from .resolve_chat_id import ResolveChatID -from .run import Run -from .start import Start - - -class Utilities( - CachePeer, - CallHolder, - GetMaxVoiceChat, - Ping, - MTProtoHandler, - ResolveChatID, - Run, - Start, -): - pass diff --git a/RyuzakiLib/methods/utilities/cache_peer.py b/RyuzakiLib/methods/utilities/cache_peer.py deleted file mode 100644 index 145f7fa1..00000000 --- a/RyuzakiLib/methods/utilities/cache_peer.py +++ /dev/null @@ -1,7 +0,0 @@ -from RyuzakiLib.scaffold import Scaffold - - -class CachePeer(Scaffold): - @property - def cache_peer(self): - return self._cache_local_peer diff --git a/RyuzakiLib/methods/utilities/call_holder.py b/RyuzakiLib/methods/utilities/call_holder.py deleted file mode 100644 index 9b5f22fa..00000000 --- a/RyuzakiLib/methods/utilities/call_holder.py +++ /dev/null @@ -1,66 +0,0 @@ -from typing import Union - -from ntgcalls import StreamStatus - -from ...exceptions import GroupCallNotFound -from ...scaffold import Scaffold -from ...types.groups.group_call import GroupCall -from ...types.list import List - - -class CallHolder(Scaffold): - PLAYING = 1 - PAUSED = 2 - IDLE = 3 - - def __init__(self): - super().__init__() - self._conversions = { - StreamStatus.Playing: self.PLAYING, - StreamStatus.Paused: self.PAUSED, - StreamStatus.Idling: self.IDLE, - } - - @property - def calls(self): - calls_list: dict = self._binding.calls() - return List([GroupCall(x, self._conversions[calls_list[x]]) for x in calls_list]) - - @property - def active_calls(self): - calls_list: dict = self._binding.calls() - return List( - [ - GroupCall(x, self._conversions[calls_list[x]]) - for x in calls_list - if calls_list[x] != StreamStatus.Idling - ] - ) - - async def get_active_call( - self, - chat_id: Union[int, str], - ): - calls_list: dict = self._binding.calls() - chat_id = await self._resolve_chat_id(chat_id) - - if chat_id in calls_list: - if calls_list[chat_id] != StreamStatus.Idling: - return GroupCall( - chat_id, - self._conversions[calls_list[chat_id]], - ) - - raise GroupCallNotFound(chat_id) - - async def get_call( - self, - chat_id: int, - ): - calls_list: dict = self._binding.calls() - chat_id = await self._resolve_chat_id(chat_id) - - if chat_id in calls_list: - return GroupCall(chat_id, self._conversions[calls_list[chat_id]]) - - raise GroupCallNotFound(chat_id) diff --git a/RyuzakiLib/methods/utilities/get_max_voice_chat.py b/RyuzakiLib/methods/utilities/get_max_voice_chat.py deleted file mode 100644 index 216efa96..00000000 --- a/RyuzakiLib/methods/utilities/get_max_voice_chat.py +++ /dev/null @@ -1,10 +0,0 @@ -import psutil - -from ...scaffold import Scaffold - - -class GetMaxVoiceChat(Scaffold): - @staticmethod - def get_max_voice_chat(consumption=5): - core_count = psutil.cpu_count() - return int((100 / consumption) * core_count) diff --git a/RyuzakiLib/methods/utilities/idle.py b/RyuzakiLib/methods/utilities/idle.py deleted file mode 100644 index 14befe66..00000000 --- a/RyuzakiLib/methods/utilities/idle.py +++ /dev/null @@ -1,30 +0,0 @@ -import asyncio -import logging -import signal -from signal import SIGABRT, SIGINT, SIGTERM -from signal import signal as signal_fn - -py_logger = logging.getLogger("ryuzakilib") - - -is_idling = False - -# Signal number to name -signals = { - k: v for v, k in signal.__dict__.items() if v.startswith("SIG") and not v.startswith("SIG_") -} - - -async def idle(): - global is_idling - - def signal_handler(signum, __): - global is_idling - py_logger.info(f"Stop signal received ({signals[signum]}). Exiting...") - is_idling = False - - for s in (SIGINT, SIGTERM, SIGABRT): - signal_fn(s, signal_handler) - is_idling = True - while is_idling: - await asyncio.sleep(1) diff --git a/RyuzakiLib/methods/utilities/mtproto_handler.py b/RyuzakiLib/methods/utilities/mtproto_handler.py deleted file mode 100644 index f5136788..00000000 --- a/RyuzakiLib/methods/utilities/mtproto_handler.py +++ /dev/null @@ -1,110 +0,0 @@ -from ntgcalls import ConnectionNotFound - -from ...scaffold import Scaffold -from ...to_async import ToAsync -from ...types import Update -from ...types.groups import ( - GroupCallParticipant, - JoinedGroupCallParticipant, - LeftGroupCallParticipant, - UpdatedGroupCallParticipant, -) - - -class MTProtoHandler(Scaffold): - async def _init_mtproto(self): - if not self._app.is_connected: - await self._app.start() - - self._my_id = await self._app.get_id() - self._cache_local_peer = await self._app.resolve_peer( - self._my_id, - ) - - def _handle_mtproto(self): - @self._app.on_kicked() - async def kicked_handler(chat_id: int): - try: - await ToAsync( - self._binding.stop, - chat_id, - ) - except ConnectionNotFound: - pass - - await self._on_event_update.propagate( - "KICK_HANDLER", - self, - chat_id, - ) - self._cache_user_peer.pop(chat_id) - - @self._app.on_closed_voice_chat() - async def closed_voice_chat_handler(chat_id: int): - self._cache_user_peer.pop(chat_id) - try: - await ToAsync( - self._binding.stop, - chat_id, - ) - except ConnectionNotFound: - pass - - await self._on_event_update.propagate( - "CLOSED_HANDLER", - self, - chat_id, - ) - - @self._app.on_receive_invite() - async def receive_invite_handler(action): - await self._on_event_update.propagate( - "INVITE_HANDLER", - self, - action, - ) - - @self._app.on_left_group() - async def left_handler(chat_id: int): - self._cache_user_peer.pop(chat_id) - try: - await ToAsync( - self._binding.stop, - chat_id, - ) - except ConnectionNotFound: - pass - await self._on_event_update.propagate( - "LEFT_HANDLER", - self, - chat_id, - ) - - @self._app.on_participants_change() - async def participants_handler( - chat_id: int, - participant: GroupCallParticipant, - just_joined: bool, - just_left: bool, - ): - if participant.user_id == self._my_id: - return - update_participant: Update = UpdatedGroupCallParticipant( - chat_id, - participant, - ) - if just_joined: - update_participant = JoinedGroupCallParticipant( - chat_id, - participant, - ) - elif just_left: - update_participant = LeftGroupCallParticipant( - chat_id, - participant, - ) - await self._on_event_update.propagate( - "PARTICIPANTS_LIST", - self, - update_participant, - ) diff --git a/RyuzakiLib/methods/utilities/nothing b/RyuzakiLib/methods/utilities/nothing deleted file mode 100644 index e69de29b..00000000 diff --git a/RyuzakiLib/methods/utilities/ping.py b/RyuzakiLib/methods/utilities/ping.py deleted file mode 100644 index 4667fbe3..00000000 --- a/RyuzakiLib/methods/utilities/ping.py +++ /dev/null @@ -1,13 +0,0 @@ -from time import time - -from ...scaffold import Scaffold -from ...to_async import ToAsync - - -class Ping(Scaffold): - @property - async def ping(self) -> float: - start_time: float = time() - await ToAsync(self._binding.ping) - - return round((time() - start_time) * 1000.0, 5) diff --git a/RyuzakiLib/methods/utilities/resolve_chat_id.py b/RyuzakiLib/methods/utilities/resolve_chat_id.py deleted file mode 100644 index 149140db..00000000 --- a/RyuzakiLib/methods/utilities/resolve_chat_id.py +++ /dev/null @@ -1,16 +0,0 @@ -from typing import Union - -from ...mtproto import BridgedClient -from ...scaffold import Scaffold - - -class ResolveChatID(Scaffold): - async def _resolve_chat_id(self, chat_id: Union[int, str]) -> int: - try: - chat_id = int(chat_id) - except ValueError: - chat_id = BridgedClient.chat_id( - await self._app.resolve_peer(chat_id), - ) - - return chat_id diff --git a/RyuzakiLib/methods/utilities/run.py b/RyuzakiLib/methods/utilities/run.py deleted file mode 100644 index 517036f5..00000000 --- a/RyuzakiLib/methods/utilities/run.py +++ /dev/null @@ -1,8 +0,0 @@ -from ...scaffold import Scaffold -from .idle import idle - - -class Run(Scaffold): - async def run(self): - await self.start() - await idle() diff --git a/RyuzakiLib/methods/utilities/start.py b/RyuzakiLib/methods/utilities/start.py deleted file mode 100644 index d3402455..00000000 --- a/RyuzakiLib/methods/utilities/start.py +++ /dev/null @@ -1,83 +0,0 @@ -import asyncio -from asyncio.log import logger - -from ntgcalls import ConnectionNotFound, MediaState, StreamType - -from RyuzakiLib.types import GroupCallParticipant, StreamAudioEnded, StreamVideoEnded - -from ...exceptions import PyTgCallsAlreadyRunning -from ...pytgcalls_session import PyTgCallsSession -from ...scaffold import Scaffold - - -class Start(Scaffold): - async def start(self): - loop = asyncio.get_event_loop() - - @self._app.on_participants_change() - async def participants_handler( - chat_id: int, - participant: GroupCallParticipant, - just_joined: bool, - just_left: bool, - ): - if chat_id in self._need_unmute: - need_unmute = self._need_unmute[chat_id] - if ( - not just_joined - and not just_left - and need_unmute - and not participant.muted_by_admin - ): - try: - await update_status( - chat_id, - self._binding.get_state(chat_id), - ) - except ConnectionNotFound: - pass - self._need_unmute[chat_id] = participant.muted_by_admin - - def stream_upgrade(chat_id: int, state: MediaState): - asyncio.run_coroutine_threadsafe( - update_status(chat_id, state), - loop, - ) - - async def update_status(chat_id: int, state: MediaState): - try: - await self._app.set_call_status( - chat_id, - state.muted, - state.video_paused, - state.video_stopped, - self._cache_user_peer.get(chat_id), - ) - except Exception as e: - logger.error(f"SetVideoCallStatus: {e}") - - def stream_ended(chat_id: int, stream: StreamType): - async def async_stream_ended(): - await self._on_event_update.propagate( - "STREAM_END_HANDLER", - self, - StreamAudioEnded( - chat_id, - ) - if stream == stream.Audio - else StreamVideoEnded(chat_id), - ) - - asyncio.run_coroutine_threadsafe(async_stream_ended(), loop) - - if not self._is_running: - self._is_running = True - self._env_checker.check_environment() - await self._init_mtproto() - self._handle_mtproto() - - self._binding.on_stream_end(stream_ended) - self._binding.on_upgrade(stream_upgrade) - await PyTgCallsSession().start() - else: - raise PyTgCallsAlreadyRunning() diff --git a/RyuzakiLib/methods/utilities/stream_params.py b/RyuzakiLib/methods/utilities/stream_params.py deleted file mode 100644 index 6e038710..00000000 --- a/RyuzakiLib/methods/utilities/stream_params.py +++ /dev/null @@ -1,51 +0,0 @@ -import logging -from typing import Optional - -from ntgcalls import AudioDescription, MediaDescription, VideoDescription - -from RyuzakiLib.types.input_stream.audio_image_piped import AudioImagePiped -from RyuzakiLib.types.input_stream.smart_stream import SmartStream -from RyuzakiLib.types.input_stream.stream import Stream - -py_logger = logging.getLogger("ryuzakilib") - - -class StreamParams: - @staticmethod - async def get_stream_params(stream: Optional[Stream]) -> MediaDescription: - audio_description = None - video_description = None - - if stream is not None: - if isinstance(stream, SmartStream): - await stream.check_stream() - - if stream.stream_audio is not None: - audio_description = AudioDescription( - input_mode=stream.stream_audio.input_mode, - input=stream.stream_audio.path, - sample_rate=stream.stream_audio.parameters.bitrate, - bits_per_sample=16, - channel_count=stream.stream_audio.parameters.channels, - ) - - if stream.stream_video is not None: - if stream.stream_video.parameters.frame_rate % 5 != 0 and not isinstance( - stream, AudioImagePiped - ): - py_logger.warning( - "For better experience the " "video frame rate must be a multiple of 5", - ) - - video_description = VideoDescription( - input_mode=stream.stream_video.input_mode, - input=stream.stream_video.path, - width=stream.stream_video.parameters.width, - height=stream.stream_video.parameters.height, - fps=stream.stream_video.parameters.frame_rate, - ) - - return MediaDescription( - audio=audio_description, - video=video_description, - ) From a7f1747e2a1303ceb2b472043931dfd8d6241006 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Wed, 21 Aug 2024 17:34:57 +0700 Subject: [PATCH 072/152] _ --- RyuzakiLib/py_tgcalls.py | 42 ---------------------------------------- 1 file changed, 42 deletions(-) delete mode 100644 RyuzakiLib/py_tgcalls.py diff --git a/RyuzakiLib/py_tgcalls.py b/RyuzakiLib/py_tgcalls.py deleted file mode 100644 index 34a75904..00000000 --- a/RyuzakiLib/py_tgcalls.py +++ /dev/null @@ -1,42 +0,0 @@ -import atexit -from typing import Any - -from ntgcalls import NTgCalls - -from .environment import Environment -from .handlers import HandlersHolder -from .methods import Methods -from .mtproto import MtProtoClient -from .scaffold import Scaffold -from .types import Cache -from .types.update_solver import UpdateSolver - - -class PyTgCalls(Methods, Scaffold): - def __init__( - self, - app: Any, - cache_duration: int = 120, - ): - super().__init__() - self._app = MtProtoClient( - cache_duration, - app, - ) - self._is_running = False - self._env_checker = Environment( - self._REQUIRED_PYROGRAM_VERSION, - self._REQUIRED_TELETHON_VERSION, - self._REQUIRED_HYDROGRAM_VERSION, - self._app.client, - ) - self._cache_user_peer = Cache() - self._wait_result = UpdateSolver() - self._on_event_update = HandlersHolder() - self._binding = NTgCalls() - - def cleanup(): - if self._async_core is not None: - self._async_core.cancel() - - atexit.register(cleanup) From 7bf2fad77bce957f40cbd18935799789df8a361d Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Wed, 21 Aug 2024 17:35:20 +0700 Subject: [PATCH 073/152] _ --- RyuzakiLib/ffmpeg.py | 256 ------------------------------------------- 1 file changed, 256 deletions(-) delete mode 100644 RyuzakiLib/ffmpeg.py diff --git a/RyuzakiLib/ffmpeg.py b/RyuzakiLib/ffmpeg.py deleted file mode 100644 index 3e759b29..00000000 --- a/RyuzakiLib/ffmpeg.py +++ /dev/null @@ -1,256 +0,0 @@ -import asyncio -import logging -import re -import shlex -import subprocess -from json import JSONDecodeError, loads -from typing import Dict, List, Optional, Union - -from ntgcalls import FFmpegError - -from .exceptions import InvalidVideoProportion, NoAudioSourceFound, NoVideoSourceFound -from .types.input_stream.audio_parameters import AudioParameters -from .types.input_stream.video_parameters import VideoParameters - - -async def check_stream( - ffmpeg_parameters: str, - path: str, - stream_parameters: Union[AudioParameters, VideoParameters], - before_commands: List[str] = None, - headers: Optional[Dict[str, str]] = None, - need_image: bool = False, -): - try: - ffprobe = await asyncio.create_subprocess_exec( - *tuple( - await cleanup_commands( - build_command( - "ffprobe", - ffmpeg_parameters, - path, - stream_parameters, - before_commands, - headers, - ), - ), - ), - stdout=asyncio.subprocess.PIPE, - stderr=asyncio.subprocess.PIPE, - ) - stream_list = [] - try: - stdout, _ = await asyncio.wait_for( - ffprobe.communicate(), - timeout=30, - ) - result = loads(stdout.decode("utf-8")) or {} - stream_list = result.get("streams", []) - except (subprocess.TimeoutExpired, JSONDecodeError): - pass - - have_video = False - have_audio = False - have_valid_video = False - - original_width, original_height = 0, 0 - - for stream in stream_list: - codec_type = stream.get("codec_type", "") - codec_name = stream.get("codec_name", "") - image_codecs = ["png", "jpeg", "jpg", "mjpeg"] - is_valid = not need_image and codec_name in image_codecs - if codec_type == "video" and not is_valid: - have_video = True - original_width = int(stream.get("width", 0)) - original_height = int(stream.get("height", 0)) - if original_height and original_width: - have_valid_video = True - elif codec_type == "audio": - have_audio = True - - if isinstance(stream_parameters, VideoParameters): - if not have_video: - raise NoVideoSourceFound(path) - if not have_valid_video: - raise InvalidVideoProportion( - "Video proportion not found", - ) - - ratio = float(original_width) / original_height - new_w = min(original_width, stream_parameters.width) - new_h = int(new_w / ratio) - - if new_h > stream_parameters.height: - new_h = stream_parameters.height - new_w = int(new_h * ratio) - - new_w = new_w - 1 if new_w % 2 else new_w - new_h = new_h - 1 if new_h % 2 else new_h - stream_parameters.height = new_h - stream_parameters.width = new_w - - if isinstance(stream_parameters, AudioParameters) and not have_audio: - raise NoAudioSourceFound(path) - except FileNotFoundError: - raise FFmpegError("ffprobe not installed") - - -async def cleanup_commands(commands: List[str]) -> List[str]: - try: - proc_res = await asyncio.create_subprocess_exec( - commands[0], - "-h", - stdout=asyncio.subprocess.PIPE, - stderr=asyncio.subprocess.PIPE, - ) - result = "" - try: - stdout, _ = await asyncio.wait_for( - proc_res.communicate(), - timeout=30, - ) - result = stdout.decode("utf-8") - except (subprocess.TimeoutExpired, JSONDecodeError): - pass - supported = re.findall(r"(-.*?)\s+", result) - new_commands = [] - ignore_next = False - - for v in commands: - if len(v) > 0: - if v[0] == "-": - ignore_next = v not in supported - if not ignore_next: - new_commands += [v] - return new_commands - except FileNotFoundError: - raise FFmpegError(f"{commands[0]} not installed") - - -def build_command( - name: str, - ffmpeg_parameters: str, - path: str, - stream_parameters: Union[AudioParameters, VideoParameters], - before_commands: List[str] = None, - headers: Optional[Dict[str, str]] = None, -) -> List[str]: - command = _get_stream_params(ffmpeg_parameters) - - if isinstance(stream_parameters, VideoParameters): - command = command["video"] - else: - command = command["audio"] - - ffmpeg_command: List = [name] - - ffmpeg_command += command["start"] - - if name == "ffprobe": - ffmpeg_command += [ - "-v", - "error", - "-show_entries", - "stream=width,height,codec_type,codec_name", - "-of", - "json", - ] - - if before_commands: - ffmpeg_command += before_commands - - if headers is not None: - for i in headers: - ffmpeg_command.append("-headers") - ffmpeg_command.append(f'"{i}: {headers[i]}"') - - ffmpeg_command += [ - "-y", - "-nostdin", - "-i", - f'"{path}"' if name == "ffmpeg" else path, - ] - ffmpeg_command += command["mid"] - - if name == "ffmpeg": - ffmpeg_command += _build_ffmpeg_options(stream_parameters) - - ffmpeg_command += command["end"] - if name == "ffmpeg": - ffmpeg_command.append("pipe:1") - - return ffmpeg_command - - -def _get_stream_params(command: str): - arg_names = ["base", "audio", "video"] - command_args: Dict = {arg: [] for arg in arg_names} - current_arg = arg_names[0] - - for part in shlex.split(command): - arg_name = part[2:] - if arg_name in arg_names: - current_arg = arg_name - else: - command_args[current_arg].append(part) - command_args = { - command: _extract_stream_params(command_args[command]) for command in command_args - } - - for arg in arg_names[1:]: - for x in command_args[arg_names[0]]: - command_args[arg][x] += command_args[arg_names[0]][x] - - del command_args[arg_names[0]] - - return command_args - - -def _extract_stream_params(command: List[str]): - arg_names = ["start", "mid", "end"] - command_args: Dict = {arg: [] for arg in arg_names} - current_arg = arg_names[0] - - for part in command: - arg_name = part[3:] - if arg_name in arg_names: - current_arg = arg_name - else: - command_args[current_arg].append(part) - - return command_args - - -def _build_ffmpeg_options( - stream_parameters: Union[AudioParameters, VideoParameters], -) -> List[str]: - log_level = logging.getLogger().level - ffmpeg_level = "info" if log_level == logging.DEBUG else "quiet" - - options = ["-v", ffmpeg_level, "-f"] - - if isinstance(stream_parameters, VideoParameters): - options.extend( - [ - "rawvideo", - "-r", - str(stream_parameters.frame_rate), - "-pix_fmt", - "yuv420p", - "-vf", - f"scale={stream_parameters.width}:{stream_parameters.height}", - ] - ) - else: - options.extend( - [ - "s16le", - "-ac", - str(stream_parameters.channels), - "-ar", - str(stream_parameters.bitrate), - ] - ) - - return options From 45379839215aff0beb33d81fa6f7fd706fe59592 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Wed, 21 Aug 2024 17:36:00 +0700 Subject: [PATCH 074/152] _ --- RyuzakiLib/pytgcalls_session.py | 77 --------------------------------- 1 file changed, 77 deletions(-) delete mode 100644 RyuzakiLib/pytgcalls_session.py diff --git a/RyuzakiLib/pytgcalls_session.py b/RyuzakiLib/pytgcalls_session.py deleted file mode 100644 index 0b2a2052..00000000 --- a/RyuzakiLib/pytgcalls_session.py +++ /dev/null @@ -1,77 +0,0 @@ -import asyncio -import re -import sys -from datetime import date - -import ntgcalls -from aiohttp import ClientConnectionError, ClientResponse, ClientSession - -from .__version__ import __version__ -from .version_manager import VersionManager - - -class PyTgCallsSession: - notice_displayed = False - - async def start(self): - if not self.notice_displayed: - PyTgCallsSession.notice_displayed = True - year = date.today().year - print( - f"PyTgCalls v{__version__} powered by " - f"NTgCalls v{ntgcalls.__version__}, Copyright (C) " - f"2021-{year} Laky-64 \n" - "Licensed under the terms of the GNU Lesser " - "General Public License v3 or later (LGPLv3+)\n", - ) - try: - remote_stable_ver = await self._remote_version("master") - remote_dev_ver = await self._remote_version("dev") - remote_test_ver = remote_stable_ver + ".99" - if VersionManager.version_tuple(__version__) > VersionManager.version_tuple( - remote_test_ver - ): - remote_ver = remote_readable_ver = remote_dev_ver - my_ver = __version__ - else: - remote_readable_ver = remote_stable_ver - remote_ver = remote_test_ver - my_ver = __version__ + ".99" - if VersionManager.version_tuple(remote_ver) > VersionManager.version_tuple(my_ver): - text = ( - f"Update Available!\n" - f"New PyTgCalls v{remote_readable_ver} " - f"is now available!\n" - ) - if not sys.platform.startswith("win"): - print(f"\033[93m{text}\033[0m") - else: - print(text) - except asyncio.exceptions.TimeoutError: - pass - except ClientConnectionError: - pass - - @staticmethod - async def _remote_version(branch: str): - async def get_async(url) -> str: - session = ClientSession() - try: - response: ClientResponse = await session.get(url, timeout=5) - result_text = await response.text() - response.close() - return result_text - finally: - await session.close() - - result = re.findall( - "__version__ = '(.*?)'", - ( - await get_async( - f"https://raw.githubusercontent.com/" - f"pytgcalls/pytgcalls/{branch}" - f"/pytgcalls/__version__.py", - ) - ), - ) - return result[0] if len(result) > 0 else __version__ From 15cc78d16f790a2c6aacbb1bf715e25b8825858d Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Wed, 21 Aug 2024 17:36:22 +0700 Subject: [PATCH 075/152] _ --- RyuzakiLib/stream_type.py | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 RyuzakiLib/stream_type.py diff --git a/RyuzakiLib/stream_type.py b/RyuzakiLib/stream_type.py deleted file mode 100644 index 86931357..00000000 --- a/RyuzakiLib/stream_type.py +++ /dev/null @@ -1,37 +0,0 @@ -from deprecation import deprecated - - -@deprecated( - deprecated_in="1.0.0.dev1", - details="This enum is no longer supported.", -) -class StreamType: - def __init__(self): - self._stream_type = 0 - - @property - def live_stream(self): - self._stream_type = 3 - return self - - @property - def local_stream(self): - self._stream_type = 10 - return self - - """ - *** Pulse Stream *** - Send bytes like a pulsation, and this reduce the slice, - because the slice is too heavy - - Support: LiveStream, LocalStream - """ - - @property - def pulse_stream(self): - self._stream_type = 4 - return self - - @property - def stream_mode(self): - return self._stream_type From ad270f28be72adf25dcd8e171ad545d2084d1f0f Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Wed, 21 Aug 2024 17:37:20 +0700 Subject: [PATCH 076/152] _ --- RyuzakiLib/sync.py | 108 --------------------------------------------- 1 file changed, 108 deletions(-) delete mode 100644 RyuzakiLib/sync.py diff --git a/RyuzakiLib/sync.py b/RyuzakiLib/sync.py deleted file mode 100644 index 6de9514f..00000000 --- a/RyuzakiLib/sync.py +++ /dev/null @@ -1,108 +0,0 @@ -import asyncio -import functools -import inspect -import threading - -from .custom_api import CustomApi -from .media_devices import MediaDevices -from .methods import Methods -from .methods.utilities import idle as idle_module -from .mtproto import MtProtoClient - - -def async_to_sync(obj, name): - function = getattr(obj, name) - main_loop = asyncio.get_event_loop() - - def async_to_sync_gen(agen, loop, is_main_thread): - async def a_next(a): - try: - return await a.__anext__(), False - except StopAsyncIteration: - return None, True - - while True: - if is_main_thread: - item, done = loop.run_until_complete( - a_next(agen), - ) - else: - item, done = asyncio.run_coroutine_threadsafe( - a_next(agen), - loop, - ).result() - if done: - break - yield item - - @functools.wraps(function) - def async_to_sync_wrap(*args, **kwargs): - coroutine = function(*args, **kwargs) - - try: - loop = asyncio.get_event_loop() - except RuntimeError: - loop = asyncio.new_event_loop() - asyncio.set_event_loop(loop) - - if threading.current_thread() is threading.main_thread() or not main_loop.is_running(): - if loop.is_running(): - return coroutine - else: - if inspect.iscoroutine(coroutine): - return loop.run_until_complete(coroutine) - - if inspect.isasyncgen(coroutine): - return async_to_sync_gen( - coroutine, - loop, - True, - ) - else: - if inspect.iscoroutine(coroutine): - if loop.is_running(): - - async def coro_wrapper(): - return await asyncio.wrap_future( - asyncio.run_coroutine_threadsafe( - coroutine, - main_loop, - ), - ) - - return coro_wrapper() - else: - return asyncio.run_coroutine_threadsafe( - coroutine, - main_loop, - ).result() - - if inspect.isasyncgen(coroutine): - if loop.is_running(): - return coroutine - else: - return async_to_sync_gen( - coroutine, - main_loop, - False, - ) - - setattr(obj, name, async_to_sync_wrap) - - -def wrap(source): - for name in dir(source): - method = getattr(source, name) - - if not name.startswith("_"): - if inspect.iscoroutinefunction(method) or inspect.isasyncgenfunction(method): - async_to_sync(source, name) - - -# Wrap all Client's relevant methods -wrap(Methods) -wrap(CustomApi) -wrap(MtProtoClient) -wrap(MediaDevices) -async_to_sync(idle_module, "idle") -idle = getattr(idle_module, "idle") From ce3a7044e3471212ade7ee7f3f8dfd69c053ca0a Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Wed, 21 Aug 2024 17:37:44 +0700 Subject: [PATCH 077/152] _ --- RyuzakiLib/exceptions.py | 153 --------------------------------------- 1 file changed, 153 deletions(-) delete mode 100644 RyuzakiLib/exceptions.py diff --git a/RyuzakiLib/exceptions.py b/RyuzakiLib/exceptions.py deleted file mode 100644 index 472d5071..00000000 --- a/RyuzakiLib/exceptions.py +++ /dev/null @@ -1,153 +0,0 @@ -class TooOldPyrogramVersion(Exception): - def __init__( - self, - version_needed: str, - pyrogram_version: str, - ): - super().__init__( - f"Needed pyrogram {version_needed}+, " "actually installed is " f"{pyrogram_version}", - ) - - -class TooOldTelethonVersion(Exception): - def __init__( - self, - version_needed: str, - telethon_version: str, - ): - super().__init__( - f"Needed telethon {version_needed}+, " "actually installed is " f"{telethon_version}", - ) - - -class TooOldHydrogramVersion(Exception): - def __init__( - self, - version_needed: str, - hydrogram_version: str, - ): - super().__init__( - f"Needed hydrogram {version_needed}+, " - "actually installed is " - f"{hydrogram_version}", - ) - - -class InvalidStreamMode(Exception): - def __init__(self): - super().__init__( - "Invalid stream mode", - ) - - -class NoMTProtoClientSet(Exception): - def __init__(self): - super().__init__( - "No MTProto client set", - ) - - -class NoActiveGroupCall(Exception): - def __init__(self): - super().__init__( - "No active group call", - ) - - -class NotInGroupCallError(Exception): - def __init__(self): - super().__init__( - "The userbot there isn't in a group call", - ) - - -class AlreadyJoinedError(Exception): - def __init__(self): - super().__init__( - "Already joined into group call", - ) - - -class TelegramServerError(Exception): - def __init__(self): - super().__init__( - "Telegram Server is having some " "internal problems", - ) - - -class ClientNotStarted(Exception): - def __init__(self): - super().__init__( - "Ensure you have started the process with start() " "before calling this method", - ) - - -class PyTgCallsAlreadyRunning(Exception): - def __init__(self): - super().__init__( - "PyTgCalls client is already running", - ) - - -class TooManyCustomApiDecorators(Exception): - def __init__(self): - super().__init__( - "Too Many Custom Api Decorators", - ) - - -class GroupCallNotFound(Exception): - def __init__( - self, - chat_id: int, - ): - super().__init__( - f"Group call not found with the chat id {chat_id}", - ) - - -class InvalidMTProtoClient(Exception): - def __init__(self): - super().__init__( - "Invalid MTProto Client", - ) - - -class NoVideoSourceFound(Exception): - def __init__(self, path: str): - super().__init__( - f'No video source found on "{path}"', - ) - - -class InvalidVideoProportion(Exception): - def __init__(self, message: str): - super().__init__( - message, - ) - - -class NoAudioSourceFound(Exception): - def __init__(self, path: str): - super().__init__( - f'No audio source found on "{path}"', - ) - - -class UnMuteNeeded(Exception): - def __init__(self): - super().__init__( - "Needed to unmute the userbot", - ) - - -class GpytranslateException(Exception): - pass - - -class TranslationError(GpytranslateException): - def __init__(self, exception: Exception): - self.args = (exception,) - - def __str__(self) -> str: - return f"An error occurred while trying to translate/tts: {self.args[0]!r}" From b69c0430e0f289056750d5888c41a17d57074f11 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Wed, 21 Aug 2024 17:38:07 +0700 Subject: [PATCH 078/152] _ --- RyuzakiLib/mtproto/__init__.py | 4 - RyuzakiLib/mtproto/bridged_client.py | 117 ------- RyuzakiLib/mtproto/client_cache.py | 168 ---------- RyuzakiLib/mtproto/hydrogram_client.py | 430 ------------------------ RyuzakiLib/mtproto/mtproto_client.py | 186 ----------- RyuzakiLib/mtproto/nothing | 0 RyuzakiLib/mtproto/pyrogram_client.py | 438 ------------------------- RyuzakiLib/mtproto/telethon_client.py | 407 ----------------------- 8 files changed, 1750 deletions(-) delete mode 100644 RyuzakiLib/mtproto/__init__.py delete mode 100644 RyuzakiLib/mtproto/bridged_client.py delete mode 100644 RyuzakiLib/mtproto/client_cache.py delete mode 100644 RyuzakiLib/mtproto/hydrogram_client.py delete mode 100644 RyuzakiLib/mtproto/mtproto_client.py delete mode 100644 RyuzakiLib/mtproto/nothing delete mode 100644 RyuzakiLib/mtproto/pyrogram_client.py delete mode 100644 RyuzakiLib/mtproto/telethon_client.py diff --git a/RyuzakiLib/mtproto/__init__.py b/RyuzakiLib/mtproto/__init__.py deleted file mode 100644 index d224dd9f..00000000 --- a/RyuzakiLib/mtproto/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -from .bridged_client import BridgedClient -from .mtproto_client import MtProtoClient - -__all__ = ("MtProtoClient", "BridgedClient") diff --git a/RyuzakiLib/mtproto/bridged_client.py b/RyuzakiLib/mtproto/bridged_client.py deleted file mode 100644 index 6b45ecda..00000000 --- a/RyuzakiLib/mtproto/bridged_client.py +++ /dev/null @@ -1,117 +0,0 @@ -from typing import Any, Callable, Dict, List, Optional - - -class BridgedClient: - HANDLERS_LIST: Dict[str, List[Callable]] = { - "CLOSED_HANDLER": [], - "KICK_HANDLER": [], - "INVITE_HANDLER": [], - "LEFT_HANDLER": [], - "PARTICIPANTS_HANDLER": [], - } - - async def get_call( - self, - chat_id: int, - ): - pass - - async def join_group_call( - self, - chat_id: int, - json_join: str, - invite_hash: str, - have_video: bool, - join_as: Any, - ) -> str: - pass - - async def leave_group_call( - self, - chat_id: int, - ): - pass - - async def get_group_call_participants( - self, - chat_id: int, - ): - pass - - async def change_volume( - self, - chat_id: int, - volume: int, - participant: Any, - ): - pass - - async def set_call_status( - self, - chat_id: int, - muted_status: Optional[bool], - paused_status: Optional[bool], - stopped_status: Optional[bool], - participant: Any, - ): - pass - - async def get_participants( - self, - input_call: Any, - ): - pass - - async def resolve_peer( - self, - user_id: int, - ): - pass - - def is_connected(self) -> bool: - pass - - async def start(self): - pass - - @staticmethod - def chat_id(input_peer) -> int: - is_channel = hasattr(input_peer, "channel_id") - is_channel_update = input_peer.__class__.__name__ == "Channel" - is_chat = input_peer.__class__.__name__ == "Chat" - is_user = ( - input_peer.__class__.__name__ == "PeerUser" - or input_peer.__class__.__name__ == "InputPeerUser" - ) - is_forbidden = input_peer.__class__.__name__ == "ChannelForbidden" - if is_user: - return input_peer.user_id - elif is_channel: - return -1000000000000 - input_peer.channel_id - elif is_channel_update or is_forbidden: - return -1000000000000 - input_peer.id - elif is_chat: - return -input_peer.id - else: - return -input_peer.chat_id - - def on_closed_voice_chat(self) -> Callable: - pass - - def on_kicked(self) -> Callable: - pass - - def on_receive_invite(self) -> Callable: - pass - - async def get_id(self) -> int: - pass - - def on_left_group(self) -> Callable: - pass - - def on_participants_change(self) -> Callable: - pass - - async def get_full_chat(self, chat_id: int): - pass diff --git a/RyuzakiLib/mtproto/client_cache.py b/RyuzakiLib/mtproto/client_cache.py deleted file mode 100644 index ad196a14..00000000 --- a/RyuzakiLib/mtproto/client_cache.py +++ /dev/null @@ -1,168 +0,0 @@ -import logging -from math import floor -from time import time -from typing import Any, List, Optional - -from ..types import Cache -from ..types.groups import GroupCallParticipant -from ..types.participant_list import ParticipantList -from .bridged_client import BridgedClient - -py_logger = logging.getLogger("pytgcalls") - - -class ClientCache: - def __init__( - self, - cache_duration: int, - app: BridgedClient, - ): - self._app: BridgedClient = app - self._cache_duration = cache_duration - self._full_chat_cache = Cache() - self._call_participants_cache = Cache() - - async def get_full_chat( - self, - chat_id: int, - ) -> Optional[Any]: - full_chat = self._full_chat_cache.get(chat_id) - if full_chat is not None: - py_logger.debug("FullChat cache hit for %d", chat_id) - return full_chat - else: - # noinspection PyBroadException - try: - py_logger.debug("FullChat cache miss for %d", chat_id) - full_chat = await self._app.get_call(chat_id) - self.set_cache( - chat_id, - full_chat, - ) - return full_chat - except Exception: - pass - return None - - def set_participants_cache( - self, - input_id: int, - user_id: int, - muted: Optional[bool], - volume: Optional[int], - can_self_unmute: Optional[bool], - video: Optional[bool], - screen_sharing: Optional[bool], - video_camera: Optional[bool], - raised_hand: Optional[int], - left: Optional[int], - ) -> Optional[GroupCallParticipant]: - chat_id = self.get_chat_id(input_id) - if chat_id is not None: - participants: Optional[ParticipantList] = self._call_participants_cache.get( - chat_id, - ) - if participants is not None: - if not left: - return participants.set_participant( - user_id, - muted if muted is not None else False, - muted != can_self_unmute, - video if video is not None else False, - screen_sharing if screen_sharing is not None else False, - video_camera if video_camera is not None else False, - raised_hand is not None, - floor(volume / 100) if volume is not None else 100, - ) - else: - return participants.remove_participant( - user_id, - muted if muted is not None else False, - muted != can_self_unmute, - video if video is not None else False, - screen_sharing if screen_sharing is not None else False, - video_camera if video_camera is not None else False, - raised_hand is not None, - floor(volume / 100) if volume is not None else 100, - ) - return None - - async def get_participant_list( - self, - chat_id: int, - ) -> Optional[List[GroupCallParticipant]]: - input_call = await self.get_full_chat( - chat_id, - ) - if input_call is not None: - participants: Optional[ParticipantList] = self._call_participants_cache.get( - chat_id, - ) - if participants is not None: - last_update = participants.last_mtproto_update - curr_time = int(time()) - if not (last_update - curr_time > 0): - py_logger.debug( - "GetParticipant cache miss for %d", - chat_id, - ) - try: - list_participants = await self._app.get_participants( - input_call, - ) - for participant in list_participants: - self.set_participants_cache( - input_call.id, - participant["user_id"], - participant["muted"], - participant["volume"], - participant["can_self_unmute"], - participant["video"] is not None - or participant["presentation"] is not None, - participant["presentation"] is not None, - participant["video"] is not None, - participant["raise_hand_rating"], - participant["left"], - ) - participants.last_mtproto_update = curr_time + self._cache_duration - except Exception as e: - py_logger.error("Error for %s in %d", e, chat_id) - else: - py_logger.debug("GetParticipant cache hit for %d", chat_id) - return participants.get_participants() - return [] - - def get_chat_id( - self, - input_group_call_id: int, - ) -> Optional[int]: - for key in self._call_participants_cache.keys(): - participants = self._call_participants_cache.get(key) - if participants is not None: - if participants.input_id == input_group_call_id: - return key - return None - - def set_cache( - self, - chat_id: int, - input_call: Any, - ) -> None: - self._full_chat_cache.put( - chat_id, - input_call, - self._cache_duration, - ) - self._call_participants_cache.put( - chat_id, - ParticipantList( - input_call.id, - ), - ) - - def drop_cache( - self, - chat_id, - ) -> None: - self._full_chat_cache.pop(chat_id) - self._call_participants_cache.pop(chat_id) diff --git a/RyuzakiLib/mtproto/hydrogram_client.py b/RyuzakiLib/mtproto/hydrogram_client.py deleted file mode 100644 index ee3afaa1..00000000 --- a/RyuzakiLib/mtproto/hydrogram_client.py +++ /dev/null @@ -1,430 +0,0 @@ -import asyncio -import json -from typing import Callable, Dict, Optional, Union - -from hydrogram import Client, ContinuePropagation -from hydrogram.raw.base import InputPeer -from hydrogram.raw.functions.channels import GetFullChannel -from hydrogram.raw.functions.messages import GetFullChat -from hydrogram.raw.functions.phone import ( - EditGroupCallParticipant, - GetGroupCall, - GetGroupParticipants, - JoinGroupCall, - LeaveGroupCall, -) -from hydrogram.raw.types import ( - Channel, - ChannelForbidden, - Chat, - ChatForbidden, - DataJSON, - GroupCall, - GroupCallDiscarded, - InputChannel, - InputGroupCall, - InputPeerChannel, - MessageActionChatDeleteUser, - MessageActionInviteToGroupCall, - MessageService, - PeerChat, - UpdateChannel, - UpdateGroupCall, - UpdateGroupCallConnection, - UpdateGroupCallParticipants, - UpdateNewChannelMessage, - UpdateNewMessage, - Updates, -) - -from .bridged_client import BridgedClient -from .client_cache import ClientCache - - -class HydrogramClient(BridgedClient): - def __init__( - self, - cache_duration: int, - client: Client, - ): - self._app: Client = client - self._cache: ClientCache = ClientCache( - cache_duration, - self, - ) - - @self._app.on_raw_update() - async def on_update(_, update, __, data2): - if isinstance( - update, - UpdateGroupCallParticipants, - ): - participants = update.participants - for participant in participants: - result = self._cache.set_participants_cache( - update.call.id, - self.chat_id(participant.peer), - participant.muted, - participant.volume, - participant.can_self_unmute, - participant.video is not None or participant.presentation is not None, - participant.presentation is not None, - participant.video is not None, - participant.raise_hand_rating, - participant.left, - ) - if result is not None: - if "PARTICIPANTS_HANDLER" in self.HANDLERS_LIST: - await self._propagate( - "PARTICIPANTS_HANDLER", - self._cache.get_chat_id(update.call.id), - result, - participant.just_joined, - participant.left, - ) - if isinstance( - update, - UpdateGroupCall, - ): - chat_id = self.chat_id(data2[update.chat_id]) - if isinstance( - update.call, - GroupCall, - ): - if update.call.schedule_date is None: - self._cache.set_cache( - chat_id, - InputGroupCall( - access_hash=update.call.access_hash, - id=update.call.id, - ), - ) - if isinstance( - update.call, - GroupCallDiscarded, - ): - self._cache.drop_cache(chat_id) - if "CLOSED_HANDLER" in self.HANDLERS_LIST: - await self._propagate( - "CLOSED_HANDLER", - chat_id, - ) - if isinstance( - update, - UpdateChannel, - ): - chat_id = self.chat_id(update) - if len(data2) > 0: - if isinstance( - data2[update.channel_id], - ChannelForbidden, - ): - self._cache.drop_cache(chat_id) - if "KICK_HANDLER" in self.HANDLERS_LIST: - await self._propagate( - "KICK_HANDLER", - chat_id, - ) - if isinstance( - update, - UpdateNewChannelMessage, - ) or isinstance( - update, - UpdateNewMessage, - ): - if isinstance( - update.message, - MessageService, - ): - if isinstance( - update.message.action, - MessageActionInviteToGroupCall, - ): - if "INVITE_HANDLER" in self.HANDLERS_LIST: - await self._propagate( - "INVITE_HANDLER", - update.message.action, - ) - if isinstance( - update.message.action, - MessageActionChatDeleteUser, - ): - if isinstance( - update.message.peer_id, - PeerChat, - ): - chat_id = self.chat_id(update.message.peer_id) - if isinstance( - data2[update.message.peer_id.chat_id], - ChatForbidden, - ): - self._cache.drop_cache(chat_id) - if "KICK_HANDLER" in self.HANDLERS_LIST: - await self._propagate( - "KICK_HANDLER", - chat_id, - ) - if isinstance( - data2, - Dict, - ): - for group_id in data2: - if isinstance( - update, - UpdateNewChannelMessage, - ) or isinstance( - update, - UpdateNewMessage, - ): - if isinstance( - update.message, - MessageService, - ): - if isinstance( - data2[group_id], - Channel, - ) or isinstance( - data2[group_id], - Chat, - ): - chat_id = self.chat_id(data2[group_id]) - if data2[group_id].left: - self._cache.drop_cache( - chat_id, - ) - if "LEFT_HANDLER" in self.HANDLERS_LIST: - await self._propagate( - "LEFT_HANDLER", - chat_id, - ) - raise ContinuePropagation() - - async def _propagate(self, event_name: str, *args, **kwargs): - for event in self.HANDLERS_LIST[event_name]: - asyncio.ensure_future(event(*args, **kwargs)) - - def on_closed_voice_chat(self) -> Callable: - def decorator(func: Callable) -> Callable: - if self is not None: - self.HANDLERS_LIST["CLOSED_HANDLER"].append(func) - return func - - return decorator - - def on_kicked(self) -> Callable: - def decorator(func: Callable) -> Callable: - if self is not None: - self.HANDLERS_LIST["KICK_HANDLER"].append(func) - return func - - return decorator - - def on_receive_invite(self) -> Callable: - def decorator(func: Callable) -> Callable: - if self is not None: - self.HANDLERS_LIST["INVITE_HANDLER"].append(func) - return func - - return decorator - - def on_left_group(self) -> Callable: - def decorator(func: Callable) -> Callable: - if self is not None: - self.HANDLERS_LIST["LEFT_HANDLER"].append(func) - return func - - return decorator - - def on_participants_change(self) -> Callable: - def decorator(func: Callable) -> Callable: - if self is not None: - self.HANDLERS_LIST["PARTICIPANTS_HANDLER"].append(func) - return func - - return decorator - - async def get_call( - self, - chat_id: int, - ) -> Optional[InputGroupCall]: - chat = await self._app.resolve_peer(chat_id) - if isinstance(chat, InputPeerChannel): - input_call = ( - await self._app.invoke( - GetFullChannel( - channel=InputChannel( - channel_id=chat.channel_id, - access_hash=chat.access_hash, - ), - ), - ) - ).full_chat.call - else: - input_call = ( - await self._app.invoke( - GetFullChat(chat_id=chat.chat_id), - ) - ).full_chat.call - - if input_call is not None: - call: GroupCall = ( - await self._app.invoke( - GetGroupCall( - call=input_call, - limit=-1, - ), - ) - ).call - - if call.schedule_date is not None: - return None - - return input_call - - async def get_group_call_participants( - self, - chat_id: int, - ): - return await self._cache.get_participant_list( - chat_id, - ) - - async def get_participants( - self, - input_call: InputGroupCall, - ): - return [ - { - "user_id": self.chat_id(participant.peer), - "muted": participant.muted, - "volume": participant.volume, - "can_self_unmute": participant.can_self_unmute, - "video": participant.video, - "presentation": participant.presentation, - "raise_hand_rating": participant.raise_hand_rating, - "left": participant.left, - } - for participant in ( - await self._app.invoke( - GetGroupParticipants( - call=input_call, - ids=[], - sources=[], - offset="", - limit=500, - ), - ) - ).participants - ] - - async def join_group_call( - self, - chat_id: int, - json_join: str, - invite_hash: str, - have_video: bool, - join_as: InputPeer, - ) -> str: - chat_call = await self._cache.get_full_chat(chat_id) - if chat_call is not None: - result: Updates = await self._app.invoke( - JoinGroupCall( - call=chat_call, - params=DataJSON(data=json_join), - muted=False, - join_as=join_as, - video_stopped=have_video, - invite_hash=invite_hash, - ), - ) - for update in result.updates: - if isinstance( - update, - UpdateGroupCallParticipants, - ): - participants = update.participants - for participant in participants: - self._cache.set_participants_cache( - update.call.id, - self.chat_id(participant.peer), - participant.muted, - participant.volume, - participant.can_self_unmute, - participant.video is not None or participant.presentation is not None, - participant.presentation is not None, - participant.video is not None, - participant.raise_hand_rating, - participant.left, - ) - if isinstance(update, UpdateGroupCallConnection): - return update.params.data - - return json.dumps({"transport": None}) - - async def leave_group_call( - self, - chat_id: int, - ): - chat_call = await self._cache.get_full_chat(chat_id) - if chat_call is not None: - await self._app.invoke( - LeaveGroupCall( - call=chat_call, - source=0, - ), - ) - - async def change_volume( - self, - chat_id: int, - volume: int, - participant: InputPeer, - ): - chat_call = await self._cache.get_full_chat(chat_id) - if chat_call is not None: - await self._app.invoke( - EditGroupCallParticipant( - call=chat_call, - participant=participant, - muted=False, - volume=volume * 100, - ), - ) - - async def set_call_status( - self, - chat_id: int, - muted_status: Optional[bool], - paused_status: Optional[bool], - stopped_status: Optional[bool], - participant: InputPeer, - ): - chat_call = await self._cache.get_full_chat(chat_id) - if chat_call is not None: - await self._app.invoke( - EditGroupCallParticipant( - call=chat_call, - participant=participant, - muted=muted_status, - video_stopped=stopped_status, - video_paused=paused_status, - ), - ) - - async def get_full_chat(self, chat_id: int): - return await self._cache.get_full_chat(chat_id) - - async def resolve_peer( - self, - user_id: Union[int, str], - ) -> InputPeer: - return await self._app.resolve_peer(user_id) - - async def get_id(self) -> int: - return (await self._app.get_me()).id - - def is_connected(self) -> bool: - return self._app.is_connected - - async def start(self): - await self._app.start() diff --git a/RyuzakiLib/mtproto/mtproto_client.py b/RyuzakiLib/mtproto/mtproto_client.py deleted file mode 100644 index b426e05f..00000000 --- a/RyuzakiLib/mtproto/mtproto_client.py +++ /dev/null @@ -1,186 +0,0 @@ -from typing import Any, Callable, List, Optional - -from ..exceptions import InvalidMTProtoClient -from ..types.groups.group_call_participant import GroupCallParticipant -from .bridged_client import BridgedClient - - -class MtProtoClient: - def __init__( - self, - cache_duration: int, - client: Any, - ): - self._bind_client: Optional[BridgedClient] = None - if client.__class__.__module__ == "pyrogram.client": - from .pyrogram_client import PyrogramClient - - self._bind_client = PyrogramClient( - cache_duration, - client, - ) - elif client.__class__.__module__ == "telethon.client.telegramclient": - from .telethon_client import TelethonClient - - self._bind_client = TelethonClient( - cache_duration, - client, - ) - elif client.__class__.__module__ == "hydrogram.client": - from .hydrogram_client import HydrogramClient - - self._bind_client = HydrogramClient( - cache_duration, - client, - ) - else: - raise InvalidMTProtoClient() - - @property - def client(self): - client_name = self._bind_client.__class__.__name__ - if client_name == "PyrogramClient": - return "pyrogram" - elif client_name == "TelethonClient": - return "telethon" - elif client_name == "HydrogramClient": - return "hydrogram" - else: - return "unknown" - - async def get_group_call_participants( - self, - chat_id: int, - ) -> Optional[List[GroupCallParticipant]]: - if self._bind_client is not None: - return await self._bind_client.get_group_call_participants( - chat_id, - ) - else: - raise InvalidMTProtoClient() - - async def join_group_call( - self, - chat_id: int, - json_join: str, - invite_hash: str, - have_video: bool, - join_as: Any, - ) -> str: - if self._bind_client is not None: - return await self._bind_client.join_group_call( - chat_id, - json_join, - invite_hash, - have_video, - join_as, - ) - else: - raise InvalidMTProtoClient() - - async def leave_group_call( - self, - chat_id: int, - ): - if self._bind_client is not None: - await self._bind_client.leave_group_call( - chat_id, - ) - else: - raise InvalidMTProtoClient() - - async def change_volume( - self, - chat_id: int, - volume: int, - participant: Any, - ): - if self._bind_client is not None: - await self._bind_client.change_volume( - chat_id, - volume, - participant, - ) - else: - raise InvalidMTProtoClient() - - async def set_call_status( - self, - chat_id: int, - muted_status: Optional[bool], - paused_status: Optional[bool], - stopped_status: Optional[bool], - participant: Any, - ): - if self._bind_client is not None: - await self._bind_client.set_call_status( - chat_id, - muted_status, - paused_status, - stopped_status, - participant, - ) - else: - raise InvalidMTProtoClient() - - async def get_full_chat( - self, - chat_id: int, - ): - if self._bind_client is not None: - return await self._bind_client.get_full_chat( - chat_id, - ) - raise InvalidMTProtoClient() - - async def resolve_peer( - self, - user_id: int, - ): - if self._bind_client is not None: - return await self._bind_client.resolve_peer( - user_id, - ) - raise InvalidMTProtoClient() - - async def get_id(self) -> int: - if self._bind_client is not None: - return await self._bind_client.get_id() - raise InvalidMTProtoClient() - - @property - def is_connected(self) -> bool: - if self._bind_client is not None: - return self._bind_client.is_connected() - raise InvalidMTProtoClient() - - async def start(self): - if self._bind_client is not None: - await self._bind_client.start() - else: - raise InvalidMTProtoClient() - - def on_closed_voice_chat(self) -> Callable: - if self._bind_client is not None: - return self._bind_client.on_closed_voice_chat() - raise InvalidMTProtoClient() - - def on_kicked(self) -> Callable: - if self._bind_client is not None: - return self._bind_client.on_kicked() - raise InvalidMTProtoClient() - - def on_receive_invite(self) -> Callable: - if self._bind_client is not None: - return self._bind_client.on_receive_invite() - raise InvalidMTProtoClient() - - def on_left_group(self) -> Callable: - if self._bind_client is not None: - return self._bind_client.on_left_group() - raise InvalidMTProtoClient() - - def on_participants_change(self) -> Callable: - if self._bind_client is not None: - return self._bind_client.on_participants_change() - raise InvalidMTProtoClient() diff --git a/RyuzakiLib/mtproto/nothing b/RyuzakiLib/mtproto/nothing deleted file mode 100644 index e69de29b..00000000 diff --git a/RyuzakiLib/mtproto/pyrogram_client.py b/RyuzakiLib/mtproto/pyrogram_client.py deleted file mode 100644 index 6660d244..00000000 --- a/RyuzakiLib/mtproto/pyrogram_client.py +++ /dev/null @@ -1,438 +0,0 @@ -import asyncio -import json -from typing import Callable, Dict, Optional, Union - -import pyrogram -from pyrogram import Client, ContinuePropagation -from pyrogram.raw.base import InputPeer -from pyrogram.raw.functions.channels import GetFullChannel -from pyrogram.raw.functions.messages import GetFullChat -from pyrogram.raw.functions.phone import ( - EditGroupCallParticipant, - GetGroupCall, - GetGroupParticipants, - JoinGroupCall, - LeaveGroupCall, -) -from pyrogram.raw.types import ( - Channel, - ChannelForbidden, - Chat, - ChatForbidden, - DataJSON, - GroupCall, - GroupCallDiscarded, - InputChannel, - InputGroupCall, - InputPeerChannel, - MessageActionChatDeleteUser, - MessageActionInviteToGroupCall, - MessageService, - PeerChat, - UpdateChannel, - UpdateGroupCall, - UpdateGroupCallConnection, - UpdateGroupCallParticipants, - UpdateNewChannelMessage, - UpdateNewMessage, - Updates, -) - -from ..version_manager import VersionManager -from .bridged_client import BridgedClient -from .client_cache import ClientCache - - -class PyrogramClient(BridgedClient): - def __init__( - self, - cache_duration: int, - client: Client, - ): - self._app: Client = client - if VersionManager.version_tuple( - pyrogram.__version__, - ) > VersionManager.version_tuple( - "2.0.0", - ): - self._app.send = self._app.invoke - self._cache: ClientCache = ClientCache( - cache_duration, - self, - ) - - @self._app.on_raw_update() - async def on_update(_, update, __, data2): - if isinstance( - update, - UpdateGroupCallParticipants, - ): - participants = update.participants - for participant in participants: - result = self._cache.set_participants_cache( - update.call.id, - self.chat_id(participant.peer), - participant.muted, - participant.volume, - participant.can_self_unmute, - participant.video is not None or participant.presentation is not None, - participant.presentation is not None, - participant.video is not None, - participant.raise_hand_rating, - participant.left, - ) - if result is not None: - if "PARTICIPANTS_HANDLER" in self.HANDLERS_LIST: - await self._propagate( - "PARTICIPANTS_HANDLER", - self._cache.get_chat_id(update.call.id), - result, - participant.just_joined, - participant.left, - ) - if isinstance( - update, - UpdateGroupCall, - ): - chat_id = self.chat_id(data2[update.chat_id]) - if isinstance( - update.call, - GroupCall, - ): - if update.call.schedule_date is None: - self._cache.set_cache( - chat_id, - InputGroupCall( - access_hash=update.call.access_hash, - id=update.call.id, - ), - ) - if isinstance( - update.call, - GroupCallDiscarded, - ): - self._cache.drop_cache(chat_id) - if "CLOSED_HANDLER" in self.HANDLERS_LIST: - await self._propagate( - "CLOSED_HANDLER", - chat_id, - ) - if isinstance( - update, - UpdateChannel, - ): - chat_id = self.chat_id(update) - if len(data2) > 0: - if isinstance( - data2[update.channel_id], - ChannelForbidden, - ): - self._cache.drop_cache(chat_id) - if "KICK_HANDLER" in self.HANDLERS_LIST: - await self._propagate( - "KICK_HANDLER", - chat_id, - ) - if isinstance( - update, - UpdateNewChannelMessage, - ) or isinstance( - update, - UpdateNewMessage, - ): - if isinstance( - update.message, - MessageService, - ): - if isinstance( - update.message.action, - MessageActionInviteToGroupCall, - ): - if "INVITE_HANDLER" in self.HANDLERS_LIST: - await self._propagate( - "INVITE_HANDLER", - update.message.action, - ) - if isinstance( - update.message.action, - MessageActionChatDeleteUser, - ): - if isinstance( - update.message.peer_id, - PeerChat, - ): - chat_id = self.chat_id(update.message.peer_id) - if isinstance( - data2[update.message.peer_id.chat_id], - ChatForbidden, - ): - self._cache.drop_cache(chat_id) - if "KICK_HANDLER" in self.HANDLERS_LIST: - await self._propagate( - "KICK_HANDLER", - chat_id, - ) - if isinstance( - data2, - Dict, - ): - for group_id in data2: - if isinstance( - update, - UpdateNewChannelMessage, - ) or isinstance( - update, - UpdateNewMessage, - ): - if isinstance( - update.message, - MessageService, - ): - if isinstance( - data2[group_id], - Channel, - ) or isinstance( - data2[group_id], - Chat, - ): - chat_id = self.chat_id(data2[group_id]) - if data2[group_id].left: - self._cache.drop_cache( - chat_id, - ) - if "LEFT_HANDLER" in self.HANDLERS_LIST: - await self._propagate( - "LEFT_HANDLER", - chat_id, - ) - raise ContinuePropagation() - - async def _propagate(self, event_name: str, *args, **kwargs): - for event in self.HANDLERS_LIST[event_name]: - asyncio.ensure_future(event(*args, **kwargs)) - - def on_closed_voice_chat(self) -> Callable: - def decorator(func: Callable) -> Callable: - if self is not None: - self.HANDLERS_LIST["CLOSED_HANDLER"].append(func) - return func - - return decorator - - def on_kicked(self) -> Callable: - def decorator(func: Callable) -> Callable: - if self is not None: - self.HANDLERS_LIST["KICK_HANDLER"].append(func) - return func - - return decorator - - def on_receive_invite(self) -> Callable: - def decorator(func: Callable) -> Callable: - if self is not None: - self.HANDLERS_LIST["INVITE_HANDLER"].append(func) - return func - - return decorator - - def on_left_group(self) -> Callable: - def decorator(func: Callable) -> Callable: - if self is not None: - self.HANDLERS_LIST["LEFT_HANDLER"].append(func) - return func - - return decorator - - def on_participants_change(self) -> Callable: - def decorator(func: Callable) -> Callable: - if self is not None: - self.HANDLERS_LIST["PARTICIPANTS_HANDLER"].append(func) - return func - - return decorator - - async def get_call( - self, - chat_id: int, - ) -> Optional[InputGroupCall]: - chat = await self._app.resolve_peer(chat_id) - if isinstance(chat, InputPeerChannel): - input_call = ( - await self._app.send( - GetFullChannel( - channel=InputChannel( - channel_id=chat.channel_id, - access_hash=chat.access_hash, - ), - ), - ) - ).full_chat.call - else: - input_call = ( - await self._app.send( - GetFullChat(chat_id=chat.chat_id), - ) - ).full_chat.call - - if input_call is not None: - call: GroupCall = ( - await self._app.send( - GetGroupCall( - call=input_call, - limit=-1, - ), - ) - ).call - - if call.schedule_date is not None: - return None - - return input_call - - async def get_group_call_participants( - self, - chat_id: int, - ): - return await self._cache.get_participant_list( - chat_id, - ) - - async def get_participants( - self, - input_call: InputGroupCall, - ): - return [ - { - "user_id": self.chat_id(participant.peer), - "muted": participant.muted, - "volume": participant.volume, - "can_self_unmute": participant.can_self_unmute, - "video": participant.video, - "presentation": participant.presentation, - "raise_hand_rating": participant.raise_hand_rating, - "left": participant.left, - } - for participant in ( - await self._app.send( - GetGroupParticipants( - call=input_call, - ids=[], - sources=[], - offset="", - limit=500, - ), - ) - ).participants - ] - - async def join_group_call( - self, - chat_id: int, - json_join: str, - invite_hash: str, - have_video: bool, - join_as: InputPeer, - ) -> str: - chat_call = await self._cache.get_full_chat(chat_id) - if chat_call is not None: - result: Updates = await self._app.send( - JoinGroupCall( - call=chat_call, - params=DataJSON(data=json_join), - muted=False, - join_as=join_as, - video_stopped=have_video, - invite_hash=invite_hash, - ), - ) - for update in result.updates: - if isinstance( - update, - UpdateGroupCallParticipants, - ): - participants = update.participants - for participant in participants: - self._cache.set_participants_cache( - update.call.id, - self.chat_id(participant.peer), - participant.muted, - participant.volume, - participant.can_self_unmute, - participant.video is not None or participant.presentation is not None, - participant.presentation is not None, - participant.video is not None, - participant.raise_hand_rating, - participant.left, - ) - if isinstance(update, UpdateGroupCallConnection): - return update.params.data - - return json.dumps({"transport": None}) - - async def leave_group_call( - self, - chat_id: int, - ): - chat_call = await self._cache.get_full_chat(chat_id) - if chat_call is not None: - await self._app.send( - LeaveGroupCall( - call=chat_call, - source=0, - ), - ) - - async def change_volume( - self, - chat_id: int, - volume: int, - participant: InputPeer, - ): - chat_call = await self._cache.get_full_chat(chat_id) - if chat_call is not None: - await self._app.send( - EditGroupCallParticipant( - call=chat_call, - participant=participant, - muted=False, - volume=volume * 100, - ), - ) - - async def set_call_status( - self, - chat_id: int, - muted_status: Optional[bool], - paused_status: Optional[bool], - stopped_status: Optional[bool], - participant: InputPeer, - ): - chat_call = await self._cache.get_full_chat(chat_id) - if chat_call is not None: - await self._app.send( - EditGroupCallParticipant( - call=chat_call, - participant=participant, - muted=muted_status, - video_stopped=stopped_status, - video_paused=paused_status, - ), - ) - - async def get_full_chat(self, chat_id: int): - return await self._cache.get_full_chat(chat_id) - - async def resolve_peer( - self, - user_id: Union[int, str], - ) -> InputPeer: - return await self._app.resolve_peer(user_id) - - async def get_id(self) -> int: - return (await self._app.get_me()).id - - def is_connected(self) -> bool: - return self._app.is_connected - - async def start(self): - await self._app.start() diff --git a/RyuzakiLib/mtproto/telethon_client.py b/RyuzakiLib/mtproto/telethon_client.py deleted file mode 100644 index 6926b19b..00000000 --- a/RyuzakiLib/mtproto/telethon_client.py +++ /dev/null @@ -1,407 +0,0 @@ -import asyncio -import json -from typing import Callable, Optional, Union - -from telethon import TelegramClient -from telethon.errors import ChannelPrivateError -from telethon.events import Raw -from telethon.tl.functions.channels import GetFullChannelRequest -from telethon.tl.functions.messages import GetFullChatRequest -from telethon.tl.functions.phone import ( - EditGroupCallParticipantRequest, - GetGroupCallRequest, - GetGroupParticipantsRequest, - JoinGroupCallRequest, - LeaveGroupCallRequest, -) -from telethon.tl.types import ( - ChatForbidden, - DataJSON, - GroupCall, - GroupCallDiscarded, - InputChannel, - InputGroupCall, - InputPeerChannel, - MessageActionChatDeleteUser, - MessageActionInviteToGroupCall, - MessageService, - PeerChat, - TypeInputPeer, - UpdateChannel, - UpdateGroupCall, - UpdateGroupCallConnection, - UpdateGroupCallParticipants, - UpdateNewChannelMessage, - UpdateNewMessage, - Updates, -) - -from .bridged_client import BridgedClient -from .client_cache import ClientCache - - -class TelethonClient(BridgedClient): - def __init__( - self, - cache_duration: int, - client: TelegramClient, - ): - self._app: TelegramClient = client - self._cache: ClientCache = ClientCache( - cache_duration, - self, - ) - - @self._app.on(Raw()) - async def on_update(update): - if isinstance( - update, - UpdateGroupCallParticipants, - ): - participants = update.participants - for participant in participants: - result = self._cache.set_participants_cache( - update.call.id, - self.chat_id(participant.peer), - participant.muted, - participant.volume, - participant.can_self_unmute, - participant.video is not None or participant.presentation is not None, - participant.presentation is not None, - participant.video is not None, - participant.raise_hand_rating, - participant.left, - ) - if result is not None: - if "PARTICIPANTS_HANDLER" in self.HANDLERS_LIST: - await self._propagate( - "PARTICIPANTS_HANDLER", - self._cache.get_chat_id(update.call.id), - result, - participant.just_joined, - participant.left, - ) - if isinstance( - update, - UpdateGroupCall, - ): - chat_id = self.chat_id( - await self._app.get_entity(update.chat_id), - ) - if isinstance( - update.call, - GroupCall, - ): - if update.call.schedule_date is None: - self._cache.set_cache( - chat_id, - InputGroupCall( - access_hash=update.call.access_hash, - id=update.call.id, - ), - ) - if isinstance( - update.call, - GroupCallDiscarded, - ): - self._cache.drop_cache( - chat_id, - ) - if "CLOSED_HANDLER" in self.HANDLERS_LIST: - await self._propagate( - "CLOSED_HANDLER", - chat_id, - ) - if isinstance( - update, - UpdateChannel, - ): - chat_id = self.chat_id(update) - try: - await self._app.get_entity(chat_id) - except ChannelPrivateError: - self._cache.drop_cache(chat_id) - if "KICK_HANDLER" in self.HANDLERS_LIST: - await self._propagate( - "KICK_HANDLER", - chat_id, - ) - - if isinstance( - update, - UpdateNewChannelMessage, - ) or isinstance( - update, - UpdateNewMessage, - ): - if isinstance( - update.message, - MessageService, - ): - if isinstance( - update.message.action, - MessageActionInviteToGroupCall, - ): - if "INVITE_HANDLER" in self.HANDLERS_LIST: - await self._propagate( - "INVITE_HANDLER", - update.message.action, - ) - if isinstance(update.message.out, bool): - if update.message.out: - chat_id = self.chat_id(update.message.peer_id) - self._cache.drop_cache(chat_id) - if "LEFT_HANDLER" in self.HANDLERS_LIST: - await self._propagate( - "LEFT_HANDLER", - chat_id, - ) - if isinstance( - update.message.action, - MessageActionChatDeleteUser, - ): - if isinstance( - update.message.peer_id, - PeerChat, - ): - chat_id = self.chat_id(update.message.peer_id) - if isinstance( - await self._app.get_entity(chat_id), - ChatForbidden, - ): - self._cache.drop_cache(chat_id) - if "KICK_HANDLER" in self.HANDLERS_LIST: - await self._propagate( - "KICK_HANDLER", - chat_id, - ) - - async def get_call( - self, - chat_id: int, - ) -> Optional[InputGroupCall]: - chat = await self._app.get_input_entity(chat_id) - if isinstance(chat, InputPeerChannel): - input_call = ( - await self._app( - GetFullChannelRequest( - InputChannel( - chat.channel_id, - chat.access_hash, - ), - ), - ) - ).full_chat.call - else: - input_call = ( - await self._app( - GetFullChatRequest(chat_id), - ) - ).full_chat.call - if input_call is not None: - try: - call: GroupCall = ( - await self._app( - GetGroupCallRequest( - call=input_call, - limit=-1, - ), - ) - ).call - if call.schedule_date is not None: - return None - except Exception as e: - print(e) - return input_call - - async def get_group_call_participants( - self, - chat_id: int, - ): - return await self._cache.get_participant_list( - chat_id, - ) - - async def get_participants( - self, - input_call: InputGroupCall, - ): - return [ - { - "user_id": self.chat_id(participant.peer), - "muted": participant.muted, - "volume": participant.volume, - "can_self_unmute": participant.can_self_unmute, - "video": participant.video, - "presentation": participant.presentation, - "raise_hand_rating": participant.raise_hand_rating, - "left": participant.left, - } - for participant in ( - await self._app( - GetGroupParticipantsRequest( - call=input_call, - ids=[], - sources=[], - offset="", - limit=500, - ), - ) - ).participants - ] - - async def join_group_call( - self, - chat_id: int, - json_join: str, - invite_hash: str, - have_video: bool, - join_as: TypeInputPeer, - ) -> str: - chat_call = await self._cache.get_full_chat(chat_id) - if chat_call is not None: - result: Updates = await self._app( - JoinGroupCallRequest( - call=chat_call, - params=DataJSON(data=json_join), - muted=False, - join_as=join_as, - video_stopped=have_video, - invite_hash=invite_hash, - ), - ) - for update in result.updates: - if isinstance( - update, - UpdateGroupCallParticipants, - ): - participants = update.participants - for participant in participants: - self._cache.set_participants_cache( - update.call.id, - self.chat_id(participant.peer), - participant.muted, - participant.volume, - participant.can_self_unmute, - participant.video is not None or participant.presentation is not None, - participant.presentation is not None, - participant.video is not None, - participant.raise_hand_rating, - participant.left, - ) - if isinstance(update, UpdateGroupCallConnection): - return update.params.data - - return json.dumps({"transport": None}) - - async def _propagate(self, event_name: str, *args, **kwargs): - for event in self.HANDLERS_LIST[event_name]: - asyncio.ensure_future(event(*args, **kwargs)) - - def on_closed_voice_chat(self) -> Callable: - def decorator(func: Callable) -> Callable: - if self is not None: - self.HANDLERS_LIST["CLOSED_HANDLER"].append(func) - return func - - return decorator - - def on_kicked(self) -> Callable: - def decorator(func: Callable) -> Callable: - if self is not None: - self.HANDLERS_LIST["KICK_HANDLER"].append(func) - return func - - return decorator - - def on_receive_invite(self) -> Callable: - def decorator(func: Callable) -> Callable: - if self is not None: - self.HANDLERS_LIST["INVITE_HANDLER"].append(func) - return func - - return decorator - - def on_left_group(self) -> Callable: - def decorator(func: Callable) -> Callable: - if self is not None: - self.HANDLERS_LIST["LEFT_HANDLER"].append(func) - return func - - return decorator - - def on_participants_change(self) -> Callable: - def decorator(func: Callable) -> Callable: - if self is not None: - self.HANDLERS_LIST["PARTICIPANTS_HANDLER"].append(func) - return func - - return decorator - - async def leave_group_call( - self, - chat_id: int, - ): - chat_call = await self._cache.get_full_chat(chat_id) - if chat_call is not None: - await self._app( - LeaveGroupCallRequest( - call=chat_call, - source=0, - ), - ) - - async def change_volume( - self, - chat_id: int, - volume: int, - participant: TypeInputPeer, - ): - chat_call = await self._cache.get_full_chat(chat_id) - if chat_call is not None: - await self._app( - EditGroupCallParticipantRequest( - call=chat_call, - participant=participant, - muted=False, - volume=volume * 100, - ), - ) - - async def set_call_status( - self, - chat_id: int, - muted_status: Optional[bool], - paused_status: Optional[bool], - stopped_status: Optional[bool], - participant: TypeInputPeer, - ): - chat_call = await self._cache.get_full_chat(chat_id) - if chat_call is not None: - await self._app( - EditGroupCallParticipantRequest( - call=chat_call, - participant=participant, - muted=muted_status, - video_stopped=stopped_status, - video_paused=paused_status, - ), - ) - - async def get_full_chat(self, chat_id: int): - return await self._cache.get_full_chat(chat_id) - - async def resolve_peer( - self, - user_id: Union[int, str], - ) -> TypeInputPeer: - return await self._app.get_input_entity(user_id) - - async def get_id(self) -> int: - return (await self._app.get_me()).id - - def is_connected(self) -> bool: - return self._app.is_connected() - - async def start(self): - await self._app.start() From ff47c23871a510b1a1acbed07e47b60c4814dc3c Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Wed, 21 Aug 2024 17:39:27 +0700 Subject: [PATCH 079/152] _ --- RyuzakiLib/__init__.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/RyuzakiLib/__init__.py b/RyuzakiLib/__init__.py index 7f462b7b..7128f9b7 100644 --- a/RyuzakiLib/__init__.py +++ b/RyuzakiLib/__init__.py @@ -56,14 +56,11 @@ from .mental import * from .profile.user import Clone from .pushdb import * -from .py_tgcalls import PyTgCalls from .pyrogramMod import PyrogramMod from .quote import * from .reminder import * from .spamwatch.clients import SibylBan from .story import * -from .stream_type import StreamType -from .sync import idle from .system.read import System from .tr import * @@ -84,9 +81,8 @@ class AwesomeCoding(BaseModel): __all__ = [ - "__version__" "CustomApi", - "PyTgCalls", - "StreamType", + "__version__" + "CustomApi", "RendyDevChat", "GeminiLatest", "Github", From 31d4318554ae4c3e7316dbdbff1be9b323395c68 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Wed, 21 Aug 2024 17:40:42 +0700 Subject: [PATCH 080/152] _ --- RyuzakiLib/types/input_stream/__init__.py | 41 ---------- .../types/input_stream/audio_image_piped.py | 81 ------------------- .../types/input_stream/audio_parameters.py | 17 ---- RyuzakiLib/types/input_stream/audio_piped.py | 43 ---------- .../types/input_stream/audio_quality.py | 8 -- RyuzakiLib/types/input_stream/audio_stream.py | 16 ---- .../types/input_stream/audio_video_piped.py | 72 ----------------- .../input_stream/capture_audio_device.py | 31 ------- .../types/input_stream/capture_av_desktop.py | 64 --------------- .../input_stream/capture_av_device_desktop.py | 55 ------------- .../input_stream/capture_video_desktop.py | 32 -------- .../types/input_stream/input_audio_stream.py | 20 ----- RyuzakiLib/types/input_stream/input_stream.py | 22 ----- .../types/input_stream/input_video_stream.py | 20 ----- .../types/input_stream/quality/__init__.py | 15 ---- .../quality/high_quality_audio.py | 14 ---- .../quality/high_quality_video.py | 14 ---- .../input_stream/quality/low_quality_audio.py | 14 ---- .../input_stream/quality/low_quality_video.py | 14 ---- .../quality/medium_quality_audio.py | 14 ---- .../quality/medium_quality_video.py | 14 ---- RyuzakiLib/types/input_stream/smart_stream.py | 27 ------- RyuzakiLib/types/input_stream/stream.py | 15 ---- .../types/input_stream/video_parameters.py | 22 ----- RyuzakiLib/types/input_stream/video_piped.py | 49 ----------- .../types/input_stream/video_quality.py | 10 --- RyuzakiLib/types/input_stream/video_stream.py | 15 ---- 27 files changed, 759 deletions(-) delete mode 100644 RyuzakiLib/types/input_stream/__init__.py delete mode 100644 RyuzakiLib/types/input_stream/audio_image_piped.py delete mode 100644 RyuzakiLib/types/input_stream/audio_parameters.py delete mode 100644 RyuzakiLib/types/input_stream/audio_piped.py delete mode 100644 RyuzakiLib/types/input_stream/audio_quality.py delete mode 100644 RyuzakiLib/types/input_stream/audio_stream.py delete mode 100644 RyuzakiLib/types/input_stream/audio_video_piped.py delete mode 100644 RyuzakiLib/types/input_stream/capture_audio_device.py delete mode 100644 RyuzakiLib/types/input_stream/capture_av_desktop.py delete mode 100644 RyuzakiLib/types/input_stream/capture_av_device_desktop.py delete mode 100644 RyuzakiLib/types/input_stream/capture_video_desktop.py delete mode 100644 RyuzakiLib/types/input_stream/input_audio_stream.py delete mode 100644 RyuzakiLib/types/input_stream/input_stream.py delete mode 100644 RyuzakiLib/types/input_stream/input_video_stream.py delete mode 100644 RyuzakiLib/types/input_stream/quality/__init__.py delete mode 100644 RyuzakiLib/types/input_stream/quality/high_quality_audio.py delete mode 100644 RyuzakiLib/types/input_stream/quality/high_quality_video.py delete mode 100644 RyuzakiLib/types/input_stream/quality/low_quality_audio.py delete mode 100644 RyuzakiLib/types/input_stream/quality/low_quality_video.py delete mode 100644 RyuzakiLib/types/input_stream/quality/medium_quality_audio.py delete mode 100644 RyuzakiLib/types/input_stream/quality/medium_quality_video.py delete mode 100644 RyuzakiLib/types/input_stream/smart_stream.py delete mode 100644 RyuzakiLib/types/input_stream/stream.py delete mode 100644 RyuzakiLib/types/input_stream/video_parameters.py delete mode 100644 RyuzakiLib/types/input_stream/video_piped.py delete mode 100644 RyuzakiLib/types/input_stream/video_quality.py delete mode 100644 RyuzakiLib/types/input_stream/video_stream.py diff --git a/RyuzakiLib/types/input_stream/__init__.py b/RyuzakiLib/types/input_stream/__init__.py deleted file mode 100644 index 4805d9f5..00000000 --- a/RyuzakiLib/types/input_stream/__init__.py +++ /dev/null @@ -1,41 +0,0 @@ -from .audio_image_piped import AudioImagePiped -from .audio_parameters import AudioParameters -from .audio_piped import AudioPiped -from .audio_quality import AudioQuality -from .audio_stream import AudioStream -from .audio_video_piped import AudioVideoPiped -from .capture_audio_device import CaptureAudioDevice -from .capture_av_desktop import CaptureAVDesktop -from .capture_av_device_desktop import CaptureAVDeviceDesktop -from .capture_video_desktop import CaptureVideoDesktop -from .input_audio_stream import InputAudioStream -from .input_stream import InputStream -from .input_video_stream import InputVideoStream -from .smart_stream import SmartStream -from .stream import Stream -from .video_parameters import VideoParameters -from .video_piped import VideoPiped -from .video_quality import VideoQuality -from .video_stream import VideoStream - -__all__ = ( - "AudioParameters", - "AudioImagePiped", - "AudioPiped", - "AudioQuality", - "AudioVideoPiped", - "InputAudioStream", - "Stream", - "InputStream", - "InputVideoStream", - "SmartStream", - "VideoStream", - "AudioStream", - "CaptureAudioDevice", - "CaptureAVDesktop", - "CaptureAVDeviceDesktop", - "CaptureVideoDesktop", - "VideoParameters", - "VideoPiped", - "VideoQuality", -) diff --git a/RyuzakiLib/types/input_stream/audio_image_piped.py b/RyuzakiLib/types/input_stream/audio_image_piped.py deleted file mode 100644 index 1ad6b950..00000000 --- a/RyuzakiLib/types/input_stream/audio_image_piped.py +++ /dev/null @@ -1,81 +0,0 @@ -from typing import Dict, Optional - -from ntgcalls import InputMode - -from ...ffmpeg import build_command, check_stream -from .audio_parameters import AudioParameters -from .audio_stream import AudioStream -from .smart_stream import SmartStream -from .video_parameters import VideoParameters -from .video_stream import VideoStream - - -class AudioImagePiped(SmartStream): - def __init__( - self, - audio_path: str, - image_path: str, - audio_parameters: AudioParameters = AudioParameters(), - video_parameters: VideoParameters = VideoParameters(), - headers: Optional[Dict[str, str]] = None, - additional_ffmpeg_parameters: str = "", - ): - self._image_path = image_path - self._audio_path = audio_path - video_parameters.frame_rate = 1 - self._audio_data = ( - additional_ffmpeg_parameters, - self._audio_path, - audio_parameters, - [], - headers, - ) - self._video_data = ( - additional_ffmpeg_parameters, - self._image_path, - video_parameters, - [ - "-loop", - "1", - "-framerate", - str(video_parameters.frame_rate), - ], - headers, - ) - super().__init__( - AudioStream( - InputMode.Shell, - " ".join( - build_command( - "ffmpeg", - *self._audio_data, - ), - ), - audio_parameters, - ), - VideoStream( - InputMode.Shell, - " ".join( - build_command( - "ffmpeg", - *self._video_data, - ), - ), - video_parameters, - ), - ) - - async def check_stream(self): - await check_stream( - *self._audio_data, - ) - await check_stream( - *self._video_data, - need_image=True, - ) - self.stream_video.path = " ".join( - build_command( - "ffmpeg", - *self._video_data, - ), - ) diff --git a/RyuzakiLib/types/input_stream/audio_parameters.py b/RyuzakiLib/types/input_stream/audio_parameters.py deleted file mode 100644 index 789dc1e8..00000000 --- a/RyuzakiLib/types/input_stream/audio_parameters.py +++ /dev/null @@ -1,17 +0,0 @@ -from ..py_object import PyObject -from .audio_quality import AudioQuality - - -class AudioParameters(PyObject): - def __init__( - self, - bitrate: int = 48000, - channels: int = 1, - ): - max_bit, max_chan = max(AudioQuality, key=lambda x: x.value[0]).value - self.bitrate: int = min(bitrate, max_bit) - self.channels: int = min(channels, max_chan) - - @staticmethod - def from_quality(quality: AudioQuality): - return AudioParameters(*quality.value) diff --git a/RyuzakiLib/types/input_stream/audio_piped.py b/RyuzakiLib/types/input_stream/audio_piped.py deleted file mode 100644 index b3370b54..00000000 --- a/RyuzakiLib/types/input_stream/audio_piped.py +++ /dev/null @@ -1,43 +0,0 @@ -from typing import Dict, Optional - -from ntgcalls import InputMode - -from ...ffmpeg import build_command, check_stream -from .audio_parameters import AudioParameters -from .audio_stream import AudioStream -from .smart_stream import SmartStream - - -class AudioPiped(SmartStream): - def __init__( - self, - path: str, - audio_parameters: AudioParameters = AudioParameters(), - headers: Optional[Dict[str, str]] = None, - additional_ffmpeg_parameters: str = "", - ): - self._path = path - self._audio_data = ( - additional_ffmpeg_parameters, - self._path, - audio_parameters, - [], - headers, - ) - super().__init__( - AudioStream( - InputMode.Shell, - " ".join( - build_command( - "ffmpeg", - *self._audio_data, - ), - ), - audio_parameters, - ), - ) - - async def check_stream(self): - await check_stream( - *self._audio_data, - ) diff --git a/RyuzakiLib/types/input_stream/audio_quality.py b/RyuzakiLib/types/input_stream/audio_quality.py deleted file mode 100644 index d5db11a8..00000000 --- a/RyuzakiLib/types/input_stream/audio_quality.py +++ /dev/null @@ -1,8 +0,0 @@ -from enum import Enum - - -class AudioQuality(Enum): - STUDIO = (96000, 2) - HIGH = (48000, 2) - MEDIUM = (36000, 1) - LOW = (24000, 1) diff --git a/RyuzakiLib/types/input_stream/audio_stream.py b/RyuzakiLib/types/input_stream/audio_stream.py deleted file mode 100644 index f95beb90..00000000 --- a/RyuzakiLib/types/input_stream/audio_stream.py +++ /dev/null @@ -1,16 +0,0 @@ -from ntgcalls import InputMode - -from ..py_object import PyObject -from .audio_parameters import AudioParameters - - -class AudioStream(PyObject): - def __init__( - self, - input_mode: InputMode, - path: str, - parameters: AudioParameters = AudioParameters(), - ): - self.input_mode: InputMode = input_mode - self.path: str = path - self.parameters: AudioParameters = parameters diff --git a/RyuzakiLib/types/input_stream/audio_video_piped.py b/RyuzakiLib/types/input_stream/audio_video_piped.py deleted file mode 100644 index f811b89a..00000000 --- a/RyuzakiLib/types/input_stream/audio_video_piped.py +++ /dev/null @@ -1,72 +0,0 @@ -from typing import Dict, Optional - -from ntgcalls import InputMode - -from ...ffmpeg import build_command, check_stream -from .audio_parameters import AudioParameters -from .audio_stream import AudioStream -from .smart_stream import SmartStream -from .video_parameters import VideoParameters -from .video_stream import VideoStream - - -class AudioVideoPiped(SmartStream): - def __init__( - self, - path: str, - audio_parameters: AudioParameters = AudioParameters(), - video_parameters: VideoParameters = VideoParameters(), - headers: Optional[Dict[str, str]] = None, - additional_ffmpeg_parameters: str = "", - ): - self._path = path - self._audio_data = ( - additional_ffmpeg_parameters, - self._path, - audio_parameters, - [], - headers, - ) - self._video_data = ( - additional_ffmpeg_parameters, - self._path, - video_parameters, - [], - headers, - ) - super().__init__( - AudioStream( - InputMode.Shell, - " ".join( - build_command( - "ffmpeg", - *self._audio_data, - ), - ), - audio_parameters, - ), - VideoStream( - InputMode.Shell, - " ".join( - build_command( - "ffmpeg", - *self._video_data, - ), - ), - video_parameters, - ), - ) - - async def check_stream(self): - await check_stream( - *self._audio_data, - ) - await check_stream( - *self._video_data, - ) - self.stream_video.path = " ".join( - build_command( - "ffmpeg", - *self._video_data, - ), - ) diff --git a/RyuzakiLib/types/input_stream/capture_audio_device.py b/RyuzakiLib/types/input_stream/capture_audio_device.py deleted file mode 100644 index 4926be5c..00000000 --- a/RyuzakiLib/types/input_stream/capture_audio_device.py +++ /dev/null @@ -1,31 +0,0 @@ -from ntgcalls import InputMode - -from ...ffmpeg import build_command -from ...media_devices.device_info import DeviceInfo -from .audio_parameters import AudioParameters -from .audio_stream import AudioStream -from .smart_stream import SmartStream - - -class CaptureAudioDevice(SmartStream): - def __init__( - self, - audio_info: DeviceInfo, - audio_parameters: AudioParameters = AudioParameters(), - ): - self._audio_path: str = audio_info.build_ffmpeg_command() - super().__init__( - AudioStream( - InputMode.Shell, - " ".join( - build_command( - "ffmpeg", - "", - self._audio_path, - audio_parameters, - audio_info.ffmpeg_parameters, - ), - ), - audio_parameters, - ), - ) diff --git a/RyuzakiLib/types/input_stream/capture_av_desktop.py b/RyuzakiLib/types/input_stream/capture_av_desktop.py deleted file mode 100644 index 5e7191cc..00000000 --- a/RyuzakiLib/types/input_stream/capture_av_desktop.py +++ /dev/null @@ -1,64 +0,0 @@ -from typing import Dict, Optional - -from ntgcalls import InputMode - -from ...ffmpeg import build_command, check_stream -from ...media_devices.screen_info import ScreenInfo -from .audio_parameters import AudioParameters -from .audio_stream import AudioStream -from .smart_stream import SmartStream -from .video_parameters import VideoParameters -from .video_stream import VideoStream - - -class CaptureAVDesktop(SmartStream): - def __init__( - self, - audio_path: str, - screen_info: ScreenInfo, - headers: Optional[Dict[str, str]] = None, - additional_ffmpeg_parameters: str = "", - audio_parameters: AudioParameters = AudioParameters(), - video_parameters: VideoParameters = VideoParameters(), - ): - self._audio_path = audio_path - self._video_path = screen_info.build_ffmpeg_command( - video_parameters.frame_rate, - ) - self._audio_data = ( - additional_ffmpeg_parameters, - self._audio_path, - audio_parameters, - [], - headers, - ) - super().__init__( - AudioStream( - InputMode.Shell, - " ".join( - build_command( - "ffmpeg", - *self._audio_data, - ), - ), - audio_parameters, - ), - VideoStream( - InputMode.Shell, - " ".join( - build_command( - "ffmpeg", - "", - self._video_path, - video_parameters, - screen_info.ffmpeg_parameters, - ), - ), - video_parameters, - ), - ) - - async def check_stream(self): - await check_stream( - *self._audio_data, - ) diff --git a/RyuzakiLib/types/input_stream/capture_av_device_desktop.py b/RyuzakiLib/types/input_stream/capture_av_device_desktop.py deleted file mode 100644 index e464614b..00000000 --- a/RyuzakiLib/types/input_stream/capture_av_device_desktop.py +++ /dev/null @@ -1,55 +0,0 @@ -from ntgcalls import InputMode - -from ...ffmpeg import build_command -from ...media_devices.device_info import DeviceInfo -from ...media_devices.screen_info import ScreenInfo -from .audio_parameters import AudioParameters -from .audio_stream import AudioStream -from .smart_stream import SmartStream -from .video_parameters import VideoParameters -from .video_stream import VideoStream - - -class CaptureAVDeviceDesktop(SmartStream): - def __init__( - self, - audio_info: DeviceInfo, - screen_info: ScreenInfo, - audio_parameters: AudioParameters = AudioParameters(), - video_parameters: VideoParameters = VideoParameters(), - ): - self._audio_path = audio_info.build_ffmpeg_command() - self._video_path = screen_info.build_ffmpeg_command( - video_parameters.frame_rate, - ) - audio_data = ( - "", - self._audio_path, - audio_parameters, - audio_info.ffmpeg_parameters, - ) - super().__init__( - AudioStream( - InputMode.Shell, - " ".join( - build_command( - "ffmpeg", - *audio_data, - ), - ), - audio_parameters, - ), - VideoStream( - InputMode.Shell, - " ".join( - build_command( - "ffmpeg", - "", - self._video_path, - video_parameters, - screen_info.ffmpeg_parameters, - ), - ), - video_parameters, - ), - ) diff --git a/RyuzakiLib/types/input_stream/capture_video_desktop.py b/RyuzakiLib/types/input_stream/capture_video_desktop.py deleted file mode 100644 index 115c3d0b..00000000 --- a/RyuzakiLib/types/input_stream/capture_video_desktop.py +++ /dev/null @@ -1,32 +0,0 @@ -from ntgcalls import InputMode - -from ...ffmpeg import build_command -from ...media_devices.screen_info import ScreenInfo -from .smart_stream import SmartStream -from .video_parameters import VideoParameters -from .video_stream import VideoStream - - -class CaptureVideoDesktop(SmartStream): - def __init__( - self, - screen_info: ScreenInfo, - video_parameters: VideoParameters = VideoParameters(), - ): - self._path = screen_info.build_ffmpeg_command( - video_parameters.frame_rate, - ) - super().__init__( - stream_video=VideoStream( - InputMode.Shell, - " ".join( - build_command( - "ffmpeg", - "", - self._path, - video_parameters, - screen_info.ffmpeg_parameters, - ), - ), - ), - ) diff --git a/RyuzakiLib/types/input_stream/input_audio_stream.py b/RyuzakiLib/types/input_stream/input_audio_stream.py deleted file mode 100644 index b628ec68..00000000 --- a/RyuzakiLib/types/input_stream/input_audio_stream.py +++ /dev/null @@ -1,20 +0,0 @@ -from deprecation import deprecated -from ntgcalls import InputMode - -from .audio_parameters import AudioParameters -from .audio_stream import AudioStream - - -@deprecated( - deprecated_in="1.0.0.dev1", - details="Use pytgcalls.types.AudioStream instead.", -) -class InputAudioStream(AudioStream): - def __init__( - self, - path: str, - parameters: AudioParameters = AudioParameters(), - header_enabled: bool = False, - ): - super().__init__(InputMode.File, path, parameters) - self.header_enabled = header_enabled diff --git a/RyuzakiLib/types/input_stream/input_stream.py b/RyuzakiLib/types/input_stream/input_stream.py deleted file mode 100644 index a33416b7..00000000 --- a/RyuzakiLib/types/input_stream/input_stream.py +++ /dev/null @@ -1,22 +0,0 @@ -from typing import Optional - -from deprecation import deprecated - -from .input_audio_stream import InputAudioStream -from .input_video_stream import InputVideoStream -from .stream import Stream - - -@deprecated( - deprecated_in="1.0.0.dev1", - details="This class is no longer supported." "Use pytgcalls.types.Stream instead.", -) -class InputStream(Stream): - def __init__( - self, - stream_audio: Optional[InputAudioStream] = None, - stream_video: Optional[InputVideoStream] = None, - lip_sync: bool = False, - ): - super().__init__(stream_audio, stream_video) - self.lip_sync = lip_sync diff --git a/RyuzakiLib/types/input_stream/input_video_stream.py b/RyuzakiLib/types/input_stream/input_video_stream.py deleted file mode 100644 index 77724512..00000000 --- a/RyuzakiLib/types/input_stream/input_video_stream.py +++ /dev/null @@ -1,20 +0,0 @@ -from deprecation import deprecated -from ntgcalls import InputMode - -from .video_parameters import VideoParameters -from .video_stream import VideoStream - - -@deprecated( - deprecated_in="1.0.0.dev1", - details="Use pytgcalls.VideoStream instead.", -) -class InputVideoStream(VideoStream): - def __init__( - self, - path: str, - parameters: VideoParameters = VideoParameters(), - header_enabled: bool = False, - ): - super().__init__(InputMode.File, path, parameters) - self.header_enabled = header_enabled diff --git a/RyuzakiLib/types/input_stream/quality/__init__.py b/RyuzakiLib/types/input_stream/quality/__init__.py deleted file mode 100644 index ee789b21..00000000 --- a/RyuzakiLib/types/input_stream/quality/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -from .high_quality_audio import HighQualityAudio -from .high_quality_video import HighQualityVideo -from .low_quality_audio import LowQualityAudio -from .low_quality_video import LowQualityVideo -from .medium_quality_audio import MediumQualityAudio -from .medium_quality_video import MediumQualityVideo - -__all__ = ( - "HighQualityAudio", - "HighQualityVideo", - "LowQualityAudio", - "LowQualityVideo", - "MediumQualityAudio", - "MediumQualityVideo", -) diff --git a/RyuzakiLib/types/input_stream/quality/high_quality_audio.py b/RyuzakiLib/types/input_stream/quality/high_quality_audio.py deleted file mode 100644 index 4bb2dcd1..00000000 --- a/RyuzakiLib/types/input_stream/quality/high_quality_audio.py +++ /dev/null @@ -1,14 +0,0 @@ -from deprecation import deprecated - -from ..audio_parameters import AudioParameters -from ..audio_quality import AudioQuality - - -@deprecated( - deprecated_in="1.0.0.dev6", - details="This class is no longer supported." - "Use pytgcalls.types.AudioParameters.from_quality instead.", -) -class HighQualityAudio(AudioParameters): - def __init__(self): - super().__init__(*AudioQuality.HIGH.value) diff --git a/RyuzakiLib/types/input_stream/quality/high_quality_video.py b/RyuzakiLib/types/input_stream/quality/high_quality_video.py deleted file mode 100644 index 01495373..00000000 --- a/RyuzakiLib/types/input_stream/quality/high_quality_video.py +++ /dev/null @@ -1,14 +0,0 @@ -from deprecation import deprecated - -from ..video_parameters import VideoParameters -from ..video_quality import VideoQuality - - -@deprecated( - deprecated_in="1.0.0.dev6", - details="This class is no longer supported." - "Use pytgcalls.types.VideoParameters.from_quality instead.", -) -class HighQualityVideo(VideoParameters): - def __init__(self): - super().__init__(*VideoQuality.HD_720p.value) diff --git a/RyuzakiLib/types/input_stream/quality/low_quality_audio.py b/RyuzakiLib/types/input_stream/quality/low_quality_audio.py deleted file mode 100644 index b8d7ac2d..00000000 --- a/RyuzakiLib/types/input_stream/quality/low_quality_audio.py +++ /dev/null @@ -1,14 +0,0 @@ -from deprecation import deprecated - -from ..audio_parameters import AudioParameters -from ..audio_quality import AudioQuality - - -@deprecated( - deprecated_in="1.0.0.dev6", - details="This class is no longer supported." - "Use pytgcalls.types.AudioParameters.from_quality instead.", -) -class LowQualityAudio(AudioParameters): - def __init__(self): - super().__init__(*AudioQuality.LOW.value) diff --git a/RyuzakiLib/types/input_stream/quality/low_quality_video.py b/RyuzakiLib/types/input_stream/quality/low_quality_video.py deleted file mode 100644 index 17d56e44..00000000 --- a/RyuzakiLib/types/input_stream/quality/low_quality_video.py +++ /dev/null @@ -1,14 +0,0 @@ -from deprecation import deprecated - -from ..video_parameters import VideoParameters -from ..video_quality import VideoQuality - - -@deprecated( - deprecated_in="1.0.0.dev6", - details="This class is no longer supported." - "Use pytgcalls.types.VideoParameters.from_quality instead.", -) -class LowQualityVideo(VideoParameters): - def __init__(self): - super().__init__(*VideoQuality.SD_480p.value) diff --git a/RyuzakiLib/types/input_stream/quality/medium_quality_audio.py b/RyuzakiLib/types/input_stream/quality/medium_quality_audio.py deleted file mode 100644 index 5f34cd6f..00000000 --- a/RyuzakiLib/types/input_stream/quality/medium_quality_audio.py +++ /dev/null @@ -1,14 +0,0 @@ -from deprecation import deprecated - -from ..audio_parameters import AudioParameters -from ..audio_quality import AudioQuality - - -@deprecated( - deprecated_in="1.0.0.dev6", - details="This class is no longer supported." - "Use pytgcalls.types.AudioParameters.from_quality instead.", -) -class MediumQualityAudio(AudioParameters): - def __init__(self): - super().__init__(*AudioQuality.MEDIUM.value) diff --git a/RyuzakiLib/types/input_stream/quality/medium_quality_video.py b/RyuzakiLib/types/input_stream/quality/medium_quality_video.py deleted file mode 100644 index 717804c3..00000000 --- a/RyuzakiLib/types/input_stream/quality/medium_quality_video.py +++ /dev/null @@ -1,14 +0,0 @@ -from deprecation import deprecated - -from ..video_parameters import VideoParameters -from ..video_quality import VideoQuality - - -@deprecated( - deprecated_in="1.0.0.dev6", - details="This class is no longer supported." - "Use pytgcalls.types.VideoParameters.from_quality instead.", -) -class MediumQualityVideo(VideoParameters): - def __init__(self): - super().__init__(*VideoQuality.SD_360p.value) diff --git a/RyuzakiLib/types/input_stream/smart_stream.py b/RyuzakiLib/types/input_stream/smart_stream.py deleted file mode 100644 index 1377f0ae..00000000 --- a/RyuzakiLib/types/input_stream/smart_stream.py +++ /dev/null @@ -1,27 +0,0 @@ -from typing import Dict, List, Optional, Tuple - -from .audio_parameters import AudioParameters -from .stream import Stream -from .video_parameters import VideoParameters - - -class SmartStream(Stream): - def __init(self): - self._audio_data: Tuple[ - str, - str, - AudioParameters, - List[str], - Optional[Dict[str, str]], - ] - self._video_data: Tuple[ - str, - str, - VideoParameters, - List[str], - Optional[Dict[str, str]], - ] - pass - - async def check_stream(self): - pass diff --git a/RyuzakiLib/types/input_stream/stream.py b/RyuzakiLib/types/input_stream/stream.py deleted file mode 100644 index 0352e774..00000000 --- a/RyuzakiLib/types/input_stream/stream.py +++ /dev/null @@ -1,15 +0,0 @@ -from typing import Optional - -from ..py_object import PyObject -from .audio_stream import AudioStream -from .video_stream import VideoStream - - -class Stream(PyObject): - def __init__( - self, - stream_audio: Optional[AudioStream] = None, - stream_video: Optional[VideoStream] = None, - ): - self.stream_audio: Optional[AudioStream] = stream_audio - self.stream_video: Optional[VideoStream] = stream_video diff --git a/RyuzakiLib/types/input_stream/video_parameters.py b/RyuzakiLib/types/input_stream/video_parameters.py deleted file mode 100644 index 3bcaa220..00000000 --- a/RyuzakiLib/types/input_stream/video_parameters.py +++ /dev/null @@ -1,22 +0,0 @@ -from ..py_object import PyObject -from .video_quality import VideoQuality - - -class VideoParameters(PyObject): - def __init__( - self, - width: int = 640, - height: int = 360, - frame_rate: int = 20, - ): - max_w, max_h, max_fps = max( - VideoQuality, - key=lambda x: x.value[0], - ).value - self.width: int = min(width, max_w) - self.height: int = min(height, max_h) - self.frame_rate: int = min(frame_rate, max_fps) - - @staticmethod - def from_quality(quality: VideoQuality): - return VideoParameters(*quality.value) diff --git a/RyuzakiLib/types/input_stream/video_piped.py b/RyuzakiLib/types/input_stream/video_piped.py deleted file mode 100644 index 0d17007e..00000000 --- a/RyuzakiLib/types/input_stream/video_piped.py +++ /dev/null @@ -1,49 +0,0 @@ -from typing import Dict, Optional - -from ntgcalls import InputMode - -from ...ffmpeg import build_command, check_stream -from .smart_stream import SmartStream -from .video_parameters import VideoParameters -from .video_stream import VideoStream - - -class VideoPiped(SmartStream): - def __init__( - self, - path: str, - video_parameters: VideoParameters = VideoParameters(), - headers: Optional[Dict[str, str]] = None, - additional_ffmpeg_parameters: str = "", - ): - self._path = path - self._video_data = ( - additional_ffmpeg_parameters, - self._path, - video_parameters, - [], - headers, - ) - super().__init__( - stream_video=VideoStream( - InputMode.Shell, - " ".join( - build_command( - "ffmpeg", - *self._video_data, - ), - ), - video_parameters, - ), - ) - - async def check_stream(self): - await check_stream( - *self._video_data, - ) - self.stream_video.path = " ".join( - build_command( - "ffmpeg", - *self._video_data, - ), - ) diff --git a/RyuzakiLib/types/input_stream/video_quality.py b/RyuzakiLib/types/input_stream/video_quality.py deleted file mode 100644 index 21bc01a1..00000000 --- a/RyuzakiLib/types/input_stream/video_quality.py +++ /dev/null @@ -1,10 +0,0 @@ -from enum import Enum - - -class VideoQuality(Enum): - UHD_4K = (3840, 2160, 60) - QHD_2K = (2560, 1440, 60) - FHD_1080p = (1920, 1080, 60) - HD_720p = (1280, 720, 30) - SD_480p = (854, 480, 30) - SD_360p = (640, 360, 30) diff --git a/RyuzakiLib/types/input_stream/video_stream.py b/RyuzakiLib/types/input_stream/video_stream.py deleted file mode 100644 index fb62f3b0..00000000 --- a/RyuzakiLib/types/input_stream/video_stream.py +++ /dev/null @@ -1,15 +0,0 @@ -from ntgcalls import InputMode - -from .video_parameters import VideoParameters - - -class VideoStream: - def __init__( - self, - input_mode: InputMode, - path: str, - parameters: VideoParameters = VideoParameters(), - ): - self.input_mode: InputMode = input_mode - self.path: str = path - self.parameters: VideoParameters = parameters From 86604127673dc716d593ef5a08f1716b01bcf27f Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Wed, 21 Aug 2024 17:41:01 +0700 Subject: [PATCH 081/152] _ --- RyuzakiLib/types/groups/__init__.py | 27 ------------------- RyuzakiLib/types/groups/already_joined.py | 9 ------- RyuzakiLib/types/groups/error_during_join.py | 9 ------- RyuzakiLib/types/groups/group_call.py | 18 ------------- .../types/groups/group_call_participant.py | 23 ---------------- .../groups/joined_group_call_participant.py | 12 --------- RyuzakiLib/types/groups/joined_voice_chat.py | 11 -------- .../groups/left_group_call_participant.py | 12 --------- RyuzakiLib/types/groups/left_voice_chat.py | 11 -------- RyuzakiLib/types/groups/muted_call.py | 9 ------- RyuzakiLib/types/groups/not_in_group_call.py | 9 ------- .../groups/updated_group_call_participant.py | 12 --------- RyuzakiLib/types/groups/upgrade_needed.py | 9 ------- 13 files changed, 171 deletions(-) delete mode 100644 RyuzakiLib/types/groups/__init__.py delete mode 100644 RyuzakiLib/types/groups/already_joined.py delete mode 100644 RyuzakiLib/types/groups/error_during_join.py delete mode 100644 RyuzakiLib/types/groups/group_call.py delete mode 100644 RyuzakiLib/types/groups/group_call_participant.py delete mode 100644 RyuzakiLib/types/groups/joined_group_call_participant.py delete mode 100644 RyuzakiLib/types/groups/joined_voice_chat.py delete mode 100644 RyuzakiLib/types/groups/left_group_call_participant.py delete mode 100644 RyuzakiLib/types/groups/left_voice_chat.py delete mode 100644 RyuzakiLib/types/groups/muted_call.py delete mode 100644 RyuzakiLib/types/groups/not_in_group_call.py delete mode 100644 RyuzakiLib/types/groups/updated_group_call_participant.py delete mode 100644 RyuzakiLib/types/groups/upgrade_needed.py diff --git a/RyuzakiLib/types/groups/__init__.py b/RyuzakiLib/types/groups/__init__.py deleted file mode 100644 index 374fc761..00000000 --- a/RyuzakiLib/types/groups/__init__.py +++ /dev/null @@ -1,27 +0,0 @@ -from .already_joined import AlreadyJoined -from .error_during_join import ErrorDuringJoin -from .group_call import GroupCall -from .group_call_participant import GroupCallParticipant -from .joined_group_call_participant import JoinedGroupCallParticipant -from .joined_voice_chat import JoinedVoiceChat -from .left_group_call_participant import LeftGroupCallParticipant -from .left_voice_chat import LeftVoiceChat -from .muted_call import MutedCall -from .not_in_group_call import NotInGroupCall -from .updated_group_call_participant import UpdatedGroupCallParticipant -from .upgrade_needed import UpgradeNeeded - -__all__ = ( - "AlreadyJoined", - "ErrorDuringJoin", - "GroupCall", - "GroupCallParticipant", - "JoinedGroupCallParticipant", - "JoinedVoiceChat", - "LeftGroupCallParticipant", - "LeftVoiceChat", - "NotInGroupCall", - "UpdatedGroupCallParticipant", - "UpgradeNeeded", - "MutedCall", -) diff --git a/RyuzakiLib/types/groups/already_joined.py b/RyuzakiLib/types/groups/already_joined.py deleted file mode 100644 index 4c48c134..00000000 --- a/RyuzakiLib/types/groups/already_joined.py +++ /dev/null @@ -1,9 +0,0 @@ -from ...types.update import Update - - -class AlreadyJoined(Update): - def __init__( - self, - chat_id: int, - ): - super().__init__(chat_id) diff --git a/RyuzakiLib/types/groups/error_during_join.py b/RyuzakiLib/types/groups/error_during_join.py deleted file mode 100644 index 4ac176c1..00000000 --- a/RyuzakiLib/types/groups/error_during_join.py +++ /dev/null @@ -1,9 +0,0 @@ -from ...types.update import Update - - -class ErrorDuringJoin(Update): - def __init__( - self, - chat_id: int, - ): - super().__init__(chat_id) diff --git a/RyuzakiLib/types/groups/group_call.py b/RyuzakiLib/types/groups/group_call.py deleted file mode 100644 index 142cead8..00000000 --- a/RyuzakiLib/types/groups/group_call.py +++ /dev/null @@ -1,18 +0,0 @@ -from RyuzakiLib.types.py_object import PyObject - - -class GroupCall(PyObject): - def __init__( - self, - chat_id: int, - binary_status: int, - ): - self.chat_id: int = chat_id - self.is_playing: bool = binary_status != 3 - self.status: str = "unknown" - if binary_status == 1: - self.status = "playing" - elif binary_status == 2: - self.status = "paused" - elif binary_status == 3: - self.status = "not_playing" diff --git a/RyuzakiLib/types/groups/group_call_participant.py b/RyuzakiLib/types/groups/group_call_participant.py deleted file mode 100644 index 1567b719..00000000 --- a/RyuzakiLib/types/groups/group_call_participant.py +++ /dev/null @@ -1,23 +0,0 @@ -from RyuzakiLib.types.py_object import PyObject - - -class GroupCallParticipant(PyObject): - def __init__( - self, - user_id: int, - muted: bool, - muted_by_admin: bool, - video: bool, - screen_sharing: bool, - video_camera: bool, - raised_hand: bool, - volume: int, - ): - self.user_id: int = user_id - self.muted: bool = muted - self.muted_by_admin: bool = muted_by_admin - self.video: bool = video - self.screen_sharing: bool = screen_sharing - self.video_camera: bool = video_camera - self.raised_hand: bool = raised_hand - self.volume: int = volume diff --git a/RyuzakiLib/types/groups/joined_group_call_participant.py b/RyuzakiLib/types/groups/joined_group_call_participant.py deleted file mode 100644 index 92e0bb46..00000000 --- a/RyuzakiLib/types/groups/joined_group_call_participant.py +++ /dev/null @@ -1,12 +0,0 @@ -from ...types.groups.group_call_participant import GroupCallParticipant -from ...types.update import Update - - -class JoinedGroupCallParticipant(Update): - def __init__( - self, - chat_id: int, - participant: GroupCallParticipant, - ): - super().__init__(chat_id) - self.participant = participant diff --git a/RyuzakiLib/types/groups/joined_voice_chat.py b/RyuzakiLib/types/groups/joined_voice_chat.py deleted file mode 100644 index cf645650..00000000 --- a/RyuzakiLib/types/groups/joined_voice_chat.py +++ /dev/null @@ -1,11 +0,0 @@ -from typing import Union - -from ...types.update import Update - - -class JoinedVoiceChat(Update): - def __init__( - self, - chat_id: Union[int, str], - ): - super().__init__(chat_id) diff --git a/RyuzakiLib/types/groups/left_group_call_participant.py b/RyuzakiLib/types/groups/left_group_call_participant.py deleted file mode 100644 index 3fea5b60..00000000 --- a/RyuzakiLib/types/groups/left_group_call_participant.py +++ /dev/null @@ -1,12 +0,0 @@ -from ...types.groups.group_call_participant import GroupCallParticipant -from ...types.update import Update - - -class LeftGroupCallParticipant(Update): - def __init__( - self, - chat_id: int, - participant: GroupCallParticipant, - ): - super().__init__(chat_id) - self.participant = participant diff --git a/RyuzakiLib/types/groups/left_voice_chat.py b/RyuzakiLib/types/groups/left_voice_chat.py deleted file mode 100644 index bd3f38d1..00000000 --- a/RyuzakiLib/types/groups/left_voice_chat.py +++ /dev/null @@ -1,11 +0,0 @@ -from typing import Union - -from ...types.update import Update - - -class LeftVoiceChat(Update): - def __init__( - self, - chat_id: Union[int, str], - ): - super().__init__(chat_id) diff --git a/RyuzakiLib/types/groups/muted_call.py b/RyuzakiLib/types/groups/muted_call.py deleted file mode 100644 index 74a2d34a..00000000 --- a/RyuzakiLib/types/groups/muted_call.py +++ /dev/null @@ -1,9 +0,0 @@ -from ...types.update import Update - - -class MutedCall(Update): - def __init__( - self, - chat_id: int, - ): - super().__init__(chat_id) diff --git a/RyuzakiLib/types/groups/not_in_group_call.py b/RyuzakiLib/types/groups/not_in_group_call.py deleted file mode 100644 index dd418096..00000000 --- a/RyuzakiLib/types/groups/not_in_group_call.py +++ /dev/null @@ -1,9 +0,0 @@ -from ...types.update import Update - - -class NotInGroupCall(Update): - def __init__( - self, - chat_id: int, - ): - super().__init__(chat_id) diff --git a/RyuzakiLib/types/groups/updated_group_call_participant.py b/RyuzakiLib/types/groups/updated_group_call_participant.py deleted file mode 100644 index 77b877be..00000000 --- a/RyuzakiLib/types/groups/updated_group_call_participant.py +++ /dev/null @@ -1,12 +0,0 @@ -from ...types.groups.group_call_participant import GroupCallParticipant -from ...types.update import Update - - -class UpdatedGroupCallParticipant(Update): - def __init__( - self, - chat_id: int, - participant: GroupCallParticipant, - ): - super().__init__(chat_id) - self.participant = participant diff --git a/RyuzakiLib/types/groups/upgrade_needed.py b/RyuzakiLib/types/groups/upgrade_needed.py deleted file mode 100644 index 0e6546f5..00000000 --- a/RyuzakiLib/types/groups/upgrade_needed.py +++ /dev/null @@ -1,9 +0,0 @@ -from ...types.update import Update - - -class UpgradeNeeded(Update): - def __init__( - self, - chat_id: int, - ): - super().__init__(chat_id) From 974fc380c313197494bcdd597432887d05e387dc Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Wed, 21 Aug 2024 17:41:16 +0700 Subject: [PATCH 082/152] _ --- RyuzakiLib/types/stream/__init__.py | 21 ------------------- RyuzakiLib/types/stream/changed_stream.py | 11 ---------- RyuzakiLib/types/stream/muted_stream.py | 9 -------- RyuzakiLib/types/stream/paused_stream.py | 11 ---------- RyuzakiLib/types/stream/resumed_stream.py | 11 ---------- RyuzakiLib/types/stream/stream_audio_ended.py | 9 -------- RyuzakiLib/types/stream/stream_deleted.py | 16 -------------- RyuzakiLib/types/stream/stream_time.py | 6 ------ RyuzakiLib/types/stream/stream_video_ended.py | 9 -------- RyuzakiLib/types/stream/unmuted_stream.py | 9 -------- 10 files changed, 112 deletions(-) delete mode 100644 RyuzakiLib/types/stream/__init__.py delete mode 100644 RyuzakiLib/types/stream/changed_stream.py delete mode 100644 RyuzakiLib/types/stream/muted_stream.py delete mode 100644 RyuzakiLib/types/stream/paused_stream.py delete mode 100644 RyuzakiLib/types/stream/resumed_stream.py delete mode 100644 RyuzakiLib/types/stream/stream_audio_ended.py delete mode 100644 RyuzakiLib/types/stream/stream_deleted.py delete mode 100644 RyuzakiLib/types/stream/stream_time.py delete mode 100644 RyuzakiLib/types/stream/stream_video_ended.py delete mode 100644 RyuzakiLib/types/stream/unmuted_stream.py diff --git a/RyuzakiLib/types/stream/__init__.py b/RyuzakiLib/types/stream/__init__.py deleted file mode 100644 index 70ae24f0..00000000 --- a/RyuzakiLib/types/stream/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -from .changed_stream import ChangedStream -from .muted_stream import MutedStream -from .paused_stream import PausedStream -from .resumed_stream import ResumedStream -from .stream_audio_ended import StreamAudioEnded -from .stream_deleted import StreamDeleted -from .stream_time import StreamTime -from .stream_video_ended import StreamVideoEnded -from .unmuted_stream import UnMutedStream - -__all__ = ( - "ChangedStream", - "MutedStream", - "PausedStream", - "ResumedStream", - "StreamAudioEnded", - "StreamDeleted", - "StreamVideoEnded", - "UnMutedStream", - "StreamTime", -) diff --git a/RyuzakiLib/types/stream/changed_stream.py b/RyuzakiLib/types/stream/changed_stream.py deleted file mode 100644 index 3c13df37..00000000 --- a/RyuzakiLib/types/stream/changed_stream.py +++ /dev/null @@ -1,11 +0,0 @@ -from typing import Union - -from ...types.update import Update - - -class ChangedStream(Update): - def __init__( - self, - chat_id: Union[int, str], - ): - super().__init__(chat_id) diff --git a/RyuzakiLib/types/stream/muted_stream.py b/RyuzakiLib/types/stream/muted_stream.py deleted file mode 100644 index 23531d80..00000000 --- a/RyuzakiLib/types/stream/muted_stream.py +++ /dev/null @@ -1,9 +0,0 @@ -from ...types.update import Update - - -class MutedStream(Update): - def __init__( - self, - chat_id: int, - ): - super().__init__(chat_id) diff --git a/RyuzakiLib/types/stream/paused_stream.py b/RyuzakiLib/types/stream/paused_stream.py deleted file mode 100644 index d0308bbc..00000000 --- a/RyuzakiLib/types/stream/paused_stream.py +++ /dev/null @@ -1,11 +0,0 @@ -from typing import Union - -from ...types.update import Update - - -class PausedStream(Update): - def __init__( - self, - chat_id: Union[int, str], - ): - super().__init__(chat_id) diff --git a/RyuzakiLib/types/stream/resumed_stream.py b/RyuzakiLib/types/stream/resumed_stream.py deleted file mode 100644 index d5b02b68..00000000 --- a/RyuzakiLib/types/stream/resumed_stream.py +++ /dev/null @@ -1,11 +0,0 @@ -from typing import Union - -from ...types.update import Update - - -class ResumedStream(Update): - def __init__( - self, - chat_id: Union[int, str], - ): - super().__init__(chat_id) diff --git a/RyuzakiLib/types/stream/stream_audio_ended.py b/RyuzakiLib/types/stream/stream_audio_ended.py deleted file mode 100644 index e5b1bd34..00000000 --- a/RyuzakiLib/types/stream/stream_audio_ended.py +++ /dev/null @@ -1,9 +0,0 @@ -from ...types.update import Update - - -class StreamAudioEnded(Update): - def __init__( - self, - chat_id: int, - ): - super().__init__(chat_id) diff --git a/RyuzakiLib/types/stream/stream_deleted.py b/RyuzakiLib/types/stream/stream_deleted.py deleted file mode 100644 index c63f563d..00000000 --- a/RyuzakiLib/types/stream/stream_deleted.py +++ /dev/null @@ -1,16 +0,0 @@ -from deprecation import deprecated - -from ...types.update import Update - - -@deprecated( - deprecated_in="1.0.0.dev1", - removed_in="1.0.0.dev1", - details="This method is no longer supported.", -) -class StreamDeleted(Update): - def __init__( - self, - chat_id: int, - ): - super().__init__(chat_id) diff --git a/RyuzakiLib/types/stream/stream_time.py b/RyuzakiLib/types/stream/stream_time.py deleted file mode 100644 index 8614e934..00000000 --- a/RyuzakiLib/types/stream/stream_time.py +++ /dev/null @@ -1,6 +0,0 @@ -class StreamTime: - def __init__( - self, - time: int, - ): - self.time = time diff --git a/RyuzakiLib/types/stream/stream_video_ended.py b/RyuzakiLib/types/stream/stream_video_ended.py deleted file mode 100644 index 07a4ab0d..00000000 --- a/RyuzakiLib/types/stream/stream_video_ended.py +++ /dev/null @@ -1,9 +0,0 @@ -from ...types.update import Update - - -class StreamVideoEnded(Update): - def __init__( - self, - chat_id: int, - ): - super().__init__(chat_id) diff --git a/RyuzakiLib/types/stream/unmuted_stream.py b/RyuzakiLib/types/stream/unmuted_stream.py deleted file mode 100644 index fea23763..00000000 --- a/RyuzakiLib/types/stream/unmuted_stream.py +++ /dev/null @@ -1,9 +0,0 @@ -from ...types.update import Update - - -class UnMutedStream(Update): - def __init__( - self, - chat_id: int, - ): - super().__init__(chat_id) From cd9f8a50b96549f6b62a55363325dbf6a1d43fd8 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Wed, 21 Aug 2024 17:42:40 +0700 Subject: [PATCH 083/152] _ --- RyuzakiLib/types/participant_list.py | 68 ---------------------------- 1 file changed, 68 deletions(-) delete mode 100644 RyuzakiLib/types/participant_list.py diff --git a/RyuzakiLib/types/participant_list.py b/RyuzakiLib/types/participant_list.py deleted file mode 100644 index e10f8a45..00000000 --- a/RyuzakiLib/types/participant_list.py +++ /dev/null @@ -1,68 +0,0 @@ -from typing import Dict - -from RyuzakiLib.types.groups import GroupCallParticipant -from RyuzakiLib.types.list import List - - -class ParticipantList: - def __init__( - self, - input_id: int, - ): - self._list_participants: Dict[int, GroupCallParticipant] = {} - self.last_mtproto_update: int = 0 - self.input_id: int = input_id - - def set_participant( - self, - user_id: int, - muted: bool, - muted_by_admin: bool, - video: bool, - screen_sharing: bool, - video_camera: bool, - raised_hand: bool, - volume: int, - ): - participant = GroupCallParticipant( - user_id, - muted, - muted_by_admin, - video, - screen_sharing, - video_camera, - raised_hand, - volume, - ) - self._list_participants[user_id] = participant - return participant - - def remove_participant( - self, - user_id: int, - muted: bool, - muted_by_admin: bool, - video: bool, - screen_sharing: bool, - video_camera: bool, - raised_hand: bool, - volume: int, - ): - participant = GroupCallParticipant( - user_id, - muted, - muted_by_admin, - video, - screen_sharing, - video_camera, - raised_hand, - volume, - ) - if user_id in self._list_participants: - del self._list_participants[user_id] - return participant - - def get_participants( - self, - ): - return List([self._list_participants[user_id] for user_id in self._list_participants]) From 24c86e012e5d2f4c794d6f0f5a928f24b1b5eeed Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Wed, 21 Aug 2024 17:44:03 +0700 Subject: [PATCH 084/152] _ --- RyuzakiLib/types/__init__.py | 96 ------------------------------------ 1 file changed, 96 deletions(-) diff --git a/RyuzakiLib/types/__init__.py b/RyuzakiLib/types/__init__.py index 3cb53752..d3130738 100644 --- a/RyuzakiLib/types/__init__.py +++ b/RyuzakiLib/types/__init__.py @@ -3,101 +3,5 @@ from .anime import * from .browsers import Browsers from .cache import Cache -from .groups import ( - AlreadyJoined, - ErrorDuringJoin, - GroupCall, - GroupCallParticipant, - JoinedGroupCallParticipant, - JoinedVoiceChat, - LeftGroupCallParticipant, - LeftVoiceChat, - MutedCall, - NotInGroupCall, - UpdatedGroupCallParticipant, - UpgradeNeeded, -) -from .input_stream import ( - AudioImagePiped, - AudioParameters, - AudioPiped, - AudioQuality, - AudioVideoPiped, - CaptureAudioDevice, - CaptureAVDesktop, - CaptureAVDeviceDesktop, - CaptureVideoDesktop, - InputAudioStream, - InputStream, - InputVideoStream, - VideoParameters, - VideoPiped, - VideoQuality, -) -from .input_stream.quality import ( - HighQualityAudio, - HighQualityVideo, - LowQualityAudio, - LowQualityVideo, - MediumQualityAudio, - MediumQualityVideo, -) -from .stream import ( - ChangedStream, - MutedStream, - PausedStream, - ResumedStream, - StreamAudioEnded, - StreamDeleted, - StreamVideoEnded, - UnMutedStream, -) from .update import Update from .waifu import * - -__all__ = [ - "AlreadyJoined", - "AudioParameters", - "AudioImagePiped", - "AudioPiped", - "AudioQuality", - "AudioVideoPiped", - "Browsers", - "Cache", - "ChangedStream", - "ErrorDuringJoin", - "GroupCall", - "GroupCallParticipant", - "HighQualityAudio", - "HighQualityVideo", - "InputAudioStream", - "InputStream", - "InputVideoStream", - "JoinedGroupCallParticipant", - "JoinedVoiceChat", - "LowQualityAudio", - "LowQualityVideo", - "LeftGroupCallParticipant", - "LeftVoiceChat", - "MutedStream", - "MediumQualityAudio", - "MediumQualityVideo", - "NotInGroupCall", - "PausedStream", - "ResumedStream", - "StreamAudioEnded", - "StreamDeleted", - "StreamVideoEnded", - "UnMutedStream", - "UpdatedGroupCallParticipant", - "Update", - "CaptureAudioDevice", - "CaptureAVDesktop", - "CaptureAVDeviceDesktop", - "CaptureVideoDesktop", - "VideoParameters", - "VideoPiped", - "VideoQuality", - "UpgradeNeeded", - "MutedCall", -] From d1f388aaf2553f668389e7cc6bf251038392021b Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Wed, 21 Aug 2024 17:45:29 +0700 Subject: [PATCH 085/152] _ --- RyuzakiLib/scaffold.py | 38 -------------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 RyuzakiLib/scaffold.py diff --git a/RyuzakiLib/scaffold.py b/RyuzakiLib/scaffold.py deleted file mode 100644 index 4773be3a..00000000 --- a/RyuzakiLib/scaffold.py +++ /dev/null @@ -1,38 +0,0 @@ -from typing import Dict, Union - -from ntgcalls import NTgCalls - - -class Scaffold: - _REQUIRED_PYROGRAM_VERSION = "1.2.20" - _REQUIRED_TELETHON_VERSION = "1.24.0" - _REQUIRED_HYDROGRAM_VERSION = "0.1.4" - - def __init__(self): - self._app = None - self._async_core = None - self._is_running = None - self._my_id = None - self._env_checker = None - self._cache_user_peer = None - self._wait_result = None - self._cache_local_peer = None - self._on_event_update = None - # noinspection PyTypeChecker - self._binding: NTgCalls = None - self._need_unmute: Dict[int, bool] = {} - - def _handle_mtproto(self): - pass - - async def _init_mtproto(self): - pass - - async def _resolve_chat_id(self, chat_id: Union[int, str]) -> int: - pass - - async def get_call(self, chat_id: int): - pass - - async def start(self): - pass From ba414a3a615f8a46157f605bab34d95e73e445b6 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Wed, 21 Aug 2024 17:46:01 +0700 Subject: [PATCH 086/152] _ --- RyuzakiLib/__version__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RyuzakiLib/__version__.py b/RyuzakiLib/__version__.py index b3f9ac7f..7f647d06 100644 --- a/RyuzakiLib/__version__.py +++ b/RyuzakiLib/__version__.py @@ -1 +1 @@ -__version__ = "1.2.4" +__version__ = "1.2.7" From eca37fa2aee92ef957f3bc54415b0930bf92748a Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Wed, 21 Aug 2024 18:07:16 +0700 Subject: [PATCH 087/152] _ --- RyuzakiLib/custom_api/__init__.py | 3 -- RyuzakiLib/custom_api/custom_api.py | 66 ----------------------------- RyuzakiLib/custom_api/nothing | 0 3 files changed, 69 deletions(-) delete mode 100644 RyuzakiLib/custom_api/__init__.py delete mode 100644 RyuzakiLib/custom_api/custom_api.py delete mode 100644 RyuzakiLib/custom_api/nothing diff --git a/RyuzakiLib/custom_api/__init__.py b/RyuzakiLib/custom_api/__init__.py deleted file mode 100644 index 769d6fec..00000000 --- a/RyuzakiLib/custom_api/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .custom_api import CustomApi - -__all__ = ("CustomApi",) diff --git a/RyuzakiLib/custom_api/custom_api.py b/RyuzakiLib/custom_api/custom_api.py deleted file mode 100644 index a92c7b4b..00000000 --- a/RyuzakiLib/custom_api/custom_api.py +++ /dev/null @@ -1,66 +0,0 @@ -from json import JSONDecodeError -from typing import Callable, Optional - -from aiohttp import web -from aiohttp.web_request import BaseRequest - -from ..exceptions import TooManyCustomApiDecorators - - -class CustomApi: - def __init__( - self, - port: int = 24859, - ): - self._handler: Optional[Callable] = None - self._app: web.Application = web.Application() - self._runner: Optional[web.AppRunner] = None - self._port = port - - def on_update_custom_api(self) -> Callable: - if self._handler is None: - - def decorator(func: Callable) -> Callable: - if self is not None: - self._handler = func - return func - - return decorator - else: - raise TooManyCustomApiDecorators() - - async def start(self): - async def on_update(request: BaseRequest): - try: - params = await request.json() - except JSONDecodeError: - return web.json_response( - { - "result": "INVALID_JSON_FORMAT_REQUEST", - } - ) - if self._handler is not None: - result = await self._handler(params) - if isinstance(result, dict) or isinstance(result, list): - return web.json_response(result) - else: - return web.json_response( - { - "result": "INVALID_RESPONSE", - } - ) - else: - return web.json_response( - { - "result": "NO_CUSTOM_API_DECORATOR", - } - ) - - self._app.router.add_post( - "/", - on_update, - ) - runner = web.AppRunner(self._app) - await runner.setup() - site = web.TCPSite(runner, "localhost", self._port) - await site.start() diff --git a/RyuzakiLib/custom_api/nothing b/RyuzakiLib/custom_api/nothing deleted file mode 100644 index e69de29b..00000000 From 36deaf7b0e43483d36ec7485d36be6f79c944a25 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Wed, 21 Aug 2024 18:12:01 +0700 Subject: [PATCH 088/152] _ --- RyuzakiLib/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/RyuzakiLib/__init__.py b/RyuzakiLib/__init__.py index 7128f9b7..bc7e97f6 100644 --- a/RyuzakiLib/__init__.py +++ b/RyuzakiLib/__init__.py @@ -32,7 +32,6 @@ from .api.yohasakura import SearchAPI from .bot import * from .channels import * -from .custom_api import CustomApi from .decorator import * from .extreme.carbon import Carbon from .extreme.quotestk import QouteSticker @@ -82,7 +81,6 @@ class AwesomeCoding(BaseModel): __all__ = [ "__version__" - "CustomApi", "RendyDevChat", "GeminiLatest", "Github", From 8f74a562ca47c9cc77b84eda58febc164d84a30a Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Fri, 23 Aug 2024 00:03:48 +0700 Subject: [PATCH 089/152] _ --- RyuzakiLib/api/reqs.py | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/RyuzakiLib/api/reqs.py b/RyuzakiLib/api/reqs.py index 966857f8..d80489e0 100644 --- a/RyuzakiLib/api/reqs.py +++ b/RyuzakiLib/api/reqs.py @@ -1,6 +1,5 @@ import aiohttp - class AsyicXSearcher: """ A class to handle asynchronous HTTP requests using aiohttp. @@ -62,3 +61,34 @@ async def search( return await response.text() else: raise DependencyMissingError("Install 'aiohttp' to use this.") + +async def async_search( + url: str, + post: bool = False, + head: bool = False, + headers: dict = None, + evaluate=None, + object: bool = False, + re_json: bool = False, + re_content: bool = False, + *args, + **kwargs, +): + + if aiohttp: + async with aiohttp.ClientSession(headers=headers) as session: + method = ( + session.head if head else (session.post if post else session.get) + ) + async with method(url, *args, **kwargs) as response: + if evaluate: + return await evaluate(response) + if re_json: + return await response.json() + if re_content: + return await response.read() + if head or object: + return response + return await response.text() + else: + raise DependencyMissingError("Install 'aiohttp' to use this.") From b33267100bc84e2c8ef07971d3abf0bad13b5c13 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Fri, 23 Aug 2024 00:06:38 +0700 Subject: [PATCH 090/152] _ --- RyuzakiLib/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RyuzakiLib/__init__.py b/RyuzakiLib/__init__.py index bc7e97f6..55efc1c6 100644 --- a/RyuzakiLib/__init__.py +++ b/RyuzakiLib/__init__.py @@ -28,7 +28,7 @@ from .api.fullstack import FullStackDev from .api.jiosaavn import Jiosaavn from .api.private import PrivateApiUrl -from .api.reqs import AsyicXSearcher +from .api.reqs import AsyicXSearcher, async_search from .api.yohasakura import SearchAPI from .bot import * from .channels import * @@ -113,4 +113,5 @@ class AwesomeCoding(BaseModel): "FluxAi", "CloudFlare", "PyrogramMod", + "async_search", ] From e2bf25150b21f5e25a279c32f75f964e65ec34c5 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Fri, 23 Aug 2024 00:20:41 +0700 Subject: [PATCH 091/152] Create xnxx.py --- RyuzakiLib/hackertools/xnxx.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 RyuzakiLib/hackertools/xnxx.py diff --git a/RyuzakiLib/hackertools/xnxx.py b/RyuzakiLib/hackertools/xnxx.py new file mode 100644 index 00000000..b2055227 --- /dev/null +++ b/RyuzakiLib/hackertools/xnxx.py @@ -0,0 +1,23 @@ +from RyuzakiLib.api.reqs import async_search +import wget + +class PornoHub: + def __init__(self): + pass + + async def x_search(self, query=None): + url = f"https://randydev-ryuzaki-api.hf.space/akeno/xnxxsearch?query={query}" + res = await async_search(url, re_json=True) + results = res["randydev"]["results"] + y = res["randydev"]["results"][0] + link = y["link"] + title = y["title"] + return [link, title, results] + + async def x_download(self, query=None): + schub = await self.x_search(query=query) + url_dl = f"https://randydev-ryuzaki-api.hf.space/akeno/xnxx-dl?link={schub[0]}" + response = await async_search(url_dl, re_json=True) + file_path = wget.download(response["randydev"]["results"]["url"]) + thumb = wget.download(response["randydev"]["results"]["thumb"]) + return file_path, thumb From 86220cda3564c1157222976b8005b047a81c9427 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Fri, 23 Aug 2024 00:21:27 +0700 Subject: [PATCH 092/152] _ --- RyuzakiLib/hackertools/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/RyuzakiLib/hackertools/__init__.py b/RyuzakiLib/hackertools/__init__.py index c9465b46..18c13ccd 100644 --- a/RyuzakiLib/hackertools/__init__.py +++ b/RyuzakiLib/hackertools/__init__.py @@ -13,3 +13,4 @@ from .reverse import * from .rmbg import * from .tiktok import * +from .xnxx import * From 48ab1d0162f14099b321d018b98edd22c8ff4dc0 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Fri, 23 Aug 2024 00:23:57 +0700 Subject: [PATCH 093/152] _ --- RyuzakiLib/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/RyuzakiLib/__init__.py b/RyuzakiLib/__init__.py index 55efc1c6..9f473b29 100644 --- a/RyuzakiLib/__init__.py +++ b/RyuzakiLib/__init__.py @@ -52,6 +52,7 @@ from .hackertools.reverse import GoogleReverseImage from .hackertools.rmbg import Background from .hackertools.tiktok import Tiktok +from .hackertools.xnxx import PornoHub from .mental import * from .profile.user import Clone from .pushdb import * @@ -114,4 +115,5 @@ class AwesomeCoding(BaseModel): "CloudFlare", "PyrogramMod", "async_search", + "PornoHub", ] From 8a32dbe1d65ca4fecee702c18d64e9730e07af68 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Fri, 23 Aug 2024 01:18:29 +0700 Subject: [PATCH 094/152] _ --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 7576bfd3..4795d027 100644 --- a/requirements.txt +++ b/requirements.txt @@ -29,3 +29,4 @@ gradio huggingface-hub>=0.23.2 motor nest-asyncio +wget From 26b5049802eb747680062dd57622c2dd2ddae953 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Fri, 23 Aug 2024 01:19:25 +0700 Subject: [PATCH 095/152] Update setup.py --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 310e79db..1073555b 100644 --- a/setup.py +++ b/setup.py @@ -55,6 +55,7 @@ def read(fname, version=False): "gradio", "huggingface-hub>=0.23.2", "motor", + "wget", ], classifiers=[ "Programming Language :: Python :: 3", From 9b366a724dc4fac7132e56a51c1280806643b4b5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 22 Aug 2024 18:35:36 +0000 Subject: [PATCH 096/152] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- RyuzakiLib/api/reqs.py | 3 ++- RyuzakiLib/hackertools/xnxx.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/RyuzakiLib/api/reqs.py b/RyuzakiLib/api/reqs.py index d80489e0..18e49970 100644 --- a/RyuzakiLib/api/reqs.py +++ b/RyuzakiLib/api/reqs.py @@ -1,5 +1,6 @@ import aiohttp + class AsyicXSearcher: """ A class to handle asynchronous HTTP requests using aiohttp. @@ -74,7 +75,7 @@ async def async_search( *args, **kwargs, ): - + if aiohttp: async with aiohttp.ClientSession(headers=headers) as session: method = ( diff --git a/RyuzakiLib/hackertools/xnxx.py b/RyuzakiLib/hackertools/xnxx.py index b2055227..fe1af798 100644 --- a/RyuzakiLib/hackertools/xnxx.py +++ b/RyuzakiLib/hackertools/xnxx.py @@ -1,6 +1,8 @@ -from RyuzakiLib.api.reqs import async_search import wget +from RyuzakiLib.api.reqs import async_search + + class PornoHub: def __init__(self): pass From e80d4cf2a062ffdb5980ca84fd4bd8bb4698c1f3 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Fri, 23 Aug 2024 07:17:49 +0700 Subject: [PATCH 097/152] _ --- RyuzakiLib/hackertools/xnxx.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/RyuzakiLib/hackertools/xnxx.py b/RyuzakiLib/hackertools/xnxx.py index fe1af798..e7849a56 100644 --- a/RyuzakiLib/hackertools/xnxx.py +++ b/RyuzakiLib/hackertools/xnxx.py @@ -16,10 +16,17 @@ async def x_search(self, query=None): title = y["title"] return [link, title, results] - async def x_download(self, query=None): - schub = await self.x_search(query=query) - url_dl = f"https://randydev-ryuzaki-api.hf.space/akeno/xnxx-dl?link={schub[0]}" - response = await async_search(url_dl, re_json=True) - file_path = wget.download(response["randydev"]["results"]["url"]) - thumb = wget.download(response["randydev"]["results"]["thumb"]) - return file_path, thumb + async def x_download(self, query=None, url=None, is_stream=False): + if is_stream and url: + url_ = f"https://randydev-ryuzaki-api.hf.space/akeno/xnxx-dl?link={url}" + response = await async_search(url_, re_json=True) + file_path = wget.download(response["randydev"]["results"]["url"]) + thumb = wget.download(response["randydev"]["results"]["thumb"]) + return file_path, thumb + else: + schub = await self.x_search(query=query) + url_dl = f"https://randydev-ryuzaki-api.hf.space/akeno/xnxx-dl?link={schub[0]}" + response = await async_search(url_dl, re_json=True) + file_path = wget.download(response["randydev"]["results"]["url"]) + thumb = wget.download(response["randydev"]["results"]["thumb"]) + return file_path, thumb From d63ff426c9c98f5acc7632bec09c59aa02014706 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Fri, 23 Aug 2024 15:12:48 +0700 Subject: [PATCH 098/152] _ --- RyuzakiLib/hackertools/xnxx.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/RyuzakiLib/hackertools/xnxx.py b/RyuzakiLib/hackertools/xnxx.py index e7849a56..496289c2 100644 --- a/RyuzakiLib/hackertools/xnxx.py +++ b/RyuzakiLib/hackertools/xnxx.py @@ -22,11 +22,13 @@ async def x_download(self, query=None, url=None, is_stream=False): response = await async_search(url_, re_json=True) file_path = wget.download(response["randydev"]["results"]["url"]) thumb = wget.download(response["randydev"]["results"]["thumb"]) - return file_path, thumb + title = response["randydev"]["results"].get("title", "Powered by Randydev") + return file_path, thumb, title else: schub = await self.x_search(query=query) url_dl = f"https://randydev-ryuzaki-api.hf.space/akeno/xnxx-dl?link={schub[0]}" response = await async_search(url_dl, re_json=True) file_path = wget.download(response["randydev"]["results"]["url"]) thumb = wget.download(response["randydev"]["results"]["thumb"]) - return file_path, thumb + title = response["randydev"]["results"].get("title", "Powered by Randydev") + return file_path, thumb, title From 9a6a82fcdb20071e1f54820cbb8711ebffdde5e7 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Sat, 24 Aug 2024 14:54:02 +0700 Subject: [PATCH 099/152] _ --- index.html | 4 ---- 1 file changed, 4 deletions(-) diff --git a/index.html b/index.html index fc7423c4..a8cc36c8 100644 --- a/index.html +++ b/index.html @@ -20,9 +20,5 @@
-
-

© 2024 RandyDev All rights reserved.

-
- From 2b821220381f2467b9bc67afe9753ba516f612f1 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Mon, 26 Aug 2024 01:00:49 +0700 Subject: [PATCH 100/152] _ --- RyuzakiLib/hackertools/chatgpt.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/RyuzakiLib/hackertools/chatgpt.py b/RyuzakiLib/hackertools/chatgpt.py index b50d6dd4..fbbaa23d 100644 --- a/RyuzakiLib/hackertools/chatgpt.py +++ b/RyuzakiLib/hackertools/chatgpt.py @@ -47,6 +47,7 @@ class RendyDevChat: @staticmethod async def chat_hacked( + base_api_dev = "https://akeno.randydev.my.id", args: str = None, latest_model: str = "openai-latest", model_id: Optional[int] = None, @@ -56,7 +57,7 @@ async def chat_hacked( list_model_all: Optional[bool] = False ): if latest_model == "openai-v2": - url = "https://randydev-ryuzaki-api.hf.space/ryuzaki/chatgpt-old" + url = f"{base_api_dev}/ryuzaki/chatgpt-old" params = {"query": args} check_response = await AsyicXSearcher.search( url, @@ -66,7 +67,7 @@ async def chat_hacked( ) return check_response["randydev"]["message"] elif latest_model == "blackbox": - url = "https://randydev-ryuzaki-api.hf.space/ryuzaki/blackbox" + url = f"{base_api_dev}/ryuzaki/blackbox" params = {"query": args} check_response = await AsyicXSearcher.search( url, @@ -105,7 +106,7 @@ async def chat_hacked( ) return check_response["randydev"]["message"] elif latest_model == "microsoft": - url = "https://randydev-ryuzaki-api.hf.space/ryuzaki/faceai" + url = f"{base_api_dev}/ryuzaki/faceai" payload = { "query": args, "clients_name": "microsoft/Phi-3-mini-4k-instruct", @@ -120,7 +121,7 @@ async def chat_hacked( ) return check_response["randydev"]["message"] elif latest_model == "gemma": - url = "https://randydev-ryuzaki-api.hf.space/ryuzaki/faceai" + url = f"{base_api_dev}/ryuzaki/faceai" payload = { "query": args, "clients_name": "google/gemma-1.1-7b-it", @@ -135,7 +136,7 @@ async def chat_hacked( ) return check_response["randydev"]["message"] elif latest_model == "mistralai": - url = "https://randydev-ryuzaki-api.hf.space/ryuzaki/faceai" + url = f"{base_api_dev}/ryuzaki/faceai" payload = { "query": args, "clients_name": "mistralai/Mixtral-8x7B-Instruct-v0.1", @@ -150,7 +151,7 @@ async def chat_hacked( ) return check_response["randydev"]["message"] elif latest_model == "faceh4": - url = "https://randydev-ryuzaki-api.hf.space/ryuzaki/faceai" + url = f"{base_api_dev}/ryuzaki/faceai" payload = { "query": args, "clients_name": "HuggingFaceH4/zephyr-7b-beta", @@ -165,7 +166,7 @@ async def chat_hacked( ) return check_response["randydev"]["message"] elif latest_model == "google-ai": - url = f"https://randydev-ryuzaki-api.hf.space/ryuzaki/google-ai" + url = f"{base_api_dev}/ryuzaki/google-ai" headers = {"accept": "application/json", "api-key": API_KEYS} params = {"query": args} check_response = await AsyicXSearcher.search( @@ -177,7 +178,7 @@ async def chat_hacked( ) return check_response["randydev"]["message"] elif latest_model == "betagoogle-ai": - url = f"https://randydev-ryuzaki-api.hf.space/ryuzaki/v1beta2-google-ai" + url = f"{base_api_dev}/ryuzaki/v1beta2-google-ai" headers = {"accept": "application/json", "api-key": API_KEYS} params = {"query": args} check_response = await AsyicXSearcher.search( @@ -189,7 +190,7 @@ async def chat_hacked( ) return check_response["randydev"]["message"] elif latest_model == "gpt-4-turbo": - url = f"https://randydev-ryuzaki-api.hf.space/ryuzaki/chatgpt-custom" + url = f"{base_api_dev}/ryuzaki/chatgpt-custom" headers = {"accept": "application/json", "api-key": API_KEYS} params = {"query": args, "model": "gpt-4-turbo"} check_response = await AsyicXSearcher.search( @@ -222,7 +223,7 @@ def download_images(image_urls): @staticmethod async def image_generator(args): - url = f"https://randydev-ryuzaki-api.hf.space/ryuzaki/dalle3xl" + url = f"{base_api_dev}/ryuzaki/dalle3xl" headers = {"accept": "application/json", "api-key": API_KEYS} payload = {"query": args} check_response = await AsyicXSearcher.search( From e50aa59b018ea689d275d4cc3e5303b909f544d8 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Mon, 26 Aug 2024 01:08:58 +0700 Subject: [PATCH 101/152] _ --- RyuzakiLib/hackertools/xnxx.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/RyuzakiLib/hackertools/xnxx.py b/RyuzakiLib/hackertools/xnxx.py index 496289c2..35ce7c7b 100644 --- a/RyuzakiLib/hackertools/xnxx.py +++ b/RyuzakiLib/hackertools/xnxx.py @@ -4,11 +4,12 @@ class PornoHub: - def __init__(self): - pass + def __init__(self, base_api_dev: str = "https://akeno.randydev.my.id", token: str): + self.base_api_dev = base_api_dev + self.token = token async def x_search(self, query=None): - url = f"https://randydev-ryuzaki-api.hf.space/akeno/xnxxsearch?query={query}" + url = f"{self.base_api_dev}/akeno/xnxxsearch-v2?query={query}&api_key={token}" res = await async_search(url, re_json=True) results = res["randydev"]["results"] y = res["randydev"]["results"][0] @@ -18,7 +19,7 @@ async def x_search(self, query=None): async def x_download(self, query=None, url=None, is_stream=False): if is_stream and url: - url_ = f"https://randydev-ryuzaki-api.hf.space/akeno/xnxx-dl?link={url}" + url_ = f"{self.base_api_dev}/akeno/xnxx-dl-v2?link={url}&api_key={self.token}" response = await async_search(url_, re_json=True) file_path = wget.download(response["randydev"]["results"]["url"]) thumb = wget.download(response["randydev"]["results"]["thumb"]) @@ -26,7 +27,7 @@ async def x_download(self, query=None, url=None, is_stream=False): return file_path, thumb, title else: schub = await self.x_search(query=query) - url_dl = f"https://randydev-ryuzaki-api.hf.space/akeno/xnxx-dl?link={schub[0]}" + url_dl = f"{base_api_dev}/akeno/xnxx-dl-v2?link={schub[0]}&api_key={self.token}" response = await async_search(url_dl, re_json=True) file_path = wget.download(response["randydev"]["results"]["url"]) thumb = wget.download(response["randydev"]["results"]["thumb"]) From 429b66a55b2b1cc243b5774837378fce2d3ce9f2 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Mon, 26 Aug 2024 01:12:10 +0700 Subject: [PATCH 102/152] _ --- RyuzakiLib/spamwatch/clients.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/RyuzakiLib/spamwatch/clients.py b/RyuzakiLib/spamwatch/clients.py index 1884e723..173fd035 100644 --- a/RyuzakiLib/spamwatch/clients.py +++ b/RyuzakiLib/spamwatch/clients.py @@ -38,7 +38,7 @@ def _make_request(method: str, url: str, params: dict = None, json_data: dict = @staticmethod def ban(user_id: int = None, reason: str = None) -> str: - url = "https://randydev-ryuzaki-api.hf.space/sibylban" + url = "https://akeno.randydev.my.id/sibylban" payload = {"user_id": user_id, "reason": reason} response = SibylBan._make_request("POST", url, json_data=payload) return response.get("randydev", {}).get( @@ -47,17 +47,17 @@ def ban(user_id: int = None, reason: str = None) -> str: @staticmethod def banlist(user_id: int = None) -> Union[dict, str]: - url = "https://randydev-ryuzaki-api.hf.space/ryuzaki/sibyl" + url = "https://akeno.randydev.my.id/ryuzaki/sibyl" payload = {"user_id": user_id} return SibylBan._make_request("GET", url, json_data=payload) @staticmethod def unban(user_id: int = None) -> Union[dict, str]: - url = "https://randydev-ryuzaki-api.hf.space/ryuzaki/sibyldel" + url = "https://akeno.randydev.my.id/ryuzaki/sibyldel" payload = {"user_id": user_id} return SibylBan._make_request("DELETE", url, json_data=payload) @staticmethod def banlist_all() -> Union[dict, str]: - url = "https://randydev-ryuzaki-api.hf.space/ryuzaki/getbanlist" + url = "https://akeno.randydev.my.id/ryuzaki/getbanlist" return SibylBan._make_request("GET", url) From 88c490e3aa3f44eb787a6d1f21f7315bb3136087 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Mon, 26 Aug 2024 01:34:14 +0700 Subject: [PATCH 103/152] Create akenoai.py --- RyuzakiLib/akenoai.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 RyuzakiLib/akenoai.py diff --git a/RyuzakiLib/akenoai.py b/RyuzakiLib/akenoai.py new file mode 100644 index 00000000..54b2c8b6 --- /dev/null +++ b/RyuzakiLib/akenoai.py @@ -0,0 +1,31 @@ +import requests +from RyuzakiLib.api.reqs import async_search + +class AkenoAi: + def __init__(self, base_api_dev: str = "https://akeno.randydev.my.id"): + self.base_api_dev = base_api_dev + + async def signup(self, gmail: str, username: str): + if not gmail.startswith("@gmail.com"): + return "Invalid gmail" + payload = {"gmail": gmail, "username": username} + response = await async_seach( + self.base_api_dev + "/register", + json=payload, + post=True, + re_json=True + ) + return response + + async def get_api_key(self, username: str): + response = await async_seach( + f"{self.base_api_dev}/get_api_key?api_key={username}", + re_json=True + ) + return response + + async def delete_api_key(self, username: str): + response = requests.delete( + f"{self.base_api_dev}/delete_api_key_by_username?username={username}" + ).json() + return response From 1e57dc55e2ad3e9fccce7457c4b2f452b6fc6164 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Mon, 26 Aug 2024 01:41:18 +0700 Subject: [PATCH 104/152] _ From 3bd1a673e0ae2d0cfbc0330a1ea5b4da467f4dea Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Mon, 26 Aug 2024 01:49:12 +0700 Subject: [PATCH 105/152] _ --- RyuzakiLib/akenoai.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/RyuzakiLib/akenoai.py b/RyuzakiLib/akenoai.py index 54b2c8b6..b36d2b25 100644 --- a/RyuzakiLib/akenoai.py +++ b/RyuzakiLib/akenoai.py @@ -24,8 +24,11 @@ async def get_api_key(self, username: str): ) return response - async def delete_api_key(self, username: str): - response = requests.delete( - f"{self.base_api_dev}/delete_api_key_by_username?username={username}" - ).json() - return response + async def delete_api_key(self, username: str, delete_project: str): + if delete_project == username": + response = requests.delete( + f"{self.base_api_dev}/delete_api_key_by_username?username={username}" + ).json() + return response + else: + return "Ok Done 🗿" From 45c24bbe4e5a54954ee85d0917151e96a13a1cd7 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Mon, 26 Aug 2024 01:50:54 +0700 Subject: [PATCH 106/152] _ --- RyuzakiLib/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/RyuzakiLib/__init__.py b/RyuzakiLib/__init__.py index 9f473b29..4de7d959 100644 --- a/RyuzakiLib/__init__.py +++ b/RyuzakiLib/__init__.py @@ -59,6 +59,7 @@ from .pyrogramMod import PyrogramMod from .quote import * from .reminder import * +from .akenoai import * from .spamwatch.clients import SibylBan from .story import * from .system.read import System @@ -116,4 +117,5 @@ class AwesomeCoding(BaseModel): "PyrogramMod", "async_search", "PornoHub", + "AkenoAI", ] From afa790527ba2214bc29880098e373528c6be6293 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Mon, 26 Aug 2024 01:51:27 +0700 Subject: [PATCH 107/152] _ --- RyuzakiLib/akenoai.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RyuzakiLib/akenoai.py b/RyuzakiLib/akenoai.py index b36d2b25..171a1da4 100644 --- a/RyuzakiLib/akenoai.py +++ b/RyuzakiLib/akenoai.py @@ -1,7 +1,7 @@ import requests from RyuzakiLib.api.reqs import async_search -class AkenoAi: +class AkenoAI: def __init__(self, base_api_dev: str = "https://akeno.randydev.my.id"): self.base_api_dev = base_api_dev From ea5270b2157b0976983417ae75c15d811ac0de64 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Mon, 26 Aug 2024 01:52:06 +0700 Subject: [PATCH 108/152] _ --- RyuzakiLib/__version__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RyuzakiLib/__version__.py b/RyuzakiLib/__version__.py index 7f647d06..b87fc0c7 100644 --- a/RyuzakiLib/__version__.py +++ b/RyuzakiLib/__version__.py @@ -1 +1 @@ -__version__ = "1.2.7" +__version__ = "1.2.9" From 65bf294b99dbad860d3c2fbd6e34c98c6642c9c4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 25 Aug 2024 18:52:56 +0000 Subject: [PATCH 109/152] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- RyuzakiLib/__init__.py | 2 +- RyuzakiLib/akenoai.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/RyuzakiLib/__init__.py b/RyuzakiLib/__init__.py index 4de7d959..b8465c6b 100644 --- a/RyuzakiLib/__init__.py +++ b/RyuzakiLib/__init__.py @@ -25,6 +25,7 @@ from . import * from .__version__ import __version__ +from .akenoai import * from .api.fullstack import FullStackDev from .api.jiosaavn import Jiosaavn from .api.private import PrivateApiUrl @@ -59,7 +60,6 @@ from .pyrogramMod import PyrogramMod from .quote import * from .reminder import * -from .akenoai import * from .spamwatch.clients import SibylBan from .story import * from .system.read import System diff --git a/RyuzakiLib/akenoai.py b/RyuzakiLib/akenoai.py index 171a1da4..49901508 100644 --- a/RyuzakiLib/akenoai.py +++ b/RyuzakiLib/akenoai.py @@ -1,6 +1,8 @@ import requests + from RyuzakiLib.api.reqs import async_search + class AkenoAI: def __init__(self, base_api_dev: str = "https://akeno.randydev.my.id"): self.base_api_dev = base_api_dev @@ -25,7 +27,7 @@ async def get_api_key(self, username: str): return response async def delete_api_key(self, username: str, delete_project: str): - if delete_project == username": + if delete_project == username": response = requests.delete( f"{self.base_api_dev}/delete_api_key_by_username?username={username}" ).json() From 16c71e0a7bfce9f3d9820a36d4f5338c565ac52d Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Mon, 26 Aug 2024 02:30:44 +0700 Subject: [PATCH 110/152] _ --- RyuzakiLib/akenoai.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RyuzakiLib/akenoai.py b/RyuzakiLib/akenoai.py index 49901508..3fbc359d 100644 --- a/RyuzakiLib/akenoai.py +++ b/RyuzakiLib/akenoai.py @@ -27,7 +27,7 @@ async def get_api_key(self, username: str): return response async def delete_api_key(self, username: str, delete_project: str): - if delete_project == username": + if delete_project == username: response = requests.delete( f"{self.base_api_dev}/delete_api_key_by_username?username={username}" ).json() From 222dda270c748e44a33fb07f5e52d831ea1f5717 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Mon, 26 Aug 2024 02:41:47 +0700 Subject: [PATCH 111/152] _ --- RyuzakiLib/hackertools/xnxx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RyuzakiLib/hackertools/xnxx.py b/RyuzakiLib/hackertools/xnxx.py index 35ce7c7b..69a04526 100644 --- a/RyuzakiLib/hackertools/xnxx.py +++ b/RyuzakiLib/hackertools/xnxx.py @@ -4,7 +4,7 @@ class PornoHub: - def __init__(self, base_api_dev: str = "https://akeno.randydev.my.id", token: str): + def __init__(self, token=None, base_api_dev: str = "https://akeno.randydev.my.id"): self.base_api_dev = base_api_dev self.token = token From 1bc2b2b601b9e21f017f1cd6e1d493ba7004e9d0 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Mon, 26 Aug 2024 02:44:25 +0700 Subject: [PATCH 112/152] _ --- RyuzakiLib/hackertools/xnxx.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RyuzakiLib/hackertools/xnxx.py b/RyuzakiLib/hackertools/xnxx.py index 69a04526..ee58eaf6 100644 --- a/RyuzakiLib/hackertools/xnxx.py +++ b/RyuzakiLib/hackertools/xnxx.py @@ -9,7 +9,7 @@ def __init__(self, token=None, base_api_dev: str = "https://akeno.randydev.my.id self.token = token async def x_search(self, query=None): - url = f"{self.base_api_dev}/akeno/xnxxsearch-v2?query={query}&api_key={token}" + url = f"{self.base_api_dev}/akeno/xnxxsearch-v2?query={query}&api_key={self.token}" res = await async_search(url, re_json=True) results = res["randydev"]["results"] y = res["randydev"]["results"][0] @@ -27,7 +27,7 @@ async def x_download(self, query=None, url=None, is_stream=False): return file_path, thumb, title else: schub = await self.x_search(query=query) - url_dl = f"{base_api_dev}/akeno/xnxx-dl-v2?link={schub[0]}&api_key={self.token}" + url_dl = f"{self.base_api_dev}/akeno/xnxx-dl-v2?link={schub[0]}&api_key={self.token}" response = await async_search(url_dl, re_json=True) file_path = wget.download(response["randydev"]["results"]["url"]) thumb = wget.download(response["randydev"]["results"]["thumb"]) From 7aba89bd41dcbd3718622d53cf3147a651cefc1c Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Mon, 26 Aug 2024 02:51:39 +0700 Subject: [PATCH 113/152] Update __version__.py --- RyuzakiLib/__version__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RyuzakiLib/__version__.py b/RyuzakiLib/__version__.py index b87fc0c7..67bc602a 100644 --- a/RyuzakiLib/__version__.py +++ b/RyuzakiLib/__version__.py @@ -1 +1 @@ -__version__ = "1.2.9" +__version__ = "1.3.0" From 93d10270fd5687a0561c86cc8dd4207951013b07 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Mon, 26 Aug 2024 03:15:19 +0700 Subject: [PATCH 114/152] _ --- RyuzakiLib/akenoai.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RyuzakiLib/akenoai.py b/RyuzakiLib/akenoai.py index 3fbc359d..1e97b61c 100644 --- a/RyuzakiLib/akenoai.py +++ b/RyuzakiLib/akenoai.py @@ -11,7 +11,7 @@ async def signup(self, gmail: str, username: str): if not gmail.startswith("@gmail.com"): return "Invalid gmail" payload = {"gmail": gmail, "username": username} - response = await async_seach( + response = await async_search( self.base_api_dev + "/register", json=payload, post=True, @@ -20,7 +20,7 @@ async def signup(self, gmail: str, username: str): return response async def get_api_key(self, username: str): - response = await async_seach( + response = await async_search( f"{self.base_api_dev}/get_api_key?api_key={username}", re_json=True ) From d3bf54348a70a68e2ffcbaef8dd7b727d977ef8a Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Mon, 26 Aug 2024 12:04:21 +0700 Subject: [PATCH 115/152] Update __version__.py --- RyuzakiLib/__version__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RyuzakiLib/__version__.py b/RyuzakiLib/__version__.py index 67bc602a..9c73af26 100644 --- a/RyuzakiLib/__version__.py +++ b/RyuzakiLib/__version__.py @@ -1 +1 @@ -__version__ = "1.3.0" +__version__ = "1.3.1" From 0d0bb8b8256ae937774f4ce2787f12e88f361902 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Mon, 26 Aug 2024 12:55:18 +0700 Subject: [PATCH 116/152] _ --- RyuzakiLib/akenoai.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RyuzakiLib/akenoai.py b/RyuzakiLib/akenoai.py index 1e97b61c..389d770a 100644 --- a/RyuzakiLib/akenoai.py +++ b/RyuzakiLib/akenoai.py @@ -8,7 +8,7 @@ def __init__(self, base_api_dev: str = "https://akeno.randydev.my.id"): self.base_api_dev = base_api_dev async def signup(self, gmail: str, username: str): - if not gmail.startswith("@gmail.com"): + if not gmail.endswith("@gmail.com"): return "Invalid gmail" payload = {"gmail": gmail, "username": username} response = await async_search( From f203721792540f912a5741b64c9a33316a543edd Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Mon, 26 Aug 2024 14:33:45 +0700 Subject: [PATCH 117/152] _ --- RyuzakiLib/akenoai.py | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/RyuzakiLib/akenoai.py b/RyuzakiLib/akenoai.py index 389d770a..ad22e436 100644 --- a/RyuzakiLib/akenoai.py +++ b/RyuzakiLib/akenoai.py @@ -2,10 +2,11 @@ from RyuzakiLib.api.reqs import async_search - class AkenoAI: def __init__(self, base_api_dev: str = "https://akeno.randydev.my.id"): self.base_api_dev = base_api_dev + self.connected = False + self.api_key = None async def signup(self, gmail: str, username: str): if not gmail.endswith("@gmail.com"): @@ -26,10 +27,30 @@ async def get_api_key(self, username: str): ) return response - async def delete_api_key(self, username: str, delete_project: str): - if delete_project == username: + async def connect(self, username: str): + response = await self.get_api_key(username) + if response.get("requests_made", 0) >= 15: + return "The limit has been reached" + else: + self.connected = True + self.api_key = username + return None + + async def hentai(self, query: str): + if not self.connected or not self.api_key: + return "Not connected or API key missing" + response = await async_search( + f"{self.base_api_dev}/akeno/hentai?query={query}&api_key={self.api_key}", + re_json=True + ) + return response + + async def delete_api_key(self, delete_project: str): + if not self.connected or not self.api_key: + return "Not connected or API key missing" + if delete_project == self.api_key: response = requests.delete( - f"{self.base_api_dev}/delete_api_key_by_username?username={username}" + f"{self.base_api_dev}/delete_api_key_by_username?username={self.api_key}" ).json() return response else: From 86e4ab25936e73c56a0353961612e3902a8b508f Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Mon, 26 Aug 2024 14:40:31 +0700 Subject: [PATCH 118/152] _ --- RyuzakiLib/akenoai.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/RyuzakiLib/akenoai.py b/RyuzakiLib/akenoai.py index ad22e436..2a84fb04 100644 --- a/RyuzakiLib/akenoai.py +++ b/RyuzakiLib/akenoai.py @@ -45,6 +45,15 @@ async def hentai(self, query: str): ) return response + async def pornopics(self, query: str): + if not self.connected or not self.api_key: + return "Not connected or API key missing" + response = await async_search( + f"{self.base_api_dev}/akeno/pornpics?query={query}&api_key={self.api_key}", + re_json=True + ) + return response + async def delete_api_key(self, delete_project: str): if not self.connected or not self.api_key: return "Not connected or API key missing" From f5de97a6476f67b615177309258d8b5db9e74e65 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Mon, 26 Aug 2024 14:45:45 +0700 Subject: [PATCH 119/152] _ --- RyuzakiLib/akenoai.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/RyuzakiLib/akenoai.py b/RyuzakiLib/akenoai.py index 2a84fb04..ae6abeac 100644 --- a/RyuzakiLib/akenoai.py +++ b/RyuzakiLib/akenoai.py @@ -54,6 +54,13 @@ async def pornopics(self, query: str): ) return response + async def x_search(self, query: str): + if not self.connected or not self.api_key: + return "Not connected or API key missing" + url = f"{self.base_api_dev}/akeno/xnxxsearch-v2?query={query}&api_key={self.api_key}" + response = await async_search(url, re_json=True) + return response + async def delete_api_key(self, delete_project: str): if not self.connected or not self.api_key: return "Not connected or API key missing" From a150d865d250da829ae935d99faa6c3ec24b6df5 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Mon, 26 Aug 2024 14:49:14 +0700 Subject: [PATCH 120/152] _ --- RyuzakiLib/akenoai.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/RyuzakiLib/akenoai.py b/RyuzakiLib/akenoai.py index ae6abeac..f823c5e3 100644 --- a/RyuzakiLib/akenoai.py +++ b/RyuzakiLib/akenoai.py @@ -61,6 +61,12 @@ async def x_search(self, query: str): response = await async_search(url, re_json=True) return response + async def x_download(self, url: str): + if not self.connected or not self.api_key: + return "Not connected or API key missing" + url_ = f"{self.base_api_dev}/akeno/xnxx-dl-v2?link={url}&api_key={self.api_key}" + response = await async_search(url_, re_json=True) + async def delete_api_key(self, delete_project: str): if not self.connected or not self.api_key: return "Not connected or API key missing" From f6255d9674d85f7e5714b0db8019bd77b459512a Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Mon, 26 Aug 2024 15:29:22 +0700 Subject: [PATCH 121/152] _ --- RyuzakiLib/akenoai.py | 1 + 1 file changed, 1 insertion(+) diff --git a/RyuzakiLib/akenoai.py b/RyuzakiLib/akenoai.py index f823c5e3..fe9337f8 100644 --- a/RyuzakiLib/akenoai.py +++ b/RyuzakiLib/akenoai.py @@ -66,6 +66,7 @@ async def x_download(self, url: str): return "Not connected or API key missing" url_ = f"{self.base_api_dev}/akeno/xnxx-dl-v2?link={url}&api_key={self.api_key}" response = await async_search(url_, re_json=True) + return response async def delete_api_key(self, delete_project: str): if not self.connected or not self.api_key: From 7e97dd9c9bc4841214c32ede00aa37adbf05f2f5 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Mon, 26 Aug 2024 15:46:39 +0700 Subject: [PATCH 122/152] _ --- RyuzakiLib/akenoai.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RyuzakiLib/akenoai.py b/RyuzakiLib/akenoai.py index fe9337f8..23f091a8 100644 --- a/RyuzakiLib/akenoai.py +++ b/RyuzakiLib/akenoai.py @@ -11,7 +11,7 @@ def __init__(self, base_api_dev: str = "https://akeno.randydev.my.id"): async def signup(self, gmail: str, username: str): if not gmail.endswith("@gmail.com"): return "Invalid gmail" - payload = {"gmail": gmail, "username": username} + payload = {"gmail": gmail, "api_key": username} response = await async_search( self.base_api_dev + "/register", json=payload, From 799b5dd1edadec47afcbe71e705afca0d55511da Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Mon, 26 Aug 2024 21:08:04 +0700 Subject: [PATCH 123/152] _ --- RyuzakiLib/akenoai.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/RyuzakiLib/akenoai.py b/RyuzakiLib/akenoai.py index 23f091a8..d85b5e3e 100644 --- a/RyuzakiLib/akenoai.py +++ b/RyuzakiLib/akenoai.py @@ -11,13 +11,11 @@ def __init__(self, base_api_dev: str = "https://akeno.randydev.my.id"): async def signup(self, gmail: str, username: str): if not gmail.endswith("@gmail.com"): return "Invalid gmail" - payload = {"gmail": gmail, "api_key": username} - response = await async_search( + params = {"new_username": username, "gmail": gmail} + response = requests.post( self.base_api_dev + "/register", - json=payload, - post=True, - re_json=True - ) + params=params + ).json() return response async def get_api_key(self, username: str): From beff735e3d7aa3c438142fc05fc4a1023889a8f2 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Mon, 26 Aug 2024 21:10:53 +0700 Subject: [PATCH 124/152] _ --- RyuzakiLib/akenoai.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RyuzakiLib/akenoai.py b/RyuzakiLib/akenoai.py index d85b5e3e..5c2bf9c8 100644 --- a/RyuzakiLib/akenoai.py +++ b/RyuzakiLib/akenoai.py @@ -25,9 +25,9 @@ async def get_api_key(self, username: str): ) return response - async def connect(self, username: str): + async def connect(self, username: str, requests_limit: int = 30): response = await self.get_api_key(username) - if response.get("requests_made", 0) >= 15: + if response.get("requests_made", 0) >= requests_limit: return "The limit has been reached" else: self.connected = True From 7c741772a27365cade8e93c7ea296ae362e31168 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Tue, 27 Aug 2024 03:08:06 +0700 Subject: [PATCH 125/152] _ --- RyuzakiLib/akenoai.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RyuzakiLib/akenoai.py b/RyuzakiLib/akenoai.py index 5c2bf9c8..d040be88 100644 --- a/RyuzakiLib/akenoai.py +++ b/RyuzakiLib/akenoai.py @@ -11,7 +11,7 @@ def __init__(self, base_api_dev: str = "https://akeno.randydev.my.id"): async def signup(self, gmail: str, username: str): if not gmail.endswith("@gmail.com"): return "Invalid gmail" - params = {"new_username": username, "gmail": gmail} + params = {"username": username, "gmail": gmail} response = requests.post( self.base_api_dev + "/register", params=params @@ -71,7 +71,7 @@ async def delete_api_key(self, delete_project: str): return "Not connected or API key missing" if delete_project == self.api_key: response = requests.delete( - f"{self.base_api_dev}/delete_api_key_by_username?username={self.api_key}" + f"{self.base_api_dev}/delete_api_key_by_username?api_key={self.api_key}" ).json() return response else: From 19d1771fca87e7c36d73b483e924dc8444298e1e Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Wed, 28 Aug 2024 18:33:43 +0700 Subject: [PATCH 126/152] _ --- RyuzakiLib/akenoai.py | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/RyuzakiLib/akenoai.py b/RyuzakiLib/akenoai.py index d040be88..0aab2941 100644 --- a/RyuzakiLib/akenoai.py +++ b/RyuzakiLib/akenoai.py @@ -18,13 +18,6 @@ async def signup(self, gmail: str, username: str): ).json() return response - async def get_api_key(self, username: str): - response = await async_search( - f"{self.base_api_dev}/get_api_key?api_key={username}", - re_json=True - ) - return response - async def connect(self, username: str, requests_limit: int = 30): response = await self.get_api_key(username) if response.get("requests_made", 0) >= requests_limit: @@ -66,13 +59,8 @@ async def x_download(self, url: str): response = await async_search(url_, re_json=True) return response - async def delete_api_key(self, delete_project: str): - if not self.connected or not self.api_key: - return "Not connected or API key missing" - if delete_project == self.api_key: - response = requests.delete( - f"{self.base_api_dev}/delete_api_key_by_username?api_key={self.api_key}" - ).json() - return response - else: - return "Ok Done 🗿" + async def delete_api_key(self, email: str): + response = requests.delete( + f"{self.base_api_dev}/delete_api_key_by_username?email={email}" + ).json() + return response From 608b673f3be52b12c65d64b8225ca953d2ce4d09 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Wed, 28 Aug 2024 18:34:29 +0700 Subject: [PATCH 127/152] Update __version__.py --- RyuzakiLib/__version__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RyuzakiLib/__version__.py b/RyuzakiLib/__version__.py index 9c73af26..f708a9b2 100644 --- a/RyuzakiLib/__version__.py +++ b/RyuzakiLib/__version__.py @@ -1 +1 @@ -__version__ = "1.3.1" +__version__ = "1.3.2" From 38626eafdc680df61bb04dee53ea7bbf7b5ff7a5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 28 Aug 2024 11:35:07 +0000 Subject: [PATCH 128/152] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- RyuzakiLib/akenoai.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RyuzakiLib/akenoai.py b/RyuzakiLib/akenoai.py index 0aab2941..e68825db 100644 --- a/RyuzakiLib/akenoai.py +++ b/RyuzakiLib/akenoai.py @@ -2,6 +2,7 @@ from RyuzakiLib.api.reqs import async_search + class AkenoAI: def __init__(self, base_api_dev: str = "https://akeno.randydev.my.id"): self.base_api_dev = base_api_dev @@ -58,7 +59,7 @@ async def x_download(self, url: str): url_ = f"{self.base_api_dev}/akeno/xnxx-dl-v2?link={url}&api_key={self.api_key}" response = await async_search(url_, re_json=True) return response - + async def delete_api_key(self, email: str): response = requests.delete( f"{self.base_api_dev}/delete_api_key_by_username?email={email}" From 6754bdaae5d751f6c252e640d0d563afbfc365ff Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Wed, 28 Aug 2024 18:41:50 +0700 Subject: [PATCH 129/152] _ --- RyuzakiLib/akenoai.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/RyuzakiLib/akenoai.py b/RyuzakiLib/akenoai.py index e68825db..4bfefa85 100644 --- a/RyuzakiLib/akenoai.py +++ b/RyuzakiLib/akenoai.py @@ -20,7 +20,10 @@ async def signup(self, gmail: str, username: str): return response async def connect(self, username: str, requests_limit: int = 30): - response = await self.get_api_key(username) + response = await async_search( + f"{self.base_api_dev}/get_api_key?api_key={username}", + re_json=True + ) if response.get("requests_made", 0) >= requests_limit: return "The limit has been reached" else: From 42fc1033d164003c2dbebf1ec46aa3b0fb479224 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Fri, 30 Aug 2024 11:05:33 +0700 Subject: [PATCH 130/152] Fix add is_working_dev default False --- RyuzakiLib/hackertools/chatgpt.py | 56 +++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 11 deletions(-) diff --git a/RyuzakiLib/hackertools/chatgpt.py b/RyuzakiLib/hackertools/chatgpt.py index fbbaa23d..978191fe 100644 --- a/RyuzakiLib/hackertools/chatgpt.py +++ b/RyuzakiLib/hackertools/chatgpt.py @@ -55,9 +55,13 @@ async def chat_hacked( mongo_url: Optional[str] = None, system_prompt: Optional[str] = owner_base, list_model_all: Optional[bool] = False + is_working_dev: Optional[bool] = False ): if latest_model == "openai-v2": - url = f"{base_api_dev}/ryuzaki/chatgpt-old" + if is_working_dev: + url = f"{base_api_dev}/ryuzaki/chatgpt-old" + else: + url "https://randydev-ryuzaki-api.hf.space/ryuzaki/chatgpt-old" params = {"query": args} check_response = await AsyicXSearcher.search( url, @@ -67,7 +71,10 @@ async def chat_hacked( ) return check_response["randydev"]["message"] elif latest_model == "blackbox": - url = f"{base_api_dev}/ryuzaki/blackbox" + if is_working_dev: + url = f"{base_api_dev}/ryuzaki/blackbox" + else: + url = f"https://randydev-ryuzaki-api.hf.space/ryuzaki/blackbox" params = {"query": args} check_response = await AsyicXSearcher.search( url, @@ -89,7 +96,10 @@ async def chat_hacked( else: return "you can check set list_model_all=True" elif latest_model == "gemini-pro": - url = f"https://randydev-ryuzaki-api.hf.space/ryuzaki/gemini-ai-pro" + if is_working_dev: + url = f"{base_api_dev}/ryuzaki/gemini-ai-pro" + else: + url = f"https://randydev-ryuzaki-api.hf.space/ryuzaki/gemini-ai-pro" payload = { "query": args, "mongo_url": mongo_url, @@ -106,7 +116,10 @@ async def chat_hacked( ) return check_response["randydev"]["message"] elif latest_model == "microsoft": - url = f"{base_api_dev}/ryuzaki/faceai" + if is_working_dev: + url = f"{base_api_dev}/ryuzaki/faceai" + else: + url = f"https://randydev-ryuzaki-api.hf.space/ryuzaki/faceai" payload = { "query": args, "clients_name": "microsoft/Phi-3-mini-4k-instruct", @@ -121,7 +134,10 @@ async def chat_hacked( ) return check_response["randydev"]["message"] elif latest_model == "gemma": - url = f"{base_api_dev}/ryuzaki/faceai" + if is_working_dev: + url = f"{base_api_dev}/ryuzaki/faceai" + else: + url = f"https://randydev-ryuzaki-api.hf.space/ryuzaki/faceai" payload = { "query": args, "clients_name": "google/gemma-1.1-7b-it", @@ -136,7 +152,10 @@ async def chat_hacked( ) return check_response["randydev"]["message"] elif latest_model == "mistralai": - url = f"{base_api_dev}/ryuzaki/faceai" + if is_working_dev: + url = f"{base_api_dev}/ryuzaki/faceai" + else: + url = f"https://randydev-ryuzaki-api.hf.space/ryuzaki/faceai" payload = { "query": args, "clients_name": "mistralai/Mixtral-8x7B-Instruct-v0.1", @@ -151,7 +170,10 @@ async def chat_hacked( ) return check_response["randydev"]["message"] elif latest_model == "faceh4": - url = f"{base_api_dev}/ryuzaki/faceai" + if is_working_dev: + url = f"{base_api_dev}/ryuzaki/faceai" + else: + url = f"https://randydev-ryuzaki-api.hf.space/ryuzaki/faceai" payload = { "query": args, "clients_name": "HuggingFaceH4/zephyr-7b-beta", @@ -166,7 +188,10 @@ async def chat_hacked( ) return check_response["randydev"]["message"] elif latest_model == "google-ai": - url = f"{base_api_dev}/ryuzaki/google-ai" + if is_working_dev: + url = f"{base_api_dev}/ryuzaki/google-ai" + else: + url = f"https://randydev-ryuzaki-api.hf.space/ryuzaki/google-ai" headers = {"accept": "application/json", "api-key": API_KEYS} params = {"query": args} check_response = await AsyicXSearcher.search( @@ -178,7 +203,10 @@ async def chat_hacked( ) return check_response["randydev"]["message"] elif latest_model == "betagoogle-ai": - url = f"{base_api_dev}/ryuzaki/v1beta2-google-ai" + if is_working_dev: + url = f"{base_api_dev}/ryuzaki/v1beta2-google-ai" + else: + url = "https://randydev-ryuzaki-api.hf.space/ryuzaki/v1beta2-google-ai" headers = {"accept": "application/json", "api-key": API_KEYS} params = {"query": args} check_response = await AsyicXSearcher.search( @@ -190,7 +218,10 @@ async def chat_hacked( ) return check_response["randydev"]["message"] elif latest_model == "gpt-4-turbo": - url = f"{base_api_dev}/ryuzaki/chatgpt-custom" + if is_working_dev: + url = f"{base_api_dev}/ryuzaki/chatgpt-custom" + else: + url = f"https://randydev-ryuzaki-api.hf.space/ryuzaki/chatgpt-custom" headers = {"accept": "application/json", "api-key": API_KEYS} params = {"query": args, "model": "gpt-4-turbo"} check_response = await AsyicXSearcher.search( @@ -223,7 +254,10 @@ def download_images(image_urls): @staticmethod async def image_generator(args): - url = f"{base_api_dev}/ryuzaki/dalle3xl" + if is_working_dev: + url = f"{base_api_dev}/ryuzaki/dalle3xl" + else: + url = f"https://randydev-ryuzaki-api.hf.space/ryuzaki/dalle3xl" headers = {"accept": "application/json", "api-key": API_KEYS} payload = {"query": args} check_response = await AsyicXSearcher.search( From 612e8af9c45a901433c9540aa6fb8e4b76b38e8e Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Fri, 30 Aug 2024 13:29:08 +0700 Subject: [PATCH 131/152] Create fastapi.py --- RyuzakiLib/fastapi.py | 59 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 RyuzakiLib/fastapi.py diff --git a/RyuzakiLib/fastapi.py b/RyuzakiLib/fastapi.py new file mode 100644 index 00000000..3e0371b0 --- /dev/null +++ b/RyuzakiLib/fastapi.py @@ -0,0 +1,59 @@ +from fastapi import FastAPI +from fastapi.middleware.cors import CORSMiddleware +from starlette.middleware.sessions import SessionMiddleware +from authlib.integrations.starlette_client import OAuth + +class FastAPISuper: + def __init__(self, docs_url=None, redoc_url=None, config=None): + self.docs_url = docs_url + self.redoc_url = redoc_url + self.fastapi = FastAPI(docs_url=self.docs_url, redoc_url=self.redoc_url) + self.auth = OAuth(config) + + def auth_register( + self, + auth0_client_id=None, + auth0_client_secrect=None, + auth0_domain=None, + domain_url=None, + ): + self.auth.register( + name="auth0", + client_id=auth0_client_id, + client_secret=auth0_client_secrect, + client_kwargs={ + "scope": "openid profile email", + "redirect_url": f"{domain_url}/callback" + }, + server_metadata_url=f"https://{auth0_domain}/.well-known/openid-configuration" + ) + + async def authorize_redirect(self, request=None, redirect_uri=None): + return await self.auth.auth0.authorize_redirect( + request, + redirect_uri=redirect_uri, + scope="openid profile email", + response_type="code" + ) + + async def authorize_access_token(self, request): + token = await self.auth.auth0.authorize_access_token(request) + return token + + def moderator(self): + return self.fastapi + + def add_session_middleware(self, secret_key=None): + self.fastapi.add_middleware( + SessionMiddleware, + secret_key=secret_key + ) + + def add_cors_middleware(self): + self.fastapi.add_middleware( + CORSMiddleware, + allow_origins=["*"], + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], + ) From faa26141e581227a9fadab0bae0539f24f755813 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Fri, 30 Aug 2024 13:30:17 +0700 Subject: [PATCH 132/152] _ --- RyuzakiLib/fastapi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RyuzakiLib/fastapi.py b/RyuzakiLib/fastapi.py index 3e0371b0..b993feee 100644 --- a/RyuzakiLib/fastapi.py +++ b/RyuzakiLib/fastapi.py @@ -36,7 +36,7 @@ async def authorize_redirect(self, request=None, redirect_uri=None): response_type="code" ) - async def authorize_access_token(self, request): + async def authorize_access_token(self, request=None): token = await self.auth.auth0.authorize_access_token(request) return token From 67b6123c0a7fc1702dd04cebc5dc7b5b9fa2dbca Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Fri, 30 Aug 2024 13:40:38 +0700 Subject: [PATCH 133/152] _ --- requirements.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/requirements.txt b/requirements.txt index 4795d027..32c71969 100644 --- a/requirements.txt +++ b/requirements.txt @@ -30,3 +30,6 @@ huggingface-hub>=0.23.2 motor nest-asyncio wget +uvicorn[standard +fastapi[all] +authlib From 239e283c126e9098e77c38a813212278faa2e8d8 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Fri, 30 Aug 2024 13:42:16 +0700 Subject: [PATCH 134/152] _ --- setup.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup.py b/setup.py index 1073555b..f70f0885 100644 --- a/setup.py +++ b/setup.py @@ -56,6 +56,9 @@ def read(fname, version=False): "huggingface-hub>=0.23.2", "motor", "wget", + "uvicorn[standard", + "fastapi[all]", + "authlib", ], classifiers=[ "Programming Language :: Python :: 3", From a396d0b7fdb36cd8d820cbd0aa5660eb94a9b62f Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Fri, 30 Aug 2024 13:44:46 +0700 Subject: [PATCH 135/152] _ --- RyuzakiLib/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/RyuzakiLib/__init__.py b/RyuzakiLib/__init__.py index b8465c6b..998b0813 100644 --- a/RyuzakiLib/__init__.py +++ b/RyuzakiLib/__init__.py @@ -58,6 +58,7 @@ from .profile.user import Clone from .pushdb import * from .pyrogramMod import PyrogramMod +from .fastapi import FastAPISuper from .quote import * from .reminder import * from .spamwatch.clients import SibylBan @@ -118,4 +119,5 @@ class AwesomeCoding(BaseModel): "async_search", "PornoHub", "AkenoAI", + "FastAPISuper", ] From 9e117d33def5198a18e0bf16a3c9651e20ad27bd Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Fri, 30 Aug 2024 13:46:03 +0700 Subject: [PATCH 136/152] _ --- RyuzakiLib/fastapi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RyuzakiLib/fastapi.py b/RyuzakiLib/fastapi.py index b993feee..f36b6ed3 100644 --- a/RyuzakiLib/fastapi.py +++ b/RyuzakiLib/fastapi.py @@ -15,7 +15,7 @@ def auth_register( auth0_client_id=None, auth0_client_secrect=None, auth0_domain=None, - domain_url=None, + domain_url=None ): self.auth.register( name="auth0", From 76a078ad2f317db3fa18e4a7afd5e55d1a513b2b Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Fri, 30 Aug 2024 14:03:00 +0700 Subject: [PATCH 137/152] _ --- RyuzakiLib/__version__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RyuzakiLib/__version__.py b/RyuzakiLib/__version__.py index f708a9b2..7b1e3120 100644 --- a/RyuzakiLib/__version__.py +++ b/RyuzakiLib/__version__.py @@ -1 +1 @@ -__version__ = "1.3.2" +__version__ = "1.3.3" From 91272ff487f5106c24ef5d9a458074cd6f1fc2d0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 30 Aug 2024 07:04:29 +0000 Subject: [PATCH 138/152] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- RyuzakiLib/__init__.py | 2 +- RyuzakiLib/fastapi.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/RyuzakiLib/__init__.py b/RyuzakiLib/__init__.py index 998b0813..6cb4f253 100644 --- a/RyuzakiLib/__init__.py +++ b/RyuzakiLib/__init__.py @@ -38,6 +38,7 @@ from .extreme.quotestk import QouteSticker from .extreme.userinfo import TelegramUserInfo from .extreme.webshot import WebShotUrl +from .fastapi import FastAPISuper from .hackertools.blackbox import Blackbox from .hackertools.chatgpt import RendyDevChat from .hackertools.cloudflare import CloudFlare @@ -58,7 +59,6 @@ from .profile.user import Clone from .pushdb import * from .pyrogramMod import PyrogramMod -from .fastapi import FastAPISuper from .quote import * from .reminder import * from .spamwatch.clients import SibylBan diff --git a/RyuzakiLib/fastapi.py b/RyuzakiLib/fastapi.py index f36b6ed3..64601dea 100644 --- a/RyuzakiLib/fastapi.py +++ b/RyuzakiLib/fastapi.py @@ -1,7 +1,8 @@ +from authlib.integrations.starlette_client import OAuth from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from starlette.middleware.sessions import SessionMiddleware -from authlib.integrations.starlette_client import OAuth + class FastAPISuper: def __init__(self, docs_url=None, redoc_url=None, config=None): @@ -30,12 +31,12 @@ def auth_register( async def authorize_redirect(self, request=None, redirect_uri=None): return await self.auth.auth0.authorize_redirect( - request, - redirect_uri=redirect_uri, + request, + redirect_uri=redirect_uri, scope="openid profile email", response_type="code" ) - + async def authorize_access_token(self, request=None): token = await self.auth.auth0.authorize_access_token(request) return token From 47c926f60107d9ea9c486518850a3be280fd7114 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Fri, 30 Aug 2024 15:21:58 +0700 Subject: [PATCH 139/152] [+] added decorator only_apikey --- RyuzakiLib/fastapi.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/RyuzakiLib/fastapi.py b/RyuzakiLib/fastapi.py index 64601dea..29c5bb7a 100644 --- a/RyuzakiLib/fastapi.py +++ b/RyuzakiLib/fastapi.py @@ -1,5 +1,6 @@ from authlib.integrations.starlette_client import OAuth -from fastapi import FastAPI +from fastapi import FastAPI, Request, HTTPException +from functools import wraps from fastapi.middleware.cors import CORSMiddleware from starlette.middleware.sessions import SessionMiddleware @@ -44,6 +45,18 @@ async def authorize_access_token(self, request=None): def moderator(self): return self.fastapi + def only_apikey(self, valid_api_keys=None): + def decorator(func): + @wraps(func) + async def wrapper(*args, **kwargs): + request: Request = kwargs.get("request") or args[0] + api_key = request.headers.get("X-API-KEY") + if api_key not in valid_api_keys: + raise HTTPException(status_code=403, detail="Invalid API Key") + return await func(*args, **kwargs) + return wrapper + return decorator + def add_session_middleware(self, secret_key=None): self.fastapi.add_middleware( SessionMiddleware, From 24cc83e4810995934776064548ce1c7684677b79 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Fri, 30 Aug 2024 15:52:07 +0700 Subject: [PATCH 140/152] _ --- RyuzakiLib/fastapi.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/RyuzakiLib/fastapi.py b/RyuzakiLib/fastapi.py index 29c5bb7a..1ab93d95 100644 --- a/RyuzakiLib/fastapi.py +++ b/RyuzakiLib/fastapi.py @@ -3,14 +3,24 @@ from functools import wraps from fastapi.middleware.cors import CORSMiddleware from starlette.middleware.sessions import SessionMiddleware - +from motor.motor_asyncio import AsyncIOMotorClient class FastAPISuper: - def __init__(self, docs_url=None, redoc_url=None, config=None): + def __init__( + self, + docs_url=None, + redoc_url=None, + config=None, + mongo_url=None + ): self.docs_url = docs_url self.redoc_url = redoc_url self.fastapi = FastAPI(docs_url=self.docs_url, redoc_url=self.redoc_url) self.auth = OAuth(config) + self.mongodb = AsyncIOMotorClient(mongo_url) + + def client_db(self): + return self.mongodb def auth_register( self, From d4078b6acda5cad8f3f6daf608e75bfb3ef15128 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 30 Aug 2024 08:58:40 +0000 Subject: [PATCH 141/152] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- RyuzakiLib/fastapi.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/RyuzakiLib/fastapi.py b/RyuzakiLib/fastapi.py index 1ab93d95..3e00535d 100644 --- a/RyuzakiLib/fastapi.py +++ b/RyuzakiLib/fastapi.py @@ -1,9 +1,11 @@ -from authlib.integrations.starlette_client import OAuth -from fastapi import FastAPI, Request, HTTPException from functools import wraps + +from authlib.integrations.starlette_client import OAuth +from fastapi import FastAPI, HTTPException, Request from fastapi.middleware.cors import CORSMiddleware -from starlette.middleware.sessions import SessionMiddleware from motor.motor_asyncio import AsyncIOMotorClient +from starlette.middleware.sessions import SessionMiddleware + class FastAPISuper: def __init__( From 90bc21d0a4051444945d930d152158b1df39057d Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Fri, 30 Aug 2024 18:25:31 +0700 Subject: [PATCH 142/152] _ --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index f70f0885..01fa1738 100644 --- a/setup.py +++ b/setup.py @@ -56,7 +56,7 @@ def read(fname, version=False): "huggingface-hub>=0.23.2", "motor", "wget", - "uvicorn[standard", + "uvicorn[standard]", "fastapi[all]", "authlib", ], From 7adf06b29422e2ea27ba92f2f3e49ba04f9e2f11 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Fri, 30 Aug 2024 18:26:41 +0700 Subject: [PATCH 143/152] Update requirements.txt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 32c71969..cd3eb924 100644 --- a/requirements.txt +++ b/requirements.txt @@ -30,6 +30,6 @@ huggingface-hub>=0.23.2 motor nest-asyncio wget -uvicorn[standard +uvicorn[standard] fastapi[all] authlib From 8609bf75cb9b75f17bbc8474087c11abac596977 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Fri, 30 Aug 2024 18:45:12 +0700 Subject: [PATCH 144/152] _ --- RyuzakiLib/fastapi.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/RyuzakiLib/fastapi.py b/RyuzakiLib/fastapi.py index 3e00535d..00619ed3 100644 --- a/RyuzakiLib/fastapi.py +++ b/RyuzakiLib/fastapi.py @@ -1,3 +1,4 @@ +import logging from functools import wraps from authlib.integrations.starlette_client import OAuth @@ -24,6 +25,12 @@ def __init__( def client_db(self): return self.mongodb + def logger(self): + logging.basicConfig(level=logging.ERROR) + logging.basicConfig(level=logging.INFO) + LOGS = logging.getLogger("[akeno]") + return LOGS + def auth_register( self, auth0_client_id=None, From 1e39bb37324513b689d26388055fbe481f4375c4 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Fri, 30 Aug 2024 19:00:13 +0700 Subject: [PATCH 145/152] _ --- RyuzakiLib/fastapi.py | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/RyuzakiLib/fastapi.py b/RyuzakiLib/fastapi.py index 00619ed3..f42f32b1 100644 --- a/RyuzakiLib/fastapi.py +++ b/RyuzakiLib/fastapi.py @@ -1,6 +1,9 @@ import logging +import smtplib from functools import wraps +from email.mime.multipart import MIMEMultipart +from email.mime.text import MIMEText from authlib.integrations.starlette_client import OAuth from fastapi import FastAPI, HTTPException, Request from fastapi.middleware.cors import CORSMiddleware @@ -28,9 +31,42 @@ def client_db(self): def logger(self): logging.basicConfig(level=logging.ERROR) logging.basicConfig(level=logging.INFO) - LOGS = logging.getLogger("[akeno]") + LOGS = logging.getLogger("[fastapi]") return LOGS + def send_verification_email( + self, + sender_email=None, + password=None, + receiver_email=None, + custom_text=None, + ): + try: + LOGS = self.logger() + smtp_server = "smtp.gmail.com" + port = 587 + msg = MIMEMultipart() + msg["From"] = 'RyuzakiLib ' + msg["To"] = receiver_email + msg["Subject"] = "Verify Email - RyuzakiLib API" + html = f""" + + +

Click the button below to verify your email address:

+ {custom_text} + + + """ + msg.attach(MIMEText(html, 'html')) + server = smtplib.SMTP(smtp_server, port) + server.starttls() + server.login(sender_email, password) + server.sendmail(sender_email, receiver_email, msg.as_string()) + server.quit() + LOGS.info("Email sent successfully!") + except Exception: + raise HTTPException(status_code=404, detail="can't send email issue") + def auth_register( self, auth0_client_id=None, From d58264c71b062f8eb5a480f9668fc10b8967fdb0 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Fri, 30 Aug 2024 21:47:32 +0700 Subject: [PATCH 146/152] async_motor_client not client_db --- RyuzakiLib/fastapi.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/RyuzakiLib/fastapi.py b/RyuzakiLib/fastapi.py index f42f32b1..d33712ce 100644 --- a/RyuzakiLib/fastapi.py +++ b/RyuzakiLib/fastapi.py @@ -23,10 +23,10 @@ def __init__( self.redoc_url = redoc_url self.fastapi = FastAPI(docs_url=self.docs_url, redoc_url=self.redoc_url) self.auth = OAuth(config) - self.mongodb = AsyncIOMotorClient(mongo_url) + self.async_mongodb = AsyncIOMotorClient(mongo_url) - def client_db(self): - return self.mongodb + def async_motor_client(self): + return self.async_mongodb def logger(self): logging.basicConfig(level=logging.ERROR) From 461e950788b804f25b0456870106baf0272d4f01 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Fri, 30 Aug 2024 22:30:07 +0700 Subject: [PATCH 147/152] _ --- RyuzakiLib/hackertools/chatgpt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RyuzakiLib/hackertools/chatgpt.py b/RyuzakiLib/hackertools/chatgpt.py index 978191fe..94a78143 100644 --- a/RyuzakiLib/hackertools/chatgpt.py +++ b/RyuzakiLib/hackertools/chatgpt.py @@ -253,7 +253,7 @@ def download_images(image_urls): return downloaded_paths @staticmethod - async def image_generator(args): + async def image_generator(args, base_api_dev="https://akeno.randydev.my.id", is_working_dev=False): if is_working_dev: url = f"{base_api_dev}/ryuzaki/dalle3xl" else: From 8f169b0cb97ff9a9ba9eb9b0e02ec3c77c1c6404 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Sat, 31 Aug 2024 01:41:58 +0700 Subject: [PATCH 148/152] _ --- RyuzakiLib/hackertools/chatgpt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RyuzakiLib/hackertools/chatgpt.py b/RyuzakiLib/hackertools/chatgpt.py index 94a78143..782c6a26 100644 --- a/RyuzakiLib/hackertools/chatgpt.py +++ b/RyuzakiLib/hackertools/chatgpt.py @@ -54,7 +54,7 @@ async def chat_hacked( user_id: Optional[int] = 0, mongo_url: Optional[str] = None, system_prompt: Optional[str] = owner_base, - list_model_all: Optional[bool] = False + list_model_all: Optional[bool] = False, is_working_dev: Optional[bool] = False ): if latest_model == "openai-v2": From 8cb60b84b74fd3b597156376ff91fd8b670b47af Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Sat, 31 Aug 2024 12:06:52 +0700 Subject: [PATCH 149/152] Update chatgpt.py --- RyuzakiLib/hackertools/chatgpt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RyuzakiLib/hackertools/chatgpt.py b/RyuzakiLib/hackertools/chatgpt.py index 782c6a26..1e0f6715 100644 --- a/RyuzakiLib/hackertools/chatgpt.py +++ b/RyuzakiLib/hackertools/chatgpt.py @@ -61,7 +61,7 @@ async def chat_hacked( if is_working_dev: url = f"{base_api_dev}/ryuzaki/chatgpt-old" else: - url "https://randydev-ryuzaki-api.hf.space/ryuzaki/chatgpt-old" + url = "https://randydev-ryuzaki-api.hf.space/ryuzaki/chatgpt-old" params = {"query": args} check_response = await AsyicXSearcher.search( url, From 369bf897ee8d6b40cd3720af51e8f97df25c9fc7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 31 Aug 2024 05:40:10 +0000 Subject: [PATCH 150/152] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- RyuzakiLib/fastapi.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RyuzakiLib/fastapi.py b/RyuzakiLib/fastapi.py index d33712ce..52e7a9de 100644 --- a/RyuzakiLib/fastapi.py +++ b/RyuzakiLib/fastapi.py @@ -1,9 +1,9 @@ import logging import smtplib -from functools import wraps - from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText +from functools import wraps + from authlib.integrations.starlette_client import OAuth from fastapi import FastAPI, HTTPException, Request from fastapi.middleware.cors import CORSMiddleware From 69207c1501541657304790930dded987db4fb640 Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Sat, 31 Aug 2024 12:47:06 +0700 Subject: [PATCH 151/152] _ --- RyuzakiLib/spamwatch/clients.py | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/RyuzakiLib/spamwatch/clients.py b/RyuzakiLib/spamwatch/clients.py index 173fd035..237540a0 100644 --- a/RyuzakiLib/spamwatch/clients.py +++ b/RyuzakiLib/spamwatch/clients.py @@ -37,8 +37,11 @@ def _make_request(method: str, url: str, params: dict = None, json_data: dict = return None @staticmethod - def ban(user_id: int = None, reason: str = None) -> str: - url = "https://akeno.randydev.my.id/sibylban" + def ban(user_id: int = None, reason: str = None, is_working_dev=False) -> str: + if is_working_dev: + url = "https://akeno.randydev.my.id/sibylban" + else: + url = "https://randydev-ryuzaki-api.hf.space/sibylban" payload = {"user_id": user_id, "reason": reason} response = SibylBan._make_request("POST", url, json_data=payload) return response.get("randydev", {}).get( @@ -46,18 +49,27 @@ def ban(user_id: int = None, reason: str = None) -> str: ) @staticmethod - def banlist(user_id: int = None) -> Union[dict, str]: - url = "https://akeno.randydev.my.id/ryuzaki/sibyl" + def banlist(user_id: int = None, is_working_dev=False) -> Union[dict, str]: + if is_working_dev: + url = "https://akeno.randydev.my.id/ryuzaki/sibyl" + else: + url = "https://randydev-ryuzaki-api.hf.space/ryuzaki/sibyl" payload = {"user_id": user_id} return SibylBan._make_request("GET", url, json_data=payload) @staticmethod - def unban(user_id: int = None) -> Union[dict, str]: - url = "https://akeno.randydev.my.id/ryuzaki/sibyldel" + def unban(user_id: int = None, is_working_dev=False) -> Union[dict, str]: + if is_working_dev: + url = "https://akeno.randydev.my.id/ryuzaki/sibyldel" + else: + url = "https://randydev-ryuzaki-api.hf.space/ryuzaki/sibydel" payload = {"user_id": user_id} return SibylBan._make_request("DELETE", url, json_data=payload) @staticmethod - def banlist_all() -> Union[dict, str]: - url = "https://akeno.randydev.my.id/ryuzaki/getbanlist" + def banlist_all(is_working_dev=False) -> Union[dict, str]: + if is_working_dev: + url = "https://akeno.randydev.my.id/ryuzaki/getbanlist" + else: + url = "https://randydev-ryuzaki-api.hf.space/ryuzaki/getbanlist" return SibylBan._make_request("GET", url) From 923e2f00d3bf217ff54c7e1c7b4ffcdcb166166d Mon Sep 17 00:00:00 2001 From: Randy Dev <90479255+xtsea@users.noreply.github.com> Date: Sat, 31 Aug 2024 13:02:34 +0700 Subject: [PATCH 152/152] _ --- RyuzakiLib/hackertools/chatgpt.py | 86 ++++--------------------------- 1 file changed, 11 insertions(+), 75 deletions(-) diff --git a/RyuzakiLib/hackertools/chatgpt.py b/RyuzakiLib/hackertools/chatgpt.py index 1e0f6715..ecc85099 100644 --- a/RyuzakiLib/hackertools/chatgpt.py +++ b/RyuzakiLib/hackertools/chatgpt.py @@ -63,12 +63,7 @@ async def chat_hacked( else: url = "https://randydev-ryuzaki-api.hf.space/ryuzaki/chatgpt-old" params = {"query": args} - check_response = await AsyicXSearcher.search( - url, - post=True, - re_json=True, - json=params - ) + check_response = requests.post(url, json=params).json() return check_response["randydev"]["message"] elif latest_model == "blackbox": if is_working_dev: @@ -76,12 +71,7 @@ async def chat_hacked( else: url = f"https://randydev-ryuzaki-api.hf.space/ryuzaki/blackbox" params = {"query": args} - check_response = await AsyicXSearcher.search( - url, - post=True, - re_json=True, - json=params - ) + check_response = requests.post(url, json=params).json() return check_response["randydev"]["message"] elif latest_model == "list-model": if list_model_all: @@ -107,13 +97,7 @@ async def chat_hacked( "is_multi_chat": True } headers = {"accept": "application/json", "api-key": API_KEYS} - check_response = await AsyicXSearcher.search( - url, - post=True, - re_json=True, - headers=headers, - json=payload - ) + check_response = requests.post(url, headers=headers, json=payload).json() return check_response["randydev"]["message"] elif latest_model == "microsoft": if is_working_dev: @@ -125,13 +109,7 @@ async def chat_hacked( "clients_name": "microsoft/Phi-3-mini-4k-instruct", } headers = {"accept": "application/json"} - check_response = await AsyicXSearcher.search( - url, - post=True, - re_json=True, - headers=headers, - json=payload - ) + check_response = requests.post(url, headers=headers, json=payload).json() return check_response["randydev"]["message"] elif latest_model == "gemma": if is_working_dev: @@ -143,13 +121,7 @@ async def chat_hacked( "clients_name": "google/gemma-1.1-7b-it", } headers = {"accept": "application/json"} - check_response = await AsyicXSearcher.search( - url, - post=True, - re_json=True, - headers=headers, - json=payload - ) + check_response = requests.post(url, headers=headers, json=payload).json() return check_response["randydev"]["message"] elif latest_model == "mistralai": if is_working_dev: @@ -161,13 +133,7 @@ async def chat_hacked( "clients_name": "mistralai/Mixtral-8x7B-Instruct-v0.1", } headers = {"accept": "application/json"} - check_response = await AsyicXSearcher.search( - url, - post=True, - re_json=True, - headers=headers, - json=payload - ) + check_response = requests.post(url, headers=headers, json=payload).json() return check_response["randydev"]["message"] elif latest_model == "faceh4": if is_working_dev: @@ -179,13 +145,7 @@ async def chat_hacked( "clients_name": "HuggingFaceH4/zephyr-7b-beta", } headers = {"accept": "application/json"} - check_response = await AsyicXSearcher.search( - url, - post=True, - re_json=True, - headers=headers, - json=payload - ) + check_response = requests.post(url, headers=headers, json=payload).json() return check_response["randydev"]["message"] elif latest_model == "google-ai": if is_working_dev: @@ -194,13 +154,7 @@ async def chat_hacked( url = f"https://randydev-ryuzaki-api.hf.space/ryuzaki/google-ai" headers = {"accept": "application/json", "api-key": API_KEYS} params = {"query": args} - check_response = await AsyicXSearcher.search( - url, - post=True, - re_json=True, - headers=headers, - json=params - ) + check_response = requests.post(url, headers=headers, json=params).json() return check_response["randydev"]["message"] elif latest_model == "betagoogle-ai": if is_working_dev: @@ -209,13 +163,7 @@ async def chat_hacked( url = "https://randydev-ryuzaki-api.hf.space/ryuzaki/v1beta2-google-ai" headers = {"accept": "application/json", "api-key": API_KEYS} params = {"query": args} - check_response = await AsyicXSearcher.search( - url, - post=True, - re_json=True, - headers=headers, - json=params - ) + check_response = requests.post(url, headers=headers, json=params).json() return check_response["randydev"]["message"] elif latest_model == "gpt-4-turbo": if is_working_dev: @@ -224,13 +172,7 @@ async def chat_hacked( url = f"https://randydev-ryuzaki-api.hf.space/ryuzaki/chatgpt-custom" headers = {"accept": "application/json", "api-key": API_KEYS} params = {"query": args, "model": "gpt-4-turbo"} - check_response = await AsyicXSearcher.search( - url, - post=True, - re_json=True, - headers=headers, - json=params - ) + check_response = requests.post(url, headers=headers, json=params).json() return check_response["randydev"]["message"] elif latest_model == "gpt-4o": clients_x = Clients_g4f() @@ -260,11 +202,5 @@ async def image_generator(args, base_api_dev="https://akeno.randydev.my.id", is_ url = f"https://randydev-ryuzaki-api.hf.space/ryuzaki/dalle3xl" headers = {"accept": "application/json", "api-key": API_KEYS} payload = {"query": args} - check_response = await AsyicXSearcher.search( - url, - post=True, - re_json=True, - headers=headers, - json=payload - ) + check_response = requests.post(url, headers=headers, json=payload).json() return check_response