├── .gitbook.yaml ├── .github └── workflows │ ├── pylint.yml │ └── pythonapp.yml ├── .gitignore ├── .isort.cfg ├── .sourcery.yaml ├── .vscode ├── extensions.json └── settings.json ├── Dockerfile ├── LICENSE ├── README.md ├── bin ├── cmrudl.py ├── megadirect └── megadown ├── docker-compose.yml ├── docs ├── README.md ├── SUMMARY.md ├── about-us │ ├── cat-userbot.md │ ├── support-us.md │ └── support.md ├── installation │ ├── guide │ │ ├── README.md │ │ └── chromium-or-chrome-setup.md │ ├── hosting │ │ ├── README.md │ │ ├── docker-compose.md │ │ ├── heroku.md │ │ ├── railway.md │ │ └── self-host.md │ └── variables │ │ ├── README.md │ │ ├── config-vars.md │ │ └── database-vars.md ├── project-info │ └── changelogs │ │ ├── README.md │ │ ├── version-3.0.0.md │ │ ├── version-3.1.0.md │ │ ├── version-3.2.0.md │ │ └── version-3.3.0.md └── tutorials │ ├── g-drive.md │ ├── github-commit.md │ ├── heroku-vars.md │ ├── ibm.md │ ├── lastfm.md │ └── spotify.md ├── exampleconfig.py ├── requirements.txt ├── sample_config.py ├── stringsetup.py └── userbot ├── Config ├── Readme.md ├── __init__.py └── catub_config.py ├── __init__.py ├── __main__.py ├── assistant ├── __init__.py ├── bot_pms.py ├── botcontrols.py ├── botmanagers.py ├── hide.py ├── inlinefm.py ├── iytdl.py ├── nsfw.py ├── secret.py └── troll.py ├── cache └── readme.md ├── core ├── __init__.py ├── client.py ├── cmdinfo.py ├── data.py ├── decorators.py ├── events.py ├── fasttelethon.py ├── helpers.py ├── inlinebot.py ├── logger.py ├── managers.py ├── pluginManager.py ├── pool.py └── session.py ├── helpers ├── FastTelethon.py ├── Readme.md ├── __init__.py ├── aiohttp_helper.py ├── aria2utils ├── chatbot.py ├── config_helper.py ├── exceptions.py ├── fonts.py ├── functions.py ├── functions │ ├── __init__.py │ ├── converter.py │ ├── findquote.py │ ├── functions.py │ ├── ialivetext.py │ ├── imgtools.py │ ├── jikan.py │ ├── musictool.py │ ├── nekos.py │ ├── utils.py │ ├── utube.py │ └── vidtools.py ├── google_image_download.py ├── google_tools.py ├── memeifyhelpers.py ├── memeshelper.py ├── progress.py ├── qhelper.py ├── resources │ └── states.py ├── styles │ ├── ProductSans-BoldItalic.ttf │ ├── ProductSans-Light.ttf │ ├── RoadRage-Regular.ttf │ ├── digital.ttf │ └── impact.ttf ├── tools.py ├── utils.py └── utils │ ├── __init__.py │ ├── events.py │ ├── extdl.py │ ├── format.py │ ├── paste.py │ ├── tools.py │ └── utils.py ├── plugins ├── README.md ├── __init__.py ├── admin.py ├── afk.py ├── aitools.py ├── alive.py ├── amongus.py ├── android.py ├── anilist.py ├── animation1.py ├── animation2.py ├── animation3.py ├── animation4.py ├── animation5.py ├── animation6.py ├── antiflood.py ├── antispambot.py ├── app.py ├── archive.py ├── art.py ├── art_img.py ├── artsay.py ├── autoprofile.py ├── badart.py ├── blacklistchats.py ├── blacklistwords.py ├── broadcast.py ├── button.py ├── calc.py ├── carbon.py ├── chain.py ├── channel_download.py ├── chatbot.py ├── climate.py ├── clone.py ├── collage.py ├── corecmds.py ├── create.py ├── cricket.py ├── custom.py ├── dialogues.py ├── dictionary.py ├── direct_links.py ├── download.py ├── echo.py ├── emojify.py ├── emojigames.py ├── evaluators.py ├── execmod.py ├── externalplugins.py ├── fake.py ├── fedutils.py ├── fedutl.py ├── ffmpeg.py ├── figlet.py ├── fileconverts.py ├── filemanager.py ├── filesummary.py ├── filext.py ├── filters.py ├── fonts.py ├── forward.py ├── fryer.py ├── funarts.py ├── funnyfonts.py ├── funtxts.py ├── gadmin.py ├── gali.py ├── game.py ├── gdrive.py ├── getid.py ├── gifs.py ├── git.py ├── glitch.py ├── google.py ├── gps.py ├── greetings.py ├── groupactions.py ├── groupdata.py ├── hack.py ├── hash.py ├── help.py ├── heroku.py ├── images.py ├── imgfun.py ├── imgmemes.py ├── invite.py ├── json.py ├── kang.py ├── lastfm.py ├── letmesearch.py ├── linkpreview.py ├── locks.py ├── logchats.py ├── logo.py ├── lyrics.py ├── markdown.py ├── mask.py ├── mediainfo.py ├── mega.py ├── meme.py ├── memes.py ├── memestext.py ├── memify.py ├── mention.py ├── myfuns.py ├── mystatus.py ├── notebook.py ├── nsfwdetect.py ├── ocr.py ├── openai.py ├── pastebin.py ├── ping.py ├── pmpermit.py ├── poll.py ├── poto.py ├── powertools.py ├── privatewelcome.py ├── profile.py ├── purge.py ├── quotes.py ├── quotly.py ├── randomsticker.py ├── randomtext.py ├── recognize.py ├── reddit.py ├── removebg.py ├── rename.py ├── sangmata.py ├── schedule.py ├── scrapers.py ├── screenshot.py ├── sed.py ├── selfdestruct.py ├── snip.py ├── songs.py ├── spam.py ├── speedtest.py ├── spotify.py ├── stats.py ├── stickerfun.py ├── stickers.py ├── stt.py ├── sudo.py ├── sysdetails.py ├── tadmin.py ├── telegraph.py ├── textformat.py ├── theri.py ├── thumbnail.py ├── time.py ├── tools.py ├── transfer_channel.py ├── translate.py ├── trolls.py ├── tts.py ├── updater.py ├── upload.py ├── urltools.py ├── vps.py ├── wall.py ├── warns.py ├── watch.py ├── webupload.py ├── welcome.py ├── whois.py ├── xiaomi.py └── ytdl.py ├── sql_helper ├── DS_Store ├── __init__.py ├── antiflood_sql.py ├── blacklist_sql.py ├── bot_blacklists.py ├── bot_pms_sql.py ├── bot_starters.py ├── broadcast_sql.py ├── chatbot_sql.py ├── echo_sql.py ├── filter_sql.py ├── gban_sql_helper.py ├── gdrive_sql.py ├── global_collection.py ├── global_collectionjson.py ├── global_list.py ├── globals.py ├── gmute_sql.py ├── google_drive_sql.py ├── locks_sql.py ├── mute_sql.py ├── no_log_pms_sql.py ├── pmpermit_sql.py ├── schedule_sql.py ├── snip_sql.py ├── warns_sql.py ├── welcome_sql.py └── welcomesql.py └── utils ├── __init__.py ├── checks.py ├── decorators.py ├── pluginmanager.py ├── startup.py └── tools.py /.gitbook.yaml: -------------------------------------------------------------------------------- 1 | root: ./docs -------------------------------------------------------------------------------- /.github/workflows/pylint.yml: -------------------------------------------------------------------------------- 1 | name: PyLint 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | PEP8: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v3 10 | 11 | - name: Setup Python 12 | uses: actions/setup-python@v3 13 | with: 14 | python-version: "3.10" 15 | - name: Install Python lint libraries 16 | run: | 17 | pip install autoflake isort black 18 | - name: Remove unused imports and variables 19 | run: | 20 | autoflake --in-place --recursive --remove-all-unused-imports --remove-unused-variables --ignore-init-module-imports . 21 | - name: lint with isort 22 | run: | 23 | isort . 24 | - name: lint with black 25 | run: | 26 | black --exclude "exampleconfig\.py" . 27 | # commit changes 28 | - uses: stefanzweifel/git-auto-commit-action@v4 29 | with: 30 | commit_message: "pylint: auto fixes" 31 | commit_options: "--no-verify" 32 | repository: . 33 | commit_user_name: Sur-vivor 34 | commit_user_email: 59915404+Sur-vivor@users.noreply.github.com 35 | commit_author: Sur-vivor <59915404+Sur-vivor@users.noreply.github.com> 36 | -------------------------------------------------------------------------------- /.github/workflows/pythonapp.yml: -------------------------------------------------------------------------------- 1 | name: catChecker 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | strategy: 9 | max-parallel: 5 10 | matrix: 11 | python-version: [3.10.x] 12 | 13 | steps: 14 | - uses: actions/checkout@v3 15 | - name: Set up Python ${{ matrix.python-version }} 16 | uses: actions/setup-python@v3 17 | with: 18 | python-version: ${{ matrix.python-version }} 19 | - name: Install dependencies 20 | run: | 21 | sudo apt-get install libpq-dev libxml2-dev libxslt-dev python3 22 | python -m pip install --upgrade pip 23 | pip install wheel flake8==5.0.4 flake8-print flake8-quotes 24 | pip install -r requirements.txt 25 | - name: Check for showstoppers 26 | run: | 27 | # stop the build if there are Python syntax errors 28 | flake8 . --count --select=E999 --show-source --statistics --exclude="exampleconfig.py" 29 | -------------------------------------------------------------------------------- /.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 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .coverage 43 | .coverage.* 44 | .cache 45 | nosetests.xml 46 | coverage.xml 47 | *.cover 48 | .hypothesis/ 49 | .pytest_cache/ 50 | 51 | # Translations 52 | *.mo 53 | *.pot 54 | 55 | # Django stuff: 56 | *.log 57 | local_settings.py 58 | db.sqlite3 59 | 60 | # Flask stuff: 61 | instance/ 62 | .webassets-cache 63 | 64 | # Scrapy stuff: 65 | .scrapy 66 | 67 | # Sphinx documentation 68 | docs/_build/ 69 | 70 | # PyBuilder 71 | target/ 72 | 73 | # Jupyter Notebook 74 | .ipynb_checkpoints 75 | 76 | # pyenv 77 | .python-version 78 | 79 | # celery beat schedule file 80 | celerybeat-schedule 81 | 82 | # SageMath parsed files 83 | *.sage.py 84 | 85 | # Environments 86 | .env 87 | .venv 88 | env/ 89 | venv/ 90 | ENV/ 91 | env.bak/ 92 | venv.bak/ 93 | config.py 94 | 95 | # Spyder project settings 96 | .spyderproject 97 | .spyproject 98 | 99 | # Rope project settings 100 | .ropeproject 101 | 102 | # mkdocs documentation 103 | /site 104 | 105 | # mypy 106 | .mypy_cache/ 107 | *.bak 108 | -------------------------------------------------------------------------------- /.isort.cfg: -------------------------------------------------------------------------------- 1 | # General Settings 2 | profile=black 3 | 4 | # Imports 5 | force_sort_within_sections=True 6 | force_to_top=future, __future__ 7 | skip_glob=**/migrations/** 8 | 9 | # Sections 10 | sections=FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER 11 | force_sort_within_sections=True 12 | known_first_party=your_module_name 13 | known_third_party=django 14 | multi_line_output=3 15 | include_trailing_comma=True 16 | force_grid_wrap=0 17 | combine_as_imports=True -------------------------------------------------------------------------------- /.sourcery.yaml: -------------------------------------------------------------------------------- 1 | # 🪄 This is your project's Sourcery configuration file. 2 | 3 | # You can use it to get Sourcery working in the way you want, such as 4 | # ignoring specific refactorings, skipping directories in your project, 5 | # or writing custom rules. 6 | 7 | # 📚 For a complete reference to this file, see the documentation at 8 | # https://docs.sourcery.ai/Configuration/Project-Settings/ 9 | 10 | # This file was auto-generated by Sourcery on 2023-04-27 at 22:34. 11 | 12 | version: '1' # The schema version of this config file 13 | 14 | ignore: # A list of paths or files which Sourcery will ignore. 15 | - .git 16 | - venv 17 | - .venv 18 | - env 19 | - .env 20 | - .tox 21 | - node_modules 22 | - vendor 23 | 24 | rule_settings: 25 | enable: 26 | - default 27 | disable: [] 28 | rule_types: 29 | - refactoring 30 | - suggestion 31 | - comment 32 | python_version: '3.10' # A string specifying the lowest Python version your project supports. Sourcery will not suggest refactorings requiring a higher Python version. 33 | 34 | # rules: # A list of custom rules Sourcery will include in its analysis. 35 | # - id: no-print-statements 36 | # description: Do not use print statements in the test directory. 37 | # pattern: print(...) 38 | # language: python 39 | # replacement: 40 | # condition: 41 | # explanation: 42 | # paths: 43 | # include: 44 | # - test 45 | # exclude: 46 | # - conftest.py 47 | # tests: [] 48 | # tags: [] 49 | 50 | # rule_tags: {} # Additional rule tags. 51 | 52 | # metrics: 53 | # quality_threshold: 25.0 54 | 55 | # github: 56 | # labels: [] 57 | # ignore_labels: 58 | # - sourcery-ignore 59 | # request_review: author 60 | # sourcery_branch: sourcery/{base_branch} 61 | 62 | # clone_detection: 63 | # min_lines: 3 64 | # min_duplicates: 2 65 | # identical_clones_only: false 66 | 67 | # proxy: 68 | # url: 69 | # ssl_certs_file: 70 | # no_ssl_verify: false 71 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "ms-python.python", 4 | "sourcery.sourcery" 5 | ] 6 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.codeActionsOnSave": { 3 | "source.organizeImports": true, 4 | "source.fixAll": true, 5 | "sourcery.apply": true 6 | }, 7 | "python.formatting.provider": "black", 8 | "editor.formatOnSave": true, 9 | } -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# CatUserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 2 | # Copyright (C) 2020-2023 by TgCatUB@Github. 3 | 4 | # This file is part of: https://github.com/TgCatUB/catuserbot 5 | # and is released under the "GNU v3.0 License Agreement". 6 | 7 | # Please see: https://github.com/TgCatUB/catuserbot/blob/master/LICENSE 8 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 9 | 10 | FROM catub/core:bullseye 11 | 12 | # Working directory 13 | WORKDIR /userbot 14 | 15 | # Timezone 16 | ENV TZ=Asia/Kolkata 17 | 18 | ## Copy files into the Docker image 19 | COPY . . 20 | 21 | ENV PATH="/home/userbot/bin:$PATH" 22 | 23 | CMD ["python3","-m","userbot"] 24 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# CatUserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 2 | # Copyright (C) 2020-2023 by TgCatUB@Github. 3 | 4 | # This file is part of: https://github.com/TgCatUB/catuserbot 5 | # and is released under the "GNU v3.0 License Agreement". 6 | 7 | # Please see: https://github.com/TgCatUB/catuserbot/blob/master/LICENSE 8 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 9 | 10 | version: '3.3' 11 | 12 | services: 13 | app: 14 | container_name: cat 15 | build: 16 | context: . 17 | dockerfile: Dockerfile 18 | command: python3 -m userbot 19 | restart: on-failure 20 | environment: 21 | - DATABASE_URL=postgresql://postgres:postgres@db/catuserbot 22 | depends_on: 23 | - db 24 | 25 | db: 26 | image: postgres 27 | restart: always 28 | environment: 29 | - POSTGRES_USER=postgres 30 | - POSTGRES_PASSWORD=postgres 31 | - POSTGRES_DB=catuserbot 32 | volumes: 33 | - db:/var/lib/postgresql/data 34 | volumes: 35 | db: 36 | driver: local 37 | botdata: 38 | driver: local 39 | 40 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: >- 3 | A powerful and versatile userbot designed to make you more lazy by doing 4 | everything from telegram itself. 5 | --- 6 | 7 | # Introduction 8 | 9 |
Cat Logo

Vidushano

10 | 11 | Catuserbot has been developed using Python programming language and Telethon MTProto, a client library for the Telegram API that provides a secure and reliable way to interact with the Telegram platform. 12 | -------------------------------------------------------------------------------- /docs/SUMMARY.md: -------------------------------------------------------------------------------- 1 | # Table of contents 2 | 3 | * [Introduction](README.md) 4 | 5 | ## Installation 6 | 7 | * [📚 Hosting](installation/hosting/README.md) 8 | * [📕 Docker Compose](installation/hosting/docker-compose.md) 9 | * [📕 Self Host](installation/hosting/self-host.md) 10 | * [📕 Heroku](installation/hosting/heroku.md) 11 | * [📕 Railway](installation/hosting/railway.md) 12 | * [📚 Variables](installation/variables/README.md) 13 | * [📕 Config Vars](installation/variables/config-vars.md) 14 | * [📕 Database Vars](installation/variables/database-vars.md) 15 | * [📚 Guide](installation/guide/README.md) 16 | * [📕 Chromium/Chrome Setup](installation/guide/chromium-or-chrome-setup.md) 17 | 18 | ## Tutorials 19 | 20 | * [📕 G-Drive](tutorials/g-drive.md) 21 | * [📕 Github Commit](tutorials/github-commit.md) 22 | * [📕 Heroku Vars](tutorials/heroku-vars.md) 23 | * [📕 IBM](tutorials/ibm.md) 24 | * [📕 LastFM](tutorials/lastfm.md) 25 | * [📕 Spotify](tutorials/spotify.md) 26 | 27 | ## About Us 28 | 29 | * [🐱 Cat UserBot](about-us/cat-userbot.md) 30 | * [📞 Support](about-us/support.md) 31 | * [🖤 Support Us](about-us/support-us.md) 32 | 33 | ## Project Info 34 | 35 | * [GitHub](https://github.com/TgCatUB) 36 | * [📑 Changelogs](project-info/changelogs/README.md) 37 | * [📄 Version 3.3.0](project-info/changelogs/version-3.3.0.md) 38 | * [📄 Version 3.2.0](project-info/changelogs/version-3.2.0.md) 39 | * [📄 Version 3.1.0](project-info/changelogs/version-3.1.0.md) 40 | * [📄 Version 3.0.0](project-info/changelogs/version-3.0.0.md) 41 | -------------------------------------------------------------------------------- /docs/about-us/cat-userbot.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: >- 3 | Catuserbot is a simple Telegram userbot based on Telethon. It is developed and 4 | maintained by the Catuserbot organization, which aims to provide a 5 | user-friendly and customizable userbot experience for 6 | --- 7 | 8 | # 🐱 Cat UserBot 9 | 10 | ## 🚀 Features 11 | 12 | Catuserbot provides various features that can enhance your Telegram experience, such as: 13 | 14 | * 🤖 Customizable commands: You can create custom commands to perform various actions in your Telegram account. 15 | * 💬 Auto-reply: You can set up auto-replies for specific keywords or phrases to respond to messages automatically. 16 | * 🗃️ Chat management: You can manage your chats, such as archiving, muting, and pinning chats, and deleting messages. 17 | * 🎬 Media manipulation: You can download and manipulate media files, such as images, videos, and audio files. 18 | 19 | ## 📦 Repositories 20 | 21 | The Catuserbot organization repositories are: 22 | 23 | * [**Catuserbot**](https://github.com/TgCatUB/catuserbot) **:** A simple Telegram userbot based on Telethon. It has 1.4k stars and 5.7k forks on GitHub. If you find Catuserbot useful, please consider giving us a ⭐. 24 | * [**Nekopack**](https://github.com/TgCatUB/nekopack) **:** A shell script that automates the installation of various tools and packages on Linux. It has 1.6k stars and 6.2k forks on GitHub. 25 | 26 | ## 👥 Our Team 27 | 28 | Catuserbot is developed and maintained by a team of dedicated contributors: 29 | 30 |
Team MembersRole
TheWeaver786Pro Hacker
JisansandeepLead Developer
ZaroxodiDeveloper
「Paरam」Admin Support
31 | 32 | We are passionate about creating a user-friendly and customizable userbot experience for Telegram users, and we welcome contributions from anyone who shares our passion. 33 | 34 | ## 🤝 Contribution 35 | 36 | Catuserbot is an open-source project, and contributions are welcome. You can contribute to the project by: 37 | 38 | * 🐛 Fixing bugs 39 | * ➕ Adding new features 40 | * 📝 Improving documentation 41 | 42 | To contribute to the project, you can fork the repository, make your changes, and submit a pull request. If you find Catuserbot useful, please consider giving us a ⭐. 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /docs/about-us/support-us.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: >- 3 | Thank you for your interest in supporting TgCatUB! Your contribution helps us 4 | maintain our open-source repositories. 5 | --- 6 | 7 | # 🖤 Support Us 8 | 9 | ## ≡ How to Donate 10 | 11 | _We accept donations through UPI, PayPal, and Bitcoin._ 12 | 13 | * **UPI :** You can donate using our UPI ID --> **md.jisan@ybl** 14 | * **PayPal :** You can donate using our PayPal --> 15 | * **Bitcoin :** You can donate Bitcoin to our wallet address --> **bc1qd6pgnstm0cm366ztxqmd45src250lz0cgm40ch** 16 | 17 | Your support is greatly appreciated and will help us continue our mission of fostering collaboration and innovation in the tech industry. Thank you for helping us make a difference! 18 | -------------------------------------------------------------------------------- /docs/about-us/support.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: >- 3 | If you have any questions or issues with Catuserbot, you can get help from our 4 | community and support channels. 5 | --- 6 | 7 | # 📞 Support 8 | 9 | ## 🌐 Community 10 | 11 | Our community is a place to ask questions, share ideas, and connect with other Catuserbot users and contributors. You can join our community on Telegram for the latest updates and news. 12 | 13 | ### ≡ Telegram Group 14 | 15 | Join our official Telegram group, [**Catuserbot Support**](https://t.me/catuserbot\_support) to get help from other users and contributors. You can also share your ideas, suggestions, and feedback about the userbot. 16 | 17 | ### ≡ Telegram Channel 18 | 19 | Follow our official Telegram channel, [**Catuserbot Updates**](https://t.me/catuserbot17) to stay up to date with the latest features, bug fixes, and announcements. 20 | 21 | ## 🐞 Issue Tracker 22 | 23 | If you encounter a bug or have a feature request, you can create an issue on our [**GitHub issue tracker**](https://github.com/TgCatUB/catuserbot/issues). Before creating a new issue, please check if there is already an existing issue for the same problem or request. 24 | 25 | If you have any questions or need help, feel free to ask in the [**Catuserbot Support**](https://t.me/catuserbot\_support) group or create an issue on the issue tracker. 26 | -------------------------------------------------------------------------------- /docs/installation/guide/README.md: -------------------------------------------------------------------------------- 1 | # 📚 Guide 2 | 3 | ### _Some additonal set-up guides that might be helpful with your hosting:_ 4 | 5 |
Install Chromium or Google-Chromechromium_pokemon.jpgchromium-or-chrome-setup.md
6 | -------------------------------------------------------------------------------- /docs/installation/hosting/README.md: -------------------------------------------------------------------------------- 1 | # 📚 Hosting 2 | 3 | ## ≡ What For ?? 4 | 5 | To get started with CatUserBot, you need to host it on a virtual private server (VPS) or in Your Local machine . 6 | 7 | Its better if you run on VPS or any hosting platform over hosting locally, so it can run always. 8 | 9 | ## ≡ Methods to Host CatUserBot 10 | 11 |
Docker ComposeHost your bot using docker-compose5docker-compose.md2982327.jpg
Self HostHost your bot manually by local hosting3self-host.md5089337.jpg
HerokuHost your bot in hosting platform heroku3heroku.mdheroku.jpg
RailwayGet SSH of Railway & host there4railway.mdlogo-light.png
12 | -------------------------------------------------------------------------------- /docs/installation/hosting/docker-compose.md: -------------------------------------------------------------------------------- 1 | # 📕 Docker Compose 2 | 3 | {% hint style="success" %} 4 | This the easiest and recommended method to host Cat Userbot. 5 | {% endhint %} 6 | 7 | ## ≡ Run your bot in docker with just simple steps 8 | 9 | ### 〣 _**Install required packages**_ 10 | 11 | {% code title="Install git & docker compose" overflow="wrap" %} 12 | ```batch 13 | sudo apt install --no-install-recommends -y git docker-compose docker.io 14 | ``` 15 | {% endcode %} 16 | 17 | ### 〣 _**Clone the repo & make config**_ 18 | 19 | {% code title="Change dir to catuserbot & make config.py to save config values" overflow="wrap" %} 20 | ```batch 21 | git clone https://github.com/TgCatUB/catuserbot && cd catuserbot && mv exampleconfig.py config.py 22 | ``` 23 | {% endcode %} 24 | 25 | ### 〣 _**Edit the config.py with your config values**_ 26 | 27 | * Modify the config.py with any text editor, like `nano config.py` 28 | * **Check :** [**Config Values**](../variables/config-vars.md#mandatory-vars) 29 | 30 | ### 〣 _**All setup completed, its time to run the bot.**_ 31 | 32 | * _**Run:**_ `sudo docker-compose up` 33 | * _**Run detached:**_ `sudo docker-compose up -d` 34 | * _**Stop:**_ `sudo docker-compose stop` 35 | * _**Check:**_ `sudo docker-compose ps` 36 | 37 | {% hint style="info" %} 38 | Whenever there is an update to our base docker image (will be notified via the channel or support group), use the below steps to update your docker instances. This is not part of the main guide or not a method to update the Bot. 39 | {% endhint %} 40 | 41 | ### 〣 _Steps to update base docker image\*\*.\*\*_ 42 | 43 | {% code title="stop the running containers " overflow="wrap" %} 44 | ```batch 45 | sudo docker-compose stop 46 | ``` 47 | {% endcode %} 48 | 49 | {% code title="pull the latest image from hub" overflow="wrap" %} 50 | ```batch 51 | sudo docker pull catub/core:bullseye 52 | ``` 53 | {% endcode %} 54 | 55 | {% code title="build and run with latest image" overflow="wrap" %} 56 | ```batch 57 | sudo docker-compose up --build 58 | ``` 59 | {% endcode %} 60 | -------------------------------------------------------------------------------- /docs/installation/hosting/heroku.md: -------------------------------------------------------------------------------- 1 | # 📕 Heroku 2 | 3 | ## ≡ Disclaimer 4 | 5 | {% hint style="warning" %} 6 | Heroku now is a paid platform so use if already have an account with paid dyno, or check other method to host if you not Elon Musk in disguise. 7 | {% endhint %} 8 | 9 | #### Deploying in Heroku is the easy method , to get started you will need 2 things 10 | 11 | 1. [Heroku account](https://id.heroku.com/login) with dyno (Heroku became paid platform) 12 | 2. [GitHub account](https://github.com/) 13 | 14 | ## ≡ How to Host? 15 | 16 | Now that you got everything lets start hosting. 17 | 18 | ### 〣 _Fork repo_ 19 | 20 | Fork this repo in your Github account with a **random name** replacing **nekopack**. 21 | 22 | **Repo:** [**https://github.com/TgCatUB/nekopack**](https://github.com/TgCatUB/nekopack) 23 | 24 | {% embed url="https://youtube.com/watch?v=dwsrFjXkALE" %} 25 | Fork Nekopack 26 | {% endembed %} 27 | 28 | {% hint style="success" %} 29 | After forking copy your repo link. 30 | 31 | For example: https://github.com/your\_git\_username/random-name 32 | {% endhint %} 33 | 34 | ### 〣 _Heroku_ 35 | 36 | Add your copied fork link with Heroku template URL & you good to go. 37 | 38 | {% code title="Heroku template URL" overflow="wrap" %} 39 | ```http 40 | https://dashboard.heroku.com/new-app?template= 41 | ``` 42 | {% endcode %} 43 | 44 | {% code title="Final link will be like bellow, visit the link and build the app." overflow="wrap" %} 45 | ```http 46 | https://dashboard.heroku.com/new-app?template=https://github.com/your_git_username/random-name 47 | ``` 48 | {% endcode %} 49 | 50 | ### 〣 Get Config vars: [**Config Values**](../variables/config-vars.md#mandatory-vars) 51 | 52 | ## ≡ Video Tutorial 53 | 54 | {% embed url="https://www.youtube.com/watch?t=4s&v=c05GBLT_Ds0" %} 55 | -------------------------------------------------------------------------------- /docs/installation/hosting/railway.md: -------------------------------------------------------------------------------- 1 | # 📕 Railway 2 | 3 | ## ≡ Disclaimer 4 | 5 | {% hint style="warning" %} 6 | Railway doesn't authorize you if have any userbot/bot related stuff. If this happens clean github & delete railway. then make new railway with the clean github. 7 | {% endhint %} 8 | 9 | #### To Deploy in Railway you will need 2 things 10 | 11 | 1. [GitHub account](https://github.com/) ( 30 days old & clean ) 12 | 2. Verified [Railway account](https://railway.app/) 13 | 14 | ## ≡ How to Host? 15 | 16 | After testing all what I find, best method will be root railway, get a vps from railway & host. 17 | 18 | ### 〣 Get VPS from Railway : [_https://github.com/Jisan09/SSH4Me_](https://github.com/Jisan09/SSH4Me) 19 | 20 | _Now that you got your vps follow the rest as nomal vps user, try the method below._ 21 | 22 |
Self HostHost your bot manually by local hosting5089337.jpgself-host.md
23 | -------------------------------------------------------------------------------- /docs/installation/hosting/self-host.md: -------------------------------------------------------------------------------- 1 | # 📕 Self Host 2 | 3 | ## ≡ Build your bot manually 4 | 5 | {% hint style="warning" %} 6 | Hosting bot manually can be a bit of pain, that why we prefer [Docker](docker-compose.md) over it. Anyways If want to host manually keep up with these 2 pointers: [Chrome](self-host.md#setup-chromium), [Venv](self-host.md#create-venv) 7 | {% endhint %} 8 | 9 | ### 〣 _**Install required packages**_ 10 | 11 | {% code title="Update and install apt packages & node.v18" overflow="wrap" %} 12 | ```batch 13 | sudo apt update && sudo apt upgrade -y \ 14 | && sudo apt install --no-install-recommends -y curl ffmpeg fonts-noto-color-emoji gcc git libmagickwand-dev libpq-dev mediainfo nano neofetch pv python3 python3-dev python3-lxml python3-pip python3-psycopg2 screen tree unzip wget zlib1g libyaml-dev \ 15 | && curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && apt-get install -y nodejs 16 | ``` 17 | {% endcode %} 18 | 19 | ### 〣 _**Clone the repo & make config**_ 20 | 21 | {% code title="Change dir to catuserbot & make config.py to save config values" overflow="wrap" %} 22 | ```batch 23 | git clone https://github.com/TgCatUB/catuserbot && cd catuserbot && mv exampleconfig.py config.py 24 | ``` 25 | {% endcode %} 26 | 27 | ### 〣 _**Setup Chromium & its driver**_ 28 | 29 |
Install Chromium or Google-Chromechromium_pokemon.jpg#chromium
30 | 31 | ### 〣 _**Edit the config.py with your config values**_ 32 | 33 | * Modify the config.py with any text editor, like `nano config.py` 34 | * **Check :** [**Config Values**](../variables/config-vars.md#mandatory-vars) 35 | 36 | ### 〣 _**Create a Virtual**_ environment _**& install requirements**_ 37 | 38 | {% code title="Create catuserbot screen session" overflow="wrap" %} 39 | ```batch 40 | screen -S catuserbot 41 | ``` 42 | {% endcode %} 43 | 44 | {% code title="Install venv & requirements" overflow="wrap" %} 45 | ```batch 46 | pip install virtualenv && virtualenv venv && source venv/bin/activate && pip3 install -r requirements.txt 47 | ``` 48 | {% endcode %} 49 | 50 | ### 〣 _**All setup completed, its time to run the bot.**_ 51 | 52 | * _**Run:**_ `python3 -m userbot` 53 | * _**Close Screen:**_ Press CTRL+A and after that CTRL+D 54 | * _**Check:**_ `screen -ls` 55 | * _**Reattach Screen:**_ `screen -r .catuserbot` 56 | 57 | ## ≡ _Video Tutorial_ 58 | 59 | {% embed url="https://youtu.be/FyfW3-7i5q0" %} 60 | Self Host 61 | {% endembed %} 62 | -------------------------------------------------------------------------------- /docs/installation/variables/README.md: -------------------------------------------------------------------------------- 1 | # 📚 Variables 2 | 3 | ## ≡ What are these ? 4 | 5 | Variables are used to store configuration settings and temporary data during the execution of commands. They are defined in config.py file and can be customized by users. 6 | 7 | In catuserbot there is two types of variables: [**Config Variables**](config-vars.md) & [**Database Variables**](database-vars.md) , understanding how variables work is crucial for customizing the bot to specific needs. 8 | 9 | ## ≡ Where it save the data? 10 | 11 | The database variables are get saved to your database that you set with [**DB\_URI**](config-vars.md#db\_uri) & the config variables are get saved to either config.py or in your app environment depending [**ENV**](config-vars.md#env) variable. 12 | 13 | ## ≡ How to save var? 14 | 15 | You can edit your config.py or in your app environment manually or can set by using bot itself by doing `.set var ` . Check `.help var` or config and Database vars section for more info on this. 16 | 17 | example `.set var REM_BG_API_KEY b12a23tRBvX45UcLi` **(Get your own key, this is just an example)** :joy: 18 | 19 | _Set all the other desired vars as per above shown example._ 20 | -------------------------------------------------------------------------------- /docs/project-info/changelogs/README.md: -------------------------------------------------------------------------------- 1 | # 📑 Changelogs 2 | 3 | -------------------------------------------------------------------------------- /docs/project-info/changelogs/version-3.2.0.md: -------------------------------------------------------------------------------- 1 | # 📄 Version 3.2.0 2 | 3 | ## ✨ Additions 4 | 5 | * Added VC support 6 | * Required Var: 7 | * `VCMODE = True` 8 | * `VC_SESSION = New Session` (Optional) 9 | * Required Buildpack: `heroku-buildpack-nodejs` → [https://github.com/rahulps1000/heroku-buildpack-nodejs](https://github.com/rahulps1000/heroku-buildpack-nodejs) 10 | * Redesigned InlineQuery 11 | * Added support for Spotify, FileManager, CmdSearch 12 | * Added multiple user support for Secret & Troll 13 | * Added new chatbot using Kuki 14 | * Removed `RANDOM_STUFF_API_KEY` var (no longer needed) 15 | 16 | ## 🛠️ Improvements 17 | 18 | * Redesigned and fixed errors in App 19 | * Added flag \[-t] in \[.glist] & post in telegraph for long list in Gdrive 20 | * Added \[.grpstats] in Groupdata 21 | * Added \[.buildpack] in Heroku 22 | * Added flag \[-f] in \[.logo] & added random backgrounds (Do \[.lbg] to get) 23 | * Added flag \[-f] in \[.write] in Notebook 24 | * Added \[.rayso] in Pastebin 25 | * Added flag \[s] in \[.shazam] in Songs 26 | * Added \[.rspam] in Spam 27 | * Added inline query & changed bot to @CatMusicRobot for \[.now] in Spotify 28 | * Added flag \[p] in \[.stat] to get public links & changed to multiple texts for long messages instead of files in Stats 29 | * Added branch switch support, can switch branch like Heroku now on VPS also in VPS 30 | * Added Is\_Premium in Whois 31 | 32 | ## 🐛 Bug Fixes 33 | 34 | * Fixed error on uppercase in \[.device] in Android 35 | * Fixed error on response in \[.mal] in Anilist 36 | * Fixed webdriver error (removed .krb) in Carbon 37 | * Reformatted using API and removed PyDictionary in \[.meaning] in Dictionary 38 | * Fixed error on promote if other than owner in \[.prankpromote] in Fake 39 | * Fixed error on document files in Ffmpeg 40 | * Fixed large gif size in \[.gif / .vtog] in FileConverts 41 | * Fixed error on VPS in Lyrics 42 | * Fixed error on getting image from file in Ocr 43 | * Improved font in \[.q] in Quotly 44 | * Fixed error for premium sticker in \[.spspam] in Spam 45 | * Fixed error on kanging video & animated stickers in Stickers 46 | * Fixed error on getting videos in \[.insta] in Ytdl 47 | -------------------------------------------------------------------------------- /docs/tutorials/github-commit.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: >- 3 | Github commit is use to upload plugins to ur github repo, so they didn't get 4 | unload after restart 5 | --- 6 | 7 | # 📕 Github Commit 8 | 9 | To set-up click [Here](https://github.com/settings/tokens) & login with Github in which u forked the repo. 10 | 11 | \ 12 | Now Click on "Personal Access Token" & "Generate" 13 | 14 |
15 | 16 | Will get this page set note Anything u want & tick "repo" & "read" like in picture. Then click on "Generate token" 17 | 18 |
19 | 20 | You will get your Token copy that somewhere. Then go to github home page 21 | 22 |
23 | 24 | These are github repo names. 25 | 26 | \ 27 | Now go to heroku & set these vers & values 28 | 29 |
30 | 31 | Vars :- GITHUB\_ACCESS\_TOKEN & GIT\_REPO\_NAME 32 | 33 | Value :- The token you copied & repo name 34 | -------------------------------------------------------------------------------- /docs/tutorials/heroku-vars.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Set Heroku App Name and API 3 | --- 4 | 5 | # 📕 Heroku Vars 6 | 7 | Goto [https://dashboard.heroku.com/account](https://dashboard.heroku.com/account) and scroll down till you see the Title API key (as shown in the screenshot), click on **reveal** to see the Heroku API key, copy it and paste in settings with the var HEROKU\_API\_KEY 8 | 9 |
10 | 11 |
12 | 13 |
14 | 15 | Fill **HEROKU\_API\_KEY** and **HEROKU\_APP\_NAME** in heroku vars as shown in above screenshot 16 | -------------------------------------------------------------------------------- /docs/tutorials/ibm.md: -------------------------------------------------------------------------------- 1 | # 📕 IBM 2 | 3 | First create an account on IBM using your email. 4 | 5 | [**Click here**](https://cloud.ibm.com/registration?target=%2Fdocs%2Fspeech-to-text%2Fgetting-started.html) & create your account. 6 | 7 |
8 | 9 | Now Login to your account. 10 | 11 |
12 | 13 | After login [**Click Here**](https://cloud.ibm.com/catalog/services/speech-to-text) it will redirect you to Speech To Text. 14 | 15 | Click on Create. 16 | 17 |
18 | 19 | Then click on manage. 20 | 21 |
22 | 23 | There you will find your **API KEY** & **URL** 24 | 25 |
26 | 27 | \ 28 | 29 | 30 | \======================= 31 | 32 | Now Set those Var , Values 33 | 34 | **IBM\_WATSON\_CRED\_PASSWORD** = **API KEY** you got here. 35 | 36 | **IBM\_WATSON\_CRED\_URL** = **URL** you got here. 37 | 38 | \======================= 39 | 40 | \ 41 | -------------------------------------------------------------------------------- /docs/tutorials/lastfm.md: -------------------------------------------------------------------------------- 1 | # 📕 LastFM 2 | 3 | GET LASTFM Details as shown in the below Guide and Fill the necessary details on HEROKU, the vars are given below 4 | 5 | LASTFM\_USERNAME= Your LASTFM Username (refer image 1-2)\ 6 | LASTFM\_PASSWORD= Your LASTFM Password (refer image 1-2)\ 7 | LASTFM\_API= Your LASTFM API Key (refer image 3-6)\ 8 | LASTFM\_SECRET= Your LASTFM Secret (refer image 3-6) 9 | 10 | * Register an account on [https://www.last.fm/](https://www.last.fm/) and fill the necessary details as shown in the below screenshots 11 | 12 |

Image 1

13 | 14 |

Image 2

15 | 16 | * After creating an account, goto your email and verify your LASTFM account by clicking the link sent by LASTFM in your email 17 | * Now go to [https://www.last.fm/api](https://www.last.fm/api) and click on **Get an API Account** 18 | 19 |

Image 3

20 | 21 | Fill Contact Detail & Application Name 22 | 23 |

Image 4

24 | 25 | and click submit (keeping everything else as it is) 26 | 27 |

Image 5

28 | 29 | Copy API Key and Shared Secret 30 | 31 |

Image 6

32 | 33 | #### Lastly if you want to connect your last.fm account to Spotify then follow the below steps. 34 | 35 | Go to [https://www.last.fm/settings/applications](https://www.last.fm/settings/applications) and connect to Spotify scrobbling (see below images) 36 | 37 |
38 | 39 |
40 | -------------------------------------------------------------------------------- /docs/tutorials/spotify.md: -------------------------------------------------------------------------------- 1 | # 📕 Spotify 2 | 3 | ## 〣 Creating a Spotify App 4 | 5 | * Go to [developer.spotify.com/dashboard/login](https://developer.spotify.com/dashboard/login) and log in with your Spotify account. 6 | * Click on the "Create An App" button. This will take you to a page where you can create a new Spotify app. 7 | 8 | 9 | 10 |

Page after clicking 'Create an App'

11 | 12 | 13 | 14 | * Enter a name for your app, a short description, and agree to the terms and conditions. Then, click the "Create" button. 15 | 16 | 17 | 18 |

Page after clicking 'Create' button

19 | * On the next page, you'll see your new app's Client ID and Client Secret. These are the credentials that your bot will use to access the Spotify API. Copy these credentials and save them in your bot's configuration file as environment variables with the following names: 20 | * `SPOTIFY_CLIENT_ID` 21 | * `SPOTIFY_CLIENT_SECRET` 22 | 23 | ## 〣 Setting up Spotify integration with the bot 24 | 25 | * After starting your bot, go to your bot log group in Telegram and type `.spsetup` it will generate a message with a link. 26 | 27 | 28 | 29 |

Page after typing .spsetup in Logger group

30 | * Click on the link in the message to open the Spotify authorization page. This is where you will authorize your bot to access your Spotify account. 31 | 32 | 33 | 34 |

Page that came after clicking the link of the Logger group

35 | * Log in to your Spotify account if you haven't already. Then, click the "Agree" button to give your bot permission to access your Spotify account. After granting permission, you will be redirected to a blank page, Copy the URL of this page. 36 | 37 | 38 | 39 | * Go back to your bot log group in Telegram and paste the URL you just copied as a reply to the `.spsetup` message. The bot will use this URL to authenticate with Spotify. 40 | 41 | 42 | 43 |

Page after copy pasting the website link in reply of the link of Logger group .

44 | * If the authentication is successful, the bot will respond with a message saying "Done! Setup Successful". Your bot is now authorized to access your Spotify account, and you can start using the Spotify commands in your Telegram chats. 45 | 46 | -------------------------------------------------------------------------------- /exampleconfig.py: -------------------------------------------------------------------------------- 1 | from sample_config import Config 2 | 3 | 4 | class Development(Config): 5 | # get this values from the my.telegram.org 6 | APP_ID = 6 7 | API_HASH = "eb06d4abfb49dc3eeb1aeb98ae0f581e" 8 | # the name to display in your alive message 9 | ALIVE_NAME = "Your value" 10 | # create any PostgreSQL database (i recommend to use elephantsql) and paste that link here 11 | DB_URI = "Your value" 12 | # After cloning the repo and installing requirements do python3 stringsetup.py an fill that value with this 13 | STRING_SESSION = "Your value" 14 | # create a new bot in @botfather and fill the following vales with bottoken 15 | TG_BOT_TOKEN = "Your value" 16 | # create a private group and a rose bot to it and type /id and paste that id here (replace that -100 with that group id) 17 | PRIVATE_GROUP_BOT_API_ID = -100 18 | # command handler 19 | COMMAND_HAND_LER = "." 20 | # command hanler for sudo 21 | SUDO_COMMAND_HAND_LER = "." 22 | # External plugins repo 23 | EXTERNAL_REPO = "https://github.com/TgCatUB/CatPlugins" 24 | # if you need badcat plugins set "True" 25 | BADCAT = "False" 26 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | aiohttp 2 | apscheduler 3 | cinemagoer 4 | cloudscraper 5 | colour 6 | cowpy 7 | emoji==1.7.0 8 | fonttools 9 | geopy 10 | gitpython 11 | glitch_this 12 | google-api-python-client 13 | google-auth-httplib2 14 | google-auth-oauthlib 15 | gtts 16 | hachoir 17 | heroku3 18 | html-telegraph-poster 19 | httpx[http2] 20 | humanize 21 | jikanpy 22 | justwatch 23 | lottie 24 | lyricsgenius 25 | markdown 26 | motor 27 | openai 28 | Pillow 29 | prettytable 30 | psutil 31 | psycopg2 32 | pyfiglet 33 | PyGithub 34 | pygments 35 | pylast 36 | pymediainfo 37 | PyMuPDF 38 | pySmartDL 39 | python-barcode 40 | pytz 41 | qrcode 42 | requests 43 | selenium 44 | setuptools 45 | ShazamAPI 46 | somnium 47 | spamwatch 48 | speedtest-cli 49 | sqlalchemy-json 50 | sqlalchemy==1.3.23 51 | telegraph==2.1.0 52 | tgcrypto 53 | ujson 54 | urlextract 55 | validators 56 | vcsi 57 | wand 58 | wget 59 | 60 | git+https://github.com/Jisan09/search-engine-parser 61 | git+https://github.com/Jisan09/Telethon@test 62 | git+https://github.com/goldsmith/Wikipedia 63 | git+https://github.com/sandy1709/py-googletrans 64 | git+https://github.com/alexmercerind/youtube-search-python 65 | git+https://github.com/yt-dlp/yt-dlp 66 | -------------------------------------------------------------------------------- /stringsetup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # (c) https://t.me/TelethonChat/37677 3 | # This Source Code Form is subject to the terms of the GNU 4 | # General Public License, v.3.0. If a copy of the GPL was not distributed with this 5 | # file, You can obtain one at https://www.gnu.org/licenses/gpl-3.0.en.html. 6 | 7 | from telethon.sessions import StringSession 8 | from telethon.sync import TelegramClient 9 | 10 | print( 11 | """Please go-to my.telegram.org 12 | Login using your Telegram account 13 | Click on API Development Tools 14 | Create a new application, by entering the required details""" 15 | ) 16 | APP_ID = int(input("Enter APP ID here: ")) 17 | API_HASH = input("Enter API HASH here: ") 18 | 19 | with TelegramClient(StringSession(), APP_ID, API_HASH) as client: 20 | print(client.session.save()) 21 | client.sendmessage("me", client.session.save()) 22 | -------------------------------------------------------------------------------- /userbot/Config/Readme.md: -------------------------------------------------------------------------------- 1 | # Config 2 | Config vars will be loaded from here 3 | -------------------------------------------------------------------------------- /userbot/Config/__init__.py: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# CatUserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 2 | # Copyright (C) 2020-2023 by TgCatUB@Github. 3 | 4 | # This file is part of: https://github.com/TgCatUB/catuserbot 5 | # and is released under the "GNU v3.0 License Agreement". 6 | 7 | # Please see: https://github.com/TgCatUB/catuserbot/blob/master/LICENSE 8 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 9 | 10 | from .catub_config import Config 11 | -------------------------------------------------------------------------------- /userbot/Config/catub_config.py: -------------------------------------------------------------------------------- 1 | """ Config values will be loaded from here""" 2 | 3 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# CatUserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 4 | # Copyright (C) 2020-2023 by TgCatUB@Github. 5 | 6 | # This file is part of: https://github.com/TgCatUB/catuserbot 7 | # and is released under the "GNU v3.0 License Agreement". 8 | 9 | # Please see: https://github.com/TgCatUB/catuserbot/blob/master/LICENSE 10 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 11 | 12 | import os 13 | 14 | ENV = bool(os.environ.get("ENV", False)) 15 | 16 | if ENV: 17 | from sample_config import Config # noqa 18 | elif os.path.exists("config.py"): 19 | from config import Development as Config # noqa 20 | -------------------------------------------------------------------------------- /userbot/__init__.py: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# CatUserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 2 | # Copyright (C) 2020-2023 by TgCatUB@Github. 3 | 4 | # This file is part of: https://github.com/TgCatUB/catuserbot 5 | # and is released under the "GNU v3.0 License Agreement". 6 | 7 | # Please see: https://github.com/TgCatUB/catuserbot/blob/master/LICENSE 8 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 9 | 10 | import signal 11 | import sys 12 | import time 13 | 14 | import heroku3 15 | 16 | from .Config import Config 17 | from .core.logger import logging 18 | from .core.session import catub 19 | from .helpers.functions.converter import Convert 20 | from .helpers.functions.musictool import * 21 | from .helpers.utils.utils import runasync 22 | from .sql_helper.globals import addgvar, delgvar, gvarstatus 23 | 24 | __version__ = "3.3.0" 25 | __license__ = "GNU Affero General Public License v3.0" 26 | __author__ = "CatUserBot " 27 | __copyright__ = f"Copyright (C) 2020 - 2023 {__author__}" 28 | 29 | catub.version = __version__ 30 | catub.tgbot.version = __version__ 31 | LOGS = logging.getLogger("CatUserbot") 32 | bot = catub 33 | 34 | StartTime = time.time() 35 | catversion = "3.3.0" 36 | 37 | 38 | def close_connection(*_): 39 | print("Closing Userbot connection.") 40 | runasync(catub.disconnect()) 41 | sys.exit(143) 42 | 43 | 44 | signal.signal(signal.SIGTERM, close_connection) 45 | 46 | UPSTREAM_REPO_URL = Config.UPSTREAM_REPO 47 | 48 | if Config.PRIVATE_GROUP_BOT_API_ID == 0: 49 | if gvarstatus("PRIVATE_GROUP_BOT_API_ID") is None: 50 | Config.BOTLOG = False 51 | Config.BOTLOG_CHATID = "me" 52 | else: 53 | Config.BOTLOG_CHATID = int(gvarstatus("PRIVATE_GROUP_BOT_API_ID")) 54 | Config.PRIVATE_GROUP_BOT_API_ID = int(gvarstatus("PRIVATE_GROUP_BOT_API_ID")) 55 | Config.BOTLOG = True 56 | else: 57 | if str(Config.PRIVATE_GROUP_BOT_API_ID)[0] != "-": 58 | Config.BOTLOG_CHATID = int(f"-{str(Config.PRIVATE_GROUP_BOT_API_ID)}") 59 | else: 60 | Config.BOTLOG_CHATID = Config.PRIVATE_GROUP_BOT_API_ID 61 | Config.BOTLOG = True 62 | 63 | if Config.PM_LOGGER_GROUP_ID == 0: 64 | if gvarstatus("PM_LOGGER_GROUP_ID") is None: 65 | Config.PM_LOGGER_GROUP_ID = -100 66 | else: 67 | Config.PM_LOGGER_GROUP_ID = int(gvarstatus("PM_LOGGER_GROUP_ID")) 68 | elif str(Config.PM_LOGGER_GROUP_ID)[0] != "-": 69 | Config.PM_LOGGER_GROUP_ID = int(f"-{str(Config.PM_LOGGER_GROUP_ID)}") 70 | 71 | try: 72 | if Config.HEROKU_API_KEY is not None or Config.HEROKU_APP_NAME is not None: 73 | HEROKU_APP = heroku3.from_key(Config.HEROKU_API_KEY).apps()[ 74 | Config.HEROKU_APP_NAME 75 | ] 76 | else: 77 | HEROKU_APP = None 78 | except Exception: 79 | HEROKU_APP = None 80 | 81 | 82 | # Global Configiables 83 | COUNT_MSG = 0 84 | USERS = {} 85 | COUNT_PM = {} 86 | LASTMSG = {} 87 | CMD_HELP = {} 88 | ISAFK = False 89 | AFKREASON = None 90 | CMD_LIST = {} 91 | SUDO_LIST = {} 92 | # for later purposes 93 | INT_PLUG = "" 94 | LOAD_PLUG = {} 95 | 96 | # Variables 97 | BOTLOG = Config.BOTLOG 98 | BOTLOG_CHATID = Config.BOTLOG_CHATID 99 | PM_LOGGER_GROUP_ID = Config.PM_LOGGER_GROUP_ID 100 | -------------------------------------------------------------------------------- /userbot/assistant/__init__.py: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# CatUserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 2 | # Copyright (C) 2020-2023 by TgCatUB@Github. 3 | 4 | # This file is part of: https://github.com/TgCatUB/catuserbot 5 | # and is released under the "GNU v3.0 License Agreement". 6 | 7 | # Please see: https://github.com/TgCatUB/catuserbot/blob/master/LICENSE 8 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 9 | 10 | from userbot import BOTLOG, BOTLOG_CHATID, catub 11 | 12 | from ..Config import Config 13 | from ..core.inlinebot import * 14 | -------------------------------------------------------------------------------- /userbot/assistant/hide.py: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# CatUserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 2 | # Copyright (C) 2020-2023 by TgCatUB@Github. 3 | 4 | # This file is part of: https://github.com/TgCatUB/catuserbot 5 | # and is released under the "GNU v3.0 License Agreement". 6 | 7 | # Please see: https://github.com/TgCatUB/catuserbot/blob/master/LICENSE 8 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 9 | 10 | import json 11 | import os 12 | import re 13 | 14 | from telethon.events import CallbackQuery 15 | 16 | from userbot import catub 17 | 18 | 19 | @catub.tgbot.on(CallbackQuery(data=re.compile(b"hide_(.*)"))) 20 | async def on_plug_in_callback_query_handler(event): 21 | timestamp = int(event.pattern_match.group(1).decode("UTF-8")) 22 | if os.path.exists("./userbot/hide.txt"): 23 | jsondata = json.load(open("./userbot/hide.txt")) 24 | try: 25 | reply_pop_up_alert = jsondata[f"{timestamp}"]["text"] 26 | except KeyError: 27 | reply_pop_up_alert = "This message no longer exists in catub server" 28 | else: 29 | reply_pop_up_alert = "This message no longer exists " 30 | await event.answer(reply_pop_up_alert, cache_time=0, alert=True) 31 | -------------------------------------------------------------------------------- /userbot/assistant/nsfw.py: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# CatUserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 2 | # Copyright (C) 2020-2023 by TgCatUB@Github. 3 | 4 | # This file is part of: https://github.com/TgCatUB/catuserbot 5 | # and is released under the "GNU v3.0 License Agreement". 6 | 7 | # Please see: https://github.com/TgCatUB/catuserbot/blob/master/LICENSE 8 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 9 | 10 | import contextlib 11 | import re 12 | 13 | from telethon import Button 14 | from telethon.errors import MessageNotModifiedError 15 | from telethon.events import CallbackQuery 16 | 17 | from userbot import catub 18 | 19 | from ..Config import Config 20 | from ..core.logger import logging 21 | 22 | LOGS = logging.getLogger(__name__) 23 | 24 | 25 | @catub.tgbot.on(CallbackQuery(data=re.compile(r"^age_verification_true"))) 26 | async def age_verification_true(event: CallbackQuery): 27 | u_id = event.query.user_id 28 | if u_id != Config.OWNER_ID and u_id not in Config.SUDO_USERS: 29 | return await event.answer( 30 | "Given That It's A Stupid-Ass Decision, I've Elected To Ignore It.", 31 | alert=True, 32 | ) 33 | await event.answer("Yes I'm 18+", alert=False) 34 | buttons = [ 35 | Button.inline( 36 | text="Unsure / Change of Decision ❔", 37 | data="chg_of_decision_", 38 | ) 39 | ] 40 | with contextlib.suppress(MessageNotModifiedError): 41 | await event.edit( 42 | text="To access this plugin type `.setdv ALLOW_NSFW True`", 43 | file="https://graph.org/file/85f3071c31279bcc280ef.jpg", 44 | buttons=buttons, 45 | ) 46 | 47 | 48 | @catub.tgbot.on(CallbackQuery(data=re.compile(r"^age_verification_false"))) 49 | async def age_verification_false(event: CallbackQuery): 50 | u_id = event.query.user_id 51 | if u_id != Config.OWNER_ID and u_id not in Config.SUDO_USERS: 52 | return await event.answer( 53 | "Given That It's A Stupid-Ass Decision, I've Elected To Ignore It.", 54 | alert=True, 55 | ) 56 | await event.answer("No I'm Not", alert=False) 57 | buttons = [ 58 | Button.inline( 59 | text="Unsure / Change of Decision ❔", 60 | data="chg_of_decision_", 61 | ) 62 | ] 63 | with contextlib.suppress(MessageNotModifiedError): 64 | await event.edit( 65 | text="GO AWAY KID !", 66 | file="https://graph.org/file/1140f16a883d35224e6a1.jpg", 67 | buttons=buttons, 68 | ) 69 | 70 | 71 | @catub.tgbot.on(CallbackQuery(data=re.compile(r"^chg_of_decision_"))) 72 | async def chg_of_decision_(event: CallbackQuery): 73 | u_id = event.query.user_id 74 | if u_id != Config.OWNER_ID and u_id not in Config.SUDO_USERS: 75 | return await event.answer( 76 | "Given That It's A Stupid-Ass Decision, I've Elected To Ignore It.", 77 | alert=True, 78 | ) 79 | await event.answer("Unsure", alert=False) 80 | buttons = [ 81 | ( 82 | Button.inline(text="Yes I'm 18+", data="age_verification_true"), 83 | Button.inline(text="No I'm Not", data="age_verification_false"), 84 | ) 85 | ] 86 | with contextlib.suppress(MessageNotModifiedError): 87 | await event.edit( 88 | text="**ARE YOU OLD ENOUGH FOR THIS ?**", 89 | file="https://graph.org/file/238f2c55930640e0e8c56.jpg", 90 | buttons=buttons, 91 | ) 92 | -------------------------------------------------------------------------------- /userbot/assistant/secret.py: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# CatUserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 2 | # Copyright (C) 2020-2023 by TgCatUB@Github. 3 | 4 | # This file is part of: https://github.com/TgCatUB/catuserbot 5 | # and is released under the "GNU v3.0 License Agreement". 6 | 7 | # Please see: https://github.com/TgCatUB/catuserbot/blob/master/LICENSE 8 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 9 | 10 | import json 11 | import os 12 | import re 13 | 14 | from telethon.events import CallbackQuery 15 | 16 | from userbot import catub 17 | 18 | 19 | @catub.tgbot.on(CallbackQuery(data=re.compile(b"secret_(.*)"))) 20 | async def on_plug_in_callback_query_handler(event): 21 | timestamp = int(event.pattern_match.group(1).decode("UTF-8")) 22 | if os.path.exists("./userbot/secret.txt"): 23 | jsondata = json.load(open("./userbot/secret.txt")) 24 | try: 25 | message = jsondata[f"{timestamp}"] 26 | userid = message["userid"] 27 | ids = userid + [catub.uid] 28 | if event.query.user_id in ids: 29 | encrypted_tcxt = message["text"] 30 | reply_pop_up_alert = encrypted_tcxt 31 | else: 32 | reply_pop_up_alert = "why were you looking at this shit go away and do your own work, idiot" 33 | except KeyError: 34 | reply_pop_up_alert = "This message no longer exists in catub server" 35 | else: 36 | reply_pop_up_alert = "This message no longer exists " 37 | await event.answer(reply_pop_up_alert, cache_time=0, alert=True) 38 | -------------------------------------------------------------------------------- /userbot/assistant/troll.py: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# CatUserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 2 | # Copyright (C) 2020-2023 by TgCatUB@Github. 3 | 4 | # This file is part of: https://github.com/TgCatUB/catuserbot 5 | # and is released under the "GNU v3.0 License Agreement". 6 | 7 | # Please see: https://github.com/TgCatUB/catuserbot/blob/master/LICENSE 8 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 9 | 10 | import json 11 | import os 12 | import re 13 | 14 | from telethon.events import CallbackQuery 15 | 16 | from userbot import catub 17 | 18 | 19 | @catub.tgbot.on(CallbackQuery(data=re.compile(b"troll_(.*)"))) 20 | async def on_plug_in_callback_query_handler(event): 21 | timestamp = int(event.pattern_match.group(1).decode("UTF-8")) 22 | if os.path.exists("./userbot/troll.txt"): 23 | jsondata = json.load(open("./userbot/troll.txt")) 24 | try: 25 | message = jsondata[f"{timestamp}"] 26 | userid = message["userid"] 27 | ids = userid 28 | if event.query.user_id in ids: 29 | reply_pop_up_alert = ( 30 | "You are not allowed to see this message, better luck next time!" 31 | ) 32 | else: 33 | encrypted_tcxt = message["text"] 34 | reply_pop_up_alert = encrypted_tcxt 35 | except KeyError: 36 | reply_pop_up_alert = "This message no longer exists in catub server" 37 | else: 38 | reply_pop_up_alert = "This message no longer exists " 39 | await event.answer(reply_pop_up_alert, cache_time=0, alert=True) 40 | -------------------------------------------------------------------------------- /userbot/cache/readme.md: -------------------------------------------------------------------------------- 1 | To store cache file of CatUserbot 2 | -------------------------------------------------------------------------------- /userbot/core/__init__.py: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# CatUserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 2 | # Copyright (C) 2020-2023 by TgCatUB@Github. 3 | 4 | # This file is part of: https://github.com/TgCatUB/catuserbot 5 | # and is released under the "GNU v3.0 License Agreement". 6 | 7 | # Please see: https://github.com/TgCatUB/catuserbot/blob/master/LICENSE 8 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 9 | 10 | from .decorators import check_owner 11 | 12 | CMD_INFO = {} 13 | PLG_INFO = {} 14 | GRP_INFO = {} 15 | BOT_INFO = [] 16 | LOADED_CMDS = {} 17 | -------------------------------------------------------------------------------- /userbot/core/data.py: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# CatUserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 2 | # Copyright (C) 2020-2023 by TgCatUB@Github. 3 | 4 | # This file is part of: https://github.com/TgCatUB/catuserbot 5 | # and is released under the "GNU v3.0 License Agreement". 6 | 7 | # Please see: https://github.com/TgCatUB/catuserbot/blob/master/LICENSE 8 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 9 | 10 | import contextlib 11 | 12 | from ..sql_helper.global_collectionjson import get_collection 13 | from ..sql_helper.global_list import get_collection_list 14 | 15 | 16 | def _sudousers_list(): 17 | sudousers = {} 18 | with contextlib.suppress(AttributeError): 19 | sudousers = get_collection("sudousers_list").json 20 | return [int(chat) for chat in [*sudousers]] 21 | 22 | 23 | def _vcusers_list(): 24 | vcusers = {} 25 | with contextlib.suppress(AttributeError): 26 | vcusers = get_collection("vcusers_list").json 27 | return [int(chat) for chat in [*vcusers]] 28 | 29 | 30 | def _users_list(): 31 | sudousers = {} 32 | with contextlib.suppress(AttributeError): 33 | sudousers = get_collection("sudousers_list").json 34 | ulist = [int(chat) for chat in [*sudousers]] 35 | ulist.append("me") 36 | return list(ulist) 37 | 38 | 39 | def blacklist_chats_list(): 40 | blacklistchats = {} 41 | with contextlib.suppress(AttributeError): 42 | blacklistchats = get_collection("blacklist_chats_list").json 43 | return [int(chat) for chat in [*blacklistchats]] 44 | 45 | 46 | def sudo_enabled_cmds(): 47 | listcmds = get_collection_list("sudo_enabled_cmds") 48 | return list(listcmds) 49 | -------------------------------------------------------------------------------- /userbot/core/decorators.py: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# CatUserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 2 | # Copyright (C) 2020-2023 by TgCatUB@Github. 3 | 4 | # This file is part of: https://github.com/TgCatUB/catuserbot 5 | # and is released under the "GNU v3.0 License Agreement". 6 | 7 | # Please see: https://github.com/TgCatUB/catuserbot/blob/master/LICENSE 8 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 9 | 10 | import asyncio 11 | 12 | from telethon.errors import FloodWaitError, MessageNotModifiedError 13 | 14 | from ..Config import Config 15 | from ..sql_helper.globals import gvarstatus 16 | from .data import _vcusers_list 17 | 18 | 19 | class check_owner: 20 | def __init__(self, func=None, vc=False): 21 | self.func = func 22 | self.vc = vc 23 | 24 | def __call__(self, *args, **kwargs): 25 | if not self.func: 26 | return self.__class__(args[0], vc=self.vc) 27 | 28 | async def wrapper(*args, **kwargs): 29 | c_q = args[0] 30 | if c_q.query.user_id and ( 31 | c_q.query.user_id == Config.OWNER_ID 32 | or c_q.query.user_id in Config.SUDO_USERS 33 | or (self.vc and c_q.query.user_id in _vcusers_list()) 34 | ): 35 | try: 36 | await self.func(c_q) 37 | except FloodWaitError as e: 38 | await asyncio.sleep(e.seconds + 5) 39 | except MessageNotModifiedError: 40 | pass 41 | else: 42 | HELP_TEXT = ( 43 | gvarstatus("HELP_TEXT") 44 | or "Only My Master can Access This !!\n\nDeploy your own Catuserbot." 45 | ) 46 | await c_q.answer( 47 | HELP_TEXT, 48 | alert=True, 49 | ) 50 | 51 | return wrapper(*args, **kwargs) 52 | -------------------------------------------------------------------------------- /userbot/core/helpers.py: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# CatUserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 2 | # Copyright (C) 2020-2023 by TgCatUB@Github. 3 | 4 | # This file is part of: https://github.com/TgCatUB/catuserbot 5 | # and is released under the "GNU v3.0 License Agreement". 6 | 7 | # Please see: https://github.com/TgCatUB/catuserbot/blob/master/LICENSE 8 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 9 | 10 | import logging 11 | from typing import Union 12 | 13 | from telethon.tl import types 14 | from telethon.utils import get_display_name 15 | 16 | from .events import NewMessage 17 | 18 | LOGGER = logging.getLogger("userbot") 19 | 20 | 21 | def printUser(entity: types.User) -> None: 22 | """Print the user's first name + last name upon start""" 23 | user = get_display_name(entity) 24 | LOGGER.warning("Successfully logged in as {0}".format(user)) 25 | 26 | 27 | async def get_chat_link( 28 | arg: Union[types.User, types.Chat, types.Channel, NewMessage.Event], reply=None 29 | ) -> str: 30 | if isinstance(arg, (types.User, types.Chat, types.Channel)): 31 | entity = arg 32 | else: 33 | entity = await arg.get_chat() 34 | 35 | if isinstance(entity, types.User): 36 | if entity.is_self: 37 | name = 'your "Saved Messages"' 38 | else: 39 | name = get_display_name(entity) or "Deleted Account?" 40 | extra = f"[{name}](tg://user?id={entity.id})" 41 | else: 42 | if hasattr(entity, "username") and entity.username is not None: 43 | username = f"@{entity.username}" 44 | else: 45 | username = entity.id 46 | if reply is not None: 47 | if isinstance(username, str) and username.startswith("@"): 48 | username = username[1:] 49 | else: 50 | username = f"c/{username}" 51 | extra = f"[{entity.title}](https://t.me/{username}/{reply})" 52 | elif isinstance(username, int): 53 | username = f"`{username}`" 54 | extra = f"{entity.title} ( {username} )" 55 | else: 56 | extra = f"[{entity.title}](tg://resolve?domain={username})" 57 | return extra 58 | -------------------------------------------------------------------------------- /userbot/core/logger.py: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# CatUserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 2 | # Copyright (C) 2020-2023 by TgCatUB@Github. 3 | 4 | # This file is part of: https://github.com/TgCatUB/catuserbot 5 | # and is released under the "GNU v3.0 License Agreement". 6 | 7 | # Please see: https://github.com/TgCatUB/catuserbot/blob/master/LICENSE 8 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 9 | 10 | import logging 11 | 12 | logging.basicConfig( 13 | format="[%(levelname)s- %(asctime)s]- %(name)s- %(message)s", 14 | handlers=[logging.FileHandler("catub.log"), logging.StreamHandler()], 15 | level=logging.INFO, 16 | datefmt="%H:%M:%S", 17 | ) 18 | 19 | logging.getLogger("telethon.client.updates").setLevel(logging.WARNING) 20 | logging.getLogger("telethon.network").setLevel(logging.WARNING) 21 | -------------------------------------------------------------------------------- /userbot/core/pluginManager.py: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# CatUserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 2 | # Copyright (C) 2020-2023 by TgCatUB@Github. 3 | 4 | # This file is part of: https://github.com/TgCatUB/catuserbot 5 | # and is released under the "GNU v3.0 License Agreement". 6 | 7 | # Please see: https://github.com/TgCatUB/catuserbot/blob/master/LICENSE 8 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 9 | 10 | import asyncio 11 | import os 12 | import re 13 | import sys 14 | 15 | from telethon import TelegramClient 16 | 17 | from ..core.logger import logging 18 | from ..sql_helper.global_collection import ( 19 | add_to_collectionlist, 20 | del_keyword_collectionlist, 21 | get_collectionlist_items, 22 | ) 23 | 24 | package_patern = re.compile(r"([\w-]+)(?:=|<|>|!)") 25 | github_patern = re.compile(r"(?:https?)?(?:www.)?(?:github.com/)?([\w\-.]+/[\w\-.]+)/?") 26 | github_raw_pattern = re.compile( 27 | r"(?:https?)?(?:raw.)?(?:githubusercontent.com/)?([\w\-.]+/[\w\-.]+)/?" 28 | ) 29 | trees_pattern = "https://api.github.com/repos/{}/git/trees/master" 30 | raw_pattern = "https://raw.githubusercontent.com/{}/master/{}" 31 | 32 | LOGS = logging.getLogger(__name__) 33 | 34 | 35 | async def get_pip_packages(requirements): 36 | """Get a list of all the pacakage's names.""" 37 | if requirements: 38 | packages = requirements 39 | else: 40 | cmd = await asyncio.create_subprocess_exec( 41 | sys.executable.replace(" ", "\\ "), 42 | "-m", 43 | "pip", 44 | "freeze", 45 | stdout=asyncio.subprocess.PIPE, 46 | stderr=asyncio.subprocess.PIPE, 47 | ) 48 | stdout, _ = await cmd.communicate() 49 | packages = stdout.decode("utf-8") 50 | tmp = package_patern.findall(packages) 51 | return [package.lower() for package in tmp] 52 | 53 | 54 | async def install_pip_packages(packages): 55 | """Install pip packages.""" 56 | args = ["-m", "pip", "install", "--upgrade", "--user"] 57 | cmd = await asyncio.create_subprocess_exec( 58 | sys.executable.replace(" ", "\\ "), 59 | *args, 60 | *packages, 61 | stdout=asyncio.subprocess.PIPE, 62 | stderr=asyncio.subprocess.PIPE, 63 | ) 64 | await cmd.communicate() 65 | return cmd.returncode == 0 66 | 67 | 68 | def run_async(func: callable): 69 | """Run async functions with the right event loop.""" 70 | asyncio.get_event_loop() 71 | return loop.run_until_complete(func) 72 | 73 | 74 | async def restart_script(client: TelegramClient, sandy): 75 | """Restart the current script.""" 76 | try: 77 | ulist = get_collectionlist_items() 78 | for i in ulist: 79 | if i == "restart_update": 80 | del_keyword_collectionlist("restart_update") 81 | except Exception as e: 82 | LOGS.error(e) 83 | try: 84 | add_to_collectionlist("restart_update", [sandy.chat_id, sandy.id]) 85 | except Exception as e: 86 | LOGS.error(e) 87 | executable = sys.executable.replace(" ", "\\ ") 88 | args = [executable, "-m", "userbot"] 89 | os.execle(executable, *args, os.environ) 90 | os._exit(143) 91 | 92 | 93 | async def get_message_link(client, event): 94 | chat = await event.get_chat() 95 | if event.is_private: 96 | return f"tg://openmessage?user_id={chat.id}&message_id={event.id}" 97 | return f"https://t.me/c/{chat.id}/{event.id}" 98 | -------------------------------------------------------------------------------- /userbot/core/pool.py: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# CatUserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 2 | # Copyright (C) 2020-2023 by TgCatUB@Github. 3 | 4 | # This file is part of: https://github.com/TgCatUB/catuserbot 5 | # and is released under the "GNU v3.0 License Agreement". 6 | 7 | # Please see: https://github.com/TgCatUB/catuserbot/blob/master/LICENSE 8 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 9 | 10 | import asyncio 11 | from concurrent.futures import Future, ThreadPoolExecutor 12 | from functools import partial, wraps 13 | from typing import Any, Callable 14 | 15 | from motor.frameworks.asyncio import _EXECUTOR 16 | 17 | from .logger import logging 18 | 19 | _LOG = logging.getLogger(__name__) 20 | _LOG_STR = "<<>>" 21 | 22 | 23 | def submit_thread(func: Callable[[Any], Any], *args: Any, **kwargs: Any) -> Future: 24 | """submit thread to thread pool""" 25 | return _EXECUTOR.submit(func, *args, **kwargs) 26 | 27 | 28 | def run_in_thread(func: Callable[[Any], Any]) -> Callable[[Any], Any]: 29 | """run in a thread""" 30 | 31 | @wraps(func) 32 | async def wrapper(*args: Any, **kwargs: Any) -> Any: 33 | loop = asyncio.get_running_loop() 34 | return await loop.run_in_executor(_EXECUTOR, partial(func, *args, **kwargs)) 35 | 36 | return wrapper 37 | 38 | 39 | def _get() -> ThreadPoolExecutor: 40 | return _EXECUTOR 41 | 42 | 43 | def _stop(): 44 | _EXECUTOR.shutdown() 45 | # pylint: disable=protected-access 46 | _LOG.info(_LOG_STR, f"Stopped Pool : {_EXECUTOR._max_workers} Workers") 47 | 48 | 49 | # pylint: disable=protected-access 50 | _LOG.info(_LOG_STR, f"Started Pool : {_EXECUTOR._max_workers} Workers") 51 | -------------------------------------------------------------------------------- /userbot/core/session.py: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# CatUserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 2 | # Copyright (C) 2020-2023 by TgCatUB@Github. 3 | 4 | # This file is part of: https://github.com/TgCatUB/catuserbot 5 | # and is released under the "GNU v3.0 License Agreement". 6 | 7 | # Please see: https://github.com/TgCatUB/catuserbot/blob/master/LICENSE 8 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 9 | 10 | import sys 11 | 12 | from telethon.network.connection.tcpabridged import ConnectionTcpAbridged 13 | from telethon.sessions import StringSession 14 | 15 | from ..Config import Config 16 | from .client import CatUserBotClient 17 | 18 | __version__ = "3.3.0" 19 | 20 | loop = None 21 | 22 | if Config.STRING_SESSION: 23 | session = StringSession(str(Config.STRING_SESSION)) 24 | else: 25 | session = "catuserbot" 26 | 27 | try: 28 | catub = CatUserBotClient( 29 | session=session, 30 | api_id=Config.APP_ID, 31 | api_hash=Config.API_HASH, 32 | loop=loop, 33 | app_version=__version__, 34 | connection=ConnectionTcpAbridged, 35 | auto_reconnect=True, 36 | connection_retries=None, 37 | ) 38 | except Exception as e: 39 | print(f"STRING_SESSION - {e}") 40 | sys.exit() 41 | 42 | 43 | catub.tgbot = tgbot = CatUserBotClient( 44 | session="CatTgbot", 45 | api_id=Config.APP_ID, 46 | api_hash=Config.API_HASH, 47 | loop=loop, 48 | app_version=__version__, 49 | connection=ConnectionTcpAbridged, 50 | auto_reconnect=True, 51 | connection_retries=None, 52 | ).start(bot_token=Config.TG_BOT_TOKEN) 53 | -------------------------------------------------------------------------------- /userbot/helpers/Readme.md: -------------------------------------------------------------------------------- 1 | # helpers 2 | 3 | Some of the functions required for plugins are defined here 4 | -------------------------------------------------------------------------------- /userbot/helpers/__init__.py: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# CatUserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 2 | # Copyright (C) 2020-2023 by TgCatUB@Github. 3 | 4 | # This file is part of: https://github.com/TgCatUB/catuserbot 5 | # and is released under the "GNU v3.0 License Agreement". 6 | 7 | # Please see: https://github.com/TgCatUB/catuserbot/blob/master/LICENSE 8 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 9 | 10 | from . import fonts 11 | from . import memeshelper as catmemes 12 | from .aiohttp_helper import AioHttp 13 | from .utils import * 14 | 15 | flag = True 16 | check = 0 17 | while flag: 18 | try: 19 | from .chatbot import * 20 | from .functions import * 21 | from .memeifyhelpers import * 22 | from .progress import * 23 | from .qhelper import * 24 | from .tools import * 25 | from .utils import _catutils, _format 26 | 27 | break 28 | except ModuleNotFoundError as e: 29 | install_pip(e.name) 30 | check += 1 31 | if check > 5: 32 | break 33 | -------------------------------------------------------------------------------- /userbot/helpers/aiohttp_helper.py: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# CatUserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 2 | # Copyright (C) 2020-2023 by TgCatUB@Github. 3 | 4 | # This file is part of: https://github.com/TgCatUB/catuserbot 5 | # and is released under the "GNU v3.0 License Agreement". 6 | 7 | # Please see: https://github.com/TgCatUB/catuserbot/blob/master/LICENSE 8 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 9 | 10 | import aiohttp 11 | 12 | 13 | class AioHttp: 14 | @staticmethod 15 | async def get_json(link): 16 | async with aiohttp.ClientSession() as session: 17 | async with session.get(link) as resp: 18 | return await resp.json() 19 | 20 | @staticmethod 21 | async def get_text(link): 22 | async with aiohttp.ClientSession() as session: 23 | async with session.get(link) as resp: 24 | return await resp.text() 25 | 26 | @staticmethod 27 | async def get_raw(link): 28 | async with aiohttp.ClientSession() as session: 29 | async with session.get(link) as resp: 30 | return await resp.read() 31 | 32 | @staticmethod 33 | async def get_status(link): 34 | async with aiohttp.ClientSession() as session: 35 | async with session.get(link) as resp: 36 | return resp.status 37 | -------------------------------------------------------------------------------- /userbot/helpers/aria2utils: -------------------------------------------------------------------------------- 1 | import os 2 | from subprocess import PIPE, Popen 3 | 4 | import aria2p 5 | from requests import get 6 | 7 | from .. import LOGS 8 | from ..Config import Config 9 | 10 | TMP_DOWNLOAD_DIRECTORY = Config.TMP_DOWNLOAD_DIRECTORY 11 | 12 | 13 | def subprocess_run(cmd): 14 | subproc = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True, universal_newlines=True) 15 | talk = subproc.communicate() 16 | exitCode = subproc.returncode 17 | if exitCode != 0: 18 | return 19 | return talk 20 | 21 | 22 | # Get best trackers for improved download speeds, thanks K-E-N-W-A-Y. 23 | trackers_list = get( 24 | "https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_best.txt" 25 | ).text.replace("\n\n", ",") 26 | trackers = f"[{trackers_list}]" 27 | 28 | cmd = f"aria2c --enable-rpc --rpc-listen-all=false --rpc-listen-port 6800 --max-connection-per-server=10 --rpc-max-request-size=1024M --seed-time=0.01 --max-upload-limit=5K --max-concurrent-downloads=5 --min-split-size=10M --follow-torrent=mem --split=10 --bt-tracker={trackers} --daemon=true --allow-overwrite=true" 29 | EDIT_SLEEP_TIME_OUT = 5 30 | 31 | aria2 = aria2p.API(aria2p.Client(host="http://localhost", port=6800, secret="")) 32 | 33 | subprocess_run(cmd) 34 | 35 | if not os.path.isdir(TMP_DOWNLOAD_DIRECTORY): 36 | os.makedirs(TMP_DOWNLOAD_DIRECTORY) 37 | 38 | download_path = os.getcwd() + TMP_DOWNLOAD_DIRECTORY.strip(".") 39 | 40 | aria2.set_global_options({"dir": download_path}) 41 | 42 | 43 | async def check_metadata(gid): 44 | file = aria2.get_download(gid) 45 | new_gid = file.followed_by_ids[0] 46 | LOGS.info("Changing GID " + gid + " to" + new_gid) 47 | return new_gid 48 | -------------------------------------------------------------------------------- /userbot/helpers/exceptions.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020 Adek Maulana 2 | # 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see . 16 | 17 | 18 | class CancelProcess(Exception): 19 | """ 20 | Cancel Process 21 | """ 22 | -------------------------------------------------------------------------------- /userbot/helpers/functions/__init__.py: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# CatUserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 2 | # Copyright (C) 2020-2023 by TgCatUB@Github. 3 | 4 | # This file is part of: https://github.com/TgCatUB/catuserbot 5 | # and is released under the "GNU v3.0 License Agreement". 6 | 7 | # Please see: https://github.com/TgCatUB/catuserbot/blob/master/LICENSE 8 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 9 | 10 | from .findquote import * 11 | from .functions import * 12 | from .ialivetext import * 13 | from .imgtools import * 14 | from .jikan import * 15 | from .nekos import * 16 | from .utils import * 17 | from .utube import * 18 | from .vidtools import * 19 | -------------------------------------------------------------------------------- /userbot/helpers/functions/findquote.py: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# CatUserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 2 | # Copyright (C) 2020-2023 by TgCatUB@Github. 3 | 4 | # This file is part of: https://github.com/TgCatUB/catuserbot 5 | # and is released under the "GNU v3.0 License Agreement". 6 | 7 | # Please see: https://github.com/TgCatUB/catuserbot/blob/master/LICENSE 8 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 9 | 10 | import random 11 | 12 | import requests 13 | from bs4 import BeautifulSoup 14 | 15 | 16 | async def extract_quote(url): 17 | results = [] 18 | request = requests.get(url).text 19 | soup = BeautifulSoup(request, "html.parser") 20 | for quote in soup.find_all("div", class_="quote"): 21 | response = quote.find("div", {"class": "quoteText"}).text 22 | results.append(response.replace("\n", " ").strip()) 23 | return results 24 | 25 | 26 | async def random_quote(): 27 | pgno = random.randint(1, 100) 28 | quoteurl = f"https://www.goodreads.com/quotes?format=html&mobile_xhr=1&page={pgno}" 29 | results = await extract_quote(quoteurl) 30 | return random.choice(results) 31 | 32 | 33 | async def search_quotes(query): 34 | pgno = random.randint(1, 5) 35 | quoteurl = f"https://www.goodreads.com/quotes/search?commit=Search&page={pgno}&q={query.replace(' ', '+')}&utf8=%E2%9C%93" 36 | results = await extract_quote(quoteurl) 37 | return random.choice(results) 38 | -------------------------------------------------------------------------------- /userbot/helpers/functions/ialivetext.py: -------------------------------------------------------------------------------- 1 | import math 2 | import time 3 | 4 | import heroku3 5 | import requests 6 | 7 | from ...Config import Config 8 | from .utils import get_readable_time 9 | 10 | Heroku = heroku3.from_key(Config.HEROKU_API_KEY) 11 | heroku_api = "https://api.heroku.com" 12 | 13 | # UniBorg Telegram UseRBot 14 | # Copyright (C) 2020 @UniBorg 15 | # This code is licensed under 16 | # the "you can't use this for anything - public or private, 17 | # unless you know the two prime factors to the number below" license 18 | # 543935563961418342898620676239017231876605452284544942043082635399903451854594062955 19 | # വിവരണം അടിച്ചുമാറ്റിക്കൊണ്ട് പോകുന്നവർ 20 | # ക്രെഡിറ്റ് വെച്ചാൽ സന്തോഷമേ ഉള്ളു..! 21 | # uniborg 22 | 23 | 24 | def check_data_base_heal_th(): 25 | # https://stackoverflow.com/a/41961968 26 | is_database_working = False 27 | output = "No Database is set" 28 | if not Config.DB_URI: 29 | return is_database_working, output 30 | from ...sql_helper import SESSION 31 | 32 | try: 33 | # to check database we will execute raw query 34 | SESSION.execute("SELECT 1") 35 | except Exception as e: 36 | output = f"❌ {e}" 37 | is_database_working = False 38 | else: 39 | output = "Functioning" 40 | is_database_working = True 41 | return is_database_working, output 42 | 43 | 44 | async def catalive(StartTime): 45 | _, check_sgnirts = check_data_base_heal_th() 46 | sudo = "Enabled" if Config.SUDO_USERS else "Disabled" 47 | uptime = await get_readable_time((time.time() - StartTime)) 48 | try: 49 | useragent = ( 50 | "Mozilla/5.0 (Linux; Android 10; SM-G975F) " 51 | "AppleWebKit/537.36 (KHTML, like Gecko) " 52 | "Chrome/80.0.3987.149 Mobile Safari/537.36" 53 | ) 54 | user_id = Heroku.account().id 55 | headers = { 56 | "User-Agent": useragent, 57 | "Authorization": f"Bearer {Config.HEROKU_API_KEY}", 58 | "Accept": "application/vnd.heroku+json; version=3.account-quotas", 59 | } 60 | path = f"/accounts/{user_id}/actions/get-quota" 61 | r = requests.get(heroku_api + path, headers=headers) 62 | result = r.json() 63 | quota = result["account_quota"] 64 | quota_used = result["quota_used"] 65 | 66 | # Used 67 | remaining_quota = quota - quota_used 68 | math.floor(remaining_quota / quota * 100) 69 | minutes_remaining = remaining_quota / 60 70 | hours = math.floor(minutes_remaining / 60) 71 | minutes = math.floor(minutes_remaining % 60) 72 | # Current 73 | App = result["apps"] 74 | try: 75 | App[0]["quota_used"] 76 | except IndexError: 77 | AppQuotaUsed = 0 78 | else: 79 | AppQuotaUsed = App[0]["quota_used"] / 60 80 | math.floor(App[0]["quota_used"] * 100 / quota) 81 | AppHours = math.floor(AppQuotaUsed / 60) 82 | AppMinutes = math.floor(AppQuotaUsed % 60) 83 | dyno = f"{AppHours}h {AppMinutes}m/{hours}h {minutes}m" 84 | except Exception as e: 85 | dyno = e 86 | return f"🖤༄ Catuserbot Stats ༄🖤\ 87 | \n\nღ Database : {check_sgnirts}\ 88 | \nღ Sudo : {sudo}\ 89 | \nღ Uptime : {uptime}\ 90 | \nღ Dyno : {dyno}\ 91 | " 92 | -------------------------------------------------------------------------------- /userbot/helpers/functions/vidtools.py: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# CatUserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 2 | # Copyright (C) 2020-2023 by TgCatUB@Github. 3 | 4 | # This file is part of: https://github.com/TgCatUB/catuserbot 5 | # and is released under the "GNU v3.0 License Agreement". 6 | 7 | # Please see: https://github.com/TgCatUB/catuserbot/blob/master/LICENSE 8 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 9 | 10 | import logging 11 | import os 12 | import random 13 | from typing import Optional 14 | 15 | from PIL import Image, ImageOps 16 | 17 | from ...core.logger import logging 18 | from ..utils.utils import runcmd 19 | 20 | LOGS = logging.getLogger(__name__) 21 | 22 | 23 | async def r_frames(image, w, h, outframes): 24 | for i in range(1, w, w // 30): 25 | img1 = img2 = image.copy() 26 | temp = Image.new("RGB", (w, h)) 27 | img1 = img1.resize((i, h)) 28 | img2 = img2.resize((w - i, h)) 29 | temp.paste(img1, (0, 0)) 30 | temp.paste(img2, (i, 0)) 31 | outframes.append(temp) 32 | return outframes 33 | 34 | 35 | async def l_frames(image, w, h, outframes): 36 | for i in range(1, w, w // 30): 37 | img1 = img2 = image.copy() 38 | temp = Image.new("RGB", (w, h)) 39 | img1 = ImageOps.mirror(img1.resize((i, h))) 40 | img2 = ImageOps.mirror(img2.resize((w - i, h))) 41 | temp.paste(img1, (0, 0)) 42 | temp.paste(img2, (i, 0)) 43 | temp = ImageOps.mirror(temp) 44 | outframes.append(temp) 45 | return outframes 46 | 47 | 48 | async def ud_frames(image, w, h, outframes, flip=False): 49 | for i in range(1, h, h // 30): 50 | img1 = img2 = image.copy() 51 | temp = Image.new("RGB", (w, h)) 52 | img1 = img1.resize((w, i)) 53 | img2 = img2.resize((w, h - i)) 54 | temp.paste(img1, (0, 0)) 55 | temp.paste(img2, (0, i)) 56 | if flip: 57 | temp = ImageOps.flip(temp) 58 | outframes.append(temp) 59 | return outframes 60 | 61 | 62 | async def spin_frames(image, w, h, outframes): 63 | image.thumbnail((512, 512), Image.ANTIALIAS) 64 | img = Image.new("RGB", (512, 512), "black") 65 | img.paste(image, ((512 - w) // 2, (512 - h) // 2)) 66 | image = img 67 | way = random.choice([1, -1]) 68 | for i in range(1, 60): 69 | img = image.rotate(i * 6 * way) 70 | outframes.append(img) 71 | return outframes 72 | 73 | 74 | async def invert_frames(image, w, h, outframes): 75 | image.convert("RGB") 76 | invert = ImageOps.invert(image) 77 | outframes.append(image) 78 | outframes.append(invert) 79 | return outframes 80 | 81 | 82 | async def take_screen_shot( 83 | video_file: str, duration: int, path: str = "" 84 | ) -> Optional[str]: 85 | thumb_image_path = path or os.path.join( 86 | "./temp/", f"{os.path.basename(video_file)}.jpg" 87 | ) 88 | command = f"ffmpeg -hide_banner -loglevel quiet -ss {duration} -i '{video_file}' -vframes 1 '{thumb_image_path}' -y" 89 | err = (await runcmd(command))[1] 90 | if err: 91 | LOGS.error(err) 92 | return thumb_image_path if os.path.exists(thumb_image_path) else None 93 | -------------------------------------------------------------------------------- /userbot/helpers/resources/states.py: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# CatUserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 2 | # Copyright (C) 2020-2023 by TgCatUB@Github. 3 | 4 | # This file is part of: https://github.com/TgCatUB/catuserbot 5 | # and is released under the "GNU v3.0 License Agreement". 6 | 7 | # Please see: https://github.com/TgCatUB/catuserbot/blob/master/LICENSE 8 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 9 | 10 | states = [ 11 | "Andaman and Nicobar Islands", 12 | "Andhra Pradesh", 13 | "Arunachal Pradesh", 14 | "Assam", 15 | "Bihar", 16 | "Chandigarh", 17 | "Chhattisgarh", 18 | "Dadra and Nagar Haveli and Daman and Diu", 19 | "Delhi", 20 | "Goa", 21 | "Gujarat", 22 | "Haryana", 23 | "Himachal Pradesh", 24 | "Jammu and Kashmir", 25 | "Jharkhand", 26 | "Karnataka", 27 | "Kerala", 28 | "Ladakh", 29 | "Lakshadweep", 30 | "Madhya Pradesh", 31 | "Maharashtra", 32 | "Manipur", 33 | "Meghalaya", 34 | "Mizoram", 35 | "Nagaland", 36 | "Odisha", 37 | "Puducherry", 38 | "Punjab", 39 | "Rajasthan", 40 | "Sikkim", 41 | "Tamil Nadu", 42 | "Telengana", 43 | "Tripura", 44 | "Uttarakhand", 45 | "Uttar Pradesh", 46 | "West Bengal", 47 | "", 48 | ] 49 | -------------------------------------------------------------------------------- /userbot/helpers/styles/ProductSans-BoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sur-vivor/CatUserbot/a0733cecae6bcb3b5e7c9cb0c603c93378e5fabd/userbot/helpers/styles/ProductSans-BoldItalic.ttf -------------------------------------------------------------------------------- /userbot/helpers/styles/ProductSans-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sur-vivor/CatUserbot/a0733cecae6bcb3b5e7c9cb0c603c93378e5fabd/userbot/helpers/styles/ProductSans-Light.ttf -------------------------------------------------------------------------------- /userbot/helpers/styles/RoadRage-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sur-vivor/CatUserbot/a0733cecae6bcb3b5e7c9cb0c603c93378e5fabd/userbot/helpers/styles/RoadRage-Regular.ttf -------------------------------------------------------------------------------- /userbot/helpers/styles/digital.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sur-vivor/CatUserbot/a0733cecae6bcb3b5e7c9cb0c603c93378e5fabd/userbot/helpers/styles/digital.ttf -------------------------------------------------------------------------------- /userbot/helpers/styles/impact.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sur-vivor/CatUserbot/a0733cecae6bcb3b5e7c9cb0c603c93378e5fabd/userbot/helpers/styles/impact.ttf -------------------------------------------------------------------------------- /userbot/helpers/utils/__init__.py: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# CatUserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 2 | # Copyright (C) 2020-2023 by TgCatUB@Github. 3 | 4 | # This file is part of: https://github.com/TgCatUB/catuserbot 5 | # and is released under the "GNU v3.0 License Agreement". 6 | 7 | # Please see: https://github.com/TgCatUB/catuserbot/blob/master/LICENSE 8 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 9 | 10 | from .extdl import * 11 | from .paste import * 12 | 13 | flag = True 14 | check = 0 15 | while flag: 16 | try: 17 | from . import format as _format 18 | from . import utils as _catutils 19 | from .events import * 20 | from .format import * 21 | from .utils import * 22 | 23 | break 24 | except ModuleNotFoundError as e: 25 | install_pip(e.name) 26 | check += 1 27 | if check > 5: 28 | break 29 | -------------------------------------------------------------------------------- /userbot/helpers/utils/extdl.py: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# CatUserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 2 | # Copyright (C) 2020-2023 by TgCatUB@Github. 3 | 4 | # This file is part of: https://github.com/TgCatUB/catuserbot 5 | # and is released under the "GNU v3.0 License Agreement". 6 | 7 | # Please see: https://github.com/TgCatUB/catuserbot/blob/master/LICENSE 8 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 9 | 10 | from subprocess import PIPE, Popen 11 | 12 | 13 | def install_pip(pipfile): 14 | print(f"installing {pipfile}") 15 | pip_cmd = ["pip", "install", f"{pipfile}"] 16 | process = Popen(pip_cmd, stdout=PIPE, stderr=PIPE) 17 | stdout, stderr = process.communicate() 18 | return stdout 19 | -------------------------------------------------------------------------------- /userbot/helpers/utils/tools.py: -------------------------------------------------------------------------------- 1 | import os 2 | from typing import Optional 3 | 4 | from moviepy.editor import VideoFileClip 5 | from PIL import Image 6 | 7 | from ...core.logger import logging 8 | from ...core.managers import edit_or_reply 9 | from ..tools import media_type 10 | from .utils import runcmd 11 | 12 | LOGS = logging.getLogger(__name__) 13 | 14 | 15 | async def media_to_pic(event, reply, noedits=False): # sourcery no-metrics 16 | mediatype = media_type(reply) 17 | if mediatype not in [ 18 | "Photo", 19 | "Round Video", 20 | "Gif", 21 | "Sticker", 22 | "Video", 23 | "Voice", 24 | "Audio", 25 | "Document", 26 | ]: 27 | return event, None 28 | if not noedits: 29 | catevent = await edit_or_reply( 30 | event, f"`Transfiguration Time! Converting to ....`" 31 | ) 32 | else: 33 | catevent = event 34 | catmedia = None 35 | catfile = os.path.join("./temp/", "meme.png") 36 | if os.path.exists(catfile): 37 | os.remove(catfile) 38 | if mediatype == "Photo": 39 | catmedia = await reply.download_media(file="./temp") 40 | im = Image.open(catmedia) 41 | im.save(catfile) 42 | elif mediatype in ["Audio", "Voice"]: 43 | await event.client.download_media(reply, catfile, thumb=-1) 44 | elif mediatype == "Sticker": 45 | catmedia = await reply.download_media(file="./temp") 46 | if catmedia.endswith(".tgs"): 47 | catcmd = f"lottie_convert.py --frame 0 -if lottie -of png '{catmedia}' '{catfile}'" 48 | stdout, stderr = (await runcmd(catcmd))[:2] 49 | if stderr: 50 | LOGS.info(stdout + stderr) 51 | elif catmedia.endswith(".webp"): 52 | im = Image.open(catmedia) 53 | im.save(catfile) 54 | elif mediatype in ["Round Video", "Video", "Gif"]: 55 | await event.client.download_media(reply, catfile, thumb=-1) 56 | if not os.path.exists(catfile): 57 | catmedia = await reply.download_media(file="./temp") 58 | clip = VideoFileClip(media) 59 | try: 60 | clip = clip.save_frame(catfile, 0.1) 61 | except Exception: 62 | clip = clip.save_frame(catfile, 0) 63 | elif mediatype == "Document": 64 | mimetype = reply.document.mime_type 65 | mtype = mimetype.split("/") 66 | if mtype[0].lower() == "image": 67 | catmedia = await reply.download_media(file="./temp") 68 | im = Image.open(catmedia) 69 | im.save(catfile) 70 | if catmedia and os.path.lexists(catmedia): 71 | os.remove(catmedia) 72 | if os.path.lexists(catfile): 73 | return catevent, catfile, mediatype 74 | return catevent, None 75 | 76 | 77 | async def take_screen_shot( 78 | video_file: str, duration: int, path: str = "" 79 | ) -> Optional[str]: 80 | thumb_image_path = path or os.path.join( 81 | "./temp/", f"{os.path.basename(video_file)}.jpg" 82 | ) 83 | command = f"ffmpeg -ss {duration} -i '{video_file}' -vframes 1 '{thumb_image_path}'" 84 | err = (await runcmd(command))[1] 85 | if err: 86 | LOGS.error(err) 87 | return thumb_image_path if os.path.exists(thumb_image_path) else None 88 | -------------------------------------------------------------------------------- /userbot/helpers/utils/utils.py: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# CatUserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 2 | # Copyright (C) 2020-2023 by TgCatUB@Github. 3 | 4 | # This file is part of: https://github.com/TgCatUB/catuserbot 5 | # and is released under the "GNU v3.0 License Agreement". 6 | 7 | # Please see: https://github.com/TgCatUB/catuserbot/blob/master/LICENSE 8 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 9 | 10 | import asyncio 11 | import functools 12 | import shlex 13 | from typing import Tuple 14 | 15 | from ...core.logger import logging 16 | 17 | LOGS = logging.getLogger(__name__) 18 | 19 | 20 | # executing of terminal commands 21 | async def runcmd(cmd: str) -> Tuple[str, str, int, int]: 22 | args = shlex.split(cmd) 23 | process = await asyncio.create_subprocess_exec( 24 | *args, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE 25 | ) 26 | stdout, stderr = await process.communicate() 27 | return ( 28 | stdout.decode("utf-8", "replace").strip(), 29 | stderr.decode("utf-8", "replace").strip(), 30 | process.returncode, 31 | process.pid, 32 | ) 33 | 34 | 35 | def run_sync(func, *args, **kwargs): 36 | return asyncio.get_event_loop().run_in_executor( 37 | None, functools.partial(func, *args, **kwargs) 38 | ) 39 | 40 | 41 | def run_async(loop, coro): 42 | return asyncio.run_coroutine_threadsafe(coro, loop).result() 43 | 44 | 45 | def runasync(func: callable): 46 | """Run async functions with the right event loop.""" 47 | loop = asyncio.get_event_loop() 48 | return loop.run_until_complete(func) 49 | -------------------------------------------------------------------------------- /userbot/plugins/README.md: -------------------------------------------------------------------------------- 1 | ## Mandatory Imports 2 | ```python3 3 | from userbot import catub 4 | 5 | from ..core.managers import edit_delete, edit_or_reply 6 | 7 | plugin_category="extra" 8 | ``` 9 | 10 | ### Formation 11 | This below one is Sample format of making plugin 12 | ```python3 13 | from userbot import catub 14 | 15 | from ..core.managers import edit_delete, edit_or_reply 16 | 17 | plugin_category="extra" 18 | 19 | @catub.cat_cmd( 20 | pattern="hibuddy(?:\s|$)([\s\S]*)", 21 | command=("hibuddy", plugin_category), 22 | info={ 23 | "header": "Just to say hi to other user.", 24 | "description": "input string along with cmd will be added to your hi text", 25 | "usage": "{tr}hibuddy ", 26 | "examples": "{tr}hibuddy how are you doing", 27 | }, 28 | ) 29 | async def hi_buddy(event): 30 | "Just to say hi to other user." 31 | input_str= event.pattern_match.group(1) 32 | if not input_str: 33 | await edit_delete(event,"No input is found. Use proper syntax.") 34 | return 35 | outputtext= f"+-+-+-+-+-+\n|h|e|l|l|o|\n+-+-+-+-+-+\n{input_str}" 36 | await edit_or_reply(event,outputtext) 37 | ``` 38 | 39 | For more information refer this [Docs](https://docs.telethon.dev/en/latest/) 40 | 41 | 42 | Arguments in cat_cmd are as follows: 43 | ``` 44 | 45 | pattern="Regex for command" 46 | command=("Just command name", plugin_category) use plugin_category name from predefined names (admin,bot,utils,tools,extra,fun,misc) 47 | info={ 48 | "header":string - "intro for command", 49 | "description": string - "Description for command", 50 | "flags": dict or string - "Flags u are using in your plugin", 51 | "options": dict or string - "Options u are using in your plugin", 52 | "types": list or string - "types u are using in your plugin", 53 | "usage": "Usage for your command", 54 | "examples": "Example for the command", 55 | "your custom name if you want to use other": str or list or dict - "data/information about it", 56 | }, 57 | 58 | groups_only=True or False(by default False) - Either your command should work only in group or not 59 | allow_sudo=True or False(by default True) - Should your sudo users need to have access or not, 60 | edited=True or False(by default True) - If suppose you entered wrong command syntax and if you edit it correct should it work or not. 61 | forword=True or False(by deafult False) - Is forword messages should react or not. 62 | disable_errors=True or False(by default False) - if any error occured during the command usage should it log or not. 63 | ``` 64 | -------------------------------------------------------------------------------- /userbot/plugins/__init__.py: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# CatUserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 2 | # Copyright (C) 2020-2023 by TgCatUB@Github. 3 | 4 | # This file is part of: https://github.com/TgCatUB/catuserbot 5 | # and is released under the "GNU v3.0 License Agreement". 6 | 7 | # Please see: https://github.com/TgCatUB/catuserbot/blob/master/LICENSE 8 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 9 | 10 | import math 11 | import os 12 | import re 13 | import time 14 | 15 | import heroku3 16 | import requests 17 | import spamwatch as spam_watch 18 | from validators.url import url 19 | 20 | from .. import * 21 | from ..Config import Config 22 | from ..core.logger import logging 23 | from ..core.managers import edit_delete, edit_or_reply 24 | from ..core.session import catub 25 | from ..helpers import * 26 | from ..helpers.utils import _catutils, _format, install_pip, reply_id 27 | from ..sql_helper.globals import gvarstatus 28 | 29 | # =================== CONSTANT =================== 30 | bot = catub 31 | LOGS = logging.getLogger(__name__) 32 | USERID = catub.uid if Config.OWNER_ID == 0 else Config.OWNER_ID 33 | ALIVE_NAME = Config.ALIVE_NAME 34 | 35 | Heroku = heroku3.from_key(Config.HEROKU_API_KEY) 36 | heroku_api = "https://api.heroku.com" 37 | HEROKU_APP_NAME = Config.HEROKU_APP_NAME 38 | HEROKU_API_KEY = Config.HEROKU_API_KEY 39 | 40 | thumb_image_path = os.path.join(Config.TMP_DOWNLOAD_DIRECTORY, "thumb_image.jpg") 41 | 42 | # mention user 43 | mention = f"[{Config.ALIVE_NAME}](tg://user?id={USERID})" 44 | hmention = f"{Config.ALIVE_NAME}" 45 | 46 | PM_START = [] 47 | PMMESSAGE_CACHE = {} 48 | PMMENU = "pmpermit_menu" not in Config.NO_LOAD 49 | 50 | # Gdrive 51 | TMP_DOWNLOAD_DIRECTORY = Config.TMP_DOWNLOAD_DIRECTORY 52 | 53 | # spamwatch support 54 | if Config.SPAMWATCH_API: 55 | token = Config.SPAMWATCH_API 56 | spamwatch = spam_watch.Client(token) 57 | else: 58 | spamwatch = None 59 | 60 | 61 | # ================================================ 62 | 63 | if not os.path.isdir(Config.TMP_DOWNLOAD_DIRECTORY): 64 | os.makedirs(Config.TMP_DOWNLOAD_DIRECTORY) 65 | 66 | 67 | # thumb image 68 | if Config.THUMB_IMAGE is not None: 69 | if check := url(Config.THUMB_IMAGE): 70 | try: 71 | with open(thumb_image_path, "wb") as f: 72 | f.write(requests.get(Config.THUMB_IMAGE).content) 73 | except Exception as e: 74 | LOGS.info(str(e)) 75 | 76 | 77 | def set_key(dictionary, key, value): 78 | if key not in dictionary: 79 | dictionary[key] = value 80 | elif isinstance(dictionary[key], list): 81 | if value in dictionary[key]: 82 | return 83 | dictionary[key].append(value) 84 | else: 85 | dictionary[key] = [dictionary[key], value] 86 | -------------------------------------------------------------------------------- /userbot/plugins/antiflood.py: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# CatUserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 2 | # Copyright (C) 2020-2023 by TgCatUB@Github. 3 | 4 | # This file is part of: https://github.com/TgCatUB/catuserbot 5 | # and is released under the "GNU v3.0 License Agreement". 6 | 7 | # Please see: https://github.com/TgCatUB/catuserbot/blob/master/LICENSE 8 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 9 | 10 | import asyncio 11 | 12 | from telethon.tl.functions.channels import EditBannedRequest 13 | from telethon.tl.types import ChatBannedRights 14 | 15 | from ..sql_helper import antiflood_sql as sql 16 | from ..utils import is_admin 17 | from . import catub, edit_or_reply 18 | 19 | plugin_category = "admin" 20 | CHAT_FLOOD = sql.__load_flood_settings() 21 | 22 | ANTI_FLOOD_WARN_MODE = ChatBannedRights( 23 | until_date=None, view_messages=None, send_messages=True 24 | ) 25 | 26 | 27 | @catub.cat_cmd(incoming=True, groups_only=True) 28 | async def _(event): 29 | if not CHAT_FLOOD: 30 | return 31 | catadmin = await is_admin(event.client, event.chat_id, event.client.uid) 32 | if not catadmin: 33 | return 34 | if str(event.chat_id) not in CHAT_FLOOD: 35 | return 36 | should_ban = sql.update_flood(event.chat_id, event.message.sender_id) 37 | if not should_ban: 38 | return 39 | try: 40 | await event.client( 41 | EditBannedRequest( 42 | event.chat_id, event.message.sender_id, ANTI_FLOOD_WARN_MODE 43 | ) 44 | ) 45 | except Exception as e: 46 | no_admin_privilege_message = await event.client.send_message( 47 | entity=event.chat_id, 48 | message=f"**Automatic AntiFlooder**\x1f@admin [User](tg://user?id={event.message.sender_id}) is flooding this chat.\x1f`{e}`", 49 | reply_to=event.message.id, 50 | ) 51 | 52 | await asyncio.sleep(4) 53 | await no_admin_privilege_message.edit( 54 | "This is useless SPAM dude. Stop this, enjoy the chat buddy " 55 | ) 56 | else: 57 | await event.client.send_message( 58 | entity=event.chat_id, 59 | message=f"""**Automatic AntiFlooder** 60 | [User](tg://user?id={event.message.sender_id}) has been automatically restricted 61 | because he reached the defined flood limit.""", 62 | reply_to=event.message.id, 63 | ) 64 | 65 | 66 | @catub.cat_cmd( 67 | pattern="setflood(?:\s|$)([\s\S]*)", 68 | command=("setflood", plugin_category), 69 | info={ 70 | "header": "To setup antiflood in a group", 71 | "description": "It warns the user if he spams the chat and if you are an admin with proper rights then it mutes him in that group.", 72 | "note": "To stop antiflood setflood with high value like 999999", 73 | "usage": "{tr}setflood ", 74 | "examples": [ 75 | "{tr}setflood 10", 76 | ], 77 | }, 78 | groups_only=True, 79 | require_admin=True, 80 | ) 81 | async def _(event): 82 | "To setup antiflood in a group to prevent spam" 83 | input_str = event.pattern_match.group(1) 84 | event = await edit_or_reply(event, "`updating flood settings!`") 85 | await asyncio.sleep(2) 86 | try: 87 | sql.set_flood(event.chat_id, input_str) 88 | sql.__load_flood_settings() 89 | await event.edit(f"Antiflood updated to {input_str} in the current chat") 90 | except Exception as e: 91 | await event.edit(str(e)) 92 | -------------------------------------------------------------------------------- /userbot/plugins/calc.py: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# CatUserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 2 | # Copyright (C) 2020-2023 by TgCatUB@Github. 3 | 4 | # This file is part of: https://github.com/TgCatUB/catuserbot 5 | # and is released under the "GNU v3.0 License Agreement". 6 | 7 | # Please see: https://github.com/TgCatUB/catuserbot/blob/master/LICENSE 8 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 9 | 10 | import io 11 | import sys 12 | import traceback 13 | 14 | from . import catub, edit_or_reply 15 | 16 | plugin_category = "utils" 17 | 18 | 19 | @catub.cat_cmd( 20 | pattern="calc ([\s\S]*)", 21 | command=("calc", plugin_category), 22 | info={ 23 | "header": "To solve basic mathematics equations.", 24 | "description": "Solves the given maths equation by BODMAS rule.", 25 | "usage": "{tr}calc 2+9", 26 | }, 27 | ) 28 | async def calculator(event): 29 | "To solve basic mathematics equations." 30 | cmd = event.text.split(" ", maxsplit=1)[1] 31 | event = await edit_or_reply(event, "Calculating ...") 32 | old_stderr = sys.stderr 33 | old_stdout = sys.stdout 34 | redirected_output = sys.stdout = io.StringIO() 35 | redirected_error = sys.stderr = io.StringIO() 36 | stdout, stderr, exc = None, None, None 37 | san = f"print({cmd})" 38 | try: 39 | await aexec(san, event) 40 | except Exception: 41 | exc = traceback.format_exc() 42 | stdout = redirected_output.getvalue() 43 | stderr = redirected_error.getvalue() 44 | sys.stdout = old_stdout 45 | sys.stderr = old_stderr 46 | evaluation = "" 47 | if exc: 48 | evaluation = exc 49 | elif stderr: 50 | evaluation = stderr 51 | elif stdout: 52 | evaluation = stdout 53 | else: 54 | evaluation = "Sorry I can't find result for the given equation" 55 | final_output = f"**EQUATION**: `{cmd}` \n\n **SOLUTION**: \n`{evaluation}` \n" 56 | await event.edit(final_output) 57 | 58 | 59 | async def aexec(code, event): 60 | exec("async def __aexec(event): " + "".join(f"\n {l}" for l in code.split("\n"))) 61 | 62 | return await locals()["__aexec"](event) 63 | -------------------------------------------------------------------------------- /userbot/plugins/chain.py: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# CatUserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 2 | # Copyright (C) 2020-2023 by TgCatUB@Github. 3 | 4 | # This file is part of: https://github.com/TgCatUB/catuserbot 5 | # and is released under the "GNU v3.0 License Agreement". 6 | 7 | # Please see: https://github.com/TgCatUB/catuserbot/blob/master/LICENSE 8 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 9 | 10 | from telethon.tl.functions.messages import SaveDraftRequest 11 | 12 | from ..core.managers import edit_delete, edit_or_reply 13 | from . import catub 14 | 15 | plugin_category = "tools" 16 | 17 | 18 | @catub.cat_cmd( 19 | pattern="chain$", 20 | command=("chain", plugin_category), 21 | info={ 22 | "header": "Reply this command to any converstion(or message) and it will find the chain length of that message", 23 | "usage": "{tr}chain ", 24 | }, 25 | ) 26 | async def chain(event): 27 | "To find the chain length of a message." 28 | msg = await event.get_reply_message() 29 | if not msg: 30 | return await edit_delete(event, "```reply to a message```", 10) 31 | chat = (await catub.get_entity(event.chat_id)).id 32 | msg_id = msg.id 33 | await edit_or_reply(event, "`Counting...`") 34 | count = -1 35 | if msg.reply_to: 36 | msg_id = msg.reply_to.reply_to_top_id or msg.reply_to.reply_to_msg_id 37 | thread = f"https://t.me/c/{chat}/{msg_id}?thread={msg_id}" 38 | while msg: 39 | reply = await msg.get_reply_message() 40 | if reply is None: 41 | await event.client( 42 | SaveDraftRequest( 43 | await event.get_input_chat(), "", reply_to_msg_id=msg.id 44 | ) 45 | ) 46 | msg = reply 47 | count += 1 48 | await edit_or_reply( 49 | event, f"**Chain length :** `{count}`\n**Thread link :** [Here]({thread})" 50 | ) 51 | -------------------------------------------------------------------------------- /userbot/plugins/cricket.py: -------------------------------------------------------------------------------- 1 | """ 2 | Created by @Jisan7509 3 | plugin for Cat_Userbot 4 | """ 5 | 6 | from telethon.errors.rpcerrorlist import YouBlockedUserError 7 | 8 | from . import catub, edit_or_reply, reply_id 9 | 10 | plugin_category = "extra" 11 | 12 | 13 | @catub.cat_cmd( 14 | pattern="score$", 15 | command=("score", plugin_category), 16 | info={ 17 | "header": "To see the score of an ongoing match.", 18 | "usage": "{tr}score", 19 | }, 20 | ) 21 | async def _(event): 22 | "To see the score of an ongoing match." 23 | chat = "@cricbuzz_bot" 24 | reply_to_id = await reply_id(event) 25 | catevent = await edit_or_reply(event, "```Gathering info...```") 26 | async with event.client.conversation(chat) as conv: 27 | try: 28 | msg_start = await conv.send_message("/start") 29 | response = await conv.get_response() 30 | msg = await conv.send_message("/score") 31 | respond = await conv.get_response() 32 | await event.client.send_read_acknowledge(conv.chat_id) 33 | except YouBlockedUserError: 34 | await catevent.edit("Unblock @cricbuzz_bot & try again") 35 | return 36 | if respond.text.startswith("I can't find that"): 37 | await catevent.edit("sorry i can't find it") 38 | else: 39 | await catevent.delete() 40 | await event.client.send_message( 41 | event.chat_id, respond.message, reply_to=reply_to_id 42 | ) 43 | await event.client.delete_messages( 44 | conv.chat_id, [msg_start.id, msg.id, response.id, respond.id] 45 | ) 46 | 47 | 48 | @catub.cat_cmd( 49 | pattern="cric ([\s\S]*)", 50 | command=("cric", plugin_category), 51 | info={ 52 | "header": "To see the scoreboard or commentary of a match", 53 | "description": "To check commands showed in {tr}score cmd that is for getting scoreboard or commentary.", 54 | "usage": "{tr}cric ", 55 | "examples": "{tr}cric /scorecard_30....", 56 | }, 57 | ) 58 | async def _(event): 59 | "To see the scoreboard or commentary of a match" 60 | details = event.pattern_match.group(1) 61 | chat = "@cricbuzz_bot" 62 | reply_to_id = await reply_id(event) 63 | catevent = await edit_or_reply(event, "```Gathering info...```") 64 | async with event.client.conversation(chat) as conv: 65 | try: 66 | msg_start = await conv.send_message("/start") 67 | response = await conv.get_response() 68 | msg = await conv.send_message(f"{details}") 69 | respond = await conv.get_response() 70 | await event.client.send_read_acknowledge(conv.chat_id) 71 | except YouBlockedUserError: 72 | await catevent.edit("Unblock @cricbuzz_bot & try again") 73 | return 74 | if respond.text.startswith("I can't find that"): 75 | await catevent.edit("sorry i can't find it") 76 | else: 77 | await catevent.delete() 78 | await event.client.send_message( 79 | event.chat_id, respond.message, reply_to=reply_to_id 80 | ) 81 | await event.client.delete_messages( 82 | conv.chat_id, [msg_start.id, msg.id, response.id, respond.id] 83 | ) 84 | -------------------------------------------------------------------------------- /userbot/plugins/emojify.py: -------------------------------------------------------------------------------- 1 | """ 2 | Created by @Jisan7509 3 | modified by @mrconfused 4 | Userbot plugin for CatUserbot 5 | """ 6 | 7 | from userbot import catub 8 | 9 | from ..core.managers import edit_or_reply 10 | from ..helpers import fonts as emojify 11 | 12 | plugin_category = "fun" 13 | 14 | 15 | @catub.cat_cmd( 16 | pattern="emoji(?:\s|$)([\s\S]*)", 17 | command=("emoji", plugin_category), 18 | info={ 19 | "header": "Converts your text to big emoji text, with some default emojis.", 20 | "usage": "{tr}emoji ", 21 | "examples": ["{tr}emoji catuserbot"], 22 | }, 23 | ) 24 | async def itachi(event): 25 | "To get emoji art text." 26 | args = event.pattern_match.group(1) 27 | get = await event.get_reply_message() 28 | if not args and get: 29 | args = get.text 30 | if not args: 31 | await edit_or_reply( 32 | event, "__What am I Supposed to do with this idiot, Give me a text.__" 33 | ) 34 | return 35 | result = "" 36 | for a in args: 37 | a = a.lower() 38 | if a in emojify.kakashitext: 39 | char = emojify.kakashiemoji[emojify.kakashitext.index(a)] 40 | result += char 41 | else: 42 | result += a 43 | await edit_or_reply(event, result) 44 | 45 | 46 | @catub.cat_cmd( 47 | pattern="cmoji(?:\s|$)([\s\S]*)", 48 | command=("cmoji", plugin_category), 49 | info={ 50 | "header": "Converts your text to big emoji text, with your custom emoji.", 51 | "usage": "{tr}cmoji ", 52 | "examples": ["{tr}cmoji 😺 catuserbot"], 53 | }, 54 | ) 55 | async def itachi(event): 56 | "To get custom emoji art text." 57 | args = event.pattern_match.group(1) 58 | get = await event.get_reply_message() 59 | if not args and get: 60 | args = get.text 61 | if not args: 62 | return await edit_or_reply( 63 | event, "__What am I Supposed to do with this idiot, Give me a text.__" 64 | ) 65 | try: 66 | emoji, arg = args.split(" ", 1) 67 | except Exception: 68 | arg = args 69 | emoji = "😺" 70 | result = "" 71 | for a in arg: 72 | a = a.lower() 73 | if a in emojify.kakashitext: 74 | char = emojify.itachiemoji[emojify.kakashitext.index(a)].format(cj=emoji) 75 | result += char 76 | else: 77 | result += a 78 | await edit_or_reply(event, result) 79 | -------------------------------------------------------------------------------- /userbot/plugins/externalplugins.py: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# CatUserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 2 | # Copyright (C) 2020-2023 by TgCatUB@Github. 3 | 4 | # This file is part of: https://github.com/TgCatUB/catuserbot 5 | # and is released under the "GNU v3.0 License Agreement". 6 | 7 | # Please see: https://github.com/TgCatUB/catuserbot/blob/master/LICENSE 8 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 9 | 10 | import os 11 | from pathlib import Path 12 | 13 | from telethon.tl.types import InputMessagesFilterDocument 14 | 15 | from ..Config import Config 16 | from ..helpers.utils import install_pip 17 | from ..utils import load_module 18 | from . import BOTLOG, BOTLOG_CHATID, catub 19 | 20 | plugin_category = "tools" 21 | 22 | if Config.PLUGIN_CHANNEL: 23 | 24 | async def install(): 25 | documentss = await catub.get_messages( 26 | Config.PLUGIN_CHANNEL, None, filter=InputMessagesFilterDocument 27 | ) 28 | total = int(documentss.total) 29 | for module in range(total): 30 | plugin_to_install = documentss[module].id 31 | plugin_name = documentss[module].file.name 32 | if os.path.exists(f"userbot/plugins/{plugin_name}"): 33 | return 34 | downloaded_file_name = await catub.download_media( 35 | await catub.get_messages(Config.PLUGIN_CHANNEL, ids=plugin_to_install), 36 | "userbot/plugins/", 37 | ) 38 | path1 = Path(downloaded_file_name) 39 | shortname = path1.stem 40 | flag = True 41 | check = 0 42 | while flag: 43 | try: 44 | load_module(shortname.replace(".py", "")) 45 | break 46 | except ModuleNotFoundError as e: 47 | install_pip(e.name) 48 | check += 1 49 | if check > 5: 50 | break 51 | if BOTLOG: 52 | await catub.send_message( 53 | BOTLOG_CHATID, 54 | f"Installed Plugin `{os.path.basename(downloaded_file_name)}` successfully.", 55 | ) 56 | 57 | catub.loop.create_task(install()) 58 | -------------------------------------------------------------------------------- /userbot/plugins/figlet.py: -------------------------------------------------------------------------------- 1 | import pyfiglet 2 | 3 | from ..helpers.utils import _format 4 | from . import _format, catub, deEmojify, edit_delete, edit_or_reply 5 | 6 | plugin_category = "extra" 7 | 8 | CMD_FIG = { 9 | "slant": "slant", 10 | "3D": "3-d", 11 | "5line": "5lineoblique", 12 | "alpha": "alphabet", 13 | "banner": "banner3-D", 14 | "doh": "doh", 15 | "basic": "basic", 16 | "binary": "binary", 17 | "iso": "isometric1", 18 | "letter": "letters", 19 | "allig": "alligator", 20 | "dotm": "dotmatrix", 21 | "bubble": "bubble", 22 | "bulb": "bulbhead", 23 | "digi": "digital", 24 | } 25 | 26 | 27 | @catub.cat_cmd( 28 | pattern="figlet(?:\s|$)([\s\S]*)", 29 | command=("figlet", plugin_category), 30 | info={ 31 | "header": "Changes the given text into the given style", 32 | "usage": ["{tr}figlet