Skip to content

Commit 90faf1a

Browse files
authored
some new changes and new modules (TgCatUB#75)
check channel for info https://t.me/catuserbot17
1 parent 166ebe2 commit 90faf1a

204 files changed

Lines changed: 11313 additions & 8328 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/pylint.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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@v2
10+
11+
- name: Setup Python
12+
uses: actions/setup-python@v1
13+
with:
14+
python-version: 3.8
15+
16+
- name: Install Python lint libraries
17+
run: |
18+
pip install autopep8 autoflake
19+
- name: Check for showstoppers
20+
run: |
21+
autopep8 --verbose --in-place --recursive --aggressive --aggressive . *.py
22+
- name: Remove unused imports and variables
23+
run: |
24+
autoflake --in-place --recursive --remove-all-unused-imports --remove-unused-variables --ignore-init-module-imports .
25+
# commit changes
26+
- uses: stefanzweifel/git-auto-commit-action@v4
27+
with:
28+
commit_message: 'pylint: auto fixes'
29+
commit_options: '--no-verify'
30+
repository: .
31+
commit_user_name: sandy1709
32+
commit_user_email: [email protected]
33+
commit_author: sandy1709 <[email protected]>

.github/workflows/pythonapp.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: FailedChecker
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ubuntu-latest
9+
strategy:
10+
max-parallel: 5
11+
matrix:
12+
python-version: [3.8]
13+
14+
steps:
15+
- uses: actions/checkout@v1
16+
- name: Set up Python ${{ matrix.python-version }}
17+
uses: actions/setup-python@v1
18+
with:
19+
python-version: ${{ matrix.python-version }}
20+
- name: Install dependencies
21+
run: |
22+
sudo apt-get install libpq-dev
23+
python -m pip install --upgrade pip
24+
pip install -r requirements.txt
25+
pip install flake8 flake8-print flake8-quotes
26+
- name: Check for showstoppers
27+
run: |
28+
# stop the build if there are Python syntax errors
29+
flake8 . --count --select=E999 --show-source --statistics
30+
shellcheck:
31+
32+
runs-on: ubuntu-latest
33+
34+
steps:
35+
- uses: actions/checkout@v1
36+
- name: Check for install script errors
37+
uses: ludeeus/[email protected]

heroku_config.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22

3+
34
class Var(object):
45
APP_ID = int(os.environ.get("APP_ID", 6))
56
# 6 is a placeholder
@@ -11,7 +12,10 @@ class Var(object):
1112
GITHUB_ACCESS_TOKEN = os.environ.get("GITHUB_ACCESS_TOKEN", None)
1213
GIT_REPO_NAME = os.environ.get("GIT_REPO_NAME", None)
1314
# Here for later purposes
14-
SUDO_USERS = set(int(x) for x in os.environ.get("SUDO_USERS", "1005520858").split())
15+
SUDO_USERS = set(
16+
int(x) for x in os.environ.get(
17+
"SUDO_USERS",
18+
"1005520858").split())
1519
LYDIA_API_KEY = os.environ.get("LYDIA_API_KEY", None)
1620
LESS_SPAMMY = os.environ.get("LESS_SPAMMY", None)
1721
HEROKU_API_KEY = os.environ.get("HEROKU_API_KEY", None)
@@ -30,15 +34,17 @@ class Var(object):
3034
if AUTH_TOKEN_DATA is not None:
3135
if not os.path.isdir(TEMP_DOWNLOAD_DIRECTORY):
3236
os.makedirs(TEMP_DOWNLOAD_DIRECTORY)
33-
t_file = open(TEMP_DOWNLOAD_DIRECTORY+"auth_token.txt","w")
37+
t_file = open(TEMP_DOWNLOAD_DIRECTORY + "auth_token.txt", "w")
3438
t_file.write(AUTH_TOKEN_DATA)
3539
t_file.close()
3640
PRIVATE_GROUP_ID = os.environ.get("PRIVATE_GROUP_ID", None)
3741
if PRIVATE_GROUP_ID is not None:
3842
try:
3943
PRIVATE_GROUP_ID = int(PRIVATE_GROUP_ID)
4044
except ValueError:
41-
raise ValueError("Invalid Private Group ID. Make sure your ID is starts with -100 and make sure that it is only numbers.")
45+
raise ValueError(
46+
"Invalid Private Group ID. Make sure your ID is starts with -100 and make sure that it is only numbers.")
47+
4248

4349
class Development(Var):
4450
LOGGER = True

userbot/__init__.py

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,55 @@
55
from var import Var
66
from pylast import LastFMNetwork, md5
77
from logging import basicConfig, getLogger, INFO, DEBUG
8-
from distutils.util import strtobool as sb
8+
from distutils.util import strtobool as sb
99
from dotenv import load_dotenv
1010
from requests import get
1111
import time
1212
from pySmartDL import SmartDL
13-
from .helpers import fonts as fonts ,functions as catdef
13+
from .helpers import fonts as fonts, functions as catdef
1414
from .helpers import memeshelper as memes
15-
from .helpers import tempmemes , process as process
15+
from .helpers import tempmemes, process as process
1616

1717
StartTime = time.time()
18-
catversion = "2.7.1"
18+
catversion = "2.7.2"
1919

2020
if Var.STRING_SESSION:
2121
session_name = str(Var.STRING_SESSION)
2222
if session_name.endswith("="):
23-
bot = TelegramClient(StringSession(session_name), Var.APP_ID, Var.API_HASH)
23+
bot = TelegramClient(
24+
StringSession(session_name),
25+
Var.APP_ID,
26+
Var.API_HASH)
2427
else:
25-
bot = TelegramClient("TG_BOT_TOKEN",api_id=Var.APP_ID,api_hash=Var.API_HASH).start(bot_token=Var.STRING_SESSION)
28+
bot = TelegramClient(
29+
"TG_BOT_TOKEN",
30+
api_id=Var.APP_ID,
31+
api_hash=Var.API_HASH).start(
32+
bot_token=Var.STRING_SESSION)
2633
else:
2734
session_name = "startup"
2835
bot = TelegramClient(session_name, Var.APP_ID, Var.API_HASH)
29-
36+
3037
# PaperPlaneExtended Support Vars
3138
ENV = os.environ.get("ENV", False)
3239

3340
CAT_ID = ["1035034432", "551290198"]
3441

3542
# Bot Logs setup:
3643
if bool(ENV):
37-
CONSOLE_LOGGER_VERBOSE = sb(os.environ.get("CONSOLE_LOGGER_VERBOSE", "False"))
44+
CONSOLE_LOGGER_VERBOSE = sb(
45+
os.environ.get(
46+
"CONSOLE_LOGGER_VERBOSE",
47+
"False"))
3848
if CONSOLE_LOGGER_VERBOSE:
3949
basicConfig(
4050
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
4151
level=DEBUG,
4252
)
4353
else:
44-
basicConfig(format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
45-
level=INFO)
54+
basicConfig(
55+
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
56+
level=INFO)
4657
LOGS = getLogger(__name__)
4758

4859
# Check if the config was edited by using the already used variable.
@@ -56,10 +67,14 @@
5667
quit(1)
5768
BOTLOG_CHATID = int(os.environ.get("PRIVATE_GROUP_BOT_API_ID", "-100"))
5869
BOTLOG = sb(os.environ.get("BOTLOG", "True"))
59-
CONSOLE_LOGGER_VERBOSE = sb(os.environ.get("CONSOLE_LOGGER_VERBOSE", "False"))
70+
CONSOLE_LOGGER_VERBOSE = sb(
71+
os.environ.get(
72+
"CONSOLE_LOGGER_VERBOSE",
73+
"False"))
6074
# Chrome Driver and Headless Google Chrome Binaries
6175
CHROME_DRIVER = os.environ.get("CHROME_DRIVER", "/usr/bin/chromedriver")
62-
GOOGLE_CHROME_BIN = os.environ.get("GOOGLE_CHROME_BIN", "/usr/bin/google-chrome")
76+
GOOGLE_CHROME_BIN = os.environ.get(
77+
"GOOGLE_CHROME_BIN", "/usr/bin/google-chrome")
6378
# OpenWeatherMap API Key
6479
OPEN_WEATHER_MAP_APPID = os.environ.get("OPEN_WEATHER_MAP_APPID", None)
6580
# Youtube API key
@@ -68,8 +83,8 @@
6883
ALIVE_NAME = os.environ.get("ALIVE_NAME", None)
6984
AUTONAME = os.environ.get("AUTONAME", None)
7085
UPSTREAM_REPO_URL = os.environ.get(
71-
"UPSTREAM_REPO_URL",
72-
"https://github.com/sandy1709/catuserbot.git")
86+
"UPSTREAM_REPO_URL",
87+
"https://github.com/sandy1709/catuserbot.git")
7388
# Last.fm Module
7489
BIO_PREFIX = os.environ.get("BIO_PREFIX", None)
7590
DEFAULT_BIO = os.environ.get("DEFAULT_BIO", None)
@@ -83,8 +98,8 @@
8398
G_DRIVE_AUTH_TOKEN_DATA = os.environ.get("G_DRIVE_AUTH_TOKEN_DATA", None)
8499
GDRIVE_FOLDER_ID = os.environ.get("GDRIVE_FOLDER_ID", None)
85100
TEMP_DOWNLOAD_DIRECTORY = os.environ.get("TEMP_DOWNLOAD_DIRECTORY",
86-
"./downloads")
87-
#time.py
101+
"./downloads")
102+
# time.py
88103
COUNTRY = str(os.environ.get("COUNTRY", ""))
89104
TZ_NUMBER = int(os.environ.get("TZ_NUMBER", 1))
90105
else:
@@ -107,7 +122,7 @@
107122
downloader = SmartDL(binary, path, progress_bar=False)
108123
downloader.start()
109124
os.chmod(path, 0o755)
110-
125+
111126
# Global Variables
112127
COUNT_MSG = 0
113128
USERS = {}

userbot/__main__.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
from userbot import bot
22
from sys import argv
3-
from telethon.errors.rpcerrorlist import PhoneNumberInvalidError
43
from telethon import TelegramClient
54
from var import Var
65
from userbot.utils import load_module
7-
from userbot import LOAD_PLUG, LOGS
6+
from userbot import LOGS
87
from pathlib import Path
98
import telethon.utils
10-
import userbot._core
119
import glob
1210

11+
1312
async def add_bot(bot_token):
1413
await bot.start(bot_token)
15-
bot.me = await bot.get_me()
14+
bot.me = await bot.get_me()
1615
bot.uid = telethon.utils.get_peer_id(bot.me)
1716

18-
17+
1918
if len(argv) not in (1, 3, 4):
2019
bot.disconnect()
2120
else:
22-
bot.tgbot = None
21+
bot.tgbot = None
2322
if Var.TG_BOT_USER_NAME_BF_HER is not None:
2423
LOGS.info("Initiating Inline Bot")
2524
# ForTheGreatrerGood of beautification
@@ -34,15 +33,15 @@ async def add_bot(bot_token):
3433
LOGS.info("Startup Completed")
3534
else:
3635
bot.start()
37-
36+
3837
path = 'userbot/plugins/*.py'
3938
files = glob.glob(path)
4039
for name in files:
4140
with open(name) as f:
4241
path1 = Path(f.name)
4342
shortname = path1.stem
4443
load_module(shortname.replace(".py", ""))
45-
44+
4645
LOGS.info("Yay your userbot is officially working.!!!")
4746
LOGS.info("Congratulation, now type .alive to see message if bot is live\n"
4847
"If you need assistance, head to https://t.me/catuserbot_support")
@@ -51,4 +50,4 @@ async def add_bot(bot_token):
5150
bot.disconnect()
5251
else:
5352
bot.tgbot = None
54-
bot.run_until_disconnected()
53+
bot.run_until_disconnected()

userbot/_core.py

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)