├── .gitbook.yaml
├── docs
├── project-info
│ └── changelogs
│ │ ├── README.md
│ │ └── version-3.2.0.md
├── README.md
├── installation
│ ├── guide
│ │ └── README.md
│ ├── hosting
│ │ ├── railway.md
│ │ ├── README.md
│ │ ├── heroku.md
│ │ ├── docker-compose.md
│ │ └── self-host.md
│ └── variables
│ │ └── README.md
├── about-us
│ ├── support-us.md
│ ├── support.md
│ └── cat-userbot.md
├── tutorials
│ ├── heroku-vars.md
│ ├── github-commit.md
│ ├── ibm.md
│ ├── lastfm.md
│ └── spotify.md
└── SUMMARY.md
├── userbot
├── cache
│ └── readme.md
├── Config
│ ├── Readme.md
│ ├── __init__.py
│ └── catub_config.py
├── helpers
│ ├── Readme.md
│ ├── styles
│ │ ├── impact.ttf
│ │ ├── digital.ttf
│ │ ├── RoadRage-Regular.ttf
│ │ ├── ProductSans-Light.ttf
│ │ └── ProductSans-BoldItalic.ttf
│ ├── functions
│ │ ├── __init__.py
│ │ ├── findquote.py
│ │ ├── vidtools.py
│ │ └── ialivetext.py
│ ├── utils
│ │ ├── extdl.py
│ │ ├── __init__.py
│ │ ├── utils.py
│ │ └── tools.py
│ ├── exceptions.py
│ ├── __init__.py
│ ├── resources
│ │ └── states.py
│ ├── aiohttp_helper.py
│ └── aria2utils
├── sql_helper
│ ├── DS_Store
│ ├── gmute_sql.py
│ ├── no_log_pms_sql.py
│ ├── mute_sql.py
│ ├── __init__.py
│ ├── gdrive_sql.py
│ ├── gban_sql_helper.py
│ ├── google_drive_sql.py
│ ├── globals.py
│ ├── snip_sql.py
│ ├── global_collectionjson.py
│ ├── bot_starters.py
│ ├── welcome_sql.py
│ ├── welcomesql.py
│ ├── bot_blacklists.py
│ ├── pmpermit_sql.py
│ ├── filter_sql.py
│ ├── locks_sql.py
│ ├── antiflood_sql.py
│ ├── echo_sql.py
│ ├── bot_pms_sql.py
│ └── chatbot_sql.py
├── assistant
│ ├── __init__.py
│ ├── hide.py
│ ├── secret.py
│ ├── troll.py
│ └── nsfw.py
├── core
│ ├── __init__.py
│ ├── logger.py
│ ├── session.py
│ ├── data.py
│ ├── pool.py
│ ├── decorators.py
│ ├── helpers.py
│ └── pluginManager.py
├── utils
│ ├── __init__.py
│ ├── checks.py
│ └── tools.py
├── plugins
│ ├── funtxts.py
│ ├── quotes.py
│ ├── gps.py
│ ├── linkpreview.py
│ ├── transfer_channel.py
│ ├── json.py
│ ├── filext.py
│ ├── chain.py
│ ├── recognize.py
│ ├── calc.py
│ ├── gifs.py
│ ├── externalplugins.py
│ ├── invite.py
│ ├── figlet.py
│ ├── emojify.py
│ ├── selfdestruct.py
│ ├── README.md
│ ├── game.py
│ ├── __init__.py
│ ├── getid.py
│ ├── nsfwdetect.py
│ ├── images.py
│ ├── mention.py
│ ├── cricket.py
│ ├── reddit.py
│ ├── glitch.py
│ ├── sangmata.py
│ ├── stt.py
│ └── antiflood.py
└── __init__.py
├── .vscode
├── extensions.json
└── settings.json
├── .isort.cfg
├── Dockerfile
├── stringsetup.py
├── .github
└── workflows
│ ├── pythonapp.yml
│ └── pylint.yml
├── docker-compose.yml
├── exampleconfig.py
├── requirements.txt
├── .gitignore
└── .sourcery.yaml
/.gitbook.yaml:
--------------------------------------------------------------------------------
1 | root: ./docs
--------------------------------------------------------------------------------
/docs/project-info/changelogs/README.md:
--------------------------------------------------------------------------------
1 | # 📑 Changelogs
2 |
3 |
--------------------------------------------------------------------------------
/userbot/cache/readme.md:
--------------------------------------------------------------------------------
1 | To store cache file of CatUserbot
2 |
--------------------------------------------------------------------------------
/userbot/Config/Readme.md:
--------------------------------------------------------------------------------
1 | # Config
2 | Config vars will be loaded from here
3 |
--------------------------------------------------------------------------------
/userbot/helpers/Readme.md:
--------------------------------------------------------------------------------
1 | # helpers
2 |
3 | Some of the functions required for plugins are defined here
4 |
--------------------------------------------------------------------------------
/userbot/sql_helper/DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sur-vivor/CatUserbot/HEAD/userbot/sql_helper/DS_Store
--------------------------------------------------------------------------------
/userbot/helpers/styles/impact.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sur-vivor/CatUserbot/HEAD/userbot/helpers/styles/impact.ttf
--------------------------------------------------------------------------------
/userbot/helpers/styles/digital.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sur-vivor/CatUserbot/HEAD/userbot/helpers/styles/digital.ttf
--------------------------------------------------------------------------------
/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | "recommendations": [
3 | "ms-python.python",
4 | "sourcery.sourcery"
5 | ]
6 | }
--------------------------------------------------------------------------------
/userbot/helpers/styles/RoadRage-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sur-vivor/CatUserbot/HEAD/userbot/helpers/styles/RoadRage-Regular.ttf
--------------------------------------------------------------------------------
/userbot/helpers/styles/ProductSans-Light.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sur-vivor/CatUserbot/HEAD/userbot/helpers/styles/ProductSans-Light.ttf
--------------------------------------------------------------------------------
/userbot/helpers/styles/ProductSans-BoldItalic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sur-vivor/CatUserbot/HEAD/userbot/helpers/styles/ProductSans-BoldItalic.ttf
--------------------------------------------------------------------------------
/.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 | }
--------------------------------------------------------------------------------
/.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
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 | 
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 |
--------------------------------------------------------------------------------
/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/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/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 ..helpers.progress import *
11 | from .checks import *
12 | from .decorators import *
13 | from .pluginmanager import *
14 | from .startup import *
15 |
--------------------------------------------------------------------------------
/docs/installation/guide/README.md:
--------------------------------------------------------------------------------
1 | # 📚 Guide
2 |
3 | ### _Some additonal set-up guides that might be helpful with your hosting:_
4 |
5 |
6 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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/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/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 |
--------------------------------------------------------------------------------
/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/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 |
--------------------------------------------------------------------------------
/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/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/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/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 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/userbot/plugins/funtxts.py:
--------------------------------------------------------------------------------
1 | import nekos
2 |
3 | from userbot import catub
4 |
5 | from ..core.managers import edit_or_reply
6 |
7 | plugin_category = "fun"
8 |
9 |
10 | @catub.cat_cmd(
11 | pattern="tcat$",
12 | command=("tcat", plugin_category),
13 | info={
14 | "header": "Some random cat facial text art",
15 | "usage": "{tr}tcat",
16 | },
17 | )
18 | async def hmm(cat):
19 | "Some random cat facial text art"
20 | reactcat = nekos.textcat()
21 | await edit_or_reply(cat, reactcat)
22 |
23 |
24 | @catub.cat_cmd(
25 | pattern="why$",
26 | command=("why", plugin_category),
27 | info={
28 | "header": "Sends you some random Funny questions",
29 | "usage": "{tr}why",
30 | },
31 | )
32 | async def hmm(cat):
33 | "Some random Funny questions"
34 | whycat = nekos.why()
35 | await edit_or_reply(cat, whycat)
36 |
37 |
38 | @catub.cat_cmd(
39 | pattern="fact$",
40 | command=("fact", plugin_category),
41 | info={
42 | "header": "Sends you some random facts",
43 | "usage": "{tr}fact",
44 | },
45 | )
46 | async def hmm(cat):
47 | "Some random facts"
48 | factcat = nekos.fact()
49 | await edit_or_reply(cat, factcat)
50 |
--------------------------------------------------------------------------------
/userbot/utils/checks.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 | # special credits: Ported from @UniBorg
10 |
11 | from telethon.tl.types import ChannelParticipantAdmin, ChannelParticipantCreator
12 |
13 | from ..core.logger import logging
14 |
15 | LOGS = logging.getLogger(__name__)
16 |
17 |
18 | async def is_admin(catub, chat_id, userid):
19 | if not str(chat_id).startswith("-100"):
20 | return False
21 | try:
22 | req_jo = await catub.get_permissions(chat_id, userid)
23 | chat_participant = req_jo.participant
24 | if isinstance(
25 | chat_participant, (ChannelParticipantCreator, ChannelParticipantAdmin)
26 | ):
27 | return True
28 | except Exception as e:
29 | LOGS.info(str(e))
30 | return False
31 | else:
32 | return False
33 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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/sql_helper/gmute_sql.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 sqlalchemy import Column, String
11 |
12 | from . import BASE, SESSION
13 |
14 |
15 | class GMute(BASE):
16 | __tablename__ = "gmute"
17 | sender = Column(String(14), primary_key=True)
18 |
19 | def __init__(self, sender):
20 | self.sender = str(sender)
21 |
22 |
23 | GMute.__table__.create(checkfirst=True)
24 |
25 |
26 | def is_gmuted(sender_id):
27 | try:
28 | return SESSION.query(GMute).all()
29 | except BaseException:
30 | return None
31 | finally:
32 | SESSION.close()
33 |
34 |
35 | def gmute(sender):
36 | adder = GMute(str(sender))
37 | SESSION.add(adder)
38 | SESSION.commit()
39 |
40 |
41 | def ungmute(sender):
42 | if rem := SESSION.query(GMute).get((str(sender))):
43 | SESSION.delete(rem)
44 | SESSION.commit()
45 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/userbot/sql_helper/no_log_pms_sql.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 sqlalchemy import Column, Numeric
11 |
12 | from . import BASE, SESSION
13 |
14 |
15 | class NOLogPMs(BASE):
16 | __tablename__ = "no_log_pms"
17 | chat_id = Column(Numeric, primary_key=True)
18 |
19 | def __init__(self, chat_id, reason=""):
20 | self.chat_id = chat_id
21 |
22 |
23 | NOLogPMs.__table__.create(checkfirst=True)
24 |
25 |
26 | def is_approved(chat_id):
27 | try:
28 | return SESSION.query(NOLogPMs).filter(NOLogPMs.chat_id == chat_id).one()
29 | except BaseException:
30 | return None
31 | finally:
32 | SESSION.close()
33 |
34 |
35 | def approve(chat_id):
36 | adder = NOLogPMs(chat_id)
37 | SESSION.add(adder)
38 | SESSION.commit()
39 |
40 |
41 | def disapprove(chat_id):
42 | if rem := SESSION.query(NOLogPMs).get(chat_id):
43 | SESSION.delete(rem)
44 | SESSION.commit()
45 |
--------------------------------------------------------------------------------
/userbot/sql_helper/mute_sql.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 sqlalchemy import Column, String
11 |
12 | from . import BASE, SESSION
13 |
14 |
15 | class Mute(BASE):
16 | __tablename__ = "mute"
17 | sender = Column(String(14), primary_key=True)
18 | chat_id = Column(String(14), primary_key=True)
19 |
20 | def __init__(self, sender, chat_id):
21 | self.sender = str(sender)
22 | self.chat_id = str(chat_id)
23 |
24 |
25 | Mute.__table__.create(checkfirst=True)
26 |
27 |
28 | def is_muted(sender, chat_id):
29 | user = SESSION.query(Mute).get((str(sender), str(chat_id)))
30 | return bool(user)
31 |
32 |
33 | def mute(sender, chat_id):
34 | adder = Mute(str(sender), str(chat_id))
35 | SESSION.add(adder)
36 | SESSION.commit()
37 |
38 |
39 | def unmute(sender, chat_id):
40 | if rem := SESSION.query(Mute).get((str(sender), str(chat_id))):
41 | SESSION.delete(rem)
42 | SESSION.commit()
43 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/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 |
23 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/userbot/utils/tools.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 import functions
11 |
12 |
13 | async def create_supergroup(group_name, client, botusername, descript):
14 | try:
15 | result = await client(
16 | functions.channels.CreateChannelRequest(
17 | title=group_name,
18 | about=descript,
19 | megagroup=True,
20 | )
21 | )
22 | created_chat_id = result.chats[0].id
23 | result = await client(
24 | functions.messages.ExportChatInviteRequest(
25 | peer=created_chat_id,
26 | )
27 | )
28 | await client(
29 | functions.channels.InviteToChannelRequest(
30 | channel=created_chat_id,
31 | users=[botusername],
32 | )
33 | )
34 | except Exception as e:
35 | return "error", str(e)
36 | if not str(created_chat_id).startswith("-100"):
37 | created_chat_id = int(f"-100{str(created_chat_id)}")
38 | return result, created_chat_id
39 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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/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 |
--------------------------------------------------------------------------------
/userbot/sql_helper/__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 os
11 |
12 | from sqlalchemy import create_engine
13 | from sqlalchemy.ext.declarative import declarative_base
14 | from sqlalchemy.orm import scoped_session, sessionmaker
15 |
16 | # the secret configuration specific things
17 | from ..Config import Config
18 | from ..core.logger import logging
19 |
20 | LOGS = logging.getLogger(__name__)
21 |
22 |
23 | def start() -> scoped_session:
24 | database_url = (
25 | Config.DB_URI.replace("postgres:", "postgresql:")
26 | if "postgres://" in Config.DB_URI
27 | else Config.DB_URI
28 | )
29 | engine = create_engine(database_url)
30 | BASE.metadata.bind = engine
31 | BASE.metadata.create_all(engine)
32 | return scoped_session(sessionmaker(bind=engine, autoflush=False))
33 |
34 |
35 | try:
36 | BASE = declarative_base()
37 | SESSION = start()
38 | except AttributeError as e:
39 | # this is a dirty way for the work-around required for #23
40 | LOGS.error(
41 | "DB_URI is not configured. Features depending on the database might have issues."
42 | )
43 | LOGS.error(str(e))
44 |
--------------------------------------------------------------------------------
/userbot/plugins/quotes.py:
--------------------------------------------------------------------------------
1 | # inspired from uniborg Quotes plugin
2 | import random
3 |
4 | from userbot import catub
5 |
6 | from ..core.logger import logging
7 | from ..core.managers import edit_delete, edit_or_reply
8 | from ..helpers import catmemes
9 | from ..helpers.functions import random_quote, search_quotes
10 | from ..helpers.utils import parse_pre
11 |
12 | LOGS = logging.getLogger(__name__)
13 | plugin_category = "extra"
14 |
15 |
16 | @catub.cat_cmd(
17 | pattern="quote(?:\s|$)([\s\S]*)",
18 | command=("quote", plugin_category),
19 | info={
20 | "header": "To get random quotes on given topic.",
21 | "description": "An api that Fetchs random Quote from `goodreads.com`",
22 | "usage": "{tr}quote ",
23 | "examples": "{tr}quote love",
24 | },
25 | )
26 | async def quote_search(event):
27 | "shows random quotes on given topic."
28 | input_str = event.pattern_match.group(1)
29 | try:
30 | response = await search_quotes(input_str) if input_str else await random_quote()
31 | except Exception:
32 | return await edit_delete(event, "`Sorry Zero results found`", 5)
33 | await edit_or_reply(event, response, parse_mode=parse_pre)
34 |
35 |
36 | @catub.cat_cmd(
37 | pattern="pquote$",
38 | command=("pquote", plugin_category),
39 | info={
40 | "header": "To get random quotes on programming.",
41 | "usage": "{tr}pquote",
42 | },
43 | )
44 | async def _(event):
45 | "Shows random programming quotes"
46 | txt = random.choice(catmemes.PROGQUOTES)
47 | await edit_or_reply(event, txt)
48 |
--------------------------------------------------------------------------------
/userbot/sql_helper/gdrive_sql.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 sqlalchemy import Column, String
11 |
12 | from . import BASE, SESSION
13 |
14 |
15 | class Gdrive(BASE):
16 | __tablename__ = "catgdrive"
17 | cat = Column(String(50), primary_key=True)
18 |
19 | def __init__(self, cat):
20 | self.cat = cat
21 |
22 |
23 | Gdrive.__table__.create(checkfirst=True)
24 |
25 |
26 | def is_folder(folder_id):
27 | try:
28 | return SESSION.query(Gdrive).filter(Gdrive.cat == str(folder_id))
29 | except BaseException:
30 | return None
31 | finally:
32 | SESSION.close()
33 |
34 |
35 | def gparent_id(folder_id):
36 | adder = SESSION.query(Gdrive).get(folder_id)
37 | if not adder:
38 | adder = Gdrive(folder_id)
39 | SESSION.add(adder)
40 | SESSION.commit()
41 |
42 |
43 | def get_parent_id():
44 | try:
45 | return SESSION.query(Gdrive).all()
46 | except BaseException:
47 | return None
48 | finally:
49 | SESSION.close()
50 |
51 |
52 | def rmparent_id(folder_id):
53 | if note := SESSION.query(Gdrive).filter(Gdrive.cat == folder_id):
54 | note.delete()
55 | SESSION.commit()
56 |
--------------------------------------------------------------------------------
/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 |
12 |
--------------------------------------------------------------------------------
/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/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/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/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/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/sql_helper/gban_sql_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 | from sqlalchemy import Column, String
11 |
12 | from . import BASE, SESSION
13 |
14 |
15 | class GBan(BASE):
16 | __tablename__ = "gban"
17 | chat_id = Column(String(14), primary_key=True)
18 | reason = Column(String(127))
19 |
20 | def __init__(self, chat_id, reason=""):
21 | self.chat_id = chat_id
22 | self.reason = reason
23 |
24 |
25 | GBan.__table__.create(checkfirst=True)
26 |
27 |
28 | def is_gbanned(chat_id):
29 | try:
30 | return SESSION.query(GBan).filter(GBan.chat_id == str(chat_id)).one()
31 | except BaseException:
32 | return None
33 | finally:
34 | SESSION.close()
35 |
36 |
37 | def get_gbanuser(chat_id):
38 | try:
39 | return SESSION.query(GBan).get(str(chat_id))
40 | finally:
41 | SESSION.close()
42 |
43 |
44 | def catgban(chat_id, reason):
45 | adder = GBan(str(chat_id), str(reason))
46 | SESSION.add(adder)
47 | SESSION.commit()
48 |
49 |
50 | def catungban(chat_id):
51 | if rem := SESSION.query(GBan).get(str(chat_id)):
52 | SESSION.delete(rem)
53 | SESSION.commit()
54 |
55 |
56 | def get_all_gbanned():
57 | rem = SESSION.query(GBan).all()
58 | SESSION.close()
59 | return rem
60 |
--------------------------------------------------------------------------------
/userbot/sql_helper/google_drive_sql.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 sqlalchemy import Column, String, Text
11 |
12 | from . import BASE, SESSION
13 |
14 |
15 | class GoogleDriveCreds(BASE):
16 | __tablename__ = "gdrive"
17 | user = Column(String, primary_key=True)
18 | credentials = Column(Text, nullable=False)
19 |
20 | def __init__(self, user):
21 | self.user = user
22 |
23 |
24 | GoogleDriveCreds.__table__.create(checkfirst=True)
25 |
26 |
27 | def save_credentials(user, credentials):
28 | saved_credentials = SESSION.query(GoogleDriveCreds).get(user)
29 | if not saved_credentials:
30 | saved_credentials = GoogleDriveCreds(user)
31 |
32 | saved_credentials.credentials = credentials
33 |
34 | SESSION.add(saved_credentials)
35 | SESSION.commit()
36 | return True
37 |
38 |
39 | def get_credentials(user):
40 | try:
41 | saved_credentials = SESSION.query(GoogleDriveCreds).get(user)
42 | return saved_credentials.credentials if saved_credentials is not None else None
43 | finally:
44 | SESSION.close()
45 |
46 |
47 | def clear_credentials(user):
48 | if saved_credentials := SESSION.query(GoogleDriveCreds).get(user):
49 | SESSION.delete(saved_credentials)
50 | SESSION.commit()
51 | return True
52 |
--------------------------------------------------------------------------------
/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/plugins/gps.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 geopy.geocoders import Nominatim
11 | from telethon.tl import types
12 |
13 | from userbot import catub
14 |
15 | from ..core.managers import edit_or_reply
16 | from ..helpers import reply_id
17 |
18 | plugin_category = "extra"
19 |
20 |
21 | @catub.cat_cmd(
22 | pattern="gps ([\s\S]*)",
23 | command=("gps", plugin_category),
24 | info={
25 | "header": "To send the map of the given location.",
26 | "usage": "{tr}gps ",
27 | "examples": "{tr}gps Hyderabad",
28 | },
29 | )
30 | async def gps(event):
31 | "Map of the given location."
32 | reply_to_id = await reply_id(event)
33 | input_str = event.pattern_match.group(1)
34 | catevent = await edit_or_reply(event, "`finding.....`")
35 | geolocator = Nominatim(user_agent="catuserbot")
36 | if geoloc := geolocator.geocode(input_str):
37 | lon = geoloc.longitude
38 | lat = geoloc.latitude
39 | await event.client.send_file(
40 | event.chat_id,
41 | file=types.InputMediaGeoPoint(types.InputGeoPoint(lat, lon)),
42 | caption=f"**Location : **`{input_str}`",
43 | reply_to=reply_to_id,
44 | )
45 | await catevent.delete()
46 | else:
47 | await catevent.edit("`i coudn't find it`")
48 |
--------------------------------------------------------------------------------
/userbot/plugins/linkpreview.py:
--------------------------------------------------------------------------------
1 | from telethon import events
2 | from telethon.errors.rpcerrorlist import YouBlockedUserError
3 |
4 | from userbot import catub
5 |
6 | from ..core.managers import edit_or_reply
7 |
8 | plugin_category = "utils"
9 |
10 |
11 | @catub.cat_cmd(
12 | pattern="ctg$",
13 | command=("ctg", plugin_category),
14 | info={
15 | "header": "Reply to link To get link preview using telegrah.s.",
16 | "usage": "{tr}ctg",
17 | },
18 | )
19 | async def _(event):
20 | "To get link preview"
21 | reply_message = await event.get_reply_message()
22 | if not reply_message:
23 | await edit_or_reply(event, "```Reply to a Link.```")
24 | return
25 | if not reply_message.text:
26 | await edit_or_reply(event, "```Reply to a Link```")
27 | return
28 | chat = "@chotamreaderbot"
29 | catevent = await edit_or_reply(event, "```Processing```")
30 | async with event.client.conversation(chat) as conv:
31 | try:
32 | response = conv.wait_event(
33 | events.NewMessage(incoming=True, from_users=272572121)
34 | )
35 | await event.client.forward_messages(chat, reply_message)
36 | response = await response
37 | await event.client.send_read_acknowledge(conv.chat_id)
38 | except YouBlockedUserError:
39 | await catevent.edit(
40 | "`RIP Check Your Blacklist Boss and unblock @chotamreaderbot`"
41 | )
42 | return
43 | if response.text.startswith(""):
44 | await catevent.edit("Am I Dumb Or Am I Dumb?")
45 | else:
46 | await catevent.delete()
47 | await event.client.send_message(event.chat_id, response.message)
48 |
--------------------------------------------------------------------------------
/userbot/plugins/transfer_channel.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 telethon.password as pwd_mod
11 | from telethon.tl import functions
12 |
13 | from userbot import catub
14 |
15 | from ..Config import Config
16 |
17 | plugin_category = "utils"
18 |
19 |
20 | @catub.cat_cmd(
21 | pattern="otransfer ([\s\S]*)",
22 | command=("otransfer", plugin_category),
23 | info={
24 | "header": "To transfer channel ownership.",
25 | "description": "Transfers ownership to the given username for this set this var `TG_2STEP_VERIFICATION_CODE` in heroku with your 2-step verification code.",
26 | "usage": "{tr}otransfer ",
27 | },
28 | )
29 | async def _(event):
30 | "To transfer channel ownership"
31 | user_name = event.pattern_match.group(1)
32 | try:
33 | pwd = await event.client(functions.account.GetPasswordRequest())
34 | my_srp_password = pwd_mod.compute_check(pwd, Config.TG_2STEP_VERIFICATION_CODE)
35 | await event.client(
36 | functions.channels.EditCreatorRequest(
37 | channel=event.chat_id, user_id=user_name, password=my_srp_password
38 | )
39 | )
40 | except Exception as e:
41 | await event.edit(f"**Error:**\n`{e}`")
42 | else:
43 | await event.edit("Transferred 🌚")
44 |
--------------------------------------------------------------------------------
/userbot/plugins/json.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 catub
11 |
12 | from ..core.managers import edit_or_reply
13 | from ..helpers.utils import _format
14 |
15 | plugin_category = "tools"
16 |
17 |
18 | # yaml_format is ported from uniborg
19 | @catub.cat_cmd(
20 | pattern="json$",
21 | command=("json", plugin_category),
22 | info={
23 | "header": "To get details of that message in json format.",
24 | "usage": "{tr}json reply to message",
25 | },
26 | )
27 | async def _(event):
28 | "To get details of that message in json format."
29 | catevent = await event.get_reply_message() if event.reply_to_msg_id else event
30 | the_real_message = catevent.stringify()
31 | await edit_or_reply(event, the_real_message, parse_mode=_format.parse_pre)
32 |
33 |
34 | @catub.cat_cmd(
35 | pattern="yaml$",
36 | command=("yaml", plugin_category),
37 | info={
38 | "header": "To get details of that message in yaml format.",
39 | "usage": "{tr}yaml reply to message",
40 | },
41 | )
42 | async def _(event):
43 | "To get details of that message in yaml format."
44 | catevent = await event.get_reply_message() if event.reply_to_msg_id else event
45 | the_real_message = _format.yaml_format(catevent)
46 | await edit_or_reply(event, the_real_message, parse_mode=_format.parse_pre)
47 |
--------------------------------------------------------------------------------
/userbot/sql_helper/globals.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 sqlalchemy import Column, String, UnicodeText
11 |
12 | from . import BASE, SESSION
13 |
14 |
15 | class Globals(BASE):
16 | __tablename__ = "globals"
17 | variable = Column(String, primary_key=True, nullable=False)
18 | value = Column(UnicodeText, primary_key=True, nullable=False)
19 |
20 | def __init__(self, variable, value):
21 | self.variable = str(variable)
22 | self.value = value
23 |
24 |
25 | Globals.__table__.create(checkfirst=True)
26 |
27 |
28 | def gvarstatus(variable):
29 | try:
30 | return (
31 | SESSION.query(Globals)
32 | .filter(Globals.variable == str(variable))
33 | .first()
34 | .value
35 | )
36 | except BaseException:
37 | return None
38 | finally:
39 | SESSION.close()
40 |
41 |
42 | def addgvar(variable, value):
43 | if SESSION.query(Globals).filter(Globals.variable == str(variable)).one_or_none():
44 | delgvar(variable)
45 | adder = Globals(str(variable), value)
46 | SESSION.add(adder)
47 | SESSION.commit()
48 |
49 |
50 | def delgvar(variable):
51 | if rem := (
52 | SESSION.query(Globals)
53 | .filter(Globals.variable == str(variable))
54 | .delete(synchronize_session="fetch")
55 | ):
56 | SESSION.commit()
57 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/userbot/plugins/filext.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 requests
11 | from bs4 import BeautifulSoup
12 |
13 | from userbot import catub
14 |
15 | from ..core.managers import edit_or_reply
16 |
17 | plugin_category = "utils"
18 |
19 |
20 | @catub.cat_cmd(
21 | pattern="filext(?:\s|$)([\s\S]*)",
22 | command=("filext", plugin_category),
23 | info={
24 | "header": "Shows you the detailed information of given extension type.",
25 | "usage": "{tr}filext ",
26 | "examples": "{tr}filext py",
27 | },
28 | )
29 | async def _(event):
30 | "Shows you the detailed information of given extension type."
31 | sample_url = "https://www.fileext.com/file-extension/{}.html"
32 | input_str = event.pattern_match.group(1).lower()
33 | response_api = requests.get(sample_url.format(input_str))
34 | status_code = response_api.status_code
35 | if status_code == 200:
36 | raw_html = response_api.content
37 | soup = BeautifulSoup(raw_html, "html.parser")
38 | ext_details = soup.find_all("td", {"colspan": "3"})[-1].text
39 | await edit_or_reply(
40 | event,
41 | f"**File Extension**: `{input_str}`\n**Description**: `{ext_details}`",
42 | )
43 | else:
44 | await edit_or_reply(
45 | event,
46 | f"https://www.fileext.com/ responded with {status_code} for query: {input_str}",
47 | )
48 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/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/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/sql_helper/snip_sql.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 sqlalchemy import Column, Numeric, UnicodeText
11 |
12 | from . import BASE, SESSION
13 |
14 |
15 | class Note(BASE):
16 | __tablename__ = "catsnip"
17 | keyword = Column(UnicodeText, primary_key=True, nullable=False)
18 | reply = Column(UnicodeText)
19 | f_mesg_id = Column(Numeric)
20 |
21 | def __init__(self, keyword, reply, f_mesg_id):
22 | self.keyword = keyword
23 | self.reply = reply
24 | self.f_mesg_id = f_mesg_id
25 |
26 |
27 | Note.__table__.create(checkfirst=True)
28 |
29 |
30 | def get_note(keyword):
31 | try:
32 | return SESSION.query(Note).get(keyword)
33 | finally:
34 | SESSION.close()
35 |
36 |
37 | def get_notes():
38 | try:
39 | return SESSION.query(Note).all()
40 | finally:
41 | SESSION.close()
42 |
43 |
44 | def add_note(keyword, reply, f_mesg_id):
45 | to_check = get_note(keyword)
46 | if not to_check:
47 | adder = Note(keyword, reply, f_mesg_id)
48 | SESSION.add(adder)
49 | SESSION.commit()
50 | return True
51 | rem = SESSION.query(Note).get(keyword)
52 | SESSION.delete(rem)
53 | SESSION.commit()
54 | adder = Note(keyword, reply, f_mesg_id)
55 | SESSION.add(adder)
56 | SESSION.commit()
57 | return False
58 |
59 |
60 | def rm_note(keyword):
61 | to_check = get_note(keyword)
62 | if not to_check:
63 | return False
64 | rem = SESSION.query(Note).get(keyword)
65 | SESSION.delete(rem)
66 | SESSION.commit()
67 | return True
68 |
--------------------------------------------------------------------------------
/userbot/plugins/recognize.py:
--------------------------------------------------------------------------------
1 | # credits: @Mr_Hops
2 | from telethon import events
3 | from telethon.errors.rpcerrorlist import YouBlockedUserError
4 |
5 | from userbot import catub
6 |
7 | from ..core.managers import edit_or_reply
8 |
9 | plugin_category = "utils"
10 |
11 |
12 | @catub.cat_cmd(
13 | pattern="recognize ?([\s\S]*)",
14 | command=("recognize", plugin_category),
15 | info={
16 | "header": "To recognize a image",
17 | "description": "Get information about an image using AWS Rekognition. Find out information including detected labels, faces. text and moderation tags",
18 | "usage": "{tr}recognize",
19 | },
20 | )
21 | async def _(event):
22 | "To recognize a image."
23 | if not event.reply_to_msg_id:
24 | return await edit_or_reply(event, "Reply to any user's media message.")
25 | reply_message = await event.get_reply_message()
26 | if not reply_message.media:
27 | return await edit_or_reply(event, "reply to media file")
28 | chat = "@Rekognition_Bot"
29 | if reply_message.sender.bot:
30 | return await event.edit("Reply to actual users message.")
31 | cat = await edit_or_reply(event, "recognizeing this media")
32 | async with event.client.conversation(chat) as conv:
33 | try:
34 | response = conv.wait_event(
35 | events.NewMessage(incoming=True, from_users=461083923)
36 | )
37 | await event.client.forward_messages(chat, reply_message)
38 | response = await response
39 | except YouBlockedUserError:
40 | await cat.edit("unblock @Rekognition_Bot and try again")
41 | return
42 | if response.text.startswith("See next message."):
43 | response = conv.wait_event(
44 | events.NewMessage(incoming=True, from_users=461083923)
45 | )
46 | response = await response
47 | msg = response.message.message
48 | await cat.edit(msg)
49 | else:
50 | await cat.edit("sorry, I couldnt find it")
51 | await event.client.send_read_acknowledge(conv.chat_id)
52 |
--------------------------------------------------------------------------------
/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/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 |
--------------------------------------------------------------------------------
/userbot/sql_helper/global_collectionjson.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 sqlalchemy import Column, UnicodeText
11 | from sqlalchemy_json import MutableJson, NestedMutableJson
12 |
13 | from . import BASE, SESSION
14 |
15 |
16 | class Cat_GlobalCollection_Json(BASE):
17 | __tablename__ = "cat_globalcollectionjson"
18 | keywoard = Column(UnicodeText, primary_key=True)
19 | json = Column(MutableJson)
20 | njson = Column(NestedMutableJson)
21 |
22 | def __init__(self, keywoard, json, njson):
23 | self.keywoard = keywoard
24 | self.json = json
25 | self.njson = njson
26 |
27 |
28 | Cat_GlobalCollection_Json.__table__.create(checkfirst=True)
29 |
30 |
31 | def get_collection(keywoard):
32 | try:
33 | return SESSION.query(Cat_GlobalCollection_Json).get(keywoard)
34 | finally:
35 | SESSION.close()
36 |
37 |
38 | def add_collection(keywoard, json, njson=None):
39 | if njson is None:
40 | njson = {}
41 | if to_check := get_collection(keywoard):
42 | keyword_items = SESSION.query(Cat_GlobalCollection_Json).get(keywoard)
43 | SESSION.delete(keyword_items)
44 | keyword_items = Cat_GlobalCollection_Json(keywoard, json, njson)
45 | SESSION.add(keyword_items)
46 | SESSION.commit()
47 | return True
48 |
49 |
50 | def del_collection(keywoard):
51 | to_check = get_collection(keywoard)
52 | if not to_check:
53 | return False
54 | keyword_items = SESSION.query(Cat_GlobalCollection_Json).get(keywoard)
55 | SESSION.delete(keyword_items)
56 | SESSION.commit()
57 | return True
58 |
59 |
60 | def get_collections():
61 | try:
62 | return SESSION.query(Cat_GlobalCollection_Json).all()
63 | finally:
64 | SESSION.close()
65 |
--------------------------------------------------------------------------------
/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/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/plugins/gifs.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 |
14 | from ..core.managers import edit_delete, edit_or_reply
15 | from ..helpers import reply_id, unsavegif
16 | from . import catub
17 |
18 | plugin_category = "Extra"
19 |
20 |
21 | @catub.cat_cmd(
22 | pattern="gifs(?:\s|$)([\s\S]*)",
23 | command=("gifs", plugin_category),
24 | info={
25 | "header": "Sends random gifs",
26 | "usage": "Search and send your desire gif randomly and in bulk",
27 | "examples": [
28 | "{tr}gifs cat",
29 | "{tr}gifs cat ; <1-20>",
30 | ],
31 | },
32 | )
33 | async def some(event):
34 | """Sends random gifs of your query"""
35 | inpt = event.pattern_match.group(1)
36 | reply_to_id = await reply_id(event)
37 | if not inpt:
38 | await edit_delete(event, "`Give an input to search...`")
39 | count = 1
40 | if ";" in inpt:
41 | inpt, count = inpt.split(";")
42 | if int(count) < 0 and int(count) > 20:
43 | await edit_delete(event, "`Give value in range 1-20`")
44 | catevent = await edit_or_reply(event, "`Sending gif....`")
45 | res = requests.get("https://giphy.com/")
46 | res = res.text.split("GIPHY_FE_WEB_API_KEY =")[1].split("\n")[0]
47 | api_key = res[2:-1]
48 | r = requests.get(
49 | f"https://api.giphy.com/v1/gifs/search?q={inpt}&api_key={api_key}&limit=50"
50 | ).json()
51 | list_id = [r["data"][i]["id"] for i in range(len(r["data"]))]
52 | rlist = random.sample(list_id, int(count))
53 | for items in rlist:
54 | nood = await event.client.send_file(
55 | event.chat_id,
56 | f"https://media.giphy.com/media/{items}/giphy.gif",
57 | reply_to=reply_to_id,
58 | )
59 | await unsavegif(event, nood)
60 | await catevent.delete()
61 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/userbot/plugins/invite.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 import functions
11 |
12 | from userbot import catub
13 |
14 | from ..core.managers import edit_delete, edit_or_reply
15 |
16 | plugin_category = "utils"
17 |
18 |
19 | @catub.cat_cmd(
20 | pattern="invite ([\s\S]*)",
21 | command=("invite", plugin_category),
22 | info={
23 | "header": "Add the given user/users to the group where u used the command.",
24 | "description": "Adds only mentioned person or bot not all members",
25 | "usage": "{tr}invite ",
26 | "examples": "{tr}invite @combot @MissRose_bot",
27 | },
28 | )
29 | async def _(event):
30 | "To invite a user to chat."
31 | to_add_users = event.pattern_match.group(1)
32 | if not event.is_channel and event.is_group:
33 | # https://lonamiwebs.github.io/Telethon/methods/messages/add_chat_user.html
34 | for user_id in to_add_users.split(" "):
35 | try:
36 | await event.client(
37 | functions.messages.AddChatUserRequest(
38 | chat_id=event.chat_id, user_id=user_id, fwd_limit=1000000
39 | )
40 | )
41 | except Exception as e:
42 | return await edit_delete(event, f"`{str(e)}`", 5)
43 | else:
44 | # https://lonamiwebs.github.io/Telethon/methods/channels/invite_to_channel.html
45 | for user_id in to_add_users.split(" "):
46 | try:
47 | await event.client(
48 | functions.channels.InviteToChannelRequest(
49 | channel=event.chat_id, users=[user_id]
50 | )
51 | )
52 | except Exception as e:
53 | return await edit_delete(event, f"`{e}`", 5)
54 |
55 | await edit_or_reply(event, f"`{to_add_users} is/are Invited Successfully`")
56 |
--------------------------------------------------------------------------------
/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