├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── bug-reports.md │ └── feature_request.md └── workflows │ └── main.yml ├── .gitignore ├── CODEOWNERS ├── Dockerfile ├── LICENSE ├── Procfile ├── README.md ├── app.json ├── assistant ├── Chatbot.py ├── inline_utils.py └── main_assistant.py ├── bot_utils_files ├── Fonts │ ├── BADABB__.TTF │ ├── Chopsic.otf │ ├── ProductSans-BoldItalic.ttf │ ├── ProductSans-Light.ttf │ ├── Quivira.otf │ ├── README.md │ ├── Streamster.ttf │ ├── impact.ttf │ ├── live_news_font.ttf │ └── ph_comment_font.TTF ├── Localization │ ├── engine.py │ └── strings │ │ ├── en.yml │ │ ├── hi.yml │ │ └── pa.yml ├── ai_helpers │ ├── README.md │ ├── colouregex.prototxt │ ├── haarcascade_frontalface_default.xml │ └── pts_in_hull.npy ├── image_templates │ ├── README.md │ ├── black_blank_image.jpg │ ├── certificate_templete.png │ ├── google_search_templete.jpg │ ├── jail_templete.png │ ├── live_new_templete.png │ ├── ph_comment_templete.jpg │ ├── tg_ghost_image.jpg │ ├── thug_life_mask.png │ └── yellow_bg_for_logo.jpg └── other_helpers │ ├── gmdl.py │ └── xtra_plugins.sh ├── database ├── __init__.py ├── afk.py ├── autopostingdb.py ├── blacklistdb.py ├── bot_settings_db.py ├── bot_users.py ├── broadcast_db.py ├── chatbot_db.py ├── chatbot_msg_db.py ├── filterdb.py ├── gbandb.py ├── gmutedb.py ├── localdb.py ├── notesdb.py ├── nsfw_watch_db.py ├── pmdb.py ├── sudodb.py └── welcomedb.py ├── heroku.yml ├── logo.jpg ├── main_startup ├── Cache │ └── README.md ├── __init__.py ├── __main__.py ├── config_var.py ├── core │ ├── decorators.py │ ├── helpers.py │ └── startup_helpers.py └── helper_func │ ├── assistant_helpers.py │ ├── basic_helpers.py │ ├── gmdl.py │ ├── logger_s.py │ └── plugin_helpers.py ├── plugins ├── __init__.py ├── afk.py ├── autopost.py ├── blacklist.py ├── broadcast.py ├── chat_filters.py ├── code_runner.py ├── fileTools.py ├── gps.py ├── grouputils.py ├── gtools.py ├── helper.py ├── heroku_helpers.py ├── imagetools.py ├── install.py ├── listmyusernames.py ├── notes.py ├── paste.py ├── pmpermit.py ├── rename.py ├── search.py ├── stats.py ├── stickers.py ├── sudo_manager.py ├── sys_utils.py ├── telegraph.py ├── tg_helpers.py ├── tts_tr.py ├── updater.py ├── videotools.py ├── welcome.py ├── whois.py ├── xtra_media.py └── yt.py ├── requirements.txt ├── startup.sh └── string_gen.py /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-reports.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug reports 3 | about: Create a report to help us improve. 4 | title: "[BUG]" 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | 12 | ## Checklist 13 | - [ ] I Am Using Latest Version. 14 | - [ ] I have searched Issues And Pull Requests And I Confirm That This is Not A Duplicate Issue. 15 | 16 | ## Command Which Causes This Issue. 17 | Command Name, Filename, And Function name. 18 | 19 | ## Description 20 | A detailed description of the Bug. 21 | 22 | ## Traceback 23 | TraceBack Of Bug (if any) 24 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: "[FEATURE-REQUEST]" 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | 12 | ## Checklist 13 | - [ ] I Confirm this is awesome and would benefit the Software. 14 | - [ ] I Confirm That This is Not A Duplicate Feature Request 15 | 16 | ## Description 17 | A detailed description of the Feature. 18 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Sed-replacer 2 | on: push 3 | jobs: 4 | build: 5 | runs-on: ubuntu-latest 6 | steps: 7 | - uses: actions/checkout@v2 8 | - name: Find and Replace 9 | uses: jacobtomlinson/gha-find-replace@master 10 | with: 11 | find: "FridayUserbot" 12 | replace: "FridayUB" 13 | - name: Pull All Updates 14 | uses: stefanzweifel/git-auto-commit-action@v4 15 | with: 16 | commit_message: 'Update' 17 | commit_options: '--no-verify' 18 | repository: . 19 | commit_user_name: StarkGang 20 | commit_user_email: starkgangz@gmail.com 21 | commit_author: StarkGang 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # celery beat schedule file 95 | celerybeat-schedule 96 | 97 | # SageMath parsed files 98 | *.sage.py 99 | 100 | # Environments 101 | .env 102 | .venv 103 | env/ 104 | venv/ 105 | ENV/ 106 | env.bak/ 107 | venv.bak/ 108 | 109 | # Spyder project settings 110 | .spyderproject 111 | .spyproject 112 | 113 | # Rope project settings 114 | .ropeproject 115 | 116 | # mkdocs documentation 117 | /site 118 | 119 | # mypy 120 | .mypy_cache/ 121 | .dmypy.json 122 | dmypy.json 123 | 124 | # Pyre type checker 125 | .pyre/ 126 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @chsaiujwal @Aditya-XD @SHRE-YANSH @StarkGang @Lakhac @InukaAsith 2 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | FROM python:3.9 10 | WORKDIR . 11 | ENV PYTHONUNBUFFERED=1 12 | COPY requirements.txt . 13 | COPY startup.sh . 14 | RUN bash startup.sh 15 | COPY . . 16 | CMD ["python3", "-m", "main_startup"] 17 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | bot: python -m main_startup 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 |

FRIDAY-USERBOT 🇮🇳

3 |

A Powerful, Smart And Simple Userbot In Pyrogram.

4 | 5 | 6 | ## Support 🚑 7 | 8 | 9 | 10 | ## Inspiration & Credits 11 | * [Userge-X](https://github.com/code-rgb/USERGE-X/contributors) 12 | * [Userge](https://github.com/UsergeTeam/Userge) 13 | * [Pokurt](https://github.com/UsergeTeam/Pokurt) 14 | * [Pyrogram](https://github.com/pyrogram/pyrogram/contributors) 15 | 16 | ## Code Owners 17 | * [Chsaiujwal](https://github.com/chsaiujwal) 18 | * [Aditya](https://github.com/Aditya-XD) 19 | * [Lakhac](https://github.com/Lakhac) 20 | * [InukaAsith](https://github.com/InukaAsith) 21 | * [SHRE-YANSH](https://github.com/SHRE-YANSH) 22 | 23 | # String Session - Pyrogram 🖱 24 | ### Repl 🧨 25 | [![Run on Repl.it](https://repl.it/badge/github/STARKGANG/friday)](https://replit.com/@MIDHUNKMKM/StringGen) 26 | ### Locally 🏆 27 | ``` 28 | $ git clone https://github.com/DevsExpo/FridayUB 29 | $ cd FridayUB 30 | $ python(3) string_gen.py 31 | ``` 32 | 33 | # Hosting 🖥 34 | 35 | ### Deploying To Heroku / Railway ⚙ 36 | 37 | [![Deploy To Heroku](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/DevsExpo/FridayUB) 38 | 39 | [![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/new/template?template=https%3A%2F%2Fgithub.com%2FDevsExpo%2FFridayUB&envs=API_HASH%2CAPI_ID%2CBOT_TOKEN%2CLOG_GRP%2CMONGO_DB%2CSTRINGSESSION%2CTZ&optionalEnvs=BOT_TOKEN%2CCOMMAND_HANDLER%2CUPSTREAM_REPO&API_HASHDesc=Get+this+value+from+my.telegram.org%21+Please+do+not+steal&API_IDDesc=Get+this+value+from+my.telegram.org%21+Please+do+not+steal&BOT_TOKENDesc=Your+Bot+Token+Obtained+From+%40BotFather.+This+is+Not+Important&COMMAND_HANDLERDesc=Your+Command+Handler.&LOAD_UNOFFICIAL_PLUGINSDesc=Do+You+Wish+To+Load+X-Tra+Plugins%3F&LOG_GRPDesc=A+Group+ID+Where+You+Want+To+Log+Important+Logs.&MONGO_DBDesc=Create+A+Database+In+Mongodb+And+Get+URL.+Make+Sure+To+Enter+Correct+URL%21&STRINGSESSIONDesc=String+Session%2C+Run+string_gen.py+to+get+String+Session.&TZDesc=Your+Time+Zone&LOAD_UNOFFICIAL_PLUGINSDefault=True&TZDefault=Asia%2FKolkata) 40 | 41 | 42 | ### Self-hosting (For Devs) ⚔ 43 | ```sh 44 | # Install Git First // (Else You Can Download And Upload to Your Local Server) 45 | $ git clone https://github.com/DevsExpo/FridayUB 46 | # Open Git Cloned File 47 | $ cd FridayUB 48 | # Install All Requirements 49 | $ pip(3) install -r requirements.txt 50 | # Create local.env with variables as given below 51 | # Start Bot 52 | $ python(3) -m main_startup 53 | ``` 54 | 55 | 56 | ### Mandatory Configs 📒 57 | ``` 58 | [+] Make Sure You Add All These Mandatory Vars. 59 | [-] API_ID: You can get this value from https://my.telegram.org 60 | [-] API_HASH : You can get this value from https://my.telegram.org 61 | [-] STRINGSESSION : Your String Session, You can get this From Repl or BY running String_Gen File Locally 62 | [-] MONGO_DB : Your Mongo DB DataBase Url. 63 | [-] LOG_GRP: Your Log Group/Channel Chat ID. This is Very Important and Some Modules Will Not Work Well Without This! 64 | [+] The fridayUserbot will not work without setting the mandatory vars. 65 | ``` 66 | 67 | # Examples - Plugins 👊 68 | 69 | ### Plugins 🔧 70 | 71 | ```python3 72 | from main_startup.core.decorators import friday_on_cmd 73 | from main_startup.helper_func.basic_helpers import edit_or_reply 74 | 75 | @friday_on_cmd(['helloworld'], 76 | cmd_help={ 77 | "help": "This is A TEST", 78 | "example": "{ch}helloworld" 79 | }) 80 | async def hello_world(client, message): 81 | mg = await edit_or_reply(message, "`Hello World! This Works!`") 82 | ``` 83 | ### Custom Filters 📣 84 | 85 | ```python3 86 | from main_startup.core.decorators import listen 87 | 88 | @listen(filters.mentioned) 89 | async def mentioned_(client, message): 90 | await message.reply_text("`Hello World! By The Way Why Did You Mention Me?`") 91 | ``` 92 | 93 | # X-Tra Plugins 🎸 94 | * Please Visit [Xtra-Plugins](https://github.com/DevsExpo/Xtra-Plugins) To Checkout Xtra-Plugins. 95 | 96 | 97 | # Licence 📋 98 | [![GNU GPLv3 Image](https://www.gnu.org/graphics/gplv3-127x51.png)](http://www.gnu.org/licenses/gpl-3.0.en.html) 99 | 100 | * Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 101 | 102 | FridayUB is Free Software: You can use, study share and improve it at your 103 | will. Specifically you can redistribute and/or modify it under the terms of the 104 | [GNU General Public License](https://www.gnu.org/licenses/gpl.html) as 105 | published by the Free Software Foundation, either version 3 of the License, or 106 | (at your option) any later version. 107 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Friday-Userbot", 3 | "description": "A Userbot Based On Pyrogram.", 4 | "logo": "https://telegra.ph/file/b4e1e36c6b1fcb32dd997.jpg", 5 | "keywords": [ 6 | "telegram", 7 | "fridaybot", 8 | "plugin", 9 | "fridaybot", 10 | "productivity" 11 | ], 12 | "repository": "https://github.com/starkgang/FridayUB", 13 | "website": "t.me/fridayot", 14 | "success_url": "t.me/FridayOT", 15 | "stack": "container", 16 | "env": { 17 | "API_ID": { 18 | "description": "Get this value from my.telegram.org! Please do not steal", 19 | "value": "" 20 | }, 21 | "API_HASH": { 22 | "description": "Get this value from my.telegram.org! Please do not steal", 23 | "value": "" 24 | }, 25 | "MONGO_DB": { 26 | "description": "Create A Database In Mongodb And Get URL. Make Sure To Enter Correct URL!", 27 | "value": "" 28 | }, 29 | "COMMAND_HANDLER": { 30 | "description": "Your Command Handler.", 31 | "value": ".", 32 | "required": false 33 | }, 34 | "LOAD_UNOFFICIAL_PLUGINS": { 35 | "description": "Do You Wish To Load X-Tra Plugins?", 36 | "value": "True" 37 | }, 38 | "LOG_GRP": { 39 | "description": "A Group ID Where You Want To Log Important Logs.", 40 | "value": "" 41 | }, 42 | "HEROKU_API_KEY": { 43 | "description": "Go to https://dashboard.heroku.com/account, scroll down and press Reveal API.", 44 | "value": "" 45 | }, 46 | "HEROKU_APP_NAME": { 47 | "description": "Heroku App Name That You Filled Above.", 48 | "value": "" 49 | }, 50 | "UPSTREAM_REPO": { 51 | "description": "Your Upstream URL HERE. If You're Beginner, Don't Change This.", 52 | "value": "https://github.com/DevsExpo/FridayUB", 53 | "required": false 54 | }, 55 | "BOT_TOKEN": { 56 | "description": "Your Bot Token Obtained From @BotFather. This is Not Important", 57 | "value": "", 58 | "required": false 59 | }, 60 | "TZ": { 61 | "description": "Your Time Zone", 62 | "value": "Asia/Kolkata" 63 | }, 64 | "STRINGSESSION": { 65 | "description": "String Session, Run string_gen.py to get String Session.", 66 | "value": "" 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /assistant/Chatbot.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | from pyrogram import filters 10 | 11 | from database.chatbot_db import ( 12 | add_blacklisted_user, 13 | is_user_blacklisted, 14 | rm_blacklisted_user, 15 | ) 16 | from database.chatbot_msg_db import add_msg_in_db, get_user_id_frm_msg_id 17 | from main_startup.__main__ import Friday, bot 18 | 19 | 20 | async def my_id_(f, client, message): 21 | me = Friday.me.id 22 | if message.from_user.id == me: 23 | return bool(True) 24 | else: 25 | return bool(False) 26 | 27 | 28 | owner_f = filters.create(func=my_id_, name="owner_f") 29 | 30 | other_cmd_list = [ 31 | "start", 32 | "help", 33 | "alive", 34 | "promote", 35 | "demote", 36 | "users", 37 | "id", 38 | "info", 39 | "ping", 40 | "tts", 41 | "tr", 42 | "broadcast", 43 | "block", 44 | "unblock", 45 | ] 46 | 47 | 48 | @bot.on_message( 49 | filters.private & filters.incoming & ~owner_f & ~filters.command(other_cmd_list) 50 | ) 51 | async def chat_bot(client, message): 52 | if await is_user_blacklisted(message.chat.id): 53 | return 54 | my_id = Friday.me.id 55 | owo = await message.forward(my_id) 56 | await add_msg_in_db(owo.message_id, message.from_user.id, message.message_id) 57 | 58 | 59 | @bot.on_message( 60 | filters.private 61 | & filters.incoming 62 | & owner_f 63 | & ~filters.edited 64 | & ~filters.command(other_cmd_list) 65 | ) 66 | async def reply_handler(client, message): 67 | if not message.reply_to_message: 68 | return 69 | msg_ = await get_user_id_frm_msg_id(message.reply_to_message.message_id) 70 | if not msg_: 71 | return 72 | try: 73 | await message.copy(msg_["sender_id"], reply_to_message_id=msg_["um_id"]) 74 | except BaseException as e: 75 | await message.reply_text( 76 | f"Unable To Reply Message To This User \nTraceBack : {e}" 77 | ) 78 | 79 | 80 | @bot.on_message( 81 | filters.private & filters.incoming & owner_f & filters.command(["block"]) 82 | ) 83 | async def rip_blocked(client, message): 84 | if not message.reply_to_message: 85 | await message.reply_text("`Please Reply To A User!`") 86 | return 87 | msg_ = await get_user_id_frm_msg_id(message.reply_to_message.message_id) 88 | if not msg_: 89 | return 90 | if await is_user_blacklisted(msg_["sender_id"]): 91 | await message.reply_text("`This User is Already Blacklisted 😥`") 92 | return 93 | await add_blacklisted_user(msg_["sender_id"]) 94 | await message.reply_text("`Sucessfully Blocked This User!`") 95 | 96 | 97 | @bot.on_message( 98 | filters.private & filters.incoming & owner_f & filters.command(["unblock"]) 99 | ) 100 | async def rip_unblocked(client, message): 101 | if not message.reply_to_message: 102 | await message.reply_text("`Please Reply To A User!`") 103 | return 104 | msg_ = await get_user_id_frm_msg_id(message.reply_to_message.message_id) 105 | if not msg_: 106 | return 107 | if not await is_user_blacklisted(msg_["sender_id"]): 108 | await message.reply_text("`This User is Not Blacklisted 😥`") 109 | return 110 | await rm_blacklisted_user(msg_["sender_id"]) 111 | await message.reply_text("`Sucessfully Un-Blocked This User!`") 112 | -------------------------------------------------------------------------------- /bot_utils_files/Fonts/BADABB__.TTF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevsExpo/FridayUB/ad8c3c60ff1823272d93e0aab849051c338c1b62/bot_utils_files/Fonts/BADABB__.TTF -------------------------------------------------------------------------------- /bot_utils_files/Fonts/Chopsic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevsExpo/FridayUB/ad8c3c60ff1823272d93e0aab849051c338c1b62/bot_utils_files/Fonts/Chopsic.otf -------------------------------------------------------------------------------- /bot_utils_files/Fonts/ProductSans-BoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevsExpo/FridayUB/ad8c3c60ff1823272d93e0aab849051c338c1b62/bot_utils_files/Fonts/ProductSans-BoldItalic.ttf -------------------------------------------------------------------------------- /bot_utils_files/Fonts/ProductSans-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevsExpo/FridayUB/ad8c3c60ff1823272d93e0aab849051c338c1b62/bot_utils_files/Fonts/ProductSans-Light.ttf -------------------------------------------------------------------------------- /bot_utils_files/Fonts/Quivira.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevsExpo/FridayUB/ad8c3c60ff1823272d93e0aab849051c338c1b62/bot_utils_files/Fonts/Quivira.otf -------------------------------------------------------------------------------- /bot_utils_files/Fonts/README.md: -------------------------------------------------------------------------------- 1 | # Fonts 2 | * Path : `bot_utils_files/Fonts` 3 | * Whats In Here? : `Contains All Types Of Fonts For Some Modules To Work!` 4 | * Note : `We Are Not CopyRight Holders Of Fonts The That You Can Find Here, All Fonts Are Taken From DaFont.com!` 5 | -------------------------------------------------------------------------------- /bot_utils_files/Fonts/Streamster.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevsExpo/FridayUB/ad8c3c60ff1823272d93e0aab849051c338c1b62/bot_utils_files/Fonts/Streamster.ttf -------------------------------------------------------------------------------- /bot_utils_files/Fonts/impact.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevsExpo/FridayUB/ad8c3c60ff1823272d93e0aab849051c338c1b62/bot_utils_files/Fonts/impact.ttf -------------------------------------------------------------------------------- /bot_utils_files/Fonts/live_news_font.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevsExpo/FridayUB/ad8c3c60ff1823272d93e0aab849051c338c1b62/bot_utils_files/Fonts/live_news_font.ttf -------------------------------------------------------------------------------- /bot_utils_files/Fonts/ph_comment_font.TTF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevsExpo/FridayUB/ad8c3c60ff1823272d93e0aab849051c338c1b62/bot_utils_files/Fonts/ph_comment_font.TTF -------------------------------------------------------------------------------- /bot_utils_files/Localization/engine.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | import logging 10 | import os 11 | import yaml 12 | import pathlib 13 | from database.localdb import check_lang 14 | from main_startup.config_var import Config 15 | from main_startup import ( 16 | CMD_LIST, 17 | XTRA_CMD_LIST, 18 | Config, 19 | Friday, 20 | Friday2, 21 | Friday3, 22 | Friday4, 23 | bot 24 | ) 25 | 26 | language_string = {} 27 | 28 | class Engine: 29 | def __init__(self): 30 | self.path = "./bot_utils_files/Localization/strings/" 31 | 32 | def get_all_files_in_path(self, path): 33 | path = pathlib.Path(path) 34 | return [i.absolute() for i in path.glob("**/*")] 35 | 36 | def load_language(self): 37 | all_files = self.get_all_files_in_path(self.path) 38 | for filepath in all_files: 39 | with open(filepath) as f: 40 | data = yaml.safe_load(f) 41 | language_to_load = data.get("language") 42 | logging.debug(f"Loading : {language_to_load}") 43 | language_string[language_to_load] = data 44 | logging.debug("All language Loaded.") 45 | 46 | def get_string(self, string): 47 | lang_ = Friday.selected_lang 48 | return ( 49 | language_string.get(lang_).get(string) 50 | or f"**404_STRING_NOT_FOUND :** `String {string} Not Found in {lang} String File. - Please Report It To @FridayChat`" 51 | ) 52 | -------------------------------------------------------------------------------- /bot_utils_files/ai_helpers/README.md: -------------------------------------------------------------------------------- 1 | # AI-Helpers 2 | * Path : `bot_utils_files/ai_helpers` 3 | * Whats In Here? : `Contains All Various Scripts That Helps Plugins Which Uses Ai!` 4 | * Note : `We Are Not CopyRight Holders Of These Scripts, Please Read License In Scripts Before Doing Anything!` 5 | -------------------------------------------------------------------------------- /bot_utils_files/ai_helpers/pts_in_hull.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevsExpo/FridayUB/ad8c3c60ff1823272d93e0aab849051c338c1b62/bot_utils_files/ai_helpers/pts_in_hull.npy -------------------------------------------------------------------------------- /bot_utils_files/image_templates/README.md: -------------------------------------------------------------------------------- 1 | # Image Templates 2 | 3 | * Path : `bot_utils_files/image_templates` 4 | * Whats In Here? : `Contains All Many Image Templetes For Some Plugins!` 5 | * Note : `We Are Not CopyRight Holders Of These Images, These Are Mostly Taken From Google.com!` 6 | -------------------------------------------------------------------------------- /bot_utils_files/image_templates/black_blank_image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevsExpo/FridayUB/ad8c3c60ff1823272d93e0aab849051c338c1b62/bot_utils_files/image_templates/black_blank_image.jpg -------------------------------------------------------------------------------- /bot_utils_files/image_templates/certificate_templete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevsExpo/FridayUB/ad8c3c60ff1823272d93e0aab849051c338c1b62/bot_utils_files/image_templates/certificate_templete.png -------------------------------------------------------------------------------- /bot_utils_files/image_templates/google_search_templete.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevsExpo/FridayUB/ad8c3c60ff1823272d93e0aab849051c338c1b62/bot_utils_files/image_templates/google_search_templete.jpg -------------------------------------------------------------------------------- /bot_utils_files/image_templates/jail_templete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevsExpo/FridayUB/ad8c3c60ff1823272d93e0aab849051c338c1b62/bot_utils_files/image_templates/jail_templete.png -------------------------------------------------------------------------------- /bot_utils_files/image_templates/live_new_templete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevsExpo/FridayUB/ad8c3c60ff1823272d93e0aab849051c338c1b62/bot_utils_files/image_templates/live_new_templete.png -------------------------------------------------------------------------------- /bot_utils_files/image_templates/ph_comment_templete.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevsExpo/FridayUB/ad8c3c60ff1823272d93e0aab849051c338c1b62/bot_utils_files/image_templates/ph_comment_templete.jpg -------------------------------------------------------------------------------- /bot_utils_files/image_templates/tg_ghost_image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevsExpo/FridayUB/ad8c3c60ff1823272d93e0aab849051c338c1b62/bot_utils_files/image_templates/tg_ghost_image.jpg -------------------------------------------------------------------------------- /bot_utils_files/image_templates/thug_life_mask.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevsExpo/FridayUB/ad8c3c60ff1823272d93e0aab849051c338c1b62/bot_utils_files/image_templates/thug_life_mask.png -------------------------------------------------------------------------------- /bot_utils_files/image_templates/yellow_bg_for_logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevsExpo/FridayUB/ad8c3c60ff1823272d93e0aab849051c338c1b62/bot_utils_files/image_templates/yellow_bg_for_logo.jpg -------------------------------------------------------------------------------- /bot_utils_files/other_helpers/xtra_plugins.sh: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | PLUGIN_REPO="$1" 10 | xtra_fold="./xtraplugins" 11 | req_file="./xtraplugins/req.txt" 12 | 13 | make_xtra_dir () { 14 | if [ -d "$xtra_fold" ] 15 | then 16 | rm -r "$xtra_fold" 17 | mkdir "$xtra_fold" 18 | else 19 | mkdir "$xtra_fold" 20 | fi 21 | } 22 | 23 | git_clone_plugin_repo () { 24 | git clone "$PLUGIN_REPO" "$xtra_fold" 25 | } 26 | 27 | xtra_pip_installer () { 28 | pip3 install -r "$req_file" 29 | } 30 | 31 | fetch_xtra_plugins () { 32 | make_xtra_dir 33 | git_clone_plugin_repo 34 | xtra_pip_installer 35 | } 36 | 37 | fetch_xtra_plugins 38 | -------------------------------------------------------------------------------- /database/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | import logging 10 | 11 | from main_startup import mongo_client 12 | from main_startup.config_var import Config 13 | 14 | db_x = mongo_client["Friday"] 15 | -------------------------------------------------------------------------------- /database/afk.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | from database import db_x 10 | 11 | afk = db_x["I_AFK"] 12 | 13 | 14 | async def go_afk(time, reason=""): 15 | midhun = await afk.find_one({"_id": "AFK"}) 16 | if midhun: 17 | await afk.update_one({"_id": "AFK"}, {"$set": {"time": time, "reason": reason}}) 18 | else: 19 | await afk.insert_one({"_id": "AFK", "time": time, "reason": reason}) 20 | 21 | 22 | async def no_afk(): 23 | midhun = await afk.find_one({"_id": "AFK"}) 24 | if midhun: 25 | await afk.delete_one({"_id": "AFK"}) 26 | 27 | 28 | async def check_afk(): 29 | midhun = await afk.find_one({"_id": "AFK"}) 30 | if midhun: 31 | return midhun 32 | else: 33 | return None -------------------------------------------------------------------------------- /database/autopostingdb.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | from database import db_x 10 | 11 | autoposter = db_x["AutoPoster"] 12 | 13 | 14 | async def add_new_autopost(to_channel, target_channel): 15 | await autoposter.insert_one( 16 | {"target_channel": int(target_channel), "to_channel": int(to_channel)} 17 | ) 18 | 19 | 20 | async def check_if_autopost_in_db(to_channel, target_channel): 21 | st = await autoposter.find_one( 22 | {"target_channel": int(target_channel), "to_channel": int(to_channel)} 23 | ) 24 | return bool(st) 25 | 26 | 27 | async def del_autopost(to_channel, target_channel): 28 | await autoposter.delete_one( 29 | {"target_channel": int(target_channel), "to_channel": int(to_channel)} 30 | ) 31 | 32 | 33 | async def get_autopost(target_channel): 34 | return [ 35 | s 36 | async for s in autoposter.find({"target_channel": int(target_channel)}) 37 | ] 38 | -------------------------------------------------------------------------------- /database/blacklistdb.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | from database import db_x 10 | 11 | blacklist = db_x["BLACKLIST"] 12 | 13 | 14 | async def add_to_blacklist(trigger, chat_id): 15 | await blacklist.insert_one({"trigger": trigger, "chat_id": chat_id}) 16 | 17 | 18 | async def del_blacklist(trigger, chat_id): 19 | await blacklist.delete_one({"trigger": trigger, "chat_id": chat_id}) 20 | 21 | 22 | async def get_chat_blacklist(chat_id): 23 | r = [u async for u in blacklist.find({"chat_id": chat_id})] 24 | if r: 25 | return r 26 | else: 27 | return False 28 | 29 | 30 | async def num_blacklist(): 31 | lol = [l async for l in blacklist.find({})] 32 | if lol: 33 | return len(lol) 34 | else: 35 | False 36 | 37 | 38 | async def num_blacklist_triggers_chat(chat_id): 39 | r = [m async for m in blacklist.find({"chat_id": chat_id})] 40 | if r: 41 | return len(r) 42 | else: 43 | return False 44 | 45 | 46 | async def is_blacklist_in_db(chat_id, trigger): 47 | m = await blacklist.find_one({"chat_id": chat_id, "trigger": trigger}) 48 | return bool(m) 49 | 50 | 51 | async def blacklists_del(chat_id): 52 | await blacklist.delete_many({"chat_id": chat_id}) 53 | -------------------------------------------------------------------------------- /database/bot_settings_db.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | from database import db_x 10 | 11 | bsdb = db_x["bot_sdb"] 12 | 13 | default_text = """Hello, {user_firstname}! 14 | This is A UserBot Of {boss_firstname}. 15 | My Master is Busy As For Now, You Can Wait For Sometime 16 | If He Needs To Talk To You, He Will Approve You! 17 | 18 | You Have {warns} Of Warns. 19 | """ 20 | 21 | default_thumb = "https://icon-icons.com/downloadimage.php?id=106660&root=1527/PNG/512/&file=shield_106660.png" 22 | 23 | 24 | async def add_pm_text(text=default_text): 25 | ujwal = await bsdb.find_one({"_id": "PM_START_MSG"}) 26 | if ujwal: 27 | await bsdb.update_one({"_id": "PM_START_MSG"}, {"$set": {"pm_msg": text}}) 28 | else: 29 | await bsdb.insert_one({"_id": "PM_START_MSG", "pm_msg": text}) 30 | 31 | 32 | async def add_pm_thumb(thumb=default_thumb): 33 | ujwal = await bsdb.find_one({"_id": "PM_START_THUMB"}) 34 | if ujwal: 35 | await bsdb.update_one({"_id": "PM_START_THUMB"}, {"$set": {"pm_img": thumb}}) 36 | else: 37 | await bsdb.insert_one({"_id": "PM_START_THUMB", "pm_img": thumb}) 38 | 39 | 40 | async def get_thumb(): 41 | ujwal = await bsdb.find_one({"_id": "PM_START_THUMB"}) 42 | if ujwal: 43 | return ujwal["pm_img"] 44 | else: 45 | return None 46 | 47 | 48 | async def get_pm_text(): 49 | ujwal = await bsdb.find_one({"_id": "PM_START_MSG"}) 50 | if ujwal: 51 | return ujwal["pm_msg"] 52 | else: 53 | return default_text 54 | 55 | 56 | async def set_pm_spam_limit(psl=3): 57 | stark = await bsdb.find_one({"_id": "LIMIT_PM"}) 58 | if stark: 59 | await bsdb.update_one({"_id": "LIMIT_PM"}, {"$set": {"psl": int(psl)}}) 60 | else: 61 | await bsdb.insert_one({"_id": "LIMIT_PM", "psl": int(psl)}) 62 | 63 | 64 | async def get_pm_spam_limit(): 65 | meisnub = await bsdb.find_one({"_id": "LIMIT_PM"}) 66 | if meisnub: 67 | return int(meisnub["psl"]) 68 | else: 69 | return 3 70 | -------------------------------------------------------------------------------- /database/bot_users.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | from database import db_x 10 | 11 | bot = db_x["BOT_USERS"] 12 | 13 | 14 | async def add_user(user_id): 15 | await bot.insert_one({"user_id": user_id}) 16 | 17 | 18 | async def check_user(user_id): 19 | Lol = await bot.find_one({"user_id": user_id}) 20 | return bool(Lol) 21 | 22 | 23 | async def get_all_users(): 24 | return [s async for s in bot.find()] 25 | -------------------------------------------------------------------------------- /database/broadcast_db.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | from database import db_x 10 | 11 | broadcast_db = db_x["BROADCAST_DB"] 12 | 13 | 14 | async def add_broadcast_chat(chat_id): 15 | await broadcast_db.insert_one({"chat_id": chat_id}) 16 | 17 | 18 | async def rmbroadcast_chat(chat_id): 19 | await broadcast_db.delete_one({"chat_id": chat_id}) 20 | 21 | 22 | async def get_all_broadcast_chats(): 23 | return [la async for la in broadcast_db.find({})] 24 | 25 | 26 | async def is_broadcast_chat_in_db(chat_id): 27 | k = await broadcast_db.find_one({"chat_id": chat_id}) 28 | return bool(k) 29 | -------------------------------------------------------------------------------- /database/chatbot_db.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | from database import db_x 10 | 11 | chatbot_user_db = db_x["chatbotuserdb"] 12 | cbb = db_x["blacklisted_users"] 13 | 14 | 15 | async def add_chatbotuser(user_id): 16 | await chatbot_user_db.insert_one({"user_id": user_id}) 17 | 18 | 19 | async def rmchatbotuser(user_id): 20 | await chatbot_user_db.delete_one({"user_id": user_id}) 21 | 22 | 23 | async def get_all_chatbotusers(): 24 | return [ko async for ko in chatbot_user_db.find()] 25 | 26 | 27 | async def is_chatbotuser_in_db(user_id): 28 | k = await chatbot_user_db.find_one({"user_id": user_id}) 29 | return bool(k) 30 | 31 | 32 | async def add_blacklisted_user(user_id): 33 | await cbb.insert_one({"user_id": user_id}) 34 | 35 | 36 | async def rm_blacklisted_user(user_id): 37 | await cbb.delete_one({"user_id": user_id}) 38 | 39 | 40 | async def is_user_blacklisted(user_id): 41 | b = await cbb.find_one({"user_id": user_id}) 42 | return bool(b) 43 | -------------------------------------------------------------------------------- /database/chatbot_msg_db.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | from database import db_x 10 | 11 | msg_db = db_x["CHATBOT_MSG_DB"] 12 | 13 | 14 | async def add_msg_in_db(msg_id, sender_id, um_id): 15 | await msg_db.insert_one({"msg_id": msg_id, "sender_id": sender_id, "um_id": um_id}) 16 | 17 | 18 | async def get_user_id_frm_msg_id(msg_id): 19 | return await msg_db.find_one({"msg_id": msg_id}) 20 | -------------------------------------------------------------------------------- /database/filterdb.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | from database import db_x 10 | 11 | filter = db_x["FILTER"] 12 | 13 | 14 | async def add_filters(keyword, chat_id, message_id) -> None: 15 | stark = await filter.find_one({"keyword": keyword}) 16 | if stark: 17 | await filter.update_one( 18 | {"keyword": keyword}, 19 | {"$set": {"chat_id": chat_id, "msg_id": message_id}}, 20 | ) 21 | else: 22 | await filter.insert_one( 23 | {"keyword": keyword, "chat_id": chat_id, "msg_id": message_id} 24 | ) 25 | 26 | 27 | async def del_filters(keyword, chat_id): 28 | await filter.delete_one({"keyword": keyword, "chat_id": chat_id}) 29 | 30 | 31 | async def filters_info(keyword, chat_id): 32 | r = await filter.find_one({"keyword": keyword, "chat_id": chat_id}) 33 | if r: 34 | return r 35 | else: 36 | return False 37 | 38 | 39 | async def filters_del(chat_id): 40 | await filter.delete_many({"chat_id": chat_id}) 41 | 42 | 43 | async def all_filters(chat_id): 44 | r = [jo async for jo in filter.find({"chat_id": chat_id})] 45 | if r: 46 | return r 47 | else: 48 | return False 49 | -------------------------------------------------------------------------------- /database/gbandb.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | from database import db_x 10 | 11 | gbun = db_x["GBAN"] 12 | 13 | 14 | async def gban_user(user, reason="#GBanned"): 15 | await gbun.insert_one({"user": user, "reason": reason}) 16 | 17 | 18 | async def ungban_user(user): 19 | await gbun.delete_one({"user": user}) 20 | 21 | 22 | async def gban_list(): 23 | return [lo async for lo in gbun.find({})] 24 | 25 | 26 | async def gban_info(user): 27 | kk = await gbun.find_one({"user": user}) 28 | if not kk: 29 | return False 30 | else: 31 | return kk["reason"] 32 | -------------------------------------------------------------------------------- /database/gmutedb.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | from database import db_x 10 | 11 | gmuteh = db_x["GMUTE"] 12 | 13 | 14 | async def is_gmuted(sender_id): 15 | kk = await gmuteh.find_one({"sender_id": sender_id}) 16 | return bool(kk) 17 | 18 | 19 | async def gmute(sender_id, reason="#GMuted"): 20 | await gmuteh.insert_one({"sender_id": sender_id, "reason": reason}) 21 | 22 | 23 | async def ungmute(sender_id): 24 | await gmuteh.delete_one({"sender_id": sender_id}) 25 | -------------------------------------------------------------------------------- /database/localdb.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | from database import db_x 10 | 11 | ulang = db_x["UB_LANG"] 12 | 13 | 14 | async def set_lang(lang): 15 | midhun = await ulang.find_one({"_id": "UB_LANG"}) 16 | if midhun: 17 | if midhun['lang'] != lang: 18 | await ulang.update_one({"_id": "UB_LANG"}, {"$set": {"lang": lang}}) 19 | else: 20 | await ulang.insert_one({"_id": "UB_LANG", "lang": lang}) 21 | 22 | 23 | async def check_lang(): 24 | midhun = await ulang.find_one({"_id": "UB_LANG"}) 25 | if midhun: 26 | return midhun['lang'] 27 | else: 28 | return 'en' 29 | -------------------------------------------------------------------------------- /database/notesdb.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | from database import db_x 10 | 11 | notes = db_x["NOTES"] 12 | 13 | 14 | async def add_note(keyword, chat_id, message_id): 15 | stark = await notes.find_one({"keyword": keyword}) 16 | if stark: 17 | await notes.update_one( 18 | {"keyword": keyword}, 19 | {"$set": {"chat_id": chat_id, "msg_id": message_id}}, 20 | ) 21 | else: 22 | await notes.insert_one( 23 | {"keyword": keyword, "chat_id": chat_id, "msg_id": message_id} 24 | ) 25 | 26 | 27 | async def del_note(keyword, chat_id): 28 | await notes.delete_one({"keyword": keyword, "chat_id": chat_id}) 29 | 30 | 31 | async def del_notes(chat_id): 32 | await notes.delete_many({"chat_id": chat_id}) 33 | 34 | 35 | async def note_info(keyword, chat_id): 36 | r = await notes.find_one({"keyword": keyword, "chat_id": chat_id}) 37 | if r: 38 | return r 39 | else: 40 | return False 41 | 42 | 43 | async def all_note(chat_id): 44 | r = [u async for u in notes.find({"chat_id": chat_id})] 45 | if r: 46 | return r 47 | else: 48 | return False 49 | -------------------------------------------------------------------------------- /database/nsfw_watch_db.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | from database import db_x 10 | 11 | nsfw = db_x["NSFW_WATCH"] 12 | 13 | 14 | async def add_chat(chat_id): 15 | await nsfw.insert_one({"chat_id": chat_id}) 16 | 17 | 18 | async def rm_chat(chat_id): 19 | await nsfw.delete_one({"chat_id": chat_id}) 20 | 21 | 22 | async def get_all_nsfw_chats(): 23 | return [kek async for kek in nsfw.find({})] 24 | 25 | 26 | async def is_chat_in_db(chat_id): 27 | k = await nsfw.find_one({"chat_id": chat_id}) 28 | return bool(k) 29 | -------------------------------------------------------------------------------- /database/pmdb.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | from database import db_x 10 | 11 | db_y = db_x["PMPERMIT"] 12 | 13 | 14 | async def approve_user(user_id): 15 | cd = await db_y.find_one({"_id": "PmPermit"}) 16 | if cd: 17 | await db_y.update_one({"_id": "PmPermit"}, {"$push": {"user_id": user_id}}) 18 | else: 19 | user_idc = [user_id] 20 | await db_y.insert_one({"_id": "PmPermit", "user_id": user_idc}) 21 | 22 | 23 | async def disapprove_user(user_id): 24 | await db_y.update_one({"_id": "PmPermit"}, {"$pull": {"user_id": user_id}}) 25 | 26 | 27 | async def is_user_approved(user_id): 28 | sm = await db_y.find_one({"_id": "PmPermit"}) 29 | if sm: 30 | kek = list(sm.get("user_id")) 31 | return user_id in kek 32 | else: 33 | return False 34 | 35 | 36 | async def user_list(): 37 | sm = await db_y.find_one({"_id": "PmPermit"}) 38 | if sm: 39 | return list(sm.get("user_id")) 40 | else: 41 | return False 42 | -------------------------------------------------------------------------------- /database/sudodb.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | from database import db_x 10 | 11 | db_y = db_x["SUDO_USERS"] 12 | 13 | 14 | async def add_sudo(user_id): 15 | cd = await db_y.find_one({"_id": "SUDO_ID"}) 16 | if cd: 17 | await db_y.update_one({"_id": "SUDO_ID"}, {"$push": {"user_id": int(user_id)}}) 18 | else: 19 | user_idc = [int(user_id)] 20 | await db_y.insert_one({"_id": "SUDO_ID", "user_id": user_idc}) 21 | 22 | 23 | async def rm_sudo(user_id): 24 | await db_y.update_one({"_id": "SUDO_ID"}, {"$pull": {"user_id": int(user_id)}}) 25 | 26 | 27 | async def is_user_sudo(user_id): 28 | sm = await db_y.find_one({"_id": "SUDO_ID"}) 29 | if sm: 30 | kek = list(sm.get("user_id")) 31 | return user_id in kek 32 | else: 33 | return False 34 | 35 | 36 | async def sudo_list(): 37 | sm = await db_y.find_one({"_id": "SUDO_ID"}) 38 | if sm: 39 | return [int(i) for i in sm.get("user_id")] 40 | else: 41 | return [] 42 | -------------------------------------------------------------------------------- /database/welcomedb.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | from database import db_x 10 | 11 | welcome = db_x["WELCOME"] 12 | 13 | 14 | async def add_welcome(chat_id, message_id): 15 | stark = await welcome.find_one({"chat_id": chat_id}) 16 | if stark: 17 | await welcome.update_one({"chat_id": chat_id}, {"$set": {"msg_id": message_id}}) 18 | else: 19 | await welcome.insert_one({"chat_id": chat_id, "msg_id": message_id}) 20 | 21 | 22 | async def del_welcome(chat_id): 23 | await welcome.delete_one({"chat_id": chat_id}) 24 | 25 | 26 | async def welcome_info(chat_id): 27 | r = await welcome.find_one({"chat_id": chat_id}) 28 | if r: 29 | return r 30 | else: 31 | return False 32 | -------------------------------------------------------------------------------- /heroku.yml: -------------------------------------------------------------------------------- 1 | build: 2 | docker: 3 | worker: Dockerfile 4 | -------------------------------------------------------------------------------- /logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevsExpo/FridayUB/ad8c3c60ff1823272d93e0aab849051c338c1b62/logo.jpg -------------------------------------------------------------------------------- /main_startup/Cache/README.md: -------------------------------------------------------------------------------- 1 | # Cache 2 | * Path : `main_startup/Cache` 3 | * Whats In Here? : `None, But All chache Files Will Be Stored Here!` 4 | -------------------------------------------------------------------------------- /main_startup/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | import logging 10 | import os 11 | import time 12 | import motor.motor_asyncio 13 | from pyrogram import Client 14 | 15 | from .config_var import Config 16 | 17 | # Note StartUp Time - To Capture Uptime. 18 | start_time = time.time() 19 | friday_version = "V9.0" 20 | 21 | # Enable Logging For Pyrogram 22 | logging.basicConfig( 23 | level=logging.INFO, 24 | format="%(asctime)s - [FridayUB] - %(levelname)s - %(message)s", 25 | ) 26 | logging.getLogger("pyrogram").setLevel(logging.ERROR) 27 | logging.getLogger("apscheduler").setLevel(logging.ERROR) 28 | 29 | 30 | mongo_client = motor.motor_asyncio.AsyncIOMotorClient(Config.MONGO_DB) 31 | 32 | CMD_LIST = {} 33 | XTRA_CMD_LIST = {} 34 | sudo_id = Config.AFS 35 | 36 | if not Config.STRINGSESSION: 37 | logging.error("No String Session Found! Friday is Exiting!") 38 | quit(1) 39 | 40 | if not Config.API_ID: 41 | logging.error("No Api-ID Found! Friday is Exiting!") 42 | quit(1) 43 | 44 | if not Config.API_HASH: 45 | logging.error("No ApiHash Found! Friday is Exiting!") 46 | quit(1) 47 | 48 | if not Config.LOG_GRP: 49 | logging.error("No Log Group ID Found! Friday is Exiting!") 50 | quit(1) 51 | 52 | 53 | # Clients - Upto 4 Clients is Supported! 54 | if Config.STRINGSESSION: 55 | Friday = Client( 56 | Config.STRINGSESSION, 57 | api_id=Config.API_ID, 58 | api_hash=Config.API_HASH, 59 | sleep_threshold=180, 60 | ) 61 | if Config.STRINGSESSION_2: 62 | Friday2 = Client( 63 | Config.STRINGSESSION_2, 64 | api_id=Config.API_ID, 65 | api_hash=Config.API_HASH, 66 | sleep_threshold=180, 67 | ) 68 | else: 69 | Friday2 = None 70 | if Config.STRINGSESSION_3: 71 | Friday3 = Client( 72 | Config.STRINGSESSION_3, 73 | api_id=Config.API_ID, 74 | api_hash=Config.API_HASH, 75 | sleep_threshold=180, 76 | ) 77 | else: 78 | Friday3 = None 79 | if Config.STRINGSESSION_4: 80 | Friday4 = Client( 81 | Config.STRINGSESSION_4, 82 | api_id=Config.API_ID, 83 | api_hash=Config.API_HASH, 84 | sleep_threshold=180, 85 | ) 86 | else: 87 | Friday4 = None 88 | 89 | if Config.BOT_TOKEN: 90 | bot = Client( 91 | "MyAssistant", 92 | api_id=Config.API_ID, 93 | api_hash=Config.API_HASH, 94 | bot_token=Config.BOT_TOKEN, 95 | sleep_threshold=180, 96 | ) 97 | else: 98 | bot = None 99 | -------------------------------------------------------------------------------- /main_startup/__main__.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | import logging 10 | import os 11 | import platform 12 | 13 | import pyrogram 14 | from pyrogram import __version__ 15 | from bot_utils_files.Localization.engine import Engine 16 | from database.localdb import check_lang 17 | from main_startup import ( 18 | Friday, 19 | Friday2, 20 | Friday3, 21 | Friday4, 22 | bot, 23 | friday_version, 24 | mongo_client, 25 | ) 26 | from main_startup.core.startup_helpers import ( 27 | load_plugin, 28 | load_xtra_mod, 29 | plugin_collecter, 30 | run_cmd, 31 | update_it 32 | ) 33 | 34 | from .config_var import Config 35 | 36 | 37 | async def mongo_check(): 38 | """Check Mongo Client""" 39 | try: 40 | await mongo_client.server_info() 41 | except BaseException as e: 42 | logging.error("Something Isn't Right With Mongo! Please Check Your URL") 43 | logging.error(str(e)) 44 | quit(1) 45 | 46 | 47 | async def load_unofficial_modules(): 48 | """Load Extra Plugins.""" 49 | logging.info("Loading X-Tra Plugins!") 50 | await run_cmd(f'bash bot_utils_files/other_helpers/xtra_plugins.sh {Config.XTRA_PLUGINS_REPO}') 51 | xtra_mods = plugin_collecter("./xtraplugins/") 52 | for mods in xtra_mods: 53 | try: 54 | load_xtra_mod(mods) 55 | except Exception as e: 56 | logging.error( 57 | "[USER][XTRA-PLUGINS] - Failed To Load : " + f"{mods} - {str(e)}" 58 | ) 59 | 60 | 61 | async def fetch_plugins_from_channel(): 62 | """Fetch Plugins From Channel""" 63 | try: 64 | async for message in Friday.search_messages( 65 | Config.PLUGIN_CHANNEL, filter="document", query=".py" 66 | ): 67 | hmm = message.document.file_name 68 | if not os.path.exists(os.path.join("./plugins/", hmm)): 69 | await Friday.download_media(message, file_name="./plugins/") 70 | except BaseException as e: 71 | logging.error(f"Failed! To Install Plugins From Plugin Channel Due To {e}!") 72 | return 73 | logging.info("All Plugins From Plugin Channel Loaded!") 74 | 75 | 76 | async def run_bot(): 77 | try: 78 | await update_it() 79 | except: 80 | pass 81 | """Run The Bot""" 82 | await mongo_check() 83 | if bot: 84 | await bot.start() 85 | bot.me = await bot.get_me() 86 | assistant_mods = plugin_collecter("./assistant/") 87 | for mods in assistant_mods: 88 | try: 89 | load_plugin(mods, assistant=True) 90 | except Exception as e: 91 | logging.error("[ASSISTANT] - Failed To Load : " + f"{mods} - {str(e)}") 92 | await Friday.start() 93 | Friday.me = await Friday.get_me() 94 | Friday.selected_lang = await check_lang() 95 | LangEngine = Engine() 96 | LangEngine.load_language() 97 | Friday.has_a_bot = bool(bot) 98 | if Friday2: 99 | await Friday2.start() 100 | Friday2.me = await Friday2.get_me() 101 | Friday2.has_a_bot = True if bot else False 102 | if Friday3: 103 | await Friday3.start() 104 | Friday3.me = await Friday3.get_me() 105 | Friday3.has_a_bot = bool(bot) 106 | if Friday4: 107 | await Friday4.start() 108 | Friday4.me = await Friday4.get_me() 109 | Friday4.has_a_bot = bool(bot) 110 | if Config.PLUGIN_CHANNEL: 111 | await fetch_plugins_from_channel() 112 | needed_mods = plugin_collecter("./plugins/") 113 | for nm in needed_mods: 114 | try: 115 | load_plugin(nm) 116 | except Exception as e: 117 | logging.error("[USER] - Failed To Load : " + f"{nm} - {str(e)}") 118 | if Config.LOAD_UNOFFICIAL_PLUGINS: 119 | await load_unofficial_modules() 120 | full_info = f"""Friday Based On Pyrogram V{__version__} 121 | Python Version : {platform.python_version()} 122 | Friday Version : {friday_version} 123 | You Can Visit @FridaySupportOfficial For Updates And @FridayChat For Any Query / Help! 124 | """ 125 | logging.info(full_info) 126 | await pyrogram.idle() 127 | 128 | 129 | if __name__ == "__main__": 130 | Friday.loop.run_until_complete(run_bot()) 131 | -------------------------------------------------------------------------------- /main_startup/config_var.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | import os 10 | 11 | import heroku3 12 | from dotenv import load_dotenv 13 | from distutils.util import strtobool 14 | 15 | if os.path.exists("local.env"): 16 | load_dotenv("local.env") 17 | 18 | 19 | def fetch_heroku_git_url(api_key, app_name): 20 | if not api_key: 21 | return None 22 | if not app_name: 23 | return None 24 | heroku = heroku3.from_key(api_key) 25 | try: 26 | heroku_applications = heroku.apps() 27 | except: 28 | return None 29 | heroku_app = None 30 | for app in heroku_applications: 31 | if app.name == app_name: 32 | heroku_app = app 33 | break 34 | if not heroku_app: 35 | return None 36 | return heroku_app.git_url.replace("https://", "https://api:" + api_key + "@") 37 | 38 | 39 | class Config((object)): 40 | API_ID = int(os.environ.get("API_ID", 1)) 41 | API_HASH = os.environ.get("API_HASH", None) 42 | BOT_TOKEN = os.environ.get("BOT_TOKEN", None) 43 | REM_BG_API_KEY = os.environ.get("REM_BG_API_KEY", None) 44 | STRINGSESSION = os.environ.get("STRINGSESSION", None) 45 | ASSISTANT_START_PIC = os.environ.get( 46 | "ASSISTANT_START_PIC", "https://telegra.ph//file/92c1a600394c723db90fc.jpg" 47 | ) 48 | STRINGSESSION_2 = os.environ.get("STRINGSESSION_2", None) 49 | STRINGSESSION_3 = os.environ.get("STRINGSESSION_3", None) 50 | STRINGSESSION_4 = os.environ.get("STRINGSESSION_4", None) 51 | LOAD_UNOFFICIAL_PLUGINS = bool(strtobool(str(os.environ.get("LOAD_UNOFFICIAL_PLUGINS", False)))) 52 | PLUGIN_CHANNEL = os.environ.get("PLUGIN_CHANNEL", False) 53 | TZ = os.environ.get("TZ", "Asia/Kolkata") 54 | MONGO_DB = os.environ.get("MONGO_DB", None) 55 | LOG_GRP = int(os.environ.get("LOG_GRP", False)) 56 | COMMAND_HANDLER = os.environ.get("COMMAND_HANDLER", ".") 57 | SUDO_USERS = {int(x) for x in os.environ.get("SUDO_USERS", "").split()} 58 | AFS = list(SUDO_USERS) 59 | CUSTOM_HELP_EMOJI = os.environ.get("CUSTOM_HELP_EMOJI", "✘") 60 | HEROKU_APP_NAME = os.environ.get("HEROKU_APP_NAME", None) 61 | LYDIA_API_KEY = os.environ.get("LYDIA_API_KEY", None) 62 | HEROKU_API_KEY = os.environ.get("HEROKU_API_KEY", None) 63 | FBAN_GROUP = int(os.environ.get("FBAN_GROUP", False)) 64 | UPSTREAM_REPO = os.environ.get( 65 | "UPSTREAM_REPO", "https://github.com/DevsExpo/FridayUB" 66 | ) 67 | ALIVE_IMG = os.environ.get( 68 | "ALIVE_IMG", "https://telegra.ph//file/b94f56dd76b158149992e.jpg" 69 | ) 70 | U_BRANCH = "master" 71 | HEROKU_URL = fetch_heroku_git_url(HEROKU_API_KEY, HEROKU_APP_NAME) 72 | V_T_KEY = os.environ.get("VIRUSTOTAL_API_KEY", None) 73 | TAG_LOGGER = os.environ.get("TAG_LOGGER", False) 74 | PM_PSW = bool(strtobool(str(os.environ.get("PM_PSW", True)))) 75 | MAIN_NO_LOAD = [x for x in os.environ.get("MAIN_NO_LOAD", "").split(',')] 76 | XTRA_NO_LOAD = [x for x in os.environ.get("XTRA_NO_LOAD", "").split(',')] 77 | DISABLED_SUDO_CMD_S = os.environ.get("DISABLED_SUDO_CMD_S", None) 78 | ENABLE_WAIFU_FOR_ALL_CHATS = bool(strtobool(str(os.environ.get("ENABLE_WAIFU_FOR_ALL_CHATS", False)))) 79 | CHROME_DRIVER_PATH = os.environ.get("CHROME_DRIVER_PATH", "/usr/bin/chromedriver") 80 | CHROME_BIN_PATH = os.environ.get("CHROME_BIN_PATH", "/usr/bin/google-chrome-stable") 81 | USERBOT_LANG = os.environ.get("USERBOT_LANG", "en") 82 | XTRA_PLUGINS_REPO = os.environ.get("XTRA_PLUGINS_REPO", "https://github.com/DevsExpo/Xtra-Plugins") 83 | -------------------------------------------------------------------------------- /main_startup/core/decorators.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | import inspect 10 | import logging 11 | import os 12 | from datetime import datetime 13 | from traceback import format_exc 14 | import asyncio 15 | import pytz 16 | from pyrogram import ContinuePropagation, StopPropagation, filters 17 | from pyrogram.errors.exceptions.bad_request_400 import ( 18 | MessageIdInvalid, 19 | MessageNotModified, 20 | MessageEmpty, 21 | UserNotParticipant 22 | ) 23 | from pyrogram.handlers import MessageHandler 24 | 25 | from main_startup import ( 26 | CMD_LIST, 27 | XTRA_CMD_LIST, 28 | Config, 29 | Friday, 30 | Friday2, 31 | Friday3, 32 | Friday4, 33 | bot 34 | ) 35 | from main_startup.config_var import Config 36 | from main_startup.helper_func.basic_helpers import is_admin_or_owner 37 | from main_startup.core.helpers import edit_or_reply 38 | from database.sudodb import sudo_list 39 | 40 | from bot_utils_files.Localization.engine import Engine as engin_e 41 | 42 | Engine = engin_e() 43 | 44 | 45 | sudo_list_ = Friday.loop.create_task(sudo_list()) 46 | 47 | async def _sudo(f, client, message): 48 | if not message: 49 | return bool(False) 50 | if not message.from_user: 51 | return bool(False) 52 | if not message.from_user.id: 53 | return bool(False) 54 | if message.from_user.id in sudo_list_.result(): 55 | return bool(True) 56 | return bool(False) 57 | 58 | _sudo = filters.create(func=_sudo, name="_sudo") 59 | 60 | def friday_on_cmd( 61 | cmd: list, 62 | group: int = 0, 63 | pm_only: bool = False, 64 | group_only: bool = False, 65 | chnnl_only: bool = False, 66 | only_if_admin: bool = False, 67 | ignore_errors: bool = False, 68 | propagate_to_next_handler: bool = True, 69 | disable_sudo: bool = False, 70 | file_name: str = None, 71 | is_official: bool = True, 72 | cmd_help: dict = {"help": "No One One Gonna Help You", "example": "{ch}what"}, 73 | ): 74 | """- Main Decorator To Register Commands. -""" 75 | if disable_sudo: 76 | filterm = ( 77 | filters.me 78 | & filters.command(cmd, Config.COMMAND_HANDLER) 79 | & ~filters.via_bot 80 | & ~filters.forwarded 81 | ) 82 | else: 83 | filterm = ( 84 | (filters.me | _sudo) 85 | & filters.command(cmd, Config.COMMAND_HANDLER) 86 | & ~filters.via_bot 87 | & ~filters.forwarded) 88 | cmd = list(cmd) 89 | add_help_menu( 90 | cmd=cmd[0], 91 | stack=inspect.stack(), 92 | is_official=is_official, 93 | cmd_help=cmd_help["help"], 94 | example=cmd_help["example"], 95 | ) 96 | def decorator(func): 97 | async def wrapper(client, message): 98 | message.Engine = Engine 99 | message.client = client 100 | chat_type = message.chat.type 101 | if only_if_admin and not await is_admin_or_owner( 102 | message, (client.me).id 103 | ): 104 | await edit_or_reply( 105 | message, "`This Command Only Works, If You Are Admin Of The Chat!`" 106 | ) 107 | return 108 | if group_only and chat_type != "supergroup": 109 | await edit_or_reply(message, "`Are you sure this is a group?`") 110 | return 111 | if chnnl_only and chat_type != "channel": 112 | await edit_or_reply(message, "This Command Only Works In Channel!") 113 | return 114 | if pm_only and chat_type != "private": 115 | await edit_or_reply(message, "`This Cmd Only Works On PM!`") 116 | return 117 | if ignore_errors: 118 | await func(client, message) 119 | else: 120 | try: 121 | await func(client, message) 122 | except StopPropagation: 123 | raise StopPropagation 124 | except KeyboardInterrupt: 125 | pass 126 | except MessageNotModified: 127 | pass 128 | except MessageIdInvalid: 129 | logging.warning( 130 | "Please Don't Delete Commands While it's Processing.." 131 | ) 132 | except UserNotParticipant: 133 | pass 134 | except ContinuePropagation: 135 | raise ContinuePropagation 136 | except BaseException: 137 | logging.error( 138 | f"Exception - {func.__module__} - {func.__name__}" 139 | ) 140 | TZ = pytz.timezone(Config.TZ) 141 | datetime_tz = datetime.now(TZ) 142 | text = "**!ERROR - REPORT!**\n\n" 143 | text += f"\n**Trace Back : ** `{str(format_exc())}`" 144 | text += f"\n**Plugin-Name :** `{func.__module__}`" 145 | text += f"\n**Function Name :** `{func.__name__}` \n" 146 | text += datetime_tz.strftime( 147 | "**Date :** `%Y-%m-%d` \n**Time :** `%H:%M:%S`" 148 | ) 149 | text += "\n\n__You can Forward This to @FridayChat, If You Think This is Serious A Error!__" 150 | try: 151 | await client.send_message(Config.LOG_GRP, text) 152 | except BaseException: 153 | logging.error(text) 154 | add_handler(filterm, wrapper, cmd) 155 | return wrapper 156 | return decorator 157 | 158 | 159 | def listen(filter_s): 160 | """Simple Decorator To Handel Custom Filters""" 161 | def decorator(func): 162 | async def wrapper(client, message): 163 | message.Engine = Engine 164 | try: 165 | await func(client, message) 166 | except StopPropagation: 167 | raise StopPropagation 168 | except ContinuePropagation: 169 | raise ContinuePropagation 170 | except UserNotParticipant: 171 | pass 172 | except MessageEmpty: 173 | pass 174 | except BaseException: 175 | logging.error(f"Exception - {func.__module__} - {func.__name__}") 176 | TZ = pytz.timezone(Config.TZ) 177 | datetime_tz = datetime.now(TZ) 178 | text = "**!ERROR WHILE HANDLING UPDATES!**\n\n" 179 | text += f"\n**Trace Back : ** `{str(format_exc())}`" 180 | text += f"\n**Plugin-Name :** `{func.__module__}`" 181 | text += f"\n**Function Name :** `{func.__name__}` \n" 182 | text += datetime_tz.strftime( 183 | "**Date :** `%Y-%m-%d` \n**Time :** `%H:%M:%S`" 184 | ) 185 | text += "\n\n__You can Forward This to @FridayChat, If You Think This is A Error!__" 186 | try: 187 | await client.send_message(Config.LOG_GRP, text) 188 | except BaseException: 189 | logging.error(text) 190 | message.continue_propagation() 191 | Friday.add_handler(MessageHandler(wrapper, filters=filter_s), group=0) 192 | if Friday2: 193 | Friday2.add_handler(MessageHandler(wrapper, filters=filter_s), group=0) 194 | if Friday3: 195 | Friday3.add_handler(MessageHandler(wrapper, filters=filter_s), group=0) 196 | if Friday4: 197 | Friday4.add_handler(MessageHandler(wrapper, filters=filter_s), group=0) 198 | return wrapper 199 | 200 | return decorator 201 | 202 | 203 | def add_help_menu( 204 | cmd, 205 | stack, 206 | is_official=True, 207 | cmd_help="No One Gonna Help You", 208 | example="{ch}what", 209 | file_name=None, 210 | ): 211 | if not file_name: 212 | previous_stack_frame = stack[1] 213 | if "xtraplugins" in previous_stack_frame.filename: 214 | is_official = False 215 | file_name = os.path.basename(previous_stack_frame.filename.replace(".py", "")) 216 | cmd_helpz = example.format(ch=Config.COMMAND_HANDLER) 217 | cmd_helper = f"**Module Name :** `{file_name.replace('_', ' ').title()}` \n\n**Command :** `{Config.COMMAND_HANDLER}{cmd}` \n**Help :** `{cmd_help}` \n**Example :** `{cmd_helpz}`" 218 | if is_official: 219 | if file_name not in CMD_LIST.keys(): 220 | CMD_LIST[file_name] = cmd_helper 221 | else: 222 | CMD_LIST[ 223 | file_name 224 | ] += f"\n\n**Command :** `{Config.COMMAND_HANDLER}{cmd}` \n**Help :** `{cmd_help}` \n**Example :** `{cmd_helpz}`" 225 | elif file_name not in XTRA_CMD_LIST.keys(): 226 | XTRA_CMD_LIST[file_name] = cmd_helper 227 | else: 228 | XTRA_CMD_LIST[ 229 | file_name 230 | ] += f"\n\n**Command :** `{Config.COMMAND_HANDLER}{cmd}` \n**Help :** `{cmd_help}` \n**Example :** `{cmd_helpz}`" 231 | 232 | 233 | def add_handler(filter_s, func_, cmd): 234 | d_c_l = Config.DISABLED_SUDO_CMD_S 235 | if d_c_l: 236 | d_c_l = d_c_l.split(" ") 237 | d_c_l = list(d_c_l) 238 | if "dev" in d_c_l: 239 | d_c_l.extend(['eval', 'bash', 'install']) 240 | if any(item in list(d_c_l) for item in list(cmd)): 241 | filter_s = (filters.me & filters.command(cmd, Config.COMMAND_HANDLER) & ~filters.via_bot & ~filters.forwarded) 242 | Friday.add_handler(MessageHandler(func_, filters=filter_s), group=0) 243 | if Friday2: 244 | Friday2.add_handler(MessageHandler(func_, filters=filter_s), group=0) 245 | if Friday3: 246 | Friday3.add_handler(MessageHandler(func_, filters=filter_s), group=0) 247 | if Friday4: 248 | Friday4.add_handler(MessageHandler(func_, filters=filter_s), group=0) 249 | -------------------------------------------------------------------------------- /main_startup/core/helpers.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | from main_startup.config_var import Config 9 | from main_startup.helper_func.basic_helpers import edit_or_reply, is_admin_or_owner 10 | -------------------------------------------------------------------------------- /main_startup/core/startup_helpers.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | import asyncio 10 | import glob 11 | import importlib 12 | import logging 13 | from main_startup import Config 14 | import ntpath 15 | import shlex 16 | from typing import Tuple 17 | import sys 18 | from datetime import datetime 19 | from os import environ, execle, path, remove 20 | import heroku3 21 | from git import Repo 22 | from git.exc import GitCommandError, InvalidGitRepositoryError, NoSuchPathError 23 | 24 | REPO_ = Config.UPSTREAM_REPO 25 | BRANCH_ = Config.U_BRANCH 26 | 27 | 28 | def load_xtra_mod(plugin_name): 29 | """Load All Extra Plugins Using ImportLib""" 30 | if plugin_name not in Config.XTRA_NO_LOAD: 31 | plugin_path = "xtraplugins." + plugin_name 32 | loader_type = "[USER][XTRA-PLUGINS]" 33 | importlib.import_module(plugin_path) 34 | logging.info(f"{loader_type} - Loaded : " + str(plugin_name)) 35 | 36 | 37 | def load_plugin(plugin_name, assistant=False): 38 | """Load PLugins - Assitant & User Using ImportLib""" 39 | if ( 40 | not plugin_name.endswith("__") 41 | and plugin_name not in Config.MAIN_NO_LOAD 42 | ): 43 | if assistant: 44 | plugin_path = "assistant." + plugin_name 45 | else: 46 | plugin_path = "plugins." + plugin_name 47 | loader_type = "[Assistant]" if assistant else "[User]" 48 | importlib.import_module(plugin_path) 49 | logging.info(f"{loader_type} - Loaded : " + str(plugin_name)) 50 | 51 | 52 | def plugin_collecter(path): 53 | """Collects All Files In A Path And Give Its Name""" 54 | if path.startswith("/"): 55 | path = path[1:] 56 | pathe = path + "*.py" if path.endswith("/") else path + "/*.py" 57 | Poppy = glob.glob(pathe) 58 | final = [] 59 | Pop = Poppy 60 | for x in Pop: 61 | k = ntpath.basename(x) 62 | if k.endswith(".py"): 63 | lily = k.replace(".py", "") 64 | final.append(lily) 65 | return final 66 | 67 | 68 | async def run_cmd(cmd: str) -> Tuple[str, str, int, int]: 69 | """Run Commands""" 70 | args = shlex.split(cmd) 71 | process = await asyncio.create_subprocess_exec( 72 | *args, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE 73 | ) 74 | stdout, stderr = await process.communicate() 75 | return ( 76 | stdout.decode("utf-8", "replace").strip(), 77 | stderr.decode("utf-8", "replace").strip(), 78 | process.returncode, 79 | process.pid, 80 | ) 81 | 82 | 83 | async def update_it(): 84 | """Update Userbot On StartUps.""" 85 | try: 86 | repo = Repo() 87 | except GitCommandError: 88 | logging.debug("Invalid Git Command. Not Updating....") 89 | return 90 | except InvalidGitRepositoryError: 91 | repo = Repo.init() 92 | if "upstream" in repo.remotes: 93 | origin = repo.remote("upstream") 94 | else: 95 | origin = repo.create_remote("upstream", REPO_) 96 | origin.fetch() 97 | repo.create_head(Config.U_BRANCH, origin.refs.master) 98 | repo.heads.master.set_tracking_branch(origin.refs.master) 99 | repo.heads.master.checkout(True) 100 | if repo.active_branch.name != Config.U_BRANCH: 101 | logging.debug("You Active Branch Doesn't Match With The Default Branch. Please Make Sure You Are on Default Branch.") 102 | return 103 | try: 104 | repo.create_remote("upstream", REPO_) 105 | except BaseException: 106 | pass 107 | ups_rem = repo.remote("upstream") 108 | ups_rem.fetch(Config.U_BRANCH) 109 | try: 110 | ups_rem.pull(Config.U_BRANCH) 111 | except GitCommandError: 112 | repo.git.reset("--hard", "FETCH_HEAD") 113 | await run_cmd("pip3 install --no-cache-dir -r requirements.txt") 114 | return -------------------------------------------------------------------------------- /main_startup/helper_func/assistant_helpers.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | from functools import wraps 10 | import aiohttp 11 | import asyncio 12 | import os 13 | import time 14 | import requests 15 | import wget 16 | from youtube_dl import YoutubeDL 17 | import aiofiles 18 | from main_startup.helper_func.basic_helpers import get_all_pros, is_admin_or_owner 19 | 20 | 21 | def _check_admin(func): 22 | @wraps(func) 23 | async def magic_admin(client, message): 24 | is_a_o = await is_admin_or_owner(message, message.from_user.id) 25 | if is_a_o: 26 | await func(client, message) 27 | else: 28 | await message.reply_text("`>> You Should Be Admin / Owner To Do This! >>`") 29 | 30 | return magic_admin 31 | 32 | 33 | def _check_owner_or_sudos(func): 34 | @wraps(func) 35 | async def magic_owner(client, message): 36 | use_ = await get_all_pros() 37 | if message.from_user.id in use_: 38 | await func(client, message) 39 | else: 40 | await message.reply_text("`>> You Should Be Owner / Sudo To Do This! >>`") 41 | 42 | return magic_owner 43 | 44 | async def _dl(url, file_name=None): 45 | if not file_name: 46 | from urllib.parse import urlparse 47 | a = urlparse(url) 48 | file_name = os.path.basename(a.path) 49 | async with aiohttp.ClientSession() as session: 50 | async with session.get(url) as resp: 51 | if resp.status != 200: 52 | return None 53 | f = await aiofiles.open(file_name, mode="wb") 54 | await f.write(await resp.read()) 55 | await f.close() 56 | return file_name 57 | 58 | async def download_yt(url, as_video=False): 59 | if as_video: 60 | opts = { 61 | "format": "best", 62 | "addmetadata": True, 63 | "key": "FFmpegMetadata", 64 | "prefer_ffmpeg": True, 65 | "geo_bypass": True, 66 | "nocheckcertificate": True, 67 | "postprocessors": [{"key": "FFmpegVideoConvertor", "preferedformat": "mp4"}], 68 | "outtmpl": "%(id)s.mp4", 69 | "logtostderr": False, 70 | "quiet": True, 71 | } 72 | else: 73 | opts = { 74 | "format": "bestaudio", 75 | "addmetadata": True, 76 | "key": "FFmpegMetadata", 77 | "writethumbnail": True, 78 | "prefer_ffmpeg": True, 79 | "geo_bypass": True, 80 | "nocheckcertificate": True, 81 | "postprocessors": [ 82 | { 83 | "key": "FFmpegExtractAudio", 84 | "preferredcodec": "mp3", 85 | "preferredquality": "720", 86 | } 87 | ], 88 | "outtmpl": "%(id)s.mp3", 89 | "quiet": True, 90 | "logtostderr": False, 91 | } 92 | try: 93 | with YoutubeDL(opts) as ytdl: 94 | ytdl_data = ytdl.extract_info(url, download=True) 95 | except Exception as e: 96 | return f"**Failed To Download** \n**Error :** `{str(e)}`", None, None, None 97 | yt_id = ytdl_data['id'] 98 | name = ytdl_data['title'] 99 | dur = ytdl_data["duration"] 100 | u_date = ytdl_data["upload_date"] 101 | uploader = ytdl_data["uploader"] 102 | views = ytdl_data["view_count"] 103 | thumb_url = f"https://img.youtube.com/vi/{yt_id}/hqdefault.jpg" 104 | downloaded_thumb = await _dl(thumb_url) 105 | file_name = f"{ytdl_data['id']}.mp4" if as_video else f"{ytdl_data['id']}.mp3" 106 | return file_name, downloaded_thumb, name, dur, u_date, uploader, views 107 | -------------------------------------------------------------------------------- /main_startup/helper_func/logger_s.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | import logging 10 | import os 11 | 12 | from main_startup import Config 13 | from main_startup.helper_func.basic_helpers import edit_or_send_as_file 14 | 15 | 16 | class LogIt: 17 | def __init__(self, message): 18 | self.chat_id = Config.LOG_GRP 19 | self.message = message 20 | 21 | async def log_msg(self, client, text: str = "?"): 22 | if len(text) > 1024: 23 | try: 24 | Hitler = await client.send_document(self.chat_id, make_file(text)) 25 | except BaseException as e: 26 | logging.error(str(e)) 27 | return None 28 | os.remove("logger.log") 29 | return Hitler 30 | else: 31 | try: 32 | return await client.send_message(self.chat_id, text) 33 | except: 34 | logging.error(str(e)) 35 | return None 36 | 37 | async def fwd_msg_to_log_chat(self): 38 | try: 39 | return await self.message.forward(self.chat_id) 40 | except BaseException as e: 41 | logging.error(str(e)) 42 | return None 43 | 44 | 45 | def make_file(text): 46 | open("logger.log", "w").write(text) 47 | return "logger.log" 48 | -------------------------------------------------------------------------------- /main_startup/helper_func/plugin_helpers.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | import json 10 | import logging 11 | import os 12 | import subprocess 13 | import textwrap 14 | from json import JSONDecodeError 15 | import numpy as np 16 | from PIL import Image, ImageDraw 17 | import requests 18 | from PIL import Image, ImageDraw, ImageFont 19 | from pymediainfo import MediaInfo 20 | 21 | from main_startup.core.startup_helpers import run_cmd 22 | 23 | 24 | def generate_meme( 25 | image_path, 26 | top_text, 27 | bottom_text="", 28 | font_path="./bot_utils_files/Fonts/impact.ttf", 29 | font_size=11, 30 | ): 31 | """Make Memes Like A Pro""" 32 | im = Image.open(image_path) 33 | draw = ImageDraw.Draw(im) 34 | image_width, image_height = im.size 35 | font = ImageFont.truetype(font=font_path, size=int(image_height * font_size) // 100) 36 | top_text = top_text.upper() 37 | bottom_text = bottom_text.upper() 38 | char_width, char_height = font.getsize("A") 39 | chars_per_line = image_width // char_width 40 | top_lines = textwrap.wrap(top_text, width=chars_per_line) 41 | bottom_lines = textwrap.wrap(bottom_text, width=chars_per_line) 42 | y = 9 43 | for line in top_lines: 44 | line_width, line_height = font.getsize(line) 45 | x = (image_width - line_width) / 2 46 | draw.text((x - 2, y - 2), line, font=font, fill="black") 47 | draw.text((x + 2, y - 2), line, font=font, fill="black") 48 | draw.text((x + 2, y + 2), line, font=font, fill="black") 49 | draw.text((x - 2, y + 2), line, font=font, fill="black") 50 | draw.text((x, y), line, fill="white", font=font) 51 | y += line_height 52 | 53 | y = image_height - char_height * len(bottom_lines) - 14 54 | for line in bottom_lines: 55 | line_width, line_height = font.getsize(line) 56 | x = (image_width - line_width) / 2 57 | draw.text((x - 2, y - 2), line, font=font, fill="black") 58 | draw.text((x + 2, y - 2), line, font=font, fill="black") 59 | draw.text((x + 2, y + 2), line, font=font, fill="black") 60 | draw.text((x - 2, y + 2), line, font=font, fill="black") 61 | draw.text((x, y), line, fill="white", font=font) 62 | y += line_height 63 | ok = "memeimg.webp" 64 | im.save(ok, "WebP") 65 | 66 | 67 | async def convert_to_image(message, client) -> [None, str]: 68 | """Convert Most Media Formats To Raw Image""" 69 | if not message: 70 | return None 71 | if not message.reply_to_message: 72 | return None 73 | final_path = None 74 | if not ( 75 | message.reply_to_message.video 76 | or message.reply_to_message.photo 77 | or message.reply_to_message.sticker 78 | or message.reply_to_message.media 79 | or message.reply_to_message.animation 80 | or message.reply_to_message.audio 81 | ): 82 | return None 83 | if message.reply_to_message.photo: 84 | final_path = await message.reply_to_message.download() 85 | elif message.reply_to_message.sticker: 86 | if message.reply_to_message.sticker.mime_type == "image/webp": 87 | final_path = "webp_to_png_s_proton.png" 88 | path_s = await message.reply_to_message.download() 89 | im = Image.open(path_s) 90 | im.save(final_path, "PNG") 91 | else: 92 | path_s = await client.download_media(message.reply_to_message) 93 | final_path = "lottie_proton.png" 94 | cmd = ( 95 | f"lottie_convert.py --frame 0 -if lottie -of png {path_s} {final_path}" 96 | ) 97 | await run_cmd(cmd) 98 | elif message.reply_to_message.audio: 99 | thumb = message.reply_to_message.audio.thumbs[0].file_id 100 | final_path = await client.download_media(thumb) 101 | elif message.reply_to_message.video or message.reply_to_message.animation: 102 | final_path = "fetched_thumb.png" 103 | vid_path = await client.download_media(message.reply_to_message) 104 | await run_cmd(f"ffmpeg -i {vid_path} -filter:v scale=500:500 -an {final_path}") 105 | return final_path 106 | 107 | 108 | async def convert_vid_to_vidnote(input_vid: str, final_path: str): 109 | """ Convert Video To Video Note (Round) """ 110 | media_info = MediaInfo.parse(input_vid) 111 | for track in media_info.tracks: 112 | if track.track_type == "Video": 113 | aspect_ratio = track.display_aspect_ratio 114 | height = track.height 115 | width = track.width 116 | if aspect_ratio != 1: 117 | crop_by = min(height, width) 118 | await run_cmd( 119 | f'ffmpeg -i {input_vid} -vf "crop={crop_by}:{crop_by}" {final_path}' 120 | ) 121 | os.remove(input_vid) 122 | else: 123 | os.rename(input_vid, final_path) 124 | 125 | async def convert_image_to_image_note(input_path): 126 | """Crop Image To Circle""" 127 | img = Image.open(input_path).convert("RGB") 128 | npImage = np.array(img) 129 | h, w = img.size 130 | alpha = Image.new('L', img.size,0) 131 | draw = ImageDraw.Draw(alpha) 132 | draw.pieslice([0,0,h,w],0,360,fill=255) 133 | npAlpha = np.array(alpha) 134 | npImage = np.dstack((npImage,npAlpha)) 135 | img_path = 'converted_by_FridayUB.webp' 136 | Image.fromarray(npImage).save(img_path) 137 | return img_path 138 | 139 | 140 | 141 | def extract_w_h(file): 142 | """ Extract Video's Width & Height """ 143 | command_to_run = [ 144 | "ffprobe", 145 | "-v", 146 | "quiet", 147 | "-print_format", 148 | "json", 149 | "-show_format", 150 | "-show_streams", 151 | file, 152 | ] 153 | try: 154 | t_response = subprocess.check_output(command_to_run, stderr=subprocess.STDOUT) 155 | except subprocess.CalledProcessError as exc: 156 | logging.error(str(exc)) 157 | else: 158 | x_reponse = t_response.decode("UTF-8") 159 | response_json = json.loads(x_reponse) 160 | width = int(response_json["streams"][0]["width"]) 161 | height = int(response_json["streams"][0]["height"]) 162 | return width, height 163 | -------------------------------------------------------------------------------- /plugins/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | from main_startup.config_var import Config 10 | from main_startup.core.decorators import friday_on_cmd 11 | from main_startup.core.startup_helpers import run_cmd 12 | from main_startup.helper_func.basic_helpers import ( 13 | edit_or_reply, 14 | get_readable_time, 15 | is_admin_or_owner, 16 | ) 17 | 18 | devs_id = [1263617196, 573738900, 1315076555, 1154752323] 19 | -------------------------------------------------------------------------------- /plugins/afk.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | import asyncio 10 | from datetime import datetime 11 | 12 | from pyrogram import filters 13 | 14 | from database.afk import check_afk, go_afk, no_afk 15 | from main_startup.config_var import Config 16 | from main_startup.core.decorators import friday_on_cmd, listen 17 | from main_startup.helper_func.basic_helpers import edit_or_reply, get_text 18 | from main_startup.helper_func.logger_s import LogIt 19 | afk_sanity_check: dict = {} 20 | 21 | 22 | async def is_afk_(f, client, message): 23 | af_k_c = await check_afk() 24 | if af_k_c: 25 | return bool(True) 26 | else: 27 | return bool(False) 28 | 29 | 30 | is_afk = filters.create(func=is_afk_, name="is_afk_") 31 | 32 | 33 | @friday_on_cmd( 34 | ["afk"], 35 | propagate_to_next_handler=False, 36 | cmd_help={ 37 | "help": "Set AFK!", 38 | "example": "{ch}afk", 39 | }, 40 | ) 41 | async def set_afk(client, message): 42 | engine = message.Engine 43 | pablo = await edit_or_reply(message, engine.get_string("PROCESSING")) 44 | msge = None 45 | msge = get_text(message) 46 | start_1 = datetime.now() 47 | afk_start = start_1.replace(microsecond=0) 48 | log = LogIt(message) 49 | if msge: 50 | msg = engine.get_string("AFK_1").format(msge) 51 | await log.log_msg( 52 | client, 53 | engine.get_string("AFK_2").format(msge) 54 | ) 55 | await go_afk(afk_start, msge) 56 | else: 57 | msg = engine.get_string("AFK_3") 58 | await log.log_msg( 59 | client, 60 | engine.get_string("AFK_2").format("Not Specified.") 61 | ) 62 | await go_afk(afk_start) 63 | await pablo.edit(msg) 64 | 65 | 66 | @listen( 67 | is_afk 68 | & (filters.mentioned | filters.private) 69 | & ~filters.me 70 | & ~filters.bot 71 | & ~filters.edited 72 | & filters.incoming 73 | ) 74 | async def afk_er(client, message): 75 | if not message: 76 | return 77 | if not message.from_user: 78 | return 79 | if message.from_user.id == client.me.id: 80 | return 81 | use_r = int(message.from_user.id) 82 | if use_r not in afk_sanity_check.keys(): 83 | afk_sanity_check[use_r] = 1 84 | else: 85 | afk_sanity_check[use_r] += 1 86 | if afk_sanity_check[use_r] == 5: 87 | await message.reply_text( 88 | "`I Told You 5 Times That My Master Isn't Available, Now I Will Not Reply To You. ;(`" 89 | ) 90 | afk_sanity_check[use_r] += 1 91 | return 92 | if afk_sanity_check[use_r] > 5: 93 | return 94 | lol = await check_afk() 95 | reason = lol["reason"] 96 | if reason == "": 97 | reason = None 98 | back_alivee = datetime.now() 99 | afk_start = lol["time"] 100 | afk_end = back_alivee.replace(microsecond=0) 101 | total_afk_time = str((afk_end - afk_start)) 102 | message_to_reply = ( 103 | f"I Am **[AFK]** Right Now. \n**Last Seen :** `{total_afk_time}`\n**Reason** : `{reason}`" 104 | if reason 105 | else f"I Am **[AFK]** Right Now. \n**Last Seen :** `{total_afk_time}`" 106 | ) 107 | await message.reply(message_to_reply) 108 | 109 | 110 | @listen(filters.outgoing & filters.me & is_afk) 111 | async def no_afke(client, message): 112 | engine = message.Engine 113 | lol = await check_afk() 114 | back_alivee = datetime.now() 115 | afk_start = lol["time"] 116 | afk_end = back_alivee.replace(microsecond=0) 117 | total_afk_time = str((afk_end - afk_start)) 118 | kk = await message.reply(engine.get_string("AFK_4").format(total_afk_time)) 119 | await kk.delete() 120 | await no_afk() 121 | log = LogIt(message) 122 | await log.log_msg( 123 | client, 124 | engine.get_string("AFK_5").format(total_afk_time) 125 | ) 126 | -------------------------------------------------------------------------------- /plugins/autopost.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | import logging 10 | 11 | from pyrogram import filters 12 | 13 | from database.autopostingdb import ( 14 | add_new_autopost, 15 | check_if_autopost_in_db, 16 | del_autopost, 17 | get_autopost, 18 | ) 19 | from main_startup.core.decorators import friday_on_cmd, listen 20 | from main_startup.helper_func.basic_helpers import edit_or_reply, get_text 21 | 22 | 23 | @friday_on_cmd( 24 | ["autopost"], 25 | cmd_help={ 26 | "help": "Add Channel To AutoPost List!", 27 | "example": "{ch}autopost @fridaysupportofficial", 28 | }, 29 | chnnl_only=True, 30 | ) 31 | async def autopost(client, message): 32 | engine = message.Engine 33 | mess_age_ = await edit_or_reply(message, engine.get_string("PROCESSING")) 34 | chnnl = get_text(message) 35 | if not chnnl: 36 | await mess_age_.edit(engine.get_string("INPUT_REQ").format("Chat ID")) 37 | return 38 | try: 39 | channel_str = int(chnnl) 40 | except ValueError: 41 | channel_str = str(chnnl) 42 | try: 43 | u_ = await client.get_chat(channel_str) 44 | except: 45 | await mess_age_.edit(engine.get_string("INVALID_CHAT_ID")) 46 | return 47 | channel_str = int(u_.id) 48 | if await check_if_autopost_in_db(int(message.chat.id), channel_str): 49 | await mess_age_.edit(engine.get_string("CHAT_ALREADY_IN_DB")) 50 | return 51 | await add_new_autopost(int(message.chat.id), channel_str) 52 | await mess_age_.edit(engine.get_string("AUTOPOSTING_1").format(chnnl)) 53 | 54 | 55 | @friday_on_cmd( 56 | ["rmautopost"], 57 | cmd_help={ 58 | "help": "Remove A Channel From Autopost List", 59 | "example": "{ch}rmautopost @fridaysupportofficial", 60 | }, 61 | chnnl_only=True, 62 | ) 63 | async def rmautopost(client, message): 64 | engine = message.Engine 65 | mess_age_ = await edit_or_reply(message, engine.get_string("PROCESSING")) 66 | chnnl = get_text(message) 67 | if not chnnl: 68 | await mess_age_.edit(engine.get_string("INPUT_REQ").format("Chat ID")) 69 | return 70 | try: 71 | channel_str = int(chnnl) 72 | except ValueError: 73 | channel_str = str(chnnl) 74 | try: 75 | u_ = await client.get_chat(channel_str) 76 | except: 77 | await mess_age_.edit(engine.get_string("INVALID_CHAT_ID")) 78 | return 79 | channel_str = int(u_.id) 80 | if not await check_if_autopost_in_db(int(message.chat.id), channel_str): 81 | await mess_age_.edit(engine.get_string("CHAT_NOT_IN_DB")) 82 | return 83 | await del_autopost(int(message.chat.id), channel_str) 84 | await mess_age_.edit(engine.get_string("AUTOPOSTING_2").format(chnnl)) 85 | 86 | 87 | @listen( 88 | (filters.incoming | filters.outgoing) 89 | & filters.channel 90 | & ~filters.edited 91 | & ~filters.service 92 | ) 93 | async def autoposterz(client, message): 94 | chat_id = message.chat.id 95 | if not await get_autopost(int(chat_id)): 96 | return 97 | channels_set = await get_autopost(int(chat_id)) 98 | if not channels_set: 99 | return 100 | for chat in channels_set: 101 | try: 102 | await message.copy(int(chat["to_channel"])) 103 | except Exception as e: 104 | logging.error( 105 | f"[AUTOPOST] | {e} | {chat['to_channel']} | {message.chat.id}" 106 | ) 107 | 108 | -------------------------------------------------------------------------------- /plugins/blacklist.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | import logging 10 | 11 | from pyrogram import filters 12 | 13 | from database.blacklistdb import ( 14 | add_to_blacklist, 15 | blacklists_del, 16 | del_blacklist, 17 | get_chat_blacklist, 18 | is_blacklist_in_db, 19 | ) 20 | from main_startup.core.decorators import friday_on_cmd, listen 21 | from main_startup.helper_func.basic_helpers import ( 22 | edit_or_reply, 23 | edit_or_send_as_file, 24 | get_text, 25 | ) 26 | from main_startup.helper_func.logger_s import LogIt 27 | 28 | 29 | @friday_on_cmd( 30 | [ 31 | "saveblacklist", 32 | "saveblockist", 33 | "addblacklist", 34 | "addblocklist", 35 | "blacklist", 36 | "textblacklist", 37 | ], 38 | cmd_help={ 39 | "help": "Adds Text Blacklist / Blocklist!", 40 | "example": "{ch}blacklist porn", 41 | }, 42 | ) 43 | async def addblacklist(client, message): 44 | engine = message.Engine 45 | messag_e_ = await edit_or_reply(message, engine.get_string("PROCESSING")) 46 | blacklist = get_text(message) 47 | if not blacklist: 48 | await messag_e_.edit(engine.get_string("INPUT_REQ").format("KeyWord")) 49 | return 50 | if await is_blacklist_in_db(int(message.chat.id), blacklist): 51 | await messag_e_.edit(engine.get_string("BLACKLIST_1")) 52 | return 53 | blacklist = blacklist.lower() 54 | await add_to_blacklist(blacklist, int(message.chat.id)) 55 | await messag_e_.edit(engine.get_string('BLACKLIST_2').format(blacklist)) 56 | 57 | 58 | @friday_on_cmd( 59 | ["listblacklist", "listblocklist"], 60 | cmd_help={"help": "Check Blacklist List!", "example": "{ch}listblocklist"}, 61 | ) 62 | async def listblacklist(client, message): 63 | engine = message.Engine 64 | messag_e_ = await edit_or_reply(message, engine.get_string("PROCESSING")) 65 | if not await get_chat_blacklist(int(message.chat.id)): 66 | await messag_e_.edit(engine.get_string("BLACKLIST_3")) 67 | return 68 | OUT_STR = engine.get_string("BLACKLIST_4") 69 | for trigger_s_ in await get_chat_blacklist(int(message.chat.id)): 70 | OUT_STR += f"👉 `{trigger_s_['trigger']}` \n" 71 | await edit_or_send_as_file(OUT_STR, messag_e_, client, "Blacklist", "blacklist") 72 | 73 | 74 | @friday_on_cmd( 75 | ["delblacklist", "rmblacklist", "delblockist", "rmblocklist"], 76 | cmd_help={ 77 | "help": "Remove Text From Blacklist / Blocklist!", 78 | "example": "{ch}blacklist porn", 79 | }, 80 | ) 81 | async def delblacklist(client, message): 82 | engine = message.Engine 83 | messag_e_ = await edit_or_reply(message, engine.get_string("PROCESSING")) 84 | blacklist = get_text(message) 85 | if not blacklist: 86 | await messag_e_.edit(engine.get_string("INPUT_REQ").format("KeyWord")) 87 | return 88 | if not await is_blacklist_in_db(int(message.chat.id), blacklist): 89 | await messag_e_.edit(engine.get_string("BLACKLIST_5")) 90 | return 91 | blacklist = blacklist.lower() 92 | await del_blacklist(blacklist, int(message.chat.id)) 93 | await messag_e_.edit(engine.get_string("BLACKLIST_6").format(blacklist)) 94 | 95 | 96 | @listen(filters.incoming & ~filters.edited & filters.group) 97 | async def activeblack(client, message): 98 | engine = message.Engine 99 | if not await get_chat_blacklist(int(message.chat.id)): 100 | return 101 | owo = message.text 102 | if owo is message.text: 103 | return 104 | owoo = owo.lower() 105 | tges = owoo.split(" ") 106 | for owo in tges: 107 | if await is_blacklist_in_db(int(message.chat.id), owo): 108 | try: 109 | await message.delete() 110 | except Exception as e: 111 | logging.error(f"[Blacklist] - {e}") 112 | log = LogIt(message) 113 | await log.log_msg( 114 | client, 115 | engine.get_strings("BLACKLIST_7").format(message.chat.title, e) 116 | ) 117 | 118 | 119 | 120 | @friday_on_cmd( 121 | ["delblacklists", "rmblacklists", "delblockists", "rmblocklists"], 122 | cmd_help={ 123 | "help": "Remove Everything From Blocklist!", 124 | "example": "{ch}delblacklists", 125 | }, 126 | ) 127 | async def delblacklists(client, message): 128 | engine = message.Engine 129 | messag_e_ = await edit_or_reply(message, engine.get_string("PROCESSING")) 130 | if not await get_chat_blacklist(int(message.chat.id)): 131 | await messag_e_.edit(engine.get_string("BLACKLIST_3")) 132 | return 133 | await blacklists_del(int(message.chat.id)) 134 | await messag_e_.edit(engine.get_string("BLACKLIST_8")) -------------------------------------------------------------------------------- /plugins/broadcast.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | import logging 10 | 11 | from database.broadcast_db import ( 12 | add_broadcast_chat, 13 | get_all_broadcast_chats, 14 | is_broadcast_chat_in_db, 15 | rmbroadcast_chat, 16 | ) 17 | from main_startup.core.decorators import friday_on_cmd 18 | from main_startup.helper_func.basic_helpers import edit_or_reply, get_text 19 | 20 | 21 | @friday_on_cmd( 22 | ["badd"], 23 | cmd_help={ 24 | "help": "Add Group/Channel For Broadcast!. Give input as 'all' to add all.", 25 | "example": "{ch}badd @fridaysupportofficial", 26 | }, 27 | ) 28 | async def badd(client, message): 29 | engine = message.Engine 30 | pablo = await edit_or_reply(message, engine.get_string("PROCESSING")) 31 | bd = get_text(message) 32 | if not bd: 33 | await pablo.edit(engine.get_string("INPUT_REQ").format("Chat ID")) 34 | return 35 | if bd.lower() == "all": 36 | await pablo.edit(engine.get_string("BROADCAST_2")) 37 | sed = 0 38 | oks = 0 39 | zxz = ["channel", "supergroup"] 40 | nd = ["creator", "administrator"] 41 | async for dialog in client.iter_dialogs(): 42 | if dialog.chat.type in zxz: 43 | x = await client.get_chat_member(dialog.chat.id, message.from_user.id) 44 | if x.status in nd: 45 | if not await is_broadcast_chat_in_db(dialog.chat.id): 46 | await add_broadcast_chat(dialog.chat.id) 47 | oks += 1 48 | else: 49 | sed += 1 50 | await pablo.edit( 51 | engine.get_string("BROADCAST_1").format(oks, oks+sed) 52 | ) 53 | else: 54 | chnl_id = await get_final_id(bd, client) 55 | if not chnl_id: 56 | await pablo.edit(engine.get_string('CHAT_NOT_IN_DB')) 57 | return 58 | chnl_id = int(chnl_id) 59 | if await is_broadcast_chat_in_db(chnl_id): 60 | await pablo.edit(engine.get_string("INVALID_CHAT_ID")) 61 | return 62 | await add_broadcast_chat(chnl_id) 63 | await pablo.edit(engine.get_string("BROADCAST_3").format(bd)) 64 | 65 | 66 | @friday_on_cmd( 67 | ["brm"], 68 | cmd_help={ 69 | "help": "Remove Group/Channel From Broadcast dB!. Give input as 'all' to Remove all.", 70 | "example": "{ch}brm @fridaysupportofficial", 71 | }, 72 | ) 73 | async def brm(client, message): 74 | engine = message.Engine 75 | pablo = await edit_or_reply(message, "`Processing..`") 76 | bd = get_text(message) 77 | if not bd: 78 | await pablo.edit(engine.get_string("INPUT_REQ").format("Chat ID")) 79 | return 80 | if bd.lower() == "all": 81 | await pablo.edit(engine.get_string("")) 82 | all = await get_all_broadcast_chats() 83 | Jill = 0 84 | for chnnl in all: 85 | await rmbroadcast_chat(chnnl["chat_id"]) 86 | Jill += 1 87 | await pablo.edit(engine.get_string("BROADCAST_5").format(Jill)) 88 | else: 89 | chnl_id = await get_final_id(bd, client) 90 | if not chnl_id: 91 | await pablo.edit(engine.get_string("INVALID_CHAT_ID")) 92 | return 93 | chnl_id = int(chnl_id) 94 | if not await is_broadcast_chat_in_db(chnl_id): 95 | await pablo.edit(engine.get_string("FILTER_1").format("BROADCAST", bd)) 96 | return 97 | await add_broadcast_chat(chnl_id) 98 | await pablo.edit(engine.get_string("BROADCAST_4").format(bd)) 99 | 100 | 101 | @friday_on_cmd( 102 | ["broadcast"], 103 | cmd_help={ 104 | "help": "Broadcast Message In All Groups/Channels which are added in dB.", 105 | "example": "{ch}broadcast (replying to broadcast message)", 106 | }, 107 | ) 108 | async def broadcast(client, message): 109 | engine = message.Engine 110 | pablo = await edit_or_reply( 111 | message, engine.get_string("BROADCAST_6") 112 | ) 113 | leat = await get_all_broadcast_chats() 114 | S = 0 115 | F = 0 116 | if len(leat) == 0: 117 | await pablo.edit(engine.get_string("BROADCAST_7")) 118 | return 119 | if not message.reply_to_message: 120 | await pablo.edit(engine.get_string("REPLY_MSG")) 121 | return 122 | for lolol in leat: 123 | try: 124 | await client.copy_message( 125 | chat_id=lolol["chat_id"], 126 | from_chat_id=message.chat.id, 127 | message_id=message.reply_to_message.message_id, 128 | ) 129 | S += 1 130 | except Exception as e: 131 | logging.error(f"[Broadcast] {e}") 132 | F += 1 133 | await pablo.edit( 134 | engine.get_string("BROADCAST_8").format(S, F) 135 | ) 136 | 137 | 138 | async def get_final_id(query, client): 139 | is_int = True 140 | try: 141 | in_t = int(query) 142 | except ValueError: 143 | is_int = False 144 | chnnl = in_t if is_int else str(query) 145 | try: 146 | return int((await client.get_chat(chnnl)).id) 147 | except: 148 | return None 149 | -------------------------------------------------------------------------------- /plugins/chat_filters.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | from pyrogram import filters 10 | 11 | from database.filterdb import ( 12 | add_filters, 13 | all_filters, 14 | del_filters, 15 | filters_del, 16 | filters_info, 17 | ) 18 | import re 19 | from main_startup.config_var import Config 20 | from main_startup.core.decorators import friday_on_cmd, listen 21 | from main_startup.helper_func.basic_helpers import edit_or_reply, get_text 22 | 23 | 24 | @friday_on_cmd( 25 | ["delfilter"], 26 | cmd_help={"help": "Delete A Filter!", "example": "{ch}delfilter (filter name)"}, 27 | group_only=True 28 | ) 29 | async def del_filterz(client, message): 30 | engine = message.Engine 31 | note_ = await edit_or_reply(message, engine.get_string("PROCESSING")) 32 | note_name = get_text(message) 33 | if not note_name: 34 | await note_.edit(engine.get_string("INPUT_REQ").format("Keyword")) 35 | return 36 | note_name = note_name.lower() 37 | if not await filters_info(note_name, int(message.chat.id)): 38 | await note_.edit(engine.get_string("FILTER_1").format("FILTERS", note_name)) 39 | return 40 | await del_filters(note_name, int(message.chat.id)) 41 | await note_.edit(engine.get_string("FILTER_2").format("Filter", note_name)) 42 | 43 | 44 | @friday_on_cmd( 45 | ["filters"], 46 | cmd_help={"help": "List All The Filters In The Chat!", "example": "{ch}filters"}, 47 | group_only=True 48 | ) 49 | async def show_filters(client, message): 50 | engine = message.Engine 51 | pablo = await edit_or_reply(message, engine.get_string("PROCESSING")) 52 | poppy = await all_filters(int(message.chat.id)) 53 | if poppy is False: 54 | await pablo.edit(engine.get_string("FILTER_3").format("Filters")) 55 | return 56 | kk = "".join(f"\n > `{Escobar.get('keyword')}`" for Escobar in poppy) 57 | mag = engine.get_string("LIST_OF").format("Filters", message.chat.title, kk) 58 | await pablo.edit(mag) 59 | 60 | 61 | @friday_on_cmd( 62 | ["savefilter"], 63 | cmd_help={ 64 | "help": "Save A Filter!", 65 | "example": "{ch}savefilter (filter name) (replying to message)", 66 | }, 67 | group_only=True 68 | ) 69 | async def s_filters(client, message): 70 | engine = message.Engine 71 | note_ = await edit_or_reply(message, engine.get_string("PROCESSING")) 72 | note_name = get_text(message) 73 | if not note_name: 74 | await note_.edit(engine.get_string("INPUT_REQ").format("KeyWord")) 75 | return 76 | if not message.reply_to_message: 77 | await note_.edit(engine.get_string("REPLY_MSG")) 78 | return 79 | note_name = note_name.lower() 80 | msg = message.reply_to_message 81 | copied_msg = await msg.copy(int(Config.LOG_GRP)) 82 | await add_filters(note_name, int(message.chat.id), copied_msg.message_id) 83 | await note_.edit(engine.get_string("FILTER_5").format(note_name, "Filters")) 84 | 85 | 86 | @listen(filters.incoming & ~filters.edited & filters.group & ~filters.private & ~filters.me) 87 | async def reply_filter_(client, message): 88 | if not message: 89 | return 90 | owo = message.text or message.caption 91 | is_m = False 92 | if not owo: 93 | return 94 | al_fil = await all_filters(int(message.chat.id)) 95 | if not al_fil: 96 | return 97 | al_fill = [all_fil.get("keyword") for all_fil in al_fil] 98 | owo = owo.lower() 99 | for filter_s in al_fill: 100 | pattern = r"( |^|[^\w])" + re.escape(filter_s) + r"( |$|[^\w])" 101 | if re.search(pattern, owo, flags=re.IGNORECASE): 102 | f_info = await filters_info(filter_s, int(message.chat.id)) 103 | m_s = await client.get_messages(int(Config.LOG_GRP), f_info["msg_id"]) 104 | if await is_media(m_s): 105 | text_ = m_s.caption or "" 106 | is_m = True 107 | else: 108 | text_ = m_s.text or "" 109 | if text_ != "": 110 | mention = message.from_user.mention 111 | user_id = message.from_user.id 112 | user_name = message.from_user.username or "No Username" 113 | first_name = message.from_user.first_name 114 | last_name = message.from_user.last_name or "No Last Name" 115 | text_ = text_.format(mention=mention, user_id=user_id, user_name=user_name, first_name=first_name, last_name=last_name) 116 | if not is_m: 117 | await client.send_message( 118 | message.chat.id, 119 | text_, 120 | reply_to_message_id=message.message_id) 121 | else: 122 | await m_s.copy( 123 | chat_id=int(message.chat.id), 124 | caption=text_, 125 | reply_to_message_id=message.message_id, 126 | ) 127 | 128 | async def is_media(message): 129 | return bool( 130 | ( 131 | message.photo 132 | or message.video 133 | or message.document 134 | or message.audio 135 | or message.sticker 136 | or message.animation 137 | or message.voice 138 | or message.video_note 139 | ) 140 | ) 141 | 142 | @friday_on_cmd( 143 | ["delfilters"], 144 | cmd_help={"help": "Delete All The Filters in chat!", "example": "{ch}delfilters"}, 145 | ) 146 | async def del_all_filters(client, message): 147 | engine = message.Engine 148 | pablo = await edit_or_reply(message, engine.get_string("PROCESSING")) 149 | poppy = await all_filters(int(message.chat.id)) 150 | if poppy is False: 151 | await pablo.edit(engine.get_string("FILTER_3").format("Filters")) 152 | return 153 | await filters_del(int(message.chat.id)) 154 | await pablo.edit(engine.get_string("REMOVED_ALL").format("Filters")) 155 | -------------------------------------------------------------------------------- /plugins/code_runner.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | import asyncio 10 | import io 11 | import sys 12 | import traceback 13 | 14 | import requests 15 | 16 | from main_startup.core.decorators import friday_on_cmd 17 | from main_startup.core.startup_helpers import run_cmd 18 | from main_startup.helper_func.basic_helpers import ( 19 | edit_or_reply, 20 | edit_or_send_as_file, 21 | get_text, 22 | ) 23 | 24 | @friday_on_cmd( 25 | cmd=["exec", "eval"], 26 | ignore_errors=True, 27 | cmd_help={"help": "Run Python Code!", "example": '{ch}eval print("FridayUB")'}, 28 | ) 29 | async def eval(client, message): 30 | engine = message.Engine 31 | stark = await edit_or_reply(message, engine.get_string("PROCESSING")) 32 | cmd = get_text(message) 33 | if not cmd: 34 | await stark.edit(engine.get_string("INPUT_REQ").format("Python Code")) 35 | return 36 | if message.reply_to_message: 37 | message.reply_to_message.message_id 38 | old_stderr = sys.stderr 39 | old_stdout = sys.stdout 40 | redirected_output = sys.stdout = io.StringIO() 41 | redirected_error = sys.stderr = io.StringIO() 42 | stdout, stderr, exc = None, None, None 43 | try: 44 | await aexec(cmd, client, message) 45 | except Exception: 46 | exc = traceback.format_exc() 47 | stdout = redirected_output.getvalue() 48 | stderr = redirected_error.getvalue() 49 | sys.stdout = old_stdout 50 | sys.stderr = old_stderr 51 | evaluation = "" 52 | if exc: 53 | evaluation = exc 54 | elif stderr: 55 | evaluation = stderr 56 | elif stdout: 57 | evaluation = stdout 58 | else: 59 | evaluation = "Success!" 60 | EVAL = engine.get_string("EVAL") 61 | final_output = EVAL.format(cmd, evaluation) 62 | capt = "Eval Result!" if len(cmd) >= 1023 else cmd 63 | await edit_or_send_as_file(final_output, stark, client, capt, "eval-result") 64 | 65 | 66 | async def aexec(code, client, message): 67 | exec( 68 | f"async def __aexec(client, message): " 69 | + "".join(f"\n {l}" for l in code.split("\n")) 70 | ) 71 | return await locals()["__aexec"](client, message) 72 | 73 | @friday_on_cmd( 74 | cmd=["bash", "terminal"], 75 | ignore_errors=True, 76 | cmd_help={"help": "Run Bash/Terminal Command!", "example": "{ch}bash ls"}, 77 | ) 78 | async def sed_terminal(client, message): 79 | engine = message.Engine 80 | stark = await edit_or_reply(message, engine.get_string("WAIT")) 81 | cmd = get_text(message) 82 | if not cmd: 83 | await stark.edit(engine.get_string("INPUT_REQ").format("Bash Code")) 84 | return 85 | cmd = message.text.split(None, 1)[1] 86 | if message.reply_to_message: 87 | message.reply_to_message.message_id 88 | 89 | pid, err, out, ret = await run_command(cmd) 90 | if not out: 91 | out = "No OutPut!" 92 | friday = engine.get_string("BASH_OUT").format(cmd, pid, err, out, ret) 93 | await edit_or_send_as_file(friday, stark, client, cmd, "bash-result") 94 | 95 | 96 | async def run_command(cmd): 97 | process = await asyncio.create_subprocess_shell( 98 | cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE 99 | ) 100 | stdout, stderr = await process.communicate() 101 | errors = stderr.decode() 102 | if not errors: 103 | errors = "No Errors!" 104 | output = stdout.decode() 105 | return process.pid, errors, output, process.returncode 106 | -------------------------------------------------------------------------------- /plugins/gps.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | import logging 10 | import os 11 | 12 | from geopy.geocoders import Nominatim 13 | 14 | from main_startup.core.decorators import friday_on_cmd 15 | from main_startup.helper_func.basic_helpers import edit_or_reply, get_text 16 | 17 | GMAPS_LOC = "https://maps.googleapis.com/maps/api/geocode/json" 18 | 19 | 20 | @friday_on_cmd( 21 | ["gps"], 22 | cmd_help={ 23 | "help": "Find and send the given location", 24 | "example": "{ch}gps ", 25 | }, 26 | ) 27 | async def gps(client, message): 28 | engine = message.Engine 29 | pablo = await edit_or_reply(message, engine.get_string("PROCESSING")) 30 | args = get_text(message) 31 | if not args: 32 | await pablo.edit(engine.get_string("INPUT_REQ").format("Location")) 33 | return 34 | try: 35 | geolocator = Nominatim(user_agent="FridayUB") 36 | location = args 37 | geoloc = geolocator.geocode(location) 38 | longitude = geoloc.longitude 39 | latitude = geoloc.latitude 40 | except Exception as e: 41 | logging.info(e) 42 | await pablo.edit(engine.get_string("GPS_2")) 43 | return 44 | gm = "https://www.google.com/maps/search/{},{}".format(latitude, longitude) 45 | await client.send_location(message.chat.id, float(latitude), float(longitude)) 46 | await pablo.reply( 47 | "Open with: [Google Maps]({})".format(gm), 48 | disable_web_page_preview=False, 49 | ) 50 | await pablo.delete() 51 | -------------------------------------------------------------------------------- /plugins/gtools.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | 10 | from pyrogram import filters 11 | 12 | from database.gbandb import gban_info, gban_list, gban_user, ungban_user 13 | from database.gmutedb import gmute, is_gmuted, ungmute 14 | from main_startup.config_var import Config 15 | from main_startup.core.decorators import friday_on_cmd, listen 16 | from main_startup.helper_func.basic_helpers import ( 17 | edit_or_reply, 18 | edit_or_send_as_file, 19 | get_text, 20 | get_user, 21 | iter_chats, 22 | ) 23 | from main_startup.helper_func.logger_s import LogIt 24 | from plugins import devs_id 25 | from database.sudodb import sudo_list 26 | 27 | 28 | @friday_on_cmd( 29 | ["gmute"], 30 | cmd_help={ 31 | "help": "Globally Mute The User!", 32 | "example": "{ch}gmute (reply to user messages OR provide his ID)", 33 | }, 34 | ) 35 | async def gmute_him(client, message): 36 | AFS = await sudo_list() 37 | engine = message.Engine 38 | g = await edit_or_reply(message, engine.get_string("PROCESSING")) 39 | text_ = get_text(message) 40 | user, reason = get_user(message, text_) 41 | if not user: 42 | await g.edit(engine.get_string("REPLY_TO_USER").format("gmute")) 43 | return 44 | try: 45 | userz = await client.get_users(user) 46 | except: 47 | await g.edit(engine.get_string("USER_MISSING").format("User Doesn't Exists In This Chat !")) 48 | return 49 | if not reason: 50 | reason = "Just_Gmutted!" 51 | if userz.id == (client.me).id: 52 | await g.edit(engine.get_string("TF_DO_IT").format("Gmute")) 53 | return 54 | if userz.id in devs_id: 55 | await g.edit("`Sadly, I Can't Do That!`") 56 | return 57 | if userz.id in AFS: 58 | await g.edit("`Sudo Users Can't Be Gmutted! Remove Him And Try Again!`") 59 | return 60 | if await is_gmuted(userz.id): 61 | await g.edit("`Re-Gmute? Seriously? :/`") 62 | return 63 | await gmute(userz.id, reason) 64 | gmu = f"**#Gmutted** \n**User :** `{userz.id}` \n**Reason :** `{reason}`" 65 | await g.edit(gmu) 66 | log = LogIt(message) 67 | await log.log_msg(client, gmu) 68 | 69 | 70 | @friday_on_cmd( 71 | ["ungmute"], 72 | cmd_help={ 73 | "help": "Globally UnMute The User!", 74 | "example": "{ch}ungmute (reply to user message OR provide his ID)", 75 | }, 76 | ) 77 | async def gmute_him(client, message): 78 | AFS = await sudo_list() 79 | engine = message.Engine 80 | ug = await edit_or_reply(message, engine.get_string("PROCESSING")) 81 | text_ = get_text(message) 82 | user_ = get_user(message, text_)[0] 83 | if not user_: 84 | await ug.edit(engine.get_string("REPLY_TO_USER").format("UN-gmute")) 85 | return 86 | try: 87 | userz = await client.get_users(user_) 88 | except BaseException as e: 89 | await ug.edit(engine.get_string("USER_MISSING").format(e)) 90 | return 91 | if userz.id == (client.me).id: 92 | await ug.edit(engine.get_string("TF_DO_IT").format("UN-gmute")) 93 | return 94 | if userz.id in AFS: 95 | await ug.edit("`Sudo Users Can't Be Un-Gmutted! Remove Him And Try Again!`") 96 | return 97 | if not await is_gmuted(userz.id): 98 | await ug.edit("`Un-Gmute A Non Gmutted User? Seriously? :/`") 99 | return 100 | await ungmute(userz.id) 101 | ugmu = f"**#Un-Gmutted** \n**User :** `{userz.id}`" 102 | await ug.edit(ugmu) 103 | log = LogIt(message) 104 | await log.log_msg(client, ugmu) 105 | 106 | 107 | @friday_on_cmd( 108 | ["gban"], 109 | cmd_help={ 110 | "help": "Globally Ban The User!", 111 | "example": "{ch}gban (reply to user message OR provide his ID)", 112 | }, 113 | ) 114 | async def gbun_him(client, message): 115 | AFS = await sudo_list() 116 | engine = message.Engine 117 | gbun = await edit_or_reply(message, engine.get_string("PROCESSING")) 118 | text_ = get_text(message) 119 | user, reason = get_user(message, text_) 120 | failed = 0 121 | if not user: 122 | await gbun.edit(engine.get_string("REPLY_TO_USER").format("gban")) 123 | return 124 | try: 125 | userz = await client.get_users(user) 126 | except BaseException as e: 127 | await gbun.edit(engine.get_string("USER_MISSING").format(e)) 128 | return 129 | if not reason: 130 | reason = "Private Reason!" 131 | if userz.id == (client.me).id: 132 | await gbun.edit(engine.get_string("TF_DO_IT").format("GBan")) 133 | return 134 | if userz.id in devs_id: 135 | await g.edit("`Sadly, I Can't Do That!`") 136 | return 137 | if userz.id in AFS: 138 | await gbun.edit("`Sudo Users Can't Be Gbanned! Remove Him And Try Again!`") 139 | return 140 | if await gban_info(userz.id): 141 | await gbun.edit("`Re-Gban? Seriously? :/`") 142 | return 143 | await gbun.edit("`Please, Wait Fectching Your Chats!`") 144 | chat_dict = await iter_chats(client) 145 | chat_len = len(chat_dict) 146 | if not chat_dict: 147 | gbun.edit("`You Have No Chats! So Sad`") 148 | return 149 | await gbun.edit(engine.get_string("GBAN_START")) 150 | for ujwal in chat_dict: 151 | try: 152 | await client.kick_chat_member(ujwal, int(userz.id)) 153 | except: 154 | failed += 1 155 | await gban_user(userz.id, reason) 156 | gbanned = f"**#GBanned** \n**User :** [{userz.first_name}](tg://user?id={userz.id}) \n**Reason :** `{reason}` \n**Affected Chats :** `{chat_len-failed}`" 157 | await gbun.edit(gbanned) 158 | log = LogIt(message) 159 | await log.log_msg(client, gbanned) 160 | 161 | 162 | @friday_on_cmd( 163 | ["ungban"], 164 | cmd_help={ 165 | "help": "Globally Unban The User!", 166 | "example": "{ch}ungban (reply to user messages OR provide his ID)", 167 | }, 168 | ) 169 | async def ungbun_him(client, message): 170 | AFS = await sudo_list() 171 | engine = message.Engine 172 | ungbun = await edit_or_reply(message, engine.get_string("PROCESSING")) 173 | text_ = get_text(message) 174 | user = get_user(message, text_)[0] 175 | failed = 0 176 | if not user: 177 | await ungbun.edit(engine.get_string("REPLY_TO_USER").format("Un-Gban")) 178 | return 179 | try: 180 | userz = await client.get_users(user) 181 | except BaseException as e: 182 | await ungbun.edit(engine.get_string("USER_MISSING").format(e)) 183 | return 184 | if userz.id == (client.me).id: 185 | await ungbun.edit(engine.get_string("TF_DO_IT").format("Un-GBan")) 186 | return 187 | if not await gban_info(userz.id): 188 | await ungbun.edit("`Un-Gban A Ungbanned User? Seriously? :/`") 189 | return 190 | await ungbun.edit("`Please, Wait Fectching Your Chats!`") 191 | chat_dict = await iter_chats(client) 192 | chat_len = len(chat_dict) 193 | if not chat_dict: 194 | ungbun.edit("`You Have No Chats! So Sad`") 195 | return 196 | await ungbun.edit("`Starting Un-GBans Now!`") 197 | for ujwal in chat_dict: 198 | try: 199 | await client.unban_chat_member(ujwal, int(userz.id)) 200 | except: 201 | failed += 1 202 | await ungban_user(userz.id) 203 | ungbanned = f"**#Un_GBanned** \n**User :** [{userz.first_name}](tg://user?id={userz.id}) \n**Affected Chats :** `{chat_len-failed}`" 204 | await ungbun.edit(ungbanned) 205 | log = LogIt(message) 206 | await log.log_msg(client, ungbanned) 207 | 208 | 209 | @listen(filters.incoming & ~filters.me & ~filters.user(Config.AFS)) 210 | async def watch(client, message): 211 | AFS = await sudo_list() 212 | if not message: 213 | return 214 | if not message.from_user: 215 | return 216 | user = message.from_user.id 217 | if not user: 218 | return 219 | if await is_gmuted(user): 220 | try: 221 | await message.delete() 222 | except: 223 | return 224 | if await gban_info(user): 225 | if message.chat.type == "private": 226 | return 227 | try: 228 | await message.chat.kick_member(int(user)) 229 | except BaseException: 230 | return 231 | await client.send_message( 232 | message.chat.id, 233 | f"**#GbanWatch** \n**Chat ID :** `{message.chat.id}` \n**User :** `{user}` \n**Reason :** `{await gban_info(user)}`", 234 | ) 235 | 236 | @friday_on_cmd( 237 | ["gbanlist"], 238 | cmd_help={ 239 | "help": "Get List Of Globally Banned Users!", 240 | "example": "{ch}gbanlist (reply to user messages OR provide his ID)", 241 | }, 242 | ) 243 | async def give_glist(client, message): 244 | engine = message.Engine 245 | oof = "**#GBanList** \n\n" 246 | glist = await edit_or_reply(message, engine.get_string("PROCESSING")) 247 | list_ = await gban_list() 248 | if len(list_) == 0: 249 | await glist.edit("`No User is Gbanned Till Now!`") 250 | return 251 | for lit in list_: 252 | oof += f"**User :** `{lit['user']}` \n**Reason :** `{lit['reason']}` \n\n" 253 | await edit_or_send_as_file(oof, glist, client, "GbanList", "Gban-List") 254 | 255 | 256 | @friday_on_cmd( 257 | ["gbroadcast"], 258 | cmd_help={ 259 | "help": "Send Message To All Chats, You Are In!", 260 | "example": "{ch}gbroadcast (replying to message)", 261 | }, 262 | ) 263 | async def gbroadcast(client, message): 264 | engine = message.Engine 265 | msg_ = await edit_or_reply(message, engine.get_string("PROCESSING")) 266 | failed = 0 267 | if not message.reply_to_message: 268 | await msg_.edit(engine.get_string("NEEDS_REPLY").format("Message")) 269 | return 270 | chat_dict = await iter_chats(client) 271 | chat_len = len(chat_dict) 272 | await msg_.edit("`Now Sending To All Chats Possible!`") 273 | if not chat_dict: 274 | msg_.edit(engine.get_string("NO_CHATS")) 275 | return 276 | for c in chat_dict: 277 | try: 278 | msg = await message.reply_to_message.copy(c) 279 | except: 280 | failed += 1 281 | await msg_.edit( 282 | engine.get_string("BROADCAST_8").format(chat_len-failed, failed) 283 | ) 284 | -------------------------------------------------------------------------------- /plugins/helper.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | 10 | from main_startup import CMD_LIST, bot, XTRA_CMD_LIST 11 | from main_startup.core.decorators import Config, friday_on_cmd 12 | from main_startup.core.startup_helpers import run_cmd 13 | from main_startup.helper_func.basic_helpers import edit_or_reply, get_text 14 | 15 | 16 | @friday_on_cmd( 17 | ["help", "helper"], 18 | cmd_help={ 19 | "help": "Gets Help Menu", 20 | "example": "{ch}help", 21 | }, 22 | ) 23 | async def help(client, message): 24 | engine = message.Engine 25 | f_ = await edit_or_reply(message, engine.get_string("PROCESSING")) 26 | if bot: 27 | starkbot = bot.me 28 | bot_username = starkbot.username 29 | try: 30 | nice = await client.get_inline_bot_results(bot=bot_username, query="help") 31 | await client.send_inline_bot_result( 32 | message.chat.id, nice.query_id, nice.results[0].id, hide_via=True 33 | ) 34 | except BaseException as e: 35 | return await f_.edit(engine.get_string("HELP_OPEN_ERROR").format(e)) 36 | await f_.delete() 37 | else: 38 | cmd_ = get_text(message) 39 | if not cmd_: 40 | help_t = prepare_cmd_list(engine) 41 | await f_.edit(help_t) 42 | else: 43 | help_s = get_help_str(cmd_) 44 | if not help_s: 45 | await f_.edit(engine.get_string("PLUGIN_NOT_FOUND")) 46 | return 47 | await f_.edit(help_s) 48 | 49 | 50 | @friday_on_cmd( 51 | ["ahelp", "ahelper"], 52 | cmd_help={ 53 | "help": "Gets Help List & Info", 54 | "example": "{ch}ahelp (cmd_name)", 55 | }, 56 | ) 57 | async def help_(client, message): 58 | engine = message.Engine 59 | f_ = await edit_or_reply(message, engine.get_string("PROCESSING")) 60 | cmd_ = get_text(message) 61 | if not cmd_: 62 | help_t = prepare_cmd_list(engine) 63 | await f_.edit(help_t) 64 | else: 65 | help_s = get_help_str(cmd_) 66 | if not help_s: 67 | await f_.edit(engine.get_string("PLUGIN_NOT_FOUND")) 68 | return 69 | await f_.edit(help_s) 70 | 71 | 72 | def get_help_str(string): 73 | if string not in CMD_LIST.keys(): 74 | if string not in XTRA_CMD_LIST.keys(): 75 | return None 76 | return XTRA_CMD_LIST[string] 77 | return CMD_LIST[string] 78 | 79 | def prepare_cmd_list(engine): 80 | main_l = engine.get_string("CMD_LIST_MENU").format(len(CMD_LIST)) 81 | for i in CMD_LIST: 82 | if i: 83 | main_l += f"{i} " 84 | if Config.LOAD_UNOFFICIAL_PLUGINS: 85 | main_l += engine.get_string("CMD_LIST_MENU2").format(len(XTRA_CMD_LIST)) 86 | for i in XTRA_CMD_LIST: 87 | if i: 88 | main_l += f"{i} " 89 | main_l += engine.get_string("KNOW_MORE_ABOUT_PLUGIN").format(Config.COMMAND_HANDLER) 90 | return main_l 91 | 92 | -------------------------------------------------------------------------------- /plugins/heroku_helpers.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | import asyncio 10 | import os 11 | import time 12 | from asyncio import sleep 13 | from functools import wraps 14 | 15 | import heroku3 16 | from pyrogram.types import ChatPermissions 17 | 18 | from main_startup.config_var import Config 19 | from main_startup.core.decorators import friday_on_cmd 20 | from main_startup.helper_func.basic_helpers import ( 21 | edit_or_reply, 22 | edit_or_send_as_file, 23 | get_text, 24 | get_user, 25 | is_admin_or_owner, 26 | ) 27 | 28 | heroku_client = None 29 | if Config.HEROKU_API_KEY: 30 | heroku_client = heroku3.from_key(Config.HEROKU_API_KEY) 31 | 32 | 33 | def _check_heroku(func): 34 | @wraps(func) 35 | async def heroku_cli(client, message): 36 | engine = message.Engine 37 | heroku_app = None 38 | if not heroku_client or not Config.HEROKU_APP_NAME: 39 | await edit_or_reply( 40 | message, engine.get_string("MISSING_API_KEY").format("HEROKU_API_KEY") 41 | ) 42 | if Config.HEROKU_APP_NAME and heroku_client: 43 | try: 44 | heroku_app = heroku_client.app(Config.HEROKU_APP_NAME) 45 | except: 46 | await edit_or_reply( 47 | message, engine.get_string("HEROKU_DONT_MATCH") 48 | ) 49 | if heroku_app: 50 | await func(client, message, heroku_app) 51 | 52 | return heroku_cli 53 | 54 | 55 | @friday_on_cmd( 56 | ["reboot"], 57 | cmd_help={"help": "Restart Your Userbot On HEROKU!", "example": "{ch}restart"}, 58 | ) 59 | @_check_heroku 60 | async def gib_restart(client, message, hap): 61 | engine = message.Engine 62 | msg_ = await edit_or_reply(message, engine.get_string("RESTART")) 63 | hap.restart() 64 | 65 | 66 | @friday_on_cmd( 67 | ["logs"], cmd_help={"help": "Get Logs From HEROKU!", "example": "{ch}logs"} 68 | ) 69 | @_check_heroku 70 | async def gib_logs(client, message, happ): 71 | engine = message.Engine 72 | msg_ = await edit_or_reply(message, engine.get_string("PROCESSING")) 73 | logs = happ.get_log() 74 | capt = f"Heroku Logs Of {Config.HEROKU_APP_NAME}" 75 | await edit_or_send_as_file(logs, msg_, client, capt, "logs") 76 | 77 | 78 | @friday_on_cmd( 79 | ["setvar"], 80 | cmd_help={ 81 | "help": "Set Var From telegram Itself, Please Seperate Var And Value With '|'", 82 | "example": "{ch}setvar LOAD_UNOFFICIAL_PLUGINS False", 83 | }, 84 | ) 85 | @_check_heroku 86 | async def set_varr(client, message, app_): 87 | engine = message.Engine 88 | msg_ = await edit_or_reply(message, engine.get_string("PROCESSING")) 89 | heroku_var = app_.config() 90 | _var = get_text(message) 91 | syntax = f"{Config.COMMAND_HANDLER}setvar ConfigVarName ConfigVarValue" 92 | if not _var: 93 | await msg_.edit(engine.get_string("USAGE").format(syntax)) 94 | return 95 | if " " not in _var: 96 | await msg_.edit(engine.get_string("USAGE").format(syntax)) 97 | return 98 | var_ = _var.split(" ", 1) 99 | if len(var_) > 2: 100 | await msg_.edit(engine.get_string("USAGE").format(syntax)) 101 | return 102 | _varname, _varvalue = var_ 103 | s = engine.get_string("VAR_ADDED").format(_varname, _varvalue) 104 | await msg_.edit(s) 105 | heroku_var[_varname] = _varvalue 106 | 107 | 108 | @friday_on_cmd( 109 | ["delvar"], 110 | cmd_help={ 111 | "help": "Delete Var From telegram Itself", 112 | "example": "{ch}delvar LOAD_UNOFFICIAL_PLUGINS", 113 | }, 114 | ) 115 | @_check_heroku 116 | async def del_varr(client, message, app_): 117 | engine = message.Engine 118 | msg_ = await edit_or_reply(message, engine.get_string("PROCESSING")) 119 | heroku_var = app_.config() 120 | _var = get_text(message) 121 | if not _var: 122 | await msg_.edit(engine.get_string("INPUT_REQ").format("Var Name")) 123 | return 124 | if _var not in heroku_var: 125 | await msg_.edit(engine.get_string("DE")) 126 | return 127 | await msg_.edit(engine.get_string("DLTED_VAR").format(_var)) 128 | del heroku_var[_var] 129 | -------------------------------------------------------------------------------- /plugins/install.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | import os 10 | 11 | from main_startup.core.decorators import friday_on_cmd 12 | from main_startup.core.startup_helpers import load_plugin 13 | from main_startup.helper_func.basic_helpers import edit_or_reply 14 | 15 | 16 | @friday_on_cmd( 17 | ["install"], 18 | cmd_help={ 19 | "help": "Install Custom Plugins In Userbot", 20 | "example": "{ch}install (replying to plugin (.py))", 21 | }, 22 | ) 23 | async def installer(client, message): 24 | engine = message.Engine 25 | pablo = await edit_or_reply(message, engine.get_string("PROCESSING")) 26 | if not message.reply_to_message: 27 | await pablo.edit(engine.get_string("NEEDS_REPLY").format("A Plugin")) 28 | return 29 | if not message.reply_to_message.document: 30 | await pablo.edit(engine.get_string("IS_NOT_DOC")) 31 | return 32 | file_name = message.reply_to_message.document.file_name 33 | ext = file_name.split(".")[1] 34 | if os.path.exists(os.path.join("./plugins/", file_name)): 35 | await pablo.edit(engine.get_string("ALREADY_INSTALLED")) 36 | return 37 | if ext.lower() != "py": 38 | await pablo.edit(engine.get_string("ONLY_PY_FILES")) 39 | return 40 | Escobar = await message.reply_to_message.download(file_name="./plugins/") 41 | base_name = os.path.basename(Escobar) 42 | file_n = base_name.split(".")[0] 43 | try: 44 | load_plugin(file_n) 45 | except Exception as e: 46 | await pablo.edit(engine.get_string("ERROR_INSTALLING").format(e)) 47 | os.remove(Escobar) 48 | return 49 | await pablo.edit(engine.get_string("PLUGIN_INSTALLED").format(file_name)) 50 | -------------------------------------------------------------------------------- /plugins/listmyusernames.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | import pyrogram 10 | 11 | from main_startup.core.decorators import friday_on_cmd 12 | from main_startup.helper_func.basic_helpers import edit_or_reply, edit_or_send_as_file 13 | 14 | 15 | @friday_on_cmd( 16 | ["listmyusernames"], 17 | cmd_help={ 18 | "help": "Get All Admin Channel / Chat List", 19 | "example": "{ch}listmyusernames", 20 | }, 21 | ) 22 | async def pabloescobar(client, message): 23 | engine = message.Engine 24 | pablo = await edit_or_reply(message, engine.get_string("PROCESSING")) 25 | channels = await client.send( 26 | pyrogram.raw.functions.channels.GetAdminedPublicChannels() 27 | ) 28 | C = channels.chats 29 | output_stre = "".join(f"{x.title}\n@{x.username}\n\n" for x in C) 30 | output_str = engine.get_string("IAM_ADMIN").format("output_stre") 31 | await edit_or_send_as_file( 32 | output_str, pablo, client, "Your Admin Chats", "admin_chat" 33 | ) 34 | -------------------------------------------------------------------------------- /plugins/notes.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | from pyrogram import filters 10 | 11 | from database.notesdb import add_note, all_note, del_note, del_notes, note_info 12 | from main_startup.config_var import Config 13 | from main_startup.core.decorators import friday_on_cmd, listen 14 | from main_startup.helper_func.basic_helpers import edit_or_reply, get_text 15 | 16 | 17 | @friday_on_cmd( 18 | ["savenote"], 19 | cmd_help={ 20 | "help": "Save Notes In The Chat!", 21 | "example": "{ch}savenote (note name) (reply to Note message)", 22 | }, 23 | ) 24 | async def notes(client, message): 25 | engine = message.Engine 26 | note_ = await edit_or_reply(message, engine.get_string("PROCESSING")) 27 | note_name = get_text(message) 28 | if not note_name: 29 | await note_.edit(engine.get_string("INPUT_REQ").format("Note Name")) 30 | return 31 | if not message.reply_to_message: 32 | await note_.edit(engine.get_string("REPLY_MSG")) 33 | return 34 | note_name = note_name.lower() 35 | msg = message.reply_to_message 36 | copied_msg = await msg.copy(int(Config.LOG_GRP)) 37 | await add_note(note_name, message.chat.id, copied_msg.message_id) 38 | await note_.edit(engine.get_string("FILTER_5").format(note_name, "Note")) 39 | 40 | 41 | @listen(filters.incoming & filters.regex("\#(\S+)")) 42 | async def lmao(client, message): 43 | engine = message.Engine 44 | if not await all_note(message.chat.id): 45 | return 46 | owo = message.matches[0].group(1) 47 | if owo is None: 48 | return 49 | if await note_info(owo, message.chat.id): 50 | sed = await note_info(owo, message.chat.id) 51 | await client.copy_message( 52 | from_chat_id=int(Config.LOG_GRP), 53 | chat_id=message.chat.id, 54 | message_id=sed["msg_id"], 55 | reply_to_message_id=message.message_id, 56 | ) 57 | 58 | 59 | 60 | @friday_on_cmd( 61 | ["delnote"], 62 | cmd_help={"help": "Delete Note In The Chat!", "example": "{ch}delnote (Note Name)"}, 63 | ) 64 | async def notes(client, message): 65 | engine = message.Engine 66 | note_ = await edit_or_reply(message, engine.get_string("PROCESSING")) 67 | note_name = get_text(message) 68 | if not note_name: 69 | await note_.edit(engine.get_string("INPUT_REQ").format("Note Name")) 70 | return 71 | note_name = note_name.lower() 72 | if not await note_info(note_name, message.chat.id): 73 | await note_.edit(engine.get_string("FILTER_1").format("NOTE", note_name)) 74 | return 75 | await del_note(note_name, message.chat.id) 76 | await note_.edit(engine.get_string("NOT_ADDED").format(note_name)) 77 | 78 | 79 | @friday_on_cmd( 80 | ["delnotes"], 81 | cmd_help={"help": "Delete All The Notes In The Chat!", "example": "{ch}delnotes"}, 82 | ) 83 | async def noteses(client, message): 84 | engine = message.Engine 85 | pablo = await edit_or_reply(message, engine.get_string("PROCESSING")) 86 | poppy = await all_note(message.chat.id) 87 | if poppy is False: 88 | await pablo.edit(engine.get_string("FILTER_3").format("Notes")) 89 | return 90 | await del_notes(message.chat.id) 91 | await pablo.edit(engine.get_string("REMOVED_ALL").format("Notes")) 92 | 93 | 94 | @friday_on_cmd( 95 | ["notes"], 96 | cmd_help={"help": "List All The Chat Notes!", "example": "{ch}notes"}, 97 | ) 98 | async def noteses(client, message): 99 | engine = message.Engine 100 | pablo = await edit_or_reply(message, engine.get_string("PROCESSING")) 101 | poppy = await all_note(message.chat.id) 102 | if poppy is False: 103 | await pablo.edit(engine.get_string("FILTER_3").format("Notes")) 104 | return 105 | kk = "".join(f"""\n~ `{Escobar.get("keyword")}`""" for Escobar in poppy) 106 | X = await client.get_chat(message.chat.id) 107 | grp_nme = X.title 108 | mag = engine.get_string("LIST_OF").format("Notes", grp_nme, kk) 109 | mag += "\n\nGet Notes With `#Notename`" 110 | await pablo.edit(mag) 111 | -------------------------------------------------------------------------------- /plugins/paste.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | import os 10 | import aiohttp 11 | from main_startup.core.decorators import friday_on_cmd 12 | from main_startup.helper_func.basic_helpers import edit_or_reply, get_text 13 | 14 | 15 | 16 | @friday_on_cmd( 17 | ["paste"], 18 | cmd_help={ 19 | "help": "Pastes The File Text In Nekobin!", 20 | "example": "{ch}paste (reply to file)", 21 | }, 22 | ) 23 | async def paste(client, message): 24 | engine = message.Engine 25 | pablo = await edit_or_reply(message, engine.get_string("PROCESSING")) 26 | tex_t = get_text(message) 27 | message_s = tex_t 28 | if not tex_t: 29 | if not message.reply_to_message: 30 | await pablo.edit(engine.get_string("NEEDS_REPLY").format("File / Text")) 31 | return 32 | if not message.reply_to_message.text: 33 | file = await message.reply_to_message.download() 34 | m_list = open(file, "r").read() 35 | message_s = m_list 36 | os.remove(file) 37 | else: 38 | message_s = message.reply_to_message.text 39 | url = "https://hastebin.com/documents" 40 | if not message_s: 41 | await pablo.edit(engine.get_string("NEEDS_REPLY").format("File / Text")) 42 | return 43 | async with aiohttp.ClientSession() as session: 44 | req = await session.post(url, data=message_s.encode('utf-8'), timeout=3) 45 | resp = await req.json() 46 | key = resp.get("key") 47 | url = f"https://hastebin.com/{key}" 48 | raw = f"https://hastebin.com/raw/{key}" 49 | reply_text = engine.get_string("PASTED").format(url, raw) 50 | await pablo.edit(reply_text) 51 | -------------------------------------------------------------------------------- /plugins/rename.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | import time 10 | 11 | from main_startup.core.decorators import friday_on_cmd 12 | from main_startup.helper_func.basic_helpers import edit_or_reply, get_text, progress 13 | 14 | 15 | @friday_on_cmd( 16 | ["rename", "rupload"], 17 | cmd_help={ 18 | "help": "Rename File!", 19 | "example": "{ch}rename (reply to file) (new name)", 20 | }, 21 | ) 22 | async def rename(client, message): 23 | engine = message.Engine 24 | pablo = await edit_or_reply(message, engine.get_string("PROCESSING")) 25 | fname = get_text(message) 26 | if not fname: 27 | await pablo.edit(engine.get_string("INPUT_REQ").format("File Name")) 28 | return 29 | if not message.reply_to_message: 30 | await pablo.edit(engine.get_string("NEEDS_REPLY").format("Media")) 31 | return 32 | await pablo.edit(engine.get_string("R_P")) 33 | file_name = None 34 | try: 35 | file_name = message.reply_to_message.document.file_name 36 | except: 37 | pass 38 | if file_name: 39 | Kk = fname.split(".") 40 | try: 41 | Kk[1] 42 | except: 43 | fuck = file_name.rpartition(".")[-1] 44 | fname = fname + "." + fuck 45 | EsCoBaR = await message.reply_to_message.download(fname) 46 | caption = message.reply_to_message.caption or "" 47 | c_time = time.time() 48 | await client.send_document( 49 | message.chat.id, 50 | EsCoBaR, 51 | caption=caption, 52 | progress=progress, 53 | progress_args=(pablo, c_time, f"`Uploading {fname}`", EsCoBaR), 54 | ) 55 | await pablo.delete() 56 | -------------------------------------------------------------------------------- /plugins/search.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | import re 10 | import urllib 11 | import urllib.parse 12 | 13 | import requests 14 | from bs4 import BeautifulSoup 15 | from fake_useragent import UserAgent 16 | 17 | from main_startup.core.decorators import friday_on_cmd 18 | from main_startup.helper_func.basic_helpers import edit_or_reply, get_text 19 | 20 | 21 | @friday_on_cmd( 22 | ["duckduckgo", "ddg"], 23 | cmd_help={"help": "duckduckgo searcher!", "example": "{ch}ddg (query to search)"}, 24 | ) 25 | async def duckduckgo(client, message): 26 | engine = message.Engine 27 | pablo = await edit_or_reply(message, engine.get_string("PROCESSING")) 28 | query = get_text(message) 29 | if not query: 30 | await pablo.edit(engine.get_string("INPUT_REQ").format("query")) 31 | return 32 | sample_url = "https://duckduckgo.com/?q={}".format(query.replace(" ", "+")) 33 | link = sample_url.rstrip() 34 | await pablo.edit( 35 | engine.get_string("DUCK_DUCK_GO").format(query, link) 36 | ) 37 | 38 | 39 | @friday_on_cmd( 40 | ["gs", "grs", "google"], 41 | cmd_help={"help": "Google Searcher!", "example": "{ch}gs (query to search)"}, 42 | ) 43 | async def grs(client, message): 44 | engine = message.Engine 45 | pablo = await edit_or_reply(message, engine.get_string("PROCESSING")) 46 | query = get_text(message) 47 | if not query: 48 | await pablo.edit(engine.get_string("INPUT_REQ").format("query")) 49 | return 50 | query = urllib.parse.quote_plus(query) 51 | number_result = 8 52 | ua = UserAgent() 53 | google_url = ( 54 | "https://www.google.com/search?q=" + query + "&num=" + str(number_result) 55 | ) 56 | response = requests.get(google_url, {"User-Agent": ua.random}) 57 | soup = BeautifulSoup(response.text, "html.parser") 58 | result_div = soup.find_all("div", attrs={"class": "ZINbbc"}) 59 | links = [] 60 | titles = [] 61 | descriptions = [] 62 | for r in result_div: 63 | try: 64 | link = r.find("a", href=True) 65 | title = r.find("div", attrs={"class": "vvjwJb"}).get_text() 66 | description = r.find("div", attrs={"class": "s3v9rd"}).get_text() 67 | if link != "" and title != "" and description != "": 68 | links.append(link["href"]) 69 | titles.append(title) 70 | descriptions.append(description) 71 | 72 | except: 73 | continue 74 | to_remove = [] 75 | clean_links = [] 76 | for i, l in enumerate(links): 77 | clean = re.search("\/url\?q\=(.*)\&sa", l) 78 | if clean is None: 79 | to_remove.append(i) 80 | continue 81 | clean_links.append(clean.group(1)) 82 | for x in to_remove: 83 | del titles[x] 84 | del descriptions[x] 85 | msg = "".join( 86 | f"[{tt}]({liek})\n`{d}`\n\n" 87 | for tt, liek, d in zip(titles, clean_links, descriptions) 88 | ) 89 | 90 | 91 | await pablo.edit("**Search Query:**\n`" + query + "`\n\n**Results:**\n" + msg) 92 | -------------------------------------------------------------------------------- /plugins/stats.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | from datetime import datetime 10 | 11 | from main_startup.core.decorators import friday_on_cmd 12 | from main_startup.helper_func.basic_helpers import edit_or_reply, get_text, progress 13 | 14 | 15 | @friday_on_cmd( 16 | ["stats", "stat"], 17 | cmd_help={ 18 | "help": "Shows user account stats!", 19 | "example": "{ch}stats", 20 | }, 21 | ) 22 | async def stats(client, message): 23 | engine = message.Engine 24 | pablo = await edit_or_reply(message, engine.get_string("PROCESSING")) 25 | start = datetime.now() 26 | u = 0 27 | g = 0 28 | sg = 0 29 | c = 0 30 | b = 0 31 | a_chat = 0 32 | group = ["supergroup", "group"] 33 | async for dialog in client.iter_dialogs(): 34 | if dialog.chat.type == "private": 35 | u += 1 36 | elif dialog.chat.type == "bot": 37 | b += 1 38 | elif dialog.chat.type == "group": 39 | g += 1 40 | elif dialog.chat.type == "supergroup": 41 | sg += 1 42 | user_s = await dialog.chat.get_member(int(client.me.id)) 43 | if user_s.status in ("creator", "administrator"): 44 | a_chat += 1 45 | elif dialog.chat.type == "channel": 46 | c += 1 47 | end = datetime.now() 48 | ms = (end - start).seconds 49 | await pablo.edit(engine.get_string("STATS").format(ms, u, g, sg, c, a_chat, b)) 50 | -------------------------------------------------------------------------------- /plugins/stickers.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | import asyncio 10 | import datetime 11 | import math 12 | import os 13 | import zipfile 14 | from collections import defaultdict 15 | from io import BytesIO 16 | 17 | from PIL import Image 18 | from pyrogram import emoji 19 | from pyrogram.errors import StickersetInvalid, YouBlockedUser 20 | from pyrogram.raw.functions.messages import GetStickerSet 21 | from pyrogram.raw.types import InputStickerSetShortName 22 | 23 | from main_startup.core.decorators import friday_on_cmd 24 | from main_startup.helper_func.basic_helpers import edit_or_reply, get_text 25 | from main_startup.helper_func.plugin_helpers import convert_to_image 26 | 27 | 28 | @friday_on_cmd( 29 | ["packinfo"], 30 | cmd_help={ 31 | "help": "Get Sticker Pack Info!", 32 | "example": "{ch}packinfo (reply to sticker)", 33 | }, 34 | ) 35 | async def packinfo(client, message): 36 | engine = message.Engine 37 | pablo = await edit_or_reply(message, engine.get_string("PROCESSING")) 38 | if not message.reply_to_message: 39 | await pablo.edit(engine.get_string("NEEDS_REPLY").format("Sticker")) 40 | return 41 | if not message.reply_to_message.sticker: 42 | await pablo.edit(engine.get_string("NEEDS_REPLY").format("Sticker")) 43 | return 44 | if not message.reply_to_message.sticker.set_name: 45 | await pablo.delete() 46 | return 47 | stickerset = await client.send( 48 | GetStickerSet( 49 | stickerset=InputStickerSetShortName( 50 | short_name=message.reply_to_message.sticker.set_name 51 | ) 52 | ) 53 | ) 54 | emojis = [] 55 | for stucker in stickerset.packs: 56 | if stucker.emoticon not in emojis: 57 | emojis.append(stucker.emoticon) 58 | output = f"""**Sticker Pack Title **: `{stickerset.set.title}` 59 | **Sticker Pack Short Name **: `{stickerset.set.short_name}` 60 | **Stickers Count **: `{stickerset.set.count}` 61 | **Archived **: `{stickerset.set.archived}` 62 | **Official **: `{stickerset.set.official}` 63 | **Masks **: `{stickerset.set.masks}` 64 | **Animated **: `{stickerset.set.animated}` 65 | **Emojis In Pack **: `{' '.join(emojis)}` 66 | """ 67 | await pablo.edit(output) 68 | 69 | 70 | @friday_on_cmd( 71 | ["kang"], 72 | cmd_help={ 73 | "help": "Get Sticker Pack Info!", 74 | "example": "{ch}packinfo (reply to sticker)", 75 | }, 76 | ) 77 | async def packinfo(client, message): 78 | engine = message.Engine 79 | pablo = await edit_or_reply(message, engine.get_string("KANG_MAGIC_")) 80 | if not message.reply_to_message: 81 | await pablo.edit(engine.get_string("NEEDS_REPLY").format("Sticker")) 82 | return 83 | Hell = get_text(message) 84 | name = "" 85 | pack = 1 86 | nm = message.from_user.username 87 | if nm: 88 | nam = message.from_user.username 89 | name = nam[1:] 90 | else: 91 | name = message.from_user.first_name 92 | packname = f"@{nm} Kang Pack {pack}" 93 | packshortname = f"FRIDAY_{message.from_user.id}_{pack}" 94 | non = [None, "None"] 95 | emoji = "😁" 96 | try: 97 | Hell = Hell.strip() 98 | if Hell.isalpha(): 99 | emoji = "😁" 100 | elif not Hell.isnumeric(): 101 | emoji = Hell 102 | except: 103 | emoji = "😁" 104 | exist = None 105 | is_anim = False 106 | if message.reply_to_message.sticker: 107 | if not Hell: 108 | emoji = message.reply_to_message.sticker.emoji or "😁" 109 | is_anim = message.reply_to_message.sticker.is_animated 110 | if is_anim: 111 | packshortname += "_animated" 112 | packname += " Animated" 113 | if message.reply_to_message.sticker.mime_type == "application/x-tgsticker": 114 | file_name = await message.reply_to_message.download("AnimatedSticker.tgs") 115 | else: 116 | cool = await convert_to_image(message, client) 117 | if not cool: 118 | await pablo.edit(engine.get_string("UNSUPPORTED").format("Media")) 119 | return 120 | file_name = resize_image(cool) 121 | elif message.reply_to_message.document: 122 | if message.reply_to_message.document.mime_type == "application/x-tgsticker": 123 | is_anim = True 124 | packshortname += "_animated" 125 | packname += " Animated" 126 | file_name = await message.reply_to_message.download("AnimatedSticker.tgs") 127 | else: 128 | cool = await convert_to_image(message, client) 129 | if not cool: 130 | await pablo.edit(engine.get_string("UNSUPPORTED").format("Media")) 131 | return 132 | file_name = resize_image(cool) 133 | try: 134 | exist = await client.send( 135 | GetStickerSet(stickerset=InputStickerSetShortName(short_name=packshortname)) 136 | ) 137 | except StickersetInvalid: 138 | pass 139 | if exist: 140 | try: 141 | await client.send_message("stickers", "/addsticker") 142 | except YouBlockedUser: 143 | await pablo.edit("`Please Unblock @Stickers`") 144 | await client.unblock_user("stickers") 145 | await client.send_message("stickers", packshortname) 146 | await asyncio.sleep(0.2) 147 | limit = "50" if is_anim else "120" 148 | messi = (await client.get_history("stickers", 1))[0] 149 | while limit in messi.text: 150 | pack += 1 151 | prev_pack = int(pack) - 1 152 | await pablo.edit(engine.get_string("KANG_FULL").format(prev_pack, pack)) 153 | packname = f"@{nm} Kang Pack {pack}" 154 | packshortname = f"FRIDAY_{message.from_user.id}_{pack}" 155 | if is_anim: 156 | packshortname += "_animated" 157 | packname += " Animated" 158 | await client.send_message("stickers", packshortname) 159 | await asyncio.sleep(0.2) 160 | messi = (await client.get_history("stickers", 1))[0] 161 | if messi.text == "Invalid pack selected.": 162 | if is_anim: 163 | await client.send_message("stickers", "/newanimated") 164 | else: 165 | await client.send_message("stickers", "/newpack") 166 | await asyncio.sleep(0.5) 167 | await client.send_message("stickers", packname) 168 | await asyncio.sleep(0.2) 169 | await client.send_document("stickers", file_name) 170 | await asyncio.sleep(1) 171 | await client.send_message("stickers", emoji) 172 | await asyncio.sleep(0.5) 173 | await client.send_message("stickers", "/publish") 174 | if is_anim: 175 | await client.send_message("stickers", f"<{packname}>") 176 | await client.send_message("stickers", "/skip") 177 | await asyncio.sleep(0.5) 178 | await client.send_message("stickers", packshortname) 179 | await pablo.edit(engine.get_string("ADDED_STICKER").format(emoji, packshortname)) 180 | return 181 | await client.send_document("stickers", file_name) 182 | await asyncio.sleep(1) 183 | await client.send_message("stickers", emoji) 184 | await asyncio.sleep(0.5) 185 | await client.send_message("stickers", "/done") 186 | await pablo.edit(engine.get_string("ADDED_STICKER").format(emoji, packshortname)) 187 | else: 188 | if is_anim: 189 | await client.send_message("stickers", "/newanimated") 190 | else: 191 | await client.send_message("stickers", "/newpack") 192 | await client.send_message("stickers", packname) 193 | await asyncio.sleep(0.2) 194 | await client.send_document("stickers", file_name) 195 | await asyncio.sleep(1) 196 | await client.send_message("stickers", emoji) 197 | await asyncio.sleep(0.5) 198 | await client.send_message("stickers", "/publish") 199 | await asyncio.sleep(0.5) 200 | if is_anim: 201 | await client.send_message("stickers", f"<{packname}>") 202 | await client.send_message("stickers", "/skip") 203 | await asyncio.sleep(0.5) 204 | await client.send_message("stickers", packshortname) 205 | await pablo.edit(engine.get_string("ADDED_STICKER").format(emoji, packshortname)) 206 | if os.path.exists(file_name): 207 | os.remove(file_name) 208 | 209 | 210 | def resize_image(image): 211 | im = Image.open(image) 212 | if (im.width and im.height) < 512: 213 | size1 = im.width 214 | size2 = im.height 215 | if im.width > im.height: 216 | scale = 512 / size1 217 | size1new = 512 218 | size2new = size2 * scale 219 | else: 220 | scale = 512 / size2 221 | size1new = size1 * scale 222 | size2new = 512 223 | size1new = math.floor(size1new) 224 | size2new = math.floor(size2new) 225 | sizenew = (size1new, size2new) 226 | im = im.resize(sizenew) 227 | else: 228 | maxsize = (512, 512) 229 | im.thumbnail(maxsize) 230 | file_name = "Sticker_FridayUB.png" 231 | im.save(file_name, "PNG") 232 | if os.path.exists(image): 233 | os.remove(image) 234 | return file_name 235 | -------------------------------------------------------------------------------- /plugins/sudo_manager.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | 10 | from pyrogram import filters 11 | 12 | from main_startup.config_var import Config 13 | from main_startup.core.decorators import friday_on_cmd, listen 14 | from main_startup.helper_func.basic_helpers import ( 15 | edit_or_reply, 16 | edit_or_send_as_file, 17 | get_text, 18 | get_user, 19 | iter_chats, 20 | ) 21 | from main_startup.helper_func.logger_s import LogIt 22 | from database.sudodb import is_user_sudo, sudo_list, add_sudo, rm_sudo 23 | from plugins import devs_id 24 | 25 | 26 | @friday_on_cmd(['addsudo'], 27 | disable_sudo=True, 28 | cmd_help={ 29 | "help": "Add User To Sudo List.", 30 | "example": "{ch}addsudo (reply_to_user)", 31 | }) 32 | async def add_s_sudo(client, message): 33 | engine = message.Engine 34 | msg_ = await edit_or_reply(message, engine.get_string("PROCESSING")) 35 | text_ = get_text(message) 36 | user = get_user(message, text_)[0] 37 | if not user: 38 | await msg_.edit(engine.get_string("REPLY_TO_USER").format("Sudo")) 39 | return 40 | try: 41 | user = await client.get_users(user) 42 | except BaseException as e: 43 | await msg_.edit(engine.get_string("USER_MISSING").format(e)) 44 | return 45 | if user.id == client.me.id: 46 | await msg_.delete() 47 | return 48 | if await is_user_sudo(user.id): 49 | return await msg_.edit(engine.get_string("USER_ALREADY_IN_SUDODB").format(user.mention)) 50 | await add_sudo(int(user.id)) 51 | await msg_.edit(engine.get_string("ADDED_TO_SUDO").format(user.mention)) 52 | 53 | @friday_on_cmd(['rmsudo'], 54 | disable_sudo=True, 55 | cmd_help={ 56 | "help": "Remove User From Sudo List.", 57 | "example": "{ch}rmsudo (reply_to_user)", 58 | }) 59 | async def rm_s_sudo(client, message): 60 | engine = message.Engine 61 | msg_ = await edit_or_reply(message, engine.get_string("PROCESSING")) 62 | text_ = get_text(message) 63 | user = get_user(message, text_)[0] 64 | if not user: 65 | await msg_.edit(engine.get_string("REPLY_TO_USER").format("Un-Sudo")) 66 | return 67 | try: 68 | user = await client.get_users(user) 69 | except BaseException as e: 70 | await msg_.edit(engine.get_string("USER_MISSING").format(e)) 71 | return 72 | if not await is_user_sudo(user.id): 73 | return await msg_.edit(engine.get_string("USER_ALREADY_NOT_IN_SUDODB").format(user.mention)) 74 | await rm_sudo(int(user.id)) 75 | await msg_.edit(engine.get_string("RM_FROM_SUDO").format(user.mention)) 76 | -------------------------------------------------------------------------------- /plugins/sys_utils.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | import platform 10 | import re 11 | import socket 12 | import sys 13 | import time 14 | import uuid 15 | from datetime import datetime 16 | from os import environ, execle, path, remove 17 | 18 | import psutil 19 | from pyrogram import __version__ 20 | 21 | from main_startup import Config, friday_version, start_time 22 | from main_startup.core.decorators import friday_on_cmd 23 | from main_startup.helper_func.basic_helpers import ( 24 | delete_or_pass, 25 | edit_or_reply, 26 | get_readable_time, 27 | humanbytes, 28 | ) 29 | 30 | 31 | @friday_on_cmd( 32 | ["ping", "pong"], 33 | cmd_help={"help": "Check Bot Uptime!", "example": "{ch}ping"}, 34 | ) 35 | async def pingy(client, message): 36 | start = datetime.now() 37 | hmm = await edit_or_reply(message, "`Pong!`") 38 | uptime = get_readable_time((time.time() - start_time)) 39 | myself = client.me 40 | mys = myself.id if not myself.username else f"@{myself.username}" 41 | end = datetime.now() 42 | ms = (end - start).microseconds / 1000 43 | await hmm.edit( 44 | f"**█▀█ █▀█ █▄░█ █▀▀ █ \n█▀▀ █▄█ █░▀█ █▄█ ▄**\n➲ `{round(ms)}ms` \n➲ `{uptime}` \n➲ `{mys}`" 45 | ) 46 | 47 | 48 | @friday_on_cmd( 49 | ["alive"], 50 | cmd_help={"help": "Get Alive Message Of Your Bot.!", "example": "{ch}alive"}, 51 | ) 52 | async def amialive(client, message): 53 | engine = message.Engine 54 | img_ = Config.ALIVE_IMG 55 | me_ = client.me.first_name 56 | du = psutil.disk_usage(client.workdir) 57 | disk = f"{humanbytes(du.used)} / {humanbytes(du.total)} " f"({du.percent}%)" 58 | alive = engine.get_string("ALIVE_").format(me_, friday_version, get_readable_time((time.time() - start_time)), __version__, platform.python_version(), platform.system(), len(psutil.Process().cpu_affinity()), disk) 59 | if message.reply_to_message: 60 | await client.send_photo( 61 | message.chat.id, 62 | img_, 63 | caption=alive, 64 | reply_to_message_id=message.reply_to_message.message_id, 65 | ) 66 | else: 67 | await client.send_photo(message.chat.id, img_, caption=alive) 68 | await delete_or_pass(message) 69 | 70 | 71 | @friday_on_cmd( 72 | ["sysinfo", "neofetch"], 73 | cmd_help={"help": "Get System Information!", "example": "{ch}sysinfo"}, 74 | ) 75 | async def give_sysinfo(client, message): 76 | splatform = platform.system() 77 | platform_release = platform.release() 78 | platform_version = platform.version() 79 | architecture = platform.machine() 80 | hostname = socket.gethostname() 81 | ip_address = socket.gethostbyname(socket.gethostname()) 82 | mac_address = ":".join(re.findall("..", "%012x" % uuid.getnode())) 83 | processor = platform.processor() 84 | ram = humanbytes(round(psutil.virtual_memory().total)) 85 | cpu_freq = psutil.cpu_freq().current 86 | if cpu_freq >= 1000: 87 | cpu_freq = f"{round(cpu_freq / 1000, 2)}GHz" 88 | else: 89 | cpu_freq = f"{round(cpu_freq, 2)}MHz" 90 | du = psutil.disk_usage(client.workdir) 91 | psutil.disk_io_counters() 92 | disk = f"{humanbytes(du.used)} / {humanbytes(du.total)} " f"({du.percent}%)" 93 | cpu_len = len(psutil.Process().cpu_affinity()) 94 | neat_msg = f"""**System Info** 95 | 96 | **PlatForm :** `{splatform}` 97 | **PlatForm - Release :** `{platform_release}` 98 | **PlatFork - Version :** `{platform_version}` 99 | **Architecture :** `{architecture}` 100 | **Hostname :** `{hostname}` 101 | **IP :** `{ip_address}` 102 | **Mac :** `{mac_address}` 103 | **Processor :** `{processor}` 104 | **Ram : ** `{ram}` 105 | **CPU :** `{cpu_len}` 106 | **CPU FREQ :** `{cpu_freq}` 107 | **DISK :** `{disk}` 108 | """ 109 | await edit_or_reply(message, neat_msg) 110 | 111 | 112 | @friday_on_cmd( 113 | ["restart"], 114 | cmd_help={"help": "Restart Your Bot!", "example": "{ch}restart"}, 115 | ) 116 | async def wow_restart(client, message): 117 | engine = message.Engine 118 | await edit_or_reply(message, engine.get_string("RESTART")) 119 | args = [sys.executable, "-m", "main_startup"] 120 | execle(sys.executable, *args, environ) 121 | exit() 122 | return 123 | -------------------------------------------------------------------------------- /plugins/telegraph.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | 10 | import os 11 | 12 | from telegraph import Telegraph, exceptions, upload_file 13 | 14 | from main_startup.core.decorators import friday_on_cmd 15 | from main_startup.helper_func.basic_helpers import edit_or_reply, get_text 16 | from main_startup.helper_func.plugin_helpers import convert_to_image 17 | 18 | telegraph = Telegraph() 19 | r = telegraph.create_account(short_name="FridayUB") 20 | auth_url = r["auth_url"] 21 | 22 | 23 | @friday_on_cmd( 24 | ["telegraph"], 25 | cmd_help={ 26 | "help": "Get Telegraph link of replied image", 27 | "example": "{ch}telegraph (reply to text or image)", 28 | }, 29 | ) 30 | async def telegrapher(client, message): 31 | engine = message.Engine 32 | pablo = await edit_or_reply(message, engine.get_string("PROCESSING")) 33 | if not message.reply_to_message: 34 | await pablo.edit(engine.get_string("NEEDS_REPLY").format("Media")) 35 | return 36 | if message.reply_to_message.media: 37 | # Assume its media 38 | if message.reply_to_message.sticker: 39 | m_d = await convert_to_image(message, client) 40 | else: 41 | m_d = await message.reply_to_message.download() 42 | try: 43 | media_url = upload_file(m_d) 44 | except exceptions.TelegraphException as exc: 45 | await pablo.edit( 46 | engine.get_string("TELEGRAPH_UP_FAILED").format(exc) 47 | ) 48 | os.remove(m_d) 49 | return 50 | U_done = engine.get_string("TELEGRAPH").format(media_url[0]) 51 | await pablo.edit(U_done, disable_web_page_preview=False) 52 | os.remove(m_d) 53 | elif message.reply_to_message.text: 54 | # Assuming its text 55 | page_title = get_text(message) or client.me.first_name 56 | page_text = message.reply_to_message.text 57 | page_text = page_text.replace("\n", "
") 58 | try: 59 | response = telegraph.create_page(page_title, html_content=page_text) 60 | except exceptions.TelegraphException as exc: 61 | await pablo.edit(engine.get_string("TELEGRAPH_UP_FAILED").format(exc)) 62 | return 63 | wow_graph = engine.get_string("TELEGRAPH").format(response['path']) 64 | await pablo.edit(wow_graph, disable_web_page_preview=False) 65 | -------------------------------------------------------------------------------- /plugins/tts_tr.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | import os 10 | import time 11 | import gtts 12 | import requests 13 | from googletrans import LANGUAGES, Translator 14 | from gtts import gTTS 15 | from hachoir.metadata import extractMetadata 16 | from hachoir.parser import createParser 17 | from langdetect import detect 18 | 19 | from main_startup.core.decorators import friday_on_cmd 20 | from main_startup.helper_func.basic_helpers import edit_or_reply, get_text, run_in_exc 21 | 22 | @run_in_exc 23 | def tr(text, lang): 24 | translator = Translator() 25 | if not LANGUAGES.get(lang): 26 | return None, None, None 27 | translated = translator.translate(text, dest=lang, src='auto') 28 | source_lan = LANGUAGES.get(translated.src.lower()) 29 | transl_lan = LANGUAGES.get(translated.dest.lower()) 30 | return source_lan, transl_lan, translated 31 | 32 | @run_in_exc 33 | def parse_tts(text_, lang, file): 34 | tts = gTTS(text_, lang=lang) 35 | tts.save(file) 36 | try: 37 | dec_s = detect(text_) 38 | except: 39 | dec_s = "unknown" 40 | duration = 0 41 | metadata = extractMetadata(createParser(file)) 42 | if metadata and metadata.has("duration"): 43 | duration = metadata.get("duration").seconds 44 | return file, dec_s, duration 45 | 46 | 47 | @friday_on_cmd( 48 | ["tts", "voice", "texttospeech"], 49 | cmd_help={ 50 | "help": "Convert Text To Speech!", 51 | "example": "{ch}voice (reply to text) (Language code)", 52 | }, 53 | ) 54 | async def gibspeech(client, message): 55 | engine = message.Engine 56 | stime = time.time() 57 | event = await edit_or_reply(message, engine.get_string("PROCESSING")) 58 | ttslang = get_text(message) 59 | if not message.reply_to_message: 60 | await event.edit(engine.get_string("NEEDS_REPLY").format("Convert To Speech")) 61 | return 62 | if not message.reply_to_message.text: 63 | await event.edit(engine.get_string("NEEDS_REPLY").format("Convert To Speech")) 64 | return 65 | text = message.reply_to_message.text 66 | language = "en" if not ttslang else ttslang 67 | kk = gtts.lang.tts_langs() 68 | if not kk.get(language): 69 | await event.edit(engine.get_string("UNSUPPORTED").format("Corrent Language Code")) 70 | return 71 | await client.send_chat_action(message.chat.id, "record_audio") 72 | file = f"{kk.get(language)}.ogg" 73 | file, dec_s, duration = await parse_tts(text, language, file) 74 | etime = time.time() 75 | hmm_time = round(etime - stime) 76 | owoc = f"**TTS** \n**Detected Text Language :** `{dec_s.capitalize()}` \n**Speech Text :** `{kk.get(language)}` \n**Time Taken :** `{hmm_time}s` \n__Powered By @FridayOT__" 77 | await message.reply_audio( 78 | audio=file, caption=owoc, duration=duration 79 | ) 80 | await client.send_chat_action(message.chat.id, action="cancel") 81 | if os.path.exists(file): 82 | os.remove(file) 83 | await event.delete() 84 | 85 | 86 | @friday_on_cmd( 87 | ["tr", "translate"], 88 | cmd_help={ 89 | "help": "Translate text from one Language To Another!", 90 | "example": "{ch}tr (reply to text) (language-code)", 91 | }, 92 | ) 93 | async def tr_pls(client, message): 94 | engine = message.Engine 95 | event = await edit_or_reply(message, engine.get_string("PROCESSING")) 96 | lang = get_text(message) 97 | if not lang: 98 | lang = "en" 99 | if not message.reply_to_message: 100 | await event.edit(engine.get_string("NEEDS_REPLY").format("Translate It")) 101 | return 102 | if not message.reply_to_message.text: 103 | await event.edit(engine.get_string("NEEDS_REPLY").format("Translate It")) 104 | return 105 | text = message.reply_to_message.text 106 | source_lan, transl_lan, translated = await tr(text, lang) 107 | if not source_lan: 108 | return await event.edit(engine.get_string("NEEDS_C_INPUT")) 109 | tr_text = f"""Source ({source_lan.capitalize()}) 110 | Translation ({transl_lan.capitalize()}): 111 | {translated}""" 112 | if len(tr_text) >= 4096: 113 | url = "https://del.dog/documents" 114 | r = requests.post(url, data=translated.encode("UTF-8")).json() 115 | url2 = f"https://del.dog/{r['key']}" 116 | tr_text = ( 117 | engine.get_string("TOO_BIG").format(url2) 118 | ) 119 | await event.edit(tr_text) 120 | -------------------------------------------------------------------------------- /plugins/updater.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | import sys 10 | from datetime import datetime 11 | from os import environ, execle, path, remove 12 | 13 | import heroku3 14 | from git import Repo 15 | from git.exc import GitCommandError, InvalidGitRepositoryError, NoSuchPathError 16 | 17 | from main_startup.config_var import Config 18 | from main_startup.core.decorators import friday_on_cmd, listen 19 | from main_startup.core.startup_helpers import run_cmd 20 | from main_startup.helper_func.basic_helpers import edit_or_reply, get_text 21 | from main_startup.helper_func.logger_s import LogIt 22 | 23 | REPO_ = Config.UPSTREAM_REPO 24 | BRANCH_ = Config.U_BRANCH 25 | 26 | 27 | @friday_on_cmd( 28 | ["update"], cmd_help={"help": "Update Your UserBot!", "example": "{ch}update"} 29 | ) 30 | async def update_it(client, message): 31 | engine = message.Engine 32 | msg_ = await edit_or_reply(message, engine.get_string("UPDATING_PLS_WAIT")) 33 | try: 34 | repo = Repo() 35 | except GitCommandError: 36 | return await msg_.edit( 37 | engine.get_string("INVALID_GIT_CMD") 38 | ) 39 | except InvalidGitRepositoryError: 40 | repo = Repo.init() 41 | if "upstream" in repo.remotes: 42 | origin = repo.remote("upstream") 43 | else: 44 | origin = repo.create_remote("upstream", REPO_) 45 | origin.fetch() 46 | repo.create_head(Config.U_BRANCH, origin.refs.master) 47 | repo.heads.master.set_tracking_branch(origin.refs.master) 48 | repo.heads.master.checkout(True) 49 | if repo.active_branch.name != Config.U_BRANCH: 50 | return await msg_.edit( 51 | engine.get_sring("CUSTOM_BRANCH").format(repo.active_branch.name, Config.U_BRANCH) 52 | ) 53 | try: 54 | repo.create_remote("upstream", REPO_) 55 | except BaseException: 56 | pass 57 | ups_rem = repo.remote("upstream") 58 | ups_rem.fetch(Config.U_BRANCH) 59 | if not Config.HEROKU_URL: 60 | try: 61 | ups_rem.pull(Config.U_BRANCH) 62 | except GitCommandError: 63 | repo.git.reset("--hard", "FETCH_HEAD") 64 | await run_cmd("pip3 install --no-cache-dir -r requirements.txt") 65 | await msg_.edit(engine.get_string("UPDATED")) 66 | args = [sys.executable, "-m", "main_startup"] 67 | execle(sys.executable, *args, environ) 68 | exit() 69 | return 70 | else: 71 | await msg_.edit(engine.get_string("HEROKU_DETECTED")) 72 | ups_rem.fetch(Config.U_BRANCH) 73 | repo.git.reset("--hard", "FETCH_HEAD") 74 | if "heroku" in repo.remotes: 75 | remote = repo.remote("heroku") 76 | remote.set_url(Config.HEROKU_URL) 77 | else: 78 | remote = repo.create_remote("heroku", Config.HEROKU_URL) 79 | try: 80 | remote.push(refspec="HEAD:refs/heads/master", force=True) 81 | except BaseException as error: 82 | await msg_.edit(f"**Updater Error** \nTraceBack : `{error}`") 83 | return repo.__del__() 84 | -------------------------------------------------------------------------------- /plugins/videotools.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | import os 10 | import time 11 | 12 | from main_startup.core.decorators import friday_on_cmd 13 | from main_startup.core.startup_helpers import run_cmd 14 | from main_startup.helper_func.basic_helpers import ( 15 | edit_or_reply, 16 | edit_or_send_as_file, 17 | get_text, 18 | progress, 19 | ) 20 | from main_startup.helper_func.plugin_helpers import convert_vid_to_vidnote 21 | 22 | 23 | @friday_on_cmd( 24 | ["getsrt", "extractsubtitle"], 25 | cmd_help={ 26 | "help": "Get Subtitle / Srt from Any Video", 27 | "example": "{ch}getsrt (replying to video file)", 28 | }, 29 | ) 30 | async def get_str(client, message): 31 | engine = message.Engine 32 | msg_ = await edit_or_reply(message, engine.get_string("PROCESSING")) 33 | if not message.reply_to_message: 34 | await msg_.edit(engine.get_string("NEEDS_REPLY").format("Get Srt")) 35 | return 36 | if not message.reply_to_message.video: 37 | await msg_.edit(engine.get_string("NEEDS_REPLY").format("Get Srt")) 38 | return 39 | c_time = time.time() 40 | file_ = await message.reply_to_message.download( 41 | progress=progress, progress_args=(msg_, c_time, f"`Downloading This Video!`") 42 | ) 43 | file_name = (message.reply_to_message.video.file_name).split(".")[0] 44 | srt_file_name = str(file_name) + ".srt" 45 | cmd_to_un = f"ffmpeg -i {file_} {srt_file_name}" 46 | await run_cmd(cmd_to_un) 47 | if not os.path.exists(srt_file_name): 48 | await msg_.edit(engine.get_string("UNABLE_TO_CONVERT")) 49 | os.remove(file_) 50 | return 51 | if message.reply_to_message: 52 | await client.send_document( 53 | message.chat.id, 54 | srt_file_name, 55 | caption=f">> {file_name} <<", 56 | reply_to_message_id=message.reply_to_message.message_id, 57 | ) 58 | else: 59 | await client.send_document( 60 | message.chat.id, srt_file_name, caption=f">> {file_name} <<" 61 | ) 62 | await msg_.delete() 63 | for files in (file_, srt_file_name): 64 | if files and os.path.exists(files): 65 | os.remove(files) 66 | 67 | 68 | @friday_on_cmd( 69 | ["fastforward"], 70 | cmd_help={ 71 | "help": "Make Any Video / Gif Fast! (Fast Forward)", 72 | "example": "{ch}fastforward (replying to video file)", 73 | }, 74 | ) 75 | async def hell_speed_s(client, message): 76 | engine = message.Engine 77 | msg_ = await edit_or_reply(message, engine.get_string("PROCESSING")) 78 | if not message.reply_to_message: 79 | await msg_.edit(engine.get_string("NEEDS_REPLY").format("Fast Forward")) 80 | return 81 | if not (message.reply_to_message.video or message.reply_to_message.animation): 82 | await msg_.edit(engine.get_string("NEEDS_REPLY").format("Fast Forward")) 83 | return 84 | c_time = time.time() 85 | file_ = await message.reply_to_message.download( 86 | progress=progress, progress_args=(msg_, c_time, f"`Downloading This Video!`") 87 | ) 88 | file_name = "FastForwarded.mp4" 89 | cmd_to_un = f'ffmpeg -i {file_} -vf "setpts=0.25*PTS" {file_name}' 90 | await run_cmd(cmd_to_un) 91 | if not os.path.exists(file_name): 92 | await msg_.edit(engine.get_string("UNABLE_TO_CONVERT")) 93 | return 94 | if message.reply_to_message: 95 | await client.send_video( 96 | message.chat.id, 97 | file_name, 98 | reply_to_message_id=message.reply_to_message.message_id, 99 | progress=progress, 100 | progress_args=(msg_, c_time, f"`Uploading Fast Forwarded Video`"), 101 | ) 102 | else: 103 | await client.send_video( 104 | message.chat.id, 105 | file_name, 106 | progress=progress, 107 | progress_args=(msg_, c_time, f"`Uploading Fast Forwarded Video`"), 108 | ) 109 | await msg_.delete() 110 | for files in (file_, file_name): 111 | if files and os.path.exists(files): 112 | os.remove(files) 113 | 114 | 115 | @friday_on_cmd( 116 | ["slowdown"], 117 | cmd_help={ 118 | "help": "Make Any Video / Gif Slow! (Slow Down)", 119 | "example": "{ch}slowdown (replying to video file)", 120 | }, 121 | ) 122 | async def fking_slow(client, message): 123 | engine = message.Engine 124 | msg_ = await edit_or_reply(message, "`Please Halt!`") 125 | if not message.reply_to_message: 126 | await msg_.edit(engine.get_string("NEEDS_REPLY").format("Slow Down")) 127 | return 128 | if not (message.reply_to_message.video or message.reply_to_message.animation): 129 | await msg_.edit(engine.get_string("NEEDS_REPLY").format("Slow Down")) 130 | return 131 | c_time = time.time() 132 | file_ = await message.reply_to_message.download( 133 | progress=progress, progress_args=(msg_, c_time, f"`Downloading This Video!`") 134 | ) 135 | file_name = "SlowDown.mp4" 136 | cmd_to_un = f'ffmpeg -i {file_} -vf "setpts=4*PTS" {file_name}' 137 | await run_cmd(cmd_to_un) 138 | if not os.path.exists(file_name): 139 | await msg_.edit(engine.get_string("UNABLE_TO_CONVERT")) 140 | return 141 | if message.reply_to_message: 142 | await client.send_video( 143 | message.chat.id, 144 | file_name, 145 | reply_to_message_id=message.reply_to_message.message_id, 146 | progress=progress, 147 | progress_args=(msg_, c_time, f"`Uploading Slow Video`"), 148 | ) 149 | else: 150 | await client.send_video( 151 | message.chat.id, 152 | file_name, 153 | progress=progress, 154 | progress_args=(msg_, c_time, f"`Uploading Slow Video`"), 155 | ) 156 | await msg_.delete() 157 | for files in (file_, file_name): 158 | if files and os.path.exists(files): 159 | os.remove(files) 160 | 161 | 162 | @friday_on_cmd( 163 | ["vidnote"], 164 | cmd_help={ 165 | "help": "Make Any Video / Gif To Video Note", 166 | "example": "{ch}vidnote (replying to video file)", 167 | }, 168 | ) 169 | async def v_note(client, message): 170 | engine = message.Engine 171 | msg_ = await edit_or_reply(message, "`Please Halt!`") 172 | if not message.reply_to_message: 173 | await msg_.edit("`Please Reply To A Video To Convert To Video Note!`") 174 | return 175 | if not (message.reply_to_message.video or message.reply_to_message.animation): 176 | await msg_.edit("`Please Reply To A Video To Convert To Video Note!`") 177 | return 178 | c_time = time.time() 179 | file_ = await message.reply_to_message.download( 180 | progress=progress, 181 | progress_args=(msg_, c_time, f"`Downloading This Video/Gif!`"), 182 | ) 183 | file_name = "vid_note.mp4" 184 | await convert_vid_to_vidnote(file_, file_name) 185 | if not os.path.exists(file_name): 186 | await msg_.edit("`My Logic Broke! Rip`") 187 | return 188 | if message.reply_to_message: 189 | await client.send_video_note( 190 | message.chat.id, 191 | file_name, 192 | progress=progress, 193 | progress_args=(msg_, c_time, f"`Uploading Video Note`"), 194 | reply_to_message_id=message.reply_to_message.message_id, 195 | ) 196 | else: 197 | await client.send_video_note( 198 | message.chat.id, 199 | file_name, 200 | progress=progress, 201 | progress_args=(msg_, c_time, f"`Uploading Video Note`"), 202 | ) 203 | await msg_.delete() 204 | for files in (file_, file_name): 205 | if files and os.path.exists(files): 206 | os.remove(files) 207 | -------------------------------------------------------------------------------- /plugins/welcome.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | from pyrogram import filters 10 | 11 | from database.welcomedb import add_welcome, del_welcome, welcome_info 12 | from main_startup.config_var import Config 13 | from main_startup.core.decorators import friday_on_cmd, listen 14 | from main_startup.helper_func.basic_helpers import edit_or_reply 15 | 16 | 17 | @friday_on_cmd( 18 | ["savewelcome"], 19 | cmd_help={ 20 | "help": "Save Welcome Message!", 21 | "example": "{ch}savewelcome (reply to welcome message)", 22 | }, 23 | ) 24 | async def save_welcome(client, message): 25 | engine = message.Engine 26 | note_ = await edit_or_reply(message, engine.get_string("PROCESSING")) 27 | if not message.reply_to_message: 28 | await note_.edit(engine.get_string("REPLY_TO_WELCOME")) 29 | return 30 | msg = message.reply_to_message 31 | cool = await msg.copy(int(Config.LOG_GRP)) 32 | await add_welcome(int(message.chat.id), cool.message_id) 33 | await note_.edit(engine.get_string("WELCOME_SAVED")) 34 | 35 | 36 | @listen(filters.new_chat_members & filters.group) 37 | async def welcomenibba(client, message): 38 | engine = message.Engine 39 | if not message: 40 | return 41 | if not await welcome_info(int(message.chat.id)): 42 | return 43 | if not message.chat: 44 | return 45 | is_m = False 46 | sed = await welcome_info(int(message.chat.id)) 47 | m_s = await client.get_messages(int(Config.LOG_GRP), sed["msg_id"]) 48 | if await is_media(m_s): 49 | text_ = m_s.caption or "" 50 | is_m = True 51 | else: 52 | text_ = m_s.text or "" 53 | if text_ != "": 54 | mention = message.new_chat_members[0].mention 55 | user_id = message.new_chat_members[0].id 56 | user_name = message.new_chat_members[0].username or "No Username" 57 | first_name = message.new_chat_members[0].first_name 58 | last_name = message.new_chat_members[0].last_name or "No Last Name" 59 | text_ = text_.format(mention=mention, user_id=user_id, user_name=user_name, first_name=first_name, last_name=last_name) 60 | if not is_m: 61 | await client.send_message( 62 | message.chat.id, 63 | text_, 64 | reply_to_message_id=message.message_id) 65 | else: 66 | await m_s.copy( 67 | chat_id=int(message.chat.id), 68 | caption=text_, 69 | reply_to_message_id=message.message_id, 70 | ) 71 | 72 | 73 | 74 | async def is_media(message): 75 | return bool( 76 | ( 77 | message.photo 78 | or message.video 79 | or message.document 80 | or message.audio 81 | or message.sticker 82 | or message.animation 83 | or message.voice 84 | or message.video_note 85 | ) 86 | ) 87 | 88 | 89 | @friday_on_cmd( 90 | ["delwelcome"], 91 | cmd_help={"help": "Delete welcome Message!", "example": "{ch}delwelcome"}, 92 | ) 93 | async def del_welcomez(client, message): 94 | engine = message.Engine 95 | note_ = await edit_or_reply(message, engine.get_string("PROCESSING")) 96 | if not await welcome_info(int(message.chat.id)): 97 | await note_.edit(engine.get_string("FILTER_3").format("Welcome Message")) 98 | return 99 | await del_welcome(int(message.chat.id)) 100 | await note_.edit(engine.get_string("FILTER_2").format("Welcome", "Message")) 101 | 102 | 103 | @friday_on_cmd( 104 | ["welcome"], 105 | cmd_help={"help": "Current Welcome Message!", "example": "{ch}welcome"}, 106 | ) 107 | async def show_welcome(client, message): 108 | engine = message.Engine 109 | pablo = await edit_or_reply(message, engine.get_string("PROCESSING")) 110 | sed = await welcome_info(int(message.chat.id)) 111 | if sed is False: 112 | await pablo.edit(engine.get_string("FILTER_3").format("Welcome Message")) 113 | return 114 | mag = f""" Welcome Message In Correct Chat Is :""" 115 | await client.copy_message( 116 | from_chat_id=int(Config.LOG_GRP), 117 | chat_id=int(message.chat.id), 118 | message_id=sed["msg_id"], 119 | reply_to_message_id=message.message_id, 120 | ) 121 | await pablo.edit(mag) 122 | -------------------------------------------------------------------------------- /plugins/whois.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | import os 10 | 11 | from database.gbandb import gban_info, gban_list, gban_user, ungban_user 12 | from database.gmutedb import gmute, is_gmuted, ungmute 13 | from main_startup.core.decorators import friday_on_cmd 14 | from main_startup.helper_func.basic_helpers import ( 15 | edit_or_reply, 16 | edit_or_send_as_file, 17 | get_text, 18 | get_user, 19 | is_admin_or_owner, 20 | ) 21 | from plugins import devs_id 22 | 23 | 24 | @friday_on_cmd( 25 | ["get_id"], 26 | cmd_help={"help": "Get Current Chat ID!", "example": "{ch}get_id"}, 27 | ) 28 | async def wew_id(client, message): 29 | t_xt = f"Chat ID : `{message.chat.id}`" 30 | pablo = await edit_or_reply(message, t_xt) 31 | 32 | 33 | @friday_on_cmd( 34 | ["info", "whois"], 35 | cmd_help={"help": "Get Info About A User", "example": "{ch}info @chsaiujwal"}, 36 | ) 37 | async def whois(client, message): 38 | engine = message.Engine 39 | user_photo = None 40 | msg_ = await edit_or_reply(message, "`Hang On!`") 41 | text_ = get_text(message) 42 | userk = get_user(message, text_)[0] 43 | if not userk: 44 | await msg_.edit(engine.get_string("REPLY_TO_USER").format("Search")) 45 | return 46 | try: 47 | user_ = await client.get_users(userk) 48 | except: 49 | await msg_.edit(engine.get_string("USER_MISSING").format(userk)) 50 | return 51 | if user_.photo: 52 | user_photo = await client.download_media(user_.photo.big_file_id) 53 | user_info = f"User Info Of {user_.mention} \n\n" 54 | user_info += f"✱ User ID : {user_.id} \n" 55 | user_info += f"✱ FirstName : {user_.first_name} \n" 56 | user_info += ( 57 | f"✱ LastName : {user_.last_name} \n" 58 | if user_.last_name 59 | else f"✱ LastName : Not Set \n" 60 | ) 61 | user_info += ( 62 | f"✱ DC : {user_.dc_id} \n" 63 | if user_.dc_id 64 | else f"✱ DC : No PFP \n" 65 | ) 66 | user_info += ( 67 | f"✱ Status : {user_.status} \n" 68 | if user_.status 69 | else f"✱ Status : Bot Can't Have Last Seen \n" 70 | ) 71 | user_info += ( 72 | f"✱ Username : {user_.username} \n" 73 | if user_.username 74 | else f"✱ Username : User Doesn't Have A UserName \n" 75 | ) 76 | user_info += f"✱ Is Scam : {user_.is_scam} \n" 77 | user_info += f"✱ Is Bot : {user_.is_bot} \n" 78 | user_info += f"✱ Is Verified : {user_.is_verified} \n" 79 | user_info += f"✱ Is Contact : {user_.is_contact} \n" 80 | common = await client.get_common_chats(user_.id) 81 | user_info += f"✱ Total Groups In Common : {len(common)} \n" 82 | if user_.id in devs_id: 83 | user_info += f"\n Wow! This User is One Of My Developer \n" 84 | if await gban_info(user_.id): 85 | user_info += f"\n This User Is Gbanned For Reason : {await gban_info(user_.id)} \n" 86 | if await is_gmuted(user_.id): 87 | user_info += f"\n This User Is Gmutted! \n" 88 | if user_photo: 89 | await msg_.delete() 90 | if message.reply_to_message: 91 | await client.send_photo( 92 | message.chat.id, 93 | user_photo, 94 | caption=user_info, 95 | reply_to_message_id=message.reply_to_message.message_id, 96 | ) 97 | else: 98 | await client.send_photo( 99 | message.chat.id, user_photo, caption=user_info, parse_mode="html" 100 | ) 101 | os.remove(user_photo) 102 | else: 103 | await msg_.edit(user_info) 104 | -------------------------------------------------------------------------------- /plugins/xtra_media.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | import json 10 | import logging 11 | import os 12 | import random 13 | import shutil 14 | import urllib 15 | from re import findall 16 | 17 | import requests 18 | from bs4 import BeautifulSoup 19 | from PIL import Image 20 | from pyrogram.types import InputMediaPhoto 21 | 22 | from main_startup.core.decorators import friday_on_cmd 23 | from main_startup.helper_func.basic_helpers import edit_or_reply, get_text, runcmd, run_in_exc 24 | from main_startup.helper_func.gmdl import googleimagesdownload 25 | 26 | opener = urllib.request.build_opener() 27 | useragent = "Mozilla/5.0 (Linux; Android 9; SM-G960F Build/PPR1.180610.011; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/74.0.3729.157 Mobile Safari/537.36" 28 | opener.addheaders = [("User-agent", useragent)] 29 | 30 | sedpath = "./yandex/" 31 | if not os.path.isdir(sedpath): 32 | os.makedirs(sedpath) 33 | 34 | 35 | @friday_on_cmd( 36 | ["lg"], 37 | cmd_help={ 38 | "help": "Mess The Animated Sticker!", 39 | "example": "{ch}lg (Reply To Animated Sticker)", 40 | }, 41 | ) 42 | async def lgo(client, message): 43 | engine = message.Engine 44 | pablo = await edit_or_reply(message, engine.get_string("PROCESSING")) 45 | if not message.reply_to_message: 46 | await pablo.edit(engine.get_string("NEEDS_REPLY").format("Animated Sticker")) 47 | return 48 | if not message.reply_to_message.sticker: 49 | await pablo.edit(engine.get_string("NEEDS_REPLY").format("Animated Sticker")) 50 | return 51 | if message.reply_to_message.sticker.mime_type != "application/x-tgsticker": 52 | await pablo.edit(engine.get_string("NEEDS_REPLY").format("Animated Sticker")) 53 | return 54 | lol = await message.reply_to_message.download("tgs.tgs") 55 | cmdo = f"lottie_convert.py {lol} json.json" 56 | await runcmd(cmdo) 57 | if not os.path.exists('json.json'): 58 | await pablo.edit(engine.get_string("NEEDS_REPLY").format("Animated Sticker")) 59 | os.remove("tgs.tgs") 60 | return 61 | with open("json.json", "r") as json: 62 | jsn = json.read() 63 | jsn = ( 64 | jsn.replace("[1]", "[2]") 65 | .replace("[2]", "[3]") 66 | .replace("[3]", "[4]") 67 | .replace("[4]", "[5]") 68 | .replace("[5]", "[6]") 69 | ) 70 | open("json.json", "w").write(jsn) 71 | await runcmd(f"lottie_convert.py json.json tgs.tgs") 72 | await client.send_sticker(message.chat.id, "tgs.tgs") 73 | os.remove("json.json") 74 | os.remove(lol) 75 | os.remove("tgs.tgs") 76 | await pablo.delete() 77 | 78 | @run_in_exc 79 | def download_imgs_from_google(query: str, lim: int): 80 | response = googleimagesdownload() 81 | arguments = { 82 | "keywords": query, 83 | "silent_mode": True, 84 | "limit": lim, 85 | "format": "jpg", 86 | "no_directory": "no_directory", 87 | } 88 | paths = response.download(arguments) 89 | path_ = paths[0][query] 90 | Beast = [InputMediaPhoto(str(x)) for x in path_] 91 | return path_, Beast 92 | 93 | @run_in_exc 94 | def rm_multiple_files(path_: list): 95 | path_ = list(path_) 96 | for i in path_: 97 | if os.path.exists(i) and os.path.isfile(i): 98 | os.remove(i) 99 | 100 | @run_in_exc 101 | def get_img_search_result(imoge: str): 102 | try: 103 | image = Image.open(imoge) 104 | except OSError: 105 | return None 106 | name = "okgoogle.png" 107 | image.save(name, "PNG") 108 | image.close() 109 | if os.path.exists(imoge): 110 | os.remove(imoge) 111 | searchUrl = "https://www.google.com/searchbyimage/upload" 112 | multipart = {"encoded_image": (name, open(name, "rb")), "image_content": ""} 113 | response = requests.post(searchUrl, files=multipart, allow_redirects=False) 114 | if os.path.exists(name): 115 | os.remove(name) 116 | if response.status_code == 400: 117 | return None 118 | return response.headers["Location"] 119 | 120 | @friday_on_cmd( 121 | ["reverse"], 122 | cmd_help={ 123 | "help": "Reverse Search Images / Stickers Using Google Reverse Search!", 124 | "example": "{ch}reverse (Reply To Image)", 125 | }, 126 | ) 127 | async def reverseing(client, message): 128 | engine = message.Engine 129 | input_ = get_text(message) 130 | pablo = await edit_or_reply(message, engine.get_string("PROCESSING")) 131 | if not message.reply_to_message or not message.reply_to_message.photo: 132 | await pablo.edit(engine.get_string("NEEDS_REPLY").format("photo")) 133 | return 134 | imoge = await message.reply_to_message.download() 135 | fetchUrl = await get_img_search_result(imoge) 136 | if not fetchUrl: 137 | return await pablo.edit(engine.get_string("IMG_NOT_FOUND").format("google")) 138 | match = await ParseSauce(fetchUrl + "&preferences?hl=en&fg=1#languages") 139 | guess = match["best_guess"] 140 | imgspage = match["similar_images"] 141 | if guess and imgspage: 142 | await pablo.edit(engine.get_string("LOOKING_FOR_IMG").format(guess, fetchUrl)) 143 | else: 144 | await pablo.edit(engine.get_string("IMG_NOT_FOUND").format("google")) 145 | return 146 | await pablo.edit(f"[{guess}]({fetchUrl})\n\n[Visually similar images]({imgspage})", disable_web_page_preview=True) 147 | if input_ and input_.isdigit(): 148 | lim = int(input_) 149 | lst, Beast = await download_imgs_from_google(quess, lim) 150 | await client.send_media_group(message.chat.id, media=Beast) 151 | await rm_multiple_files(Beast) 152 | @run_in_exc 153 | def ParseSauce(googleurl): 154 | """Parse/Scrape the HTML code for the info we want.""" 155 | source = opener.open(googleurl).read() 156 | soup = BeautifulSoup(source, "html.parser") 157 | results = {"similar_images": "", "best_guess": ""} 158 | try: 159 | for similar_image in soup.findAll("input", {"class": "gLFyf"}): 160 | url = "https://www.google.com/search?tbm=isch&q=" + urllib.parse.quote_plus( 161 | similar_image.get("value") 162 | ) 163 | results["similar_images"] = url 164 | except BaseException: 165 | pass 166 | for best_guess in soup.findAll("div", attrs={"class": "r5a77d"}): 167 | results["best_guess"] = best_guess.get_text() 168 | return results 169 | 170 | 171 | @friday_on_cmd( 172 | ["yandex"], 173 | cmd_help={ 174 | "help": "Reverse Search Images / Stickers Using Yandex Reverse Search!", 175 | "example": "{ch}yandex (Reply To Image)", 176 | }, 177 | ) 178 | async def yandex_(client, message): 179 | engine = message.Engine 180 | pablo = await edit_or_reply( 181 | message, engine.get_string("PROCESSING")) 182 | if not message.reply_to_message or not message.reply_to_message.photo: 183 | await pablo.edit(engine.get_string("NEEDS_REPLY").format("photo")) 184 | return 185 | imoge = await message.reply_to_message.download() 186 | filePath = imoge 187 | searchUrl = "https://yandex.ru/images/search" 188 | files = {"upfile": ("blob", open(filePath, "rb"), "image/jpeg")} 189 | params = { 190 | "rpt": "imageview", 191 | "format": "json", 192 | "request": '{"blocks":[{"block":"b-page_type_search-by-image__link"}]}', 193 | } 194 | response = requests.post(searchUrl, params=params, files=files) 195 | try: 196 | query_string = json.loads(response.content)["blocks"][0]["params"]["url"] 197 | except: 198 | await pablo.edit(engine.get_string("IMG_NOT_FOUND").format("yandex")) 199 | return 200 | img_search_url = searchUrl + "?" + query_string 201 | caption = engine.get_string("YANDEX").format(img_search_url) 202 | await pablo.edit(caption, parse_mode="HTML", disable_web_page_preview=True) 203 | os.remove(imoge) 204 | 205 | 206 | @friday_on_cmd( 207 | ["img", "googleimage", "image", "gi"], 208 | cmd_help={ 209 | "help": "Search Images In Telegram Itself", 210 | "example": "{ch}img fridayuserbot", 211 | }, 212 | ) 213 | async def img_search(client, message): 214 | engine = message.Engine 215 | pablo = await edit_or_reply(message, engine.get_string("PROCESSING")) 216 | query = get_text(message) 217 | if not query: 218 | await pablo.edit(engine.get_string("INPUT_REQ").format("Query")) 219 | return 220 | if "|" in query: 221 | lim = query.split("|")[1] if (query.split("|")[1]).isdigit() else 5 222 | else: 223 | lim = 5 224 | lst, Beast = await download_imgs_from_google(query, lim) 225 | await client.send_media_group(message.chat.id, media=Beast) 226 | await rm_multiple_files(Beast) 227 | await pablo.delete() 228 | 229 | 230 | @friday_on_cmd( 231 | ["waifuwrite", "wq"], 232 | cmd_help={ 233 | "help": "Make Cool Stickers Using @stickerizerbot", 234 | "example": "{ch}wq Hi!", 235 | }, 236 | ) 237 | async def wow_nice(client, message): 238 | engine = message.Engine 239 | msg_ = await edit_or_reply(message, engine.get_string("PROCESSING")) 240 | random_s = random.randint(0, 63) 241 | te_t = get_text(message) 242 | if not te_t: 243 | msg_.edit(engine.get_string("INPUT_REQ").format("Text")) 244 | return 245 | text = f"#{random_s} {te_t}" 246 | nice = await client.get_inline_bot_results(bot="stickerizerbot", query=text) 247 | if message.reply_to_message: 248 | await client.send_inline_bot_result( 249 | message.chat.id, 250 | nice.query_id, 251 | nice.results[0].id, 252 | reply_to_message_id=message.reply_to_message.message_id, 253 | hide_via=True, 254 | ) 255 | else: 256 | await client.send_inline_bot_result( 257 | message.chat.id, nice.query_id, nice.results[0].id, hide_via=True 258 | ) 259 | await msg_.delete() 260 | -------------------------------------------------------------------------------- /plugins/yt.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | import asyncio 10 | import os 11 | import time 12 | import requests 13 | import wget 14 | from youtube_dl import YoutubeDL 15 | from youtubesearchpython import SearchVideos 16 | from main_startup.core.decorators import friday_on_cmd 17 | from main_startup.helper_func.assistant_helpers import _dl 18 | from main_startup.helper_func.basic_helpers import edit_or_reply, get_text, progress, humanbytes, run_in_exc, time_formatter 19 | import threading 20 | from concurrent.futures import ThreadPoolExecutor 21 | from pyrogram.errors import FloodWait, MessageNotModified 22 | 23 | def edit_msg(client, message, to_edit): 24 | try: 25 | client.loop.create_task(message.edit(to_edit)) 26 | except MessageNotModified: 27 | pass 28 | except FloodWait as e: 29 | client.loop.create_task(asyncio.sleep(e.x)) 30 | except TypeError: 31 | pass 32 | 33 | def download_progress_hook(d, message, client): 34 | if d['status'] == 'downloading': 35 | current = d.get("_downloaded_bytes_str") or humanbytes(int(d.get("downloaded_bytes", 1))) 36 | total = d.get("_total_bytes_str") or d.get("_total_bytes_estimate_str") 37 | file_name = d.get("filename") 38 | eta = d.get('_eta_str', "N/A") 39 | percent = d.get("_percent_str", "N/A") 40 | speed = d.get("_speed_str", "N/A") 41 | to_edit = f"Downloading File \nFile Name : {file_name} \nFile Size : {total} \nSpeed : {speed} \nETA : {eta} \nDownload {current} out of {total} (__{percent}__)" 42 | threading.Thread(target=edit_msg, args=(client, message, to_edit)).start() 43 | 44 | @run_in_exc 45 | def yt_dl(url, client, message, type_): 46 | if type_ == "audio": 47 | opts = { 48 | "format": "bestaudio", 49 | "addmetadata": True, 50 | "key": "FFmpegMetadata", 51 | "prefer_ffmpeg": True, 52 | "geo_bypass": True, 53 | "progress_hooks": [lambda d: download_progress_hook(d, message, client)], 54 | "nocheckcertificate": True, 55 | "postprocessors": [ 56 | { 57 | "key": "FFmpegExtractAudio", 58 | "preferredcodec": "mp3", 59 | "preferredquality": "320", 60 | } 61 | ], 62 | "outtmpl": "%(id)s.mp3", 63 | "quiet": True, 64 | "logtostderr": False, 65 | } 66 | else: 67 | opts = { 68 | "format": "best", 69 | "addmetadata": True, 70 | "key": "FFmpegMetadata", 71 | "prefer_ffmpeg": True, 72 | "geo_bypass": True, 73 | "nocheckcertificate": True, 74 | "progress_hooks": [lambda d: download_progress_hook(d, message, client)], 75 | "postprocessors": [ 76 | {"key": "FFmpegVideoConvertor", "preferedformat": "mp4"} 77 | ], 78 | "outtmpl": "%(id)s.mp4", 79 | "logtostderr": False, 80 | "quiet": True, 81 | } 82 | with YoutubeDL(opts) as ytdl: 83 | ytdl_data = ytdl.extract_info(url, download=True) 84 | file_name = f"{ytdl_data['id']}.mp3" if type_ == "audio" else f"{ytdl_data['id']}.mp4" 85 | print(file_name) 86 | return file_name, ytdl_data 87 | 88 | 89 | @friday_on_cmd( 90 | ["yt", "ytdl"], 91 | cmd_help={ 92 | "help": "Download YouTube Videos / Audio just with name!", 93 | "example": "{ch}yt (video name OR link)|audio if audio else video", 94 | }, 95 | ) 96 | async def yt_vid(client, message): 97 | input_str = get_text(message) 98 | engine = message.Engine 99 | type_ = "video" 100 | pablo = await edit_or_reply(message, engine.get_string("PROCESSING")) 101 | if not input_str: 102 | await pablo.edit( 103 | engine.get_string("INPUT_REQ").format("Query") 104 | ) 105 | return 106 | _m = ('http://', 'https://') 107 | if "|" in input_str: 108 | input_str = input_str.strip() 109 | input_str, type_ = input_str.split("|") 110 | if type_ not in ['audio', 'video']: 111 | return await pablo.edit(engine.get_string("NEEDS_C_INPUT")) 112 | if input_str.startswith(_m): 113 | url = input_str 114 | else: 115 | await pablo.edit(engine.get_string("GETTING_RESULTS").format(input_str)) 116 | search = SearchVideos(str(input_str), offset=1, mode="dict", max_results=1) 117 | if not search: 118 | return await pablo.edit(engine.get_string("NO_RESULTS").format(input_str)) 119 | rt = search.result() 120 | result_s = rt["search_result"] 121 | url = result_s[0]["link"] 122 | try: 123 | yt_file, yt_data = await yt_dl(url, client, message, type_) 124 | except Exception as e: 125 | return await pablo.edit(engine.get_string("YTDL_FAILED").format(e)) 126 | vid_title = yt_data['title'] 127 | uploade_r = yt_data['uploader'] 128 | yt_id = yt_data['id'] 129 | msg = message.reply_to_message or message 130 | thumb_url = f"https://img.youtube.com/vi/{yt_id}/hqdefault.jpg" 131 | thumb = await _dl(thumb_url) 132 | caption = f"**{type_.title()} Name ➠** `{vid_title}` \n**Requested For ➠** `{input_str}` \n**Channel ➠** `{uploade_r}` \n**Link ➠** `{url}`" 133 | c_time = time.time() 134 | if type_ == "video": 135 | await msg.reply_video( 136 | yt_file, 137 | duration=int(yt_data["duration"]), 138 | thumb=thumb, 139 | caption=caption, 140 | supports_streaming=True, 141 | progress=progress, 142 | progress_args=( 143 | pablo, 144 | c_time, 145 | f"`Uploading Downloaded Youtube File.`", 146 | str(yt_file), 147 | ), 148 | ) 149 | else: 150 | await msg.reply_audio( 151 | yt_file, 152 | duration=int(yt_data["duration"]), 153 | title=str(yt_data["title"]), 154 | performer=uploade_r, 155 | thumb=thumb, 156 | caption=caption, 157 | progress=progress, 158 | progress_args=( 159 | pablo, 160 | c_time, 161 | f"`Uploading Downloaded Youtube File.`", 162 | str(yt_file), 163 | ), 164 | ) 165 | await pablo.delete() 166 | for files in (thumb, yt_file): 167 | if files and os.path.exists(files): 168 | os.remove(files) -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | pyrogram==1.4.16 2 | filesplit 3 | wget>=3.2 4 | CairoSVG>=2.5.2 5 | faker>=6.6.2 6 | html5lib 7 | langdetect>=1.0.8 8 | geopy>=2.1.0 9 | PyYAML>=5.4.1 10 | selenium>=3.141.0 11 | opencv-contrib-python>=4.5.1.48 12 | fake_useragent>=0.1.11 13 | scipy>=1.6.1 14 | numpy>=1.20.1 15 | NoteShrinker>=0.2.0 16 | pytest>=6.2.2 17 | glitch_this>=1.0.2 18 | lottie>=0.6.6 19 | pygifsicle>=1.0.2 20 | psutil>=5.8.0 21 | python-dotenv>=0.15.0 22 | pymediainfo>=5.0.3 23 | motor>=2.3.1 24 | youtube-search-python>=1.4.2 25 | dnspython>=2.1.0 26 | Markdown>=3.3.4 27 | gTTS>=2.2.2 28 | youtube-search>=2.1.0 29 | ffmpeg-python>=0.2.0 30 | wheel>=0.36.2 31 | anime_downloader>=5.0.7 32 | hachoir>=3.1.2 33 | googletrans==4.0.0-rc1 34 | beautifulsoup4>=4.9.3 35 | tinydb>=4.4.0 36 | img2pdf>=0.4.0 37 | gitpython>=3.1.14 38 | TgCrypto>=1.2.2 39 | pytz>=2021.1 40 | apscheduler>=3.7.0 41 | requests>=2.25.1 42 | git+https://github.com/ytdl-org/youtube-dl 43 | Pillow 44 | pyshorteners>=1.0.1 45 | telegraph>=1.4.1 46 | heroku3>=4.2.3 47 | aiofiles>=0.6.0 48 | aiohttp 49 | -------------------------------------------------------------------------------- /startup.sh: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 2 | # 3 | # This file is part of < https://github.com/DevsExpo/FridayUB > project, 4 | # and is released under the "GNU v3.0 License Agreement". 5 | # Please see < https://github.com/DevsExpo/blob/master/LICENSE > 6 | # 7 | # All rights reserved. 8 | 9 | nowtime=$(date) 10 | echo " 11 | FridayUB 12 | 13 | (C) @FridayOT 14 | Powered By @DevsExpo. 15 | Time : $nowtime 16 | " 17 | update_and_install_packages () { 18 | apt -qq update -y 19 | apt -qq install -y --no-install-recommends \ 20 | git \ 21 | ffmpeg \ 22 | mediainfo \ 23 | unzip \ 24 | wget \ 25 | gifsicle 26 | } 27 | 28 | # Thanks To Userge For The Chrome Version Hecks 29 | install_helper_packages () { 30 | wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && apt -fqqy install ./google-chrome-stable_current_amd64.deb && rm google-chrome-stable_current_amd64.deb 31 | wget https://chromedriver.storage.googleapis.com/$(curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE)/chromedriver_linux64.zip && unzip chromedriver_linux64.zip && chmod +x chromedriver && mv -f chromedriver /usr/bin/ && rm chromedriver_linux64.zip 32 | wget -O opencv.zip https://github.com/opencv/opencv/archive/master.zip && unzip opencv.zip && mv -f opencv-master /usr/bin/ && rm opencv.zip 33 | wget https://people.eecs.berkeley.edu/~rich.zhang/projects/2016_colorization/files/demo_v2/colorization_release_v2.caffemodel -P ./bot_utils_files/ai_helpers/ 34 | } 35 | 36 | ech_final () { 37 | echo " 38 | 39 | =+---------------------------------------------------------+= 40 | Deployment Sucessfull. 41 | Docker Images Are Being Pushed, Please Wait. 42 | Thank You For Installing FridayUB. 43 | (C) @DevsExpo 44 | =+---------------------------------------------------------+= 45 | 46 | " 47 | } 48 | 49 | _run_all () { 50 | update_and_install_packages 51 | install_helper_packages 52 | pip3 install –upgrade pip 53 | pip3 install --no-cache-dir -r requirements.txt 54 | ech_final 55 | } 56 | 57 | _run_all 58 | -------------------------------------------------------------------------------- /string_gen.py: -------------------------------------------------------------------------------- 1 | import pyrogram 2 | from pyrogram import Client 3 | 4 | friday_ = """ 5 | ╔═══╗───╔═╗─╔═╗ 6 | ║ ══╬═╦═╬═╬═╝ ╠═══╦═╦═╗ 7 | ║ ╔═╣ ╔═╣ ║╔╗ ║╔╗ ╠══ ║ 8 | ╚═╝ ╚═╝ ╚═╩═══╩═╩═╩═══╝ 9 | Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >. 10 | This file is part of < https://github.com/DevsExpo/FridayUB > project, 11 | and is released under the "GNU v3.0 License Agreement". 12 | Please see < https://github.com/DevsExpo/blob/master/LICENSE > 13 | All rights reserved. 14 | """ 15 | 16 | print(friday_) 17 | 18 | api_id = input("Enter Your API ID: \n") 19 | api_hash = input("Enter Your API HASH : \n") 20 | 21 | with Client("FridayUB", api_id=api_id, api_hash=api_hash) as bot_: 22 | first_name = (bot_.get_me()).first_name 23 | string_session_ = f"String Session For {first_name} \n{bot_.export_session_string()}" 24 | bot_.send_message("me", string_session_, parse_mode="html") 25 | print(f"String Has Been Sent To Your Saved Message : {first_name}") 26 | --------------------------------------------------------------------------------