├── setup ├── __init__.py └── updater.py ├── Procfile ├── runtime.txt ├── Aptfile ├── README.md ├── stringsetup.py ├── requirements.txt ├── app.json ├── start └── catub /setup/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | worker: bash catub 2 | -------------------------------------------------------------------------------- /runtime.txt: -------------------------------------------------------------------------------- 1 | python-3.10.5 2 | -------------------------------------------------------------------------------- /Aptfile: -------------------------------------------------------------------------------- 1 | pv 2 | tree 3 | mediainfo 4 | p7zip-full 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Catuserbot-heroku 2 | [![Hits](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Ftgcatub%2Fnekopack&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false)](https://github.com/TgCatUB/nekopack) 3 | 4 | This repo is only for deploying purpose if you want to look into main source code head to [main source](https://github.com/tgcatub/catuserbot) and fork and give star to these repos 5 | 6 | ## Deploy 7 | 8 | To be safe fork this repo and then press deploy button from the forked repo 9 | 10 | Fork Deploy is highly recommended 11 | 12 | [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy) 13 | 14 | ## credits 15 | - [@midnightmadwalk](https://t.me/midnightmadwalk) 16 | - [@DeletedUser420](https://t.me/DeletedUser420) 17 | -------------------------------------------------------------------------------- /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.send_message("me", client.session.save()) 22 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | aiohttp 2 | cinemagoer 3 | cloudscraper 4 | colour 5 | cowpy 6 | emoji==1.7.0 7 | fonttools 8 | geopy 9 | gitpython 10 | glitch_this 11 | google-api-python-client 12 | google-auth-httplib2 13 | google-auth-oauthlib 14 | gtts 15 | hachoir 16 | heroku3 17 | html-telegraph-poster 18 | httpx[http2] 19 | humanize 20 | jikanpy 21 | justwatch 22 | lottie 23 | lyricsgenius 24 | markdown 25 | motor 26 | Pillow 27 | prettytable 28 | psutil 29 | psycopg2 30 | pyfiglet 31 | PyGithub 32 | pygments 33 | pylast 34 | pymediainfo 35 | PyMuPDF 36 | pySmartDL 37 | python-barcode 38 | pytz 39 | qrcode 40 | requests 41 | selenium 42 | setuptools 43 | ShazamAPI 44 | spamwatch 45 | speedtest-cli 46 | sqlalchemy-json 47 | sqlalchemy==1.3.23 48 | telegraph==2.1.0 49 | tgcrypto 50 | ujson 51 | urlextract 52 | validators 53 | vcsi 54 | wand 55 | wget 56 | yt_dlp 57 | 58 | git+https://github.com/Jisan09/search-engine-parser 59 | git+https://github.com/jisan09/Telethon@beta 60 | git+https://github.com/goldsmith/Wikipedia 61 | git+https://github.com/sandy1709/py-googletrans 62 | git+https://github.com/alexmercerind/youtube-search-python 63 | -------------------------------------------------------------------------------- /setup/updater.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import difflib 3 | import shlex 4 | from typing import Tuple 5 | import sys 6 | 7 | # if any requirements are cahnged then install that requirement 8 | async def lines_differnce(file1, file2): 9 | with open(file1) as f1: 10 | lines1 = f1.readlines() 11 | lines1 = [line.rstrip("\n") for line in lines1] 12 | with open(file2) as f2: 13 | lines2 = f2.readlines() 14 | lines2 = [line.rstrip("\n") for line in lines2] 15 | diff = difflib.unified_diff( 16 | lines1, lines2, fromfile=file1, tofile=file2, lineterm="", n=0 17 | ) 18 | lines = list(diff)[2:] 19 | added = [line[1:] for line in lines if line[0] == "+"] 20 | removed = [line[1:] for line in lines if line[0] == "-"] 21 | additions = [i for i in added if i not in removed] 22 | removedt = [i for i in removed if i not in added] 23 | return additions, removedt 24 | 25 | 26 | async def runcmd(cmd: str) -> Tuple[str, str, int, int]: 27 | args = shlex.split(cmd) 28 | process = await asyncio.create_subprocess_exec( 29 | *args, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE 30 | ) 31 | stdout, stderr = await process.communicate() 32 | return ( 33 | stdout.decode("utf-8", "replace").strip(), 34 | stderr.decode("utf-8", "replace").strip(), 35 | process.returncode, 36 | process.pid, 37 | ) 38 | 39 | 40 | async def update_requirements(main , test): 41 | a, r = await lines_differnce(main, test) 42 | try: 43 | for i in a: 44 | await runcmd(f"pip install {i}") 45 | print(f"Succesfully installed {i}") 46 | except Exception as e: 47 | print(f"Error while installing requirments {str(e)}") 48 | 49 | 50 | asyncio.run(update_requirements(sys.argv[1] , sys.argv[2])) -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "CatUserbot", 3 | "description": "A simple Telegram userbot based on Telethon . Maintained by Sandeep ", 4 | "logo": "https://telegra.ph/file/3d60313110c58684b31ea.jpg", 5 | "keywords": [ 6 | "plugin", 7 | "modular", 8 | "productivity" 9 | ], 10 | "repository": "https://github.com/TgCatUB/catuserbot", 11 | "website": "#TODO", 12 | "success_url": "#TODO", 13 | "env": { 14 | "ALIVE_NAME": { 15 | "description": "give your name", 16 | "value": "" 17 | }, 18 | "APP_ID": { 19 | "description": "Get this value from my.telegram.org! Please do not steal", 20 | "value": "" 21 | }, 22 | "API_HASH": { 23 | "description": "Get this value from my.telegram.org! Please do not steal", 24 | "value": "" 25 | }, 26 | "STRING_SESSION": { 27 | "description": "Get this value by running python3 stringsetup.py locally or https://generatestringsession.sandeep1709.repl.run", 28 | "value": "" 29 | }, 30 | "TG_BOT_TOKEN": { 31 | "description": "Needed for inline buttons maker. Make a bot at http://telegram.dog/BotFather and get the token of your bot.", 32 | "value": "" 33 | }, 34 | "COMMAND_HAND_LER": { 35 | "description": "Set this one with only one the symbol to use it before your command to run like . , ' `", 36 | "value": ".", 37 | "required": false 38 | }, 39 | "ENV": { 40 | "description": "Setting this to ANYTHING will enable heroku.", 41 | "value": "ANYTHING", 42 | "required": false 43 | }, 44 | "HEROKU_API_KEY": { 45 | "description": "Required for updating the bot and other stuff get it from https://dashboard.heroku.com/account", 46 | "value": "", 47 | "required": false 48 | }, 49 | "HEROKU_APP_NAME": { 50 | "description": "YOUR app name ", 51 | "value": "", 52 | "required": false 53 | }, 54 | "TZ": { 55 | "description": "Required for Correct Time on autopic/get time. Know your timezone from http://www.timezoneconverter.com/cgi-bin/findzone.tzc", 56 | "value": "Asia/Kolkata", 57 | "required": false 58 | }, 59 | "EXTERNAL_REPO": { 60 | "description": "To install external plugins. if you don't want, change value to 'False'", 61 | "value": "True", 62 | "required": false 63 | }, 64 | "BADCAT": { 65 | "description": "set 'True' to install 18+ plugins.", 66 | "value": "False", 67 | "required": false 68 | } 69 | }, 70 | "addons": [{ 71 | "plan": "heroku-postgresql", 72 | "options": { 73 | "version": "12" 74 | } 75 | }], 76 | "buildpacks": [{ 77 | "url": "https://github.com/jonathanong/heroku-buildpack-ffmpeg-latest" 78 | },{ 79 | "url":"https://github.com/heroku/heroku-buildpack-google-chrome" 80 | },{ 81 | "url":"https://github.com/heroku/heroku-buildpack-chromedriver" 82 | },{ 83 | "url": "https://github.com/opendoor-labs/heroku-buildpack-p7zip" 84 | },{ 85 | "url": "https://github.com/heroku/heroku-buildpack-apt.git" 86 | },{ 87 | "url": "https://github.com/chrismytton/heroku-buildpack-jq" 88 | },{ 89 | "url": "https://github.com/rahulps1000/heroku-buildpack-nodejs" 90 | },{ 91 | "url": "heroku/python" 92 | }], 93 | "stack": "heroku-22" 94 | } 95 | -------------------------------------------------------------------------------- /start: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | _get_zlink () { 4 | local regex 5 | regex='(https?)://github.com/.+/.+' 6 | if [[ $UPSTREAM_REPO == "goodcat" ]] 7 | then 8 | echo "aHR0cHM6Ly9naXRodWIuY29tL1RnQ2F0VUIvY2F0dXNlcmJvdC9hcmNoaXZlL21hc3Rlci56aXA=" | base64 -d 9 | elif [[ $UPSTREAM_REPO == "badcat" ]] 10 | then 11 | echo "aHR0cHM6Ly9naXRodWIuY29tL2ppc2FuMDkvY2F0dXNlcmJvdC9hcmNoaXZlL21hc3Rlci56aXA=" | base64 -d 12 | elif [[ $UPSTREAM_REPO =~ $regex ]] 13 | then 14 | if [[ $UPSTREAM_REPO_BRANCH ]] 15 | then 16 | echo "${UPSTREAM_REPO}/archive/${UPSTREAM_REPO_BRANCH}.zip" 17 | else 18 | echo "${UPSTREAM_REPO}/archive/master.zip" 19 | fi 20 | else 21 | echo "aHR0cHM6Ly9naXRodWIuY29tL1RnQ2F0VUIvY2F0dXNlcmJvdC9hcmNoaXZlL21hc3Rlci56aXA=" | base64 -d 22 | fi 23 | } 24 | 25 | _get_repolink () { 26 | local regex 27 | local rlink 28 | regex='(https?)://github.com/.+/.+' 29 | if [[ $UPSTREAM_REPO == "goodcat" ]] 30 | then 31 | rlink=`echo "aHR0cHM6Ly9naXRodWIuY29tL1RnQ2F0VUIvY2F0dXNlcmJvdA==" | base64 -d` 32 | elif [[ $UPSTREAM_REPO == "badcat" ]] 33 | then 34 | rlink=`echo "aHR0cHM6Ly9naXRodWIuY29tL0ppc2FuMDkvY2F0dXNlcmJvdA==" | base64 -d` 35 | elif [[ $UPSTREAM_REPO =~ $regex ]] 36 | then 37 | rlink=`echo "${UPSTREAM_REPO}"` 38 | else 39 | rlink=`echo "aHR0cHM6Ly9naXRodWIuY29tL1RnQ2F0VUIvY2F0dXNlcmJvdA==" | base64 -d` 40 | fi 41 | echo "$rlink" 42 | } 43 | 44 | 45 | _run_python_code() { 46 | python3${pVer%.*} -c "$1" 47 | } 48 | 49 | _run_catpackgit() { 50 | $(_run_python_code 'from git import Repo 51 | import sys 52 | OFFICIAL_UPSTREAM_REPO = "https://github.com/TgCatUB/nekopack" 53 | ACTIVE_BRANCH_NAME = "master" 54 | repo = Repo.init() 55 | origin = repo.create_remote("temponame", OFFICIAL_UPSTREAM_REPO) 56 | origin.fetch() 57 | repo.create_head(ACTIVE_BRANCH_NAME, origin.refs[ACTIVE_BRANCH_NAME]) 58 | repo.heads[ACTIVE_BRANCH_NAME].checkout(True) ') 59 | } 60 | 61 | _run_catgit() { 62 | local repolink=$(_get_repolink) 63 | $(_run_python_code 'from git import Repo 64 | import sys 65 | OFFICIAL_UPSTREAM_REPO="'$repolink'" 66 | ACTIVE_BRANCH_NAME = "'$UPSTREAM_REPO_BRANCH'" or "master" 67 | repo = Repo.init() 68 | origin = repo.create_remote("temponame", OFFICIAL_UPSTREAM_REPO) 69 | origin.fetch() 70 | repo.create_head(ACTIVE_BRANCH_NAME, origin.refs[ACTIVE_BRANCH_NAME]) 71 | repo.heads[ACTIVE_BRANCH_NAME].checkout(True) ') 72 | } 73 | 74 | _start_bot () { 75 | local zippath 76 | zippath="catuserbot.zip" 77 | echo " Downloading source code ..." 78 | wget -q $(_get_zlink) -O "$zippath" 79 | echo " Unpacking Data ..." 80 | CATPATH=$(zipinfo -1 "$zippath" | grep -v "/."); 81 | unzip -qq "$zippath" 82 | echo "Done" 83 | echo " Cleaning ..." 84 | rm -rf "$zippath" 85 | _run_catpackgit 86 | cd $CATPATH 87 | _run_catgit 88 | python3 ../setup/updater.py ../requirements.txt requirements.txt 89 | chmod -R 755 bin 90 | echo " Starting CatUserBot " 91 | echo " 92 | :'######:::::'###::::'########:::: 93 | '##... ##:::'## ##:::... ##..::::: 94 | ##:::..:::'##:. ##::::: ##::::::: 95 | ##:::::::'##:::. ##:::: ##::::::: 96 | ##::::::: #########:::: ##::::::: 97 | ##::: ##: ##.... ##:::: ##::::::: 98 | . ######:: ##:::: ##:::: ##::::::: 99 | :......:::..:::::..:::::..:::::::: 100 | " 101 | 102 | echo " 103 | '##::::'##::'######::'########:'########::'########:::'#######::'########: 104 | ##:::: ##:'##... ##: ##.....:: ##.... ##: ##.... ##:'##.... ##:... ##..:: 105 | ##:::: ##: ##:::..:: ##::::::: ##:::: ##: ##:::: ##: ##:::: ##:::: ##:::: 106 | ##:::: ##:. ######:: ######::: ########:: ########:: ##:::: ##:::: ##:::: 107 | ##:::: ##::..... ##: ##...:::: ##.. ##::: ##.... ##: ##:::: ##:::: ##:::: 108 | ##:::: ##:'##::: ##: ##::::::: ##::. ##:: ##:::: ##: ##:::: ##:::: ##:::: 109 | . #######::. ######:: ########: ##:::. ##: ########::. #######::::: ##:::: 110 | :.......::::......:::........::..:::::..::........::::.......::::::..::::: 111 | " 112 | python3 -m userbot 113 | } 114 | 115 | _start_bot 116 | -------------------------------------------------------------------------------- /catub: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | _get_zlink () { 4 | local regex 5 | regex='(https?)://github.com/.+/.+' 6 | if [[ $UPSTREAM_REPO == "goodcat" ]] 7 | then 8 | echo "aHR0cHM6Ly9naXRodWIuY29tL1RnQ2F0VUIvY2F0dXNlcmJvdC9hcmNoaXZlL21hc3Rlci56aXA=" | base64 -d 9 | elif [[ $UPSTREAM_REPO == "badcat" ]] 10 | then 11 | echo "aHR0cHM6Ly9naXRodWIuY29tL2ppc2FuMDkvY2F0dXNlcmJvdC9hcmNoaXZlL21hc3Rlci56aXA=" | base64 -d 12 | elif [[ $UPSTREAM_REPO =~ $regex ]] 13 | then 14 | if [[ $UPSTREAM_REPO_BRANCH ]] 15 | then 16 | echo "${UPSTREAM_REPO}/archive/${UPSTREAM_REPO_BRANCH}.zip" 17 | else 18 | echo "${UPSTREAM_REPO}/archive/master.zip" 19 | fi 20 | else 21 | echo "aHR0cHM6Ly9naXRodWIuY29tL1RnQ2F0VUIvY2F0dXNlcmJvdC9hcmNoaXZlL21hc3Rlci56aXA=" | base64 -d 22 | fi 23 | } 24 | 25 | _get_repolink () { 26 | local regex 27 | local rlink 28 | regex='(https?)://github.com/.+/.+' 29 | if [[ $UPSTREAM_REPO == "goodcat" ]] 30 | then 31 | rlink=`echo "aHR0cHM6Ly9naXRodWIuY29tL1RnQ2F0VUIvY2F0dXNlcmJvdA==" | base64 -d` 32 | elif [[ $UPSTREAM_REPO == "badcat" ]] 33 | then 34 | rlink=`echo "aHR0cHM6Ly9naXRodWIuY29tL0ppc2FuMDkvY2F0dXNlcmJvdA==" | base64 -d` 35 | elif [[ $UPSTREAM_REPO =~ $regex ]] 36 | then 37 | rlink=`echo "${UPSTREAM_REPO}"` 38 | else 39 | rlink=`echo "aHR0cHM6Ly9naXRodWIuY29tL1RnQ2F0VUIvY2F0dXNlcmJvdA==" | base64 -d` 40 | fi 41 | echo "$rlink" 42 | } 43 | 44 | 45 | _run_python_code() { 46 | python3${pVer%.*} -c "$1" 47 | } 48 | 49 | _run_catpackgit() { 50 | $(_run_python_code 'from git import Repo 51 | import sys 52 | 53 | OFFICIAL_UPSTREAM_REPO = "https://github.com/TgCatUB/nekopack" 54 | ACTIVE_BRANCH_NAME = "master" 55 | 56 | repo = Repo.init() 57 | origin = repo.create_remote("temponame", OFFICIAL_UPSTREAM_REPO) 58 | origin.fetch() 59 | repo.create_head(ACTIVE_BRANCH_NAME, origin.refs[ACTIVE_BRANCH_NAME]) 60 | repo.heads[ACTIVE_BRANCH_NAME].checkout(True) ') 61 | } 62 | 63 | _run_catgit() { 64 | local repolink=$(_get_repolink) 65 | $(_run_python_code 'from git import Repo 66 | import sys 67 | OFFICIAL_UPSTREAM_REPO="'$repolink'" 68 | ACTIVE_BRANCH_NAME = "'$UPSTREAM_REPO_BRANCH'" or "master" 69 | repo = Repo.init() 70 | origin = repo.create_remote("temponame", OFFICIAL_UPSTREAM_REPO) 71 | origin.fetch() 72 | repo.create_head(ACTIVE_BRANCH_NAME, origin.refs[ACTIVE_BRANCH_NAME]) 73 | repo.heads[ACTIVE_BRANCH_NAME].checkout(True) ') 74 | } 75 | 76 | _start_bot () { 77 | local zippath 78 | zippath="catuserbot.zip" 79 | echo " Downloading source code ..." 80 | wget -q $(_get_zlink) -O "$zippath" 81 | echo " Unpacking Data ..." 82 | CATPATH=$(zipinfo -1 "$zippath" | grep -v "/."); 83 | unzip -qq "$zippath" 84 | echo "Done" 85 | echo " Cleaning ..." 86 | rm -rf "$zippath" 87 | _run_catpackgit 88 | cd $CATPATH 89 | _run_catgit 90 | python3 ../setup/updater.py ../requirements.txt requirements.txt 91 | chmod -R 755 bin 92 | echo " Starting CatUserBot " 93 | echo " 94 | :'######:::::'###::::'########:::: 95 | '##... ##:::'## ##:::... ##..::::: 96 | ##:::..:::'##:. ##::::: ##::::::: 97 | ##:::::::'##:::. ##:::: ##::::::: 98 | ##::::::: #########:::: ##::::::: 99 | ##::: ##: ##.... ##:::: ##::::::: 100 | . ######:: ##:::: ##:::: ##::::::: 101 | :......:::..:::::..:::::..:::::::: 102 | " 103 | 104 | echo " 105 | '##::::'##::'######::'########:'########::'########:::'#######::'########: 106 | ##:::: ##:'##... ##: ##.....:: ##.... ##: ##.... ##:'##.... ##:... ##..:: 107 | ##:::: ##: ##:::..:: ##::::::: ##:::: ##: ##:::: ##: ##:::: ##:::: ##:::: 108 | ##:::: ##:. ######:: ######::: ########:: ########:: ##:::: ##:::: ##:::: 109 | ##:::: ##::..... ##: ##...:::: ##.. ##::: ##.... ##: ##:::: ##:::: ##:::: 110 | ##:::: ##:'##::: ##: ##::::::: ##::. ##:: ##:::: ##: ##:::: ##:::: ##:::: 111 | . #######::. ######:: ########: ##:::. ##: ########::. #######::::: ##:::: 112 | :.......::::......:::........::..:::::..::........::::.......::::::..::::: 113 | " 114 | python3 -m userbot 115 | } 116 | 117 | _start_bot 118 | --------------------------------------------------------------------------------