Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
AshokShau committed Jan 26, 2024
0 parents commit 5d09497
Show file tree
Hide file tree
Showing 21 changed files with 830 additions and 0 deletions.
77 changes: 77 additions & 0 deletions .github/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
━━━━━━━━━━━━━━━━━━━━
**ᴀʙɪsʜɴᴏɪ**

<img src="https://user-images.githubusercontent.com/73097560/115834477-dbab4500-a447-11eb-908a-139a6edaec5c.gif">
<img src="https://user-images.githubusercontent.com/73097560/115834477-dbab4500-a447-11eb-908a-139a6edaec5c.gif">


<h2 align="center">
──「 ASSISTANT 」──
</h2>


## ᴄᴀᴛᴄʜ ᴍᴇ ɪɴ [ᴛɢ🏃‍♀️](https://t.me/AbishnoiMF)


## ⚡ (ɢɪᴠᴇ sᴛᴀʀ)


━━━━━━━━━━━━━━━━━━━━
━━━━━━━━━━━━━━━━━━━━
<img src="https://user-images.githubusercontent.com/73097560/115834477-dbab4500-a447-11eb-908a-139a6edaec5c.gif">
<img src="https://user-images.githubusercontent.com/73097560/115834477-dbab4500-a447-11eb-908a-139a6edaec5c.gif">



<p align="center">
<b>𝗗𝗘𝗣𝗟𝗢𝗬𝗠𝗘𝗡𝗧 𝗠𝗘𝗧𝗛𝗢𝗗𝗦</b>
</p>

<h3 align="center">
─「 ᴅᴇᴩʟᴏʏ ᴏɴ ʜᴇʀᴏᴋᴜ 」─
</h3>

<p align="center"><a href="https://dashboard.heroku.com/new?template=https://github.com/Abishnoi69/Assistant"> <img src="https://img.shields.io/badge/Deploy%20On%20Heroku-black?style=for-the-badge&logo=heroku" width="220" height="38.45"/></a></p>


<h3 align="center">
─「 ᴠᴘs/ʟᴏᴄᴀʟʟʏ ᴅᴇᴘʟᴏʏ 」─
</h3>

```console
$ sudo apt install tmux && tmux
$ apt update
$ apt-get -y install git gcc python3-dev
$ git clone https://github.com/Abishnoi69/Assistant && cd Assistant
$ pip3 install -U -r requirements.txt
$ cp sample.env .env
$ vi .env
-ᴘʀᴇss ɪ ʙᴜᴛᴛᴏɴ ᴏɴ ᴋᴇʏʙᴏᴀʀᴅ ᴛᴏ sᴛᴀʀᴛ ᴇᴅɪᴛɪɴɢ

-ᴘʀᴇss Ctrl + C ᴏɴᴄᴇ ʏᴏᴜ ᴀʀᴇ ᴅᴏɴᴇ ᴡɪᴛʜ ᴇᴅɪᴛɪɴɢ ᴠᴀʀs ᴀɴᴅ ᴛʏᴘᴇ :wq ᴛᴏ sᴀᴠᴇ .ᴇɴᴠ ᴏʀ :qa ᴛᴏ ᴇxɪᴛ ᴇᴅɪᴛɪɴɢ.

$ bash start
```

━━━━━━━━━━━━━━━━━━━━

<h3 align="center">
─「 sᴜᴩᴩᴏʀᴛ 」─
</h3>

<p align="center">
<a href="https://telegram.me/AbishnoiMF"><img src="https://img.shields.io/badge/-Support%20Group-blue.svg?style=for-the-badge&logo=Telegram"></a>
</p>
<p align="center">
<a href="https://telegram.me/Abishnoi1M"><img src="https://img.shields.io/badge/Abishnoi%20-blue.svg?style=for-the-badge&logo=Telegram"></a>
</p>

[ᴜᴘᴅᴀᴛɪɴɢ ʏᴏᴜʀ ғᴏʀᴋ ᴡɪᴛʜ ᴛʜᴇ ᴜᴘsᴛʀᴇᴀᴍ ʀᴇᴘᴏ](https://t.me/Abishnoi_bots/43)

━━━━━━━━━━━━━━━━━━━━
<img src="https://user-images.githubusercontent.com/73097560/115834477-dbab4500-a447-11eb-908a-139a6edaec5c.gif">
<img src="https://user-images.githubusercontent.com/73097560/115834477-dbab4500-a447-11eb-908a-139a6edaec5c.gif">
━━━━━━━━━━━━━━━━━━━━



35 changes: 35 additions & 0 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: PyLint

on: [push, pull_request]

jobs:
PEP8:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v3
with:
python-version: 3.11.6
- name: Install Python lint libraries
run: |
pip install autoflake isort black
- name: Remove unused imports and variables
run: |
autoflake --in-place --recursive --remove-all-unused-imports .
- name: lint with isort
run: |
isort .
- name: lint with black
run: |
black .
# commit changes
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: 'Auto Fixes'
commit_options: '--no-verify'
repository: .
commit_user_name: Abishnoi69
commit_user_email: Abishnoi1M@gmail.com
commit_author: Abishnoi69 <Abishnoi1M@gmail.com>
160 changes: 160 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
27 changes: 27 additions & 0 deletions Assistant/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import logging
from time import time

from config import DEBUG, SUDO_USER

if DEBUG:
logging.basicConfig(
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
handlers=[logging.FileHandler("log.txt"), logging.StreamHandler()],
level=logging.DEBUG,
)
else:
logging.basicConfig(
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
handlers=[logging.FileHandler("log.txt"), logging.StreamHandler()],
level=logging.INFO,
)
logging.getLogger("apscheduler").setLevel(logging.WARNING)
logging.getLogger("httpx").setLevel(logging.ERROR)


LOGGER = logging.getLogger(__name__)


StartTime = time()

SUDO_USERS = SUDO_USER
14 changes: 14 additions & 0 deletions Assistant/database/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from sys import exit

from async_mongo import AsyncClient

from Assistant import LOGGER
from config import DB_URI

try:
mongo = AsyncClient(DB_URI)
db = mongo["Assistant"]
LOGGER.info("Connected to your Mongo Database.")
except Exception as e:
LOGGER.error(f"Failed to connect to your Mongo Database.\ {e}")
exit(1)
38 changes: 38 additions & 0 deletions Assistant/database/block_db.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from . import db

blockeddb = db["blocked"]


async def get_banned_users() -> list:
results = []
async for user in blockeddb.find({"user_id": {"$gt": 0}}):
user_id = user["user_id"]
results.append(user_id)
return results


async def get_banned_count() -> int:
users = blockeddb.find({"user_id": {"$gt": 0}})
users = await users.to_list(length=100000)
return len(users)


async def is_banned_user(user_id: int) -> bool:
user = await blockeddb.find_one({"user_id": user_id})
if not user:
return False
return True


async def add_banned_user(user_id: int):
is_gbanned = await is_banned_user(user_id)
if is_gbanned:
return
return await blockeddb.insert_one({"user_id": user_id})


async def remove_banned_user(user_id: int):
is_gbanned = await is_banned_user(user_id)
if not is_gbanned:
return
return await blockeddb.delete_one({"user_id": user_id})
33 changes: 33 additions & 0 deletions Assistant/database/forward_db.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from . import db

modelist = {}
modedb = db["mode"]


async def is_group() -> bool:
chat_id = 123
mode = modelist.get(chat_id)
if not mode:
user = await modedb.find_one({"chat_id": chat_id})
if not user:
modelist[chat_id] = False
return False
modelist[chat_id] = True
return True
return mode


async def group_on():
chat_id = 123
modelist[chat_id] = True
user = await modedb.find_one({"chat_id": chat_id})
if not user:
return await modedb.insert_one({"chat_id": chat_id})


async def group_off():
chat_id = 123
modelist[chat_id] = False
user = await modedb.find_one({"chat_id": chat_id})
if user:
return await modelist.delete_one({"chat_id": chat_id})
Loading

0 comments on commit 5d09497

Please sign in to comment.