From 93067d9a91395c339ce55a111ce4b6e1020f0121 Mon Sep 17 00:00:00 2001 From: Igor Tolmachov Date: Sat, 9 Jul 2022 01:13:20 +0900 Subject: Теперь доступен не только в ананасах! MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit + опрос на вступление человека --- .gitignore | 5 +- README.md | 2 +- config.sample.py | 1 - data/.keep | 0 docker-compose.yaml | 6 +- env.env.sample | 1 + handlers/__init__.py | 8 +- handlers/gen.py | 18 ++-- handlers/leave.py | 8 +- handlers/member.py | 105 +++++++++---------- handlers/msg.py | 6 +- handlers/pin.py | 48 +++++++++ handlers/poll.py | 50 --------- poetry.lock | 282 ++++++++++++++++++++++++++++++++++++++++++--------- pyproject.toml | 4 + requirements.txt | 21 ++-- shared/__init__.py | 4 + shared/config.py | 3 + shared/instances.py | 4 +- utils/filters.py | 2 - 20 files changed, 384 insertions(+), 194 deletions(-) delete mode 100644 config.sample.py delete mode 100644 data/.keep create mode 100644 env.env.sample create mode 100644 handlers/pin.py delete mode 100644 handlers/poll.py create mode 100644 shared/config.py diff --git a/.gitignore b/.gitignore index 3f04cab..710696a 100644 --- a/.gitignore +++ b/.gitignore @@ -125,10 +125,7 @@ venv.bak/ .dmypy.json dmypy.json - # Pyre type checker .pyre/ -data/* -config.py -!.keep +env.env diff --git a/README.md b/README.md index 8312bf7..ee98c92 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,6 @@ # Основные возможности - Генерация текста -- Преобразование изображения в `.gif` формат +- Приём заявок **Данного бота нельзя добавить в другую группу** diff --git a/config.sample.py b/config.sample.py deleted file mode 100644 index 9124afc..0000000 --- a/config.sample.py +++ /dev/null @@ -1 +0,0 @@ -token = "" diff --git a/data/.keep b/data/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/docker-compose.yaml b/docker-compose.yaml index f7f5289..91b2b7c 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -5,5 +5,9 @@ services: build: "." restart: "always" volumes: - - "./data/samples.txt:/app/samples.txt" + - "data:/app/data" + env_file: + env.env +volumes: + data: diff --git a/env.env.sample b/env.env.sample new file mode 100644 index 0000000..13854d0 --- /dev/null +++ b/env.env.sample @@ -0,0 +1 @@ +TOKEN="123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11" diff --git a/handlers/__init__.py b/handlers/__init__.py index 5de35a4..5608612 100644 --- a/handlers/__init__.py +++ b/handlers/__init__.py @@ -1,7 +1,7 @@ -from . import leave -from . import msg +# isort: skip_file from . import gen -from . import poll +from . import pin +from . import member -# from . import member +from . import msg from . import system diff --git a/handlers/gen.py b/handlers/gen.py index 55ea01a..a27fb86 100644 --- a/handlers/gen.py +++ b/handlers/gen.py @@ -6,12 +6,12 @@ from shared.instances import bot, dp from utils import filters as f -@dp.message_handler(f.message.is_chat, commands=["gen"]) +@dp.message_handler(commands=["gen"]) async def сгенерировать_хуету(msg: t.Message): - await msg.answer(получить_говно()) + await msg.answer(получить_говно(msg.chat.id)) -@dp.message_handler(f.message.is_chat, commands=["del"]) +@dp.message_handler(commands=["del"]) async def удалить_хуету(msg: t.Message): await msg.delete() @@ -43,13 +43,11 @@ async def изменить_шанс_срания(msg: t.Message): await msg.answer(f"Я сру с шансом в: {ins.gen_chance.get(msg.chat.id, 10)}%") -@dp.message_handler( - f.message.chance, f.message.is_chat, content_types=[t.ContentType.ANY] -) +@dp.message_handler(f.message.chance, content_types=[t.ContentType.ANY]) async def срать_сообщение_с_шансом(msg: t.Message): - await msg.answer(получить_говно()) + await msg.answer(получить_говно(msg.chat.id)) -def получить_говно() -> str: - samples = mc.util.load_txt_samples("samples.txt", separator="§") - return mc.StringGenerator(samples=samples).generate_string().capitalize() +def получить_говно(id: int) -> str: + samples = mc.util.load_txt_samples(f"data/{id}", separator="§") + return mc.StringGenerator(samples=samples).generate_string() diff --git a/handlers/leave.py b/handlers/leave.py index 990795f..198e847 100644 --- a/handlers/leave.py +++ b/handlers/leave.py @@ -5,9 +5,5 @@ from utils import filters as f @dp.my_chat_member_handler(f.user.add_member) -async def пососи(upd: t.ChatMemberUpdated): - if upd.chat.id not in (-1001444484622, -1001197098429): - await upd.bot.send_message( - upd.chat.id, "https://www.youtube.com/watch?v=xdDhmagsXrc" - ) - await upd.chat.leave() +async def создатьтемплейты(upd: t.ChatMemberUpdated): + open(f"data/{upd.chat.id}", "w").close() diff --git a/handlers/member.py b/handlers/member.py index d242779..3704c33 100644 --- a/handlers/member.py +++ b/handlers/member.py @@ -1,66 +1,69 @@ -from asyncio import sleep - from aiogram import types as t from shared.instances import bot, dp from utils import filters as f -unmute = t.ChatPermissions(*[True] * 8) -mute = t.ChatPermissions(*[False] * 8) +request_queue: list[int] = [] -@dp.chat_member_handler(f.user.add_member) -async def запрашиваем_пропуск(upd: t.ChatMemberUpdated): - pass_user_markup = t.InlineKeyboardMarkup().add( - t.InlineKeyboardButton( - "Да", callback_data=f"pass_user@{upd.new_chat_member.user.id}" - ), - t.InlineKeyboardButton( - "Нет", callback_data=f"kick_user@{upd.new_chat_member.user.id}" - ), - ) - await upd.chat.restrict(upd.new_chat_member.user.id, mute) - await bot.send_message( - upd.chat.id, - f'Это наш чел ?', - parse_mode=t.ParseMode.HTML, - reply_markup=pass_user_markup, - ) +@dp.chat_join_request_handler() +async def приём_запроса(cjr: t.ChatJoinRequest): + if cjr.from_user.id not in request_queue: + request_queue.append(cjr.from_user.id) + r = await bot.send_message( + cjr.chat.id, + f'{cjr.from_user.mention} хочет в чат', + parse_mode=t.ParseMode.HTML, + ) + await bot.send_poll( + cjr.chat.id, + "Пускаем ?", + [ + "Да", + "Нет", + ], + False, + reply_to_message_id=r.message_id, + open_period=600, + reply_markup=t.InlineKeyboardMarkup().add( + t.InlineKeyboardButton( + "Проверить опрос", + callback_data=f"check_request_poll:{cjr.from_user.id}", + ) + ), + ) + await bot.send_message( + cjr.from_user.id, "Заявка на вступление в группу будет вскоре рассмотрена" + ) @dp.callback_query_handler( - f.message.is_chat, lambda clb: clb.data.split("@")[0] == "pass_user" + f.message.is_chat, lambda clb: clb.data.split(":")[0] == "check_request_poll" ) -async def пропустить(clb: t.CallbackQuery): - member = await clb.message.chat.get_member(clb.from_user.id) +async def проверить_запрос(clb: t.CallbackQuery): + poll = clb.message.poll + msg = clb.message + data = clb.data.split(":") + user_id = int(data[1]) - if not member.is_chat_admin(): - await clb.answer("Ты не админ") - return + if poll.total_voter_count < 4: + await clb.answer(f"Нужно хотябы 4 голоса, сейчас {poll.total_voter_count}") else: - await clb.message.chat.restrict(int(clb.data.split("@")[1]), unmute) - - await clb.message.delete() - await clb.message.answer( - f'Ананасер добро пожаловать в чат для крутых', - parse_mode=t.ParseMode.HTML, - ) + if not poll.is_closed: + await bot.stop_poll(msg.chat.id, msg.message_id) + request_queue.remove(user_id) + yes = poll.options[0].voter_count + no = poll.options[1].voter_count + win = max(yes, no) -@dp.callback_query_handler( - f.message.is_chat, lambda clb: clb.data.split("@")[0] == "kick_user" -) -async def выкинуть(clb: t.CallbackQuery): - member = await clb.message.chat.get_member(clb.from_user.id) - - if not member.is_chat_admin(): - await clb.answer("Ты не админ") - return - else: - await clb.message.chat.unban(int(clb.data.split("@")[1]), False) - - await clb.message.delete() - await clb.message.answer( - f'Эта группа для крутых', - parse_mode=t.ParseMode.HTML, - ) + if win == yes: + await bot.approve_chat_join_request(msg.chat.id, user_id) + await bot.send_message( + user_id, "Ваша заявка на вступление принята, добро пожаловать в группу" + ) + elif win == no: + await bot.decline_chat_join_request(msg.chat.id, user_id) + await bot.send_message(user_id, "Ваша заявка на вступление НЕ принята") + if not msg.chat.has_protected_content: + await msg.forward(user_id) diff --git a/handlers/msg.py b/handlers/msg.py index 12dfa6c..dca295f 100644 --- a/handlers/msg.py +++ b/handlers/msg.py @@ -8,13 +8,11 @@ async def сосалка(msg: t.Message): text = msg.text or msg.caption if text.startswith("/"): return False - with open("samples.txt", "a+") as file: + with open(f"data/{msg.chat.id}", "a+") as file: file.write(text.lower().replace("§", "") + "§") return False -@dp.message_handler( - f.message.is_chat, f.message.has_text, сосалка, content_types=[t.ContentType.ANY] -) +@dp.message_handler(f.message.has_text, сосалка, content_types=[t.ContentType.ANY]) async def ХУЙ(): pass diff --git a/handlers/pin.py b/handlers/pin.py new file mode 100644 index 0000000..dc08633 --- /dev/null +++ b/handlers/pin.py @@ -0,0 +1,48 @@ +from datetime import datetime, timedelta + +from aiogram import types as t + +from shared.instances import bot, dp +from utils import filters as f + + +@dp.message_handler(f.message.is_chat, commands=["pin"]) +async def закрепить_хуету(msg: t.Message): + await msg.delete() + if msg.reply_to_message: + r = await msg.reply_to_message.reply( + f'{msg.from_user.mention} хочет закрепить сообщение', + parse_mode=t.ParseMode.HTML, + ) + await r.reply_poll( + "Закрепить ?", + ["Да", "УДАЛИ НАХУЙ", "Нет"], + close_date=datetime.now() + timedelta(minutes=10), + reply_markup=t.InlineKeyboardMarkup().add( + t.InlineKeyboardButton("Проверить опрос", callback_data="check_pin_poll") + ), + ) + else: + await msg.answer("Ты умник, ответь на сообщение") + + +@dp.callback_query_handler(f.message.is_chat, lambda clb: clb.data == "check_pin_poll") +async def проверить_закреп(clb: t.CallbackQuery): + poll = clb.message.poll + msg = clb.message + + if poll.total_voter_count < 2: + await clb.answer(f"Нужно хотябы 2 голоса, сейчас {poll.total_voter_count}") + else: + if not poll.is_closed: + await bot.stop_poll(msg.chat.id, msg.message_id) + + yes = poll.options[0].voter_count + delete = poll.options[1].voter_count + win = max(yes, delete) + + if win == yes: + await msg.reply_to_message.pin() + elif win == delete: + await msg.reply_to_message.delete() + await msg.delete() diff --git a/handlers/poll.py b/handlers/poll.py deleted file mode 100644 index 8e7b542..0000000 --- a/handlers/poll.py +++ /dev/null @@ -1,50 +0,0 @@ -from datetime import datetime, timedelta - -from aiogram import types as t - -from shared.instances import bot, dp -from utils import filters as f - -pin_reply_markup = t.InlineKeyboardMarkup().add( - t.InlineKeyboardButton("Проверить сейчас", callback_data="check_pin_poll") -) - - -@dp.message_handler(f.message.is_chat, commands=["pin"]) -async def закрепить_хуету(msg: t.Message): - await msg.delete() - if msg.reply_to_message: - await msg.reply_to_message.reply_poll( - "Закрепить ?", - ["Да", "УДАЛИ НАХУЙ", "Нет"], - close_date=datetime.now() + timedelta(minutes=10), - reply_markup=pin_reply_markup, - ) - else: - await msg.answer("Ты умник, ответь на сообщение") - - -@dp.callback_query_handler(f.message.is_chat, lambda clb: clb.data == "check_pin_poll") -async def проверить_закреп(clb: t.CallbackQuery): - poll = clb.message.poll - msg = clb.message - - if poll.total_voter_count <= 0: - await clb.answer("Видишь голоса? Вот и я невижу") - elif poll.total_voter_count <= 2: - await clb.answer("Видишь голоса? Они есть, но их мало") - else: - if not poll.is_closed: - await bot.stop_poll(msg.chat.id, msg.message_id) - poll.is_closed = True - yes = poll.options[0].voter_count - delete = poll.options[1].voter_count - win = max(yes, delete) - - if win == yes: - await msg.reply_to_message.pin() - elif win == delete: - await msg.reply_to_message.delete() - - if poll.is_closed: - await msg.delete() diff --git a/poetry.lock b/poetry.lock index 90c31a4..d0db6c4 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,6 +1,6 @@ [[package]] name = "aiogram" -version = "2.20" +version = "2.21" description = "Is a pretty simple and fully asynchronous framework for Telegram Bot API" category = "main" optional = false @@ -81,7 +81,7 @@ pytz = ">=2015.7" [[package]] name = "black" -version = "22.3.0" +version = "22.6.0" description = "The uncompromising code formatter." category = "dev" optional = false @@ -92,7 +92,7 @@ click = ">=8.0.0" mypy-extensions = ">=0.4.3" pathspec = ">=0.9.0" platformdirs = ">=2" -tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} +tomli = {version = ">=1.1.0", markers = "python_full_version < \"3.11.0a7\""} [package.extras] colorama = ["colorama (>=0.4.3)"] @@ -102,26 +102,26 @@ uvloop = ["uvloop (>=0.15.2)"] [[package]] name = "certifi" -version = "2021.10.8" +version = "2022.6.15" description = "Python package for providing Mozilla's CA Bundle." category = "main" optional = false -python-versions = "*" +python-versions = ">=3.6" [[package]] name = "charset-normalizer" -version = "2.0.12" +version = "2.1.0" description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." category = "main" optional = false -python-versions = ">=3.5.0" +python-versions = ">=3.6.0" [package.extras] unicode_backport = ["unicodedata2"] [[package]] name = "click" -version = "8.1.2" +version = "8.1.3" description = "Composable command line interface toolkit" category = "dev" optional = false @@ -132,7 +132,7 @@ colorama = {version = "*", markers = "platform_system == \"Windows\""} [[package]] name = "colorama" -version = "0.4.4" +version = "0.4.5" description = "Cross-platform colored terminal text." category = "dev" optional = false @@ -168,6 +168,21 @@ requirements_deprecated_finder = ["pipreqs", "pip-api"] colors = ["colorama (>=0.4.3,<0.5.0)"] plugins = ["setuptools"] +[[package]] +name = "jedi" +version = "0.18.1" +description = "An autocompletion tool for Python that can be used for text editors." +category = "dev" +optional = false +python-versions = ">=3.6" + +[package.dependencies] +parso = ">=0.8.0,<0.9.0" + +[package.extras] +qa = ["flake8 (==3.8.3)", "mypy (==0.782)"] +testing = ["Django (<3.1)", "colorama", "docopt", "pytest (<7.0.0)"] + [[package]] name = "mc.py" version = "3.1.1" @@ -184,6 +199,24 @@ category = "main" optional = false python-versions = ">=3.7" +[[package]] +name = "mypy" +version = "0.961" +description = "Optional static typing for Python" +category = "dev" +optional = false +python-versions = ">=3.6" + +[package.dependencies] +mypy-extensions = ">=0.4.3" +tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} +typing-extensions = ">=3.10" + +[package.extras] +dmypy = ["psutil (>=4.0)"] +python2 = ["typed-ast (>=1.4.0,<2)"] +reports = ["lxml"] + [[package]] name = "mypy-extensions" version = "0.4.3" @@ -192,6 +225,18 @@ category = "dev" optional = false python-versions = "*" +[[package]] +name = "parso" +version = "0.8.3" +description = "A Python Parser" +category = "dev" +optional = false +python-versions = ">=3.6" + +[package.extras] +qa = ["flake8 (==3.8.3)", "mypy (==0.782)"] +testing = ["docopt", "pytest (<6.0.0)"] + [[package]] name = "pathspec" version = "0.9.0" @@ -212,6 +257,103 @@ python-versions = ">=3.7" docs = ["furo (>=2021.7.5b38)", "proselint (>=0.10.2)", "sphinx-autodoc-typehints (>=1.12)", "sphinx (>=4)"] test = ["appdirs (==1.4.4)", "pytest-cov (>=2.7)", "pytest-mock (>=3.6)", "pytest (>=6)"] +[[package]] +name = "pluggy" +version = "1.0.0" +description = "plugin and hook calling mechanisms for python" +category = "dev" +optional = false +python-versions = ">=3.6" + +[package.extras] +dev = ["pre-commit", "tox"] +testing = ["pytest", "pytest-benchmark"] + +[[package]] +name = "pyls-isort" +version = "0.2.2" +description = "Isort plugin for python-lsp-server" +category = "dev" +optional = false +python-versions = "*" + +[package.dependencies] +isort = "*" +python-lsp-server = "*" + +[[package]] +name = "pylsp-mypy" +version = "0.6.2" +description = "Mypy linter for the Python LSP Server" +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +mypy = "*" +python-lsp-server = "*" +toml = "*" + +[package.extras] +test = ["tox", "pytest", "pytest-cov", "coverage"] + +[[package]] +name = "python-lsp-black" +version = "1.2.1" +description = "Black plugin for the Python LSP Server" +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +black = ">=22.3.0" +python-lsp-server = ">=1.4.0" +toml = "*" + +[package.extras] +dev = ["flake8", "isort (>=5.0)", "mypy", "pre-commit", "pytest", "types-pkg-resources", "types-setuptools", "types-toml"] + +[[package]] +name = "python-lsp-jsonrpc" +version = "1.0.0" +description = "JSON RPC 2.0 server library" +category = "dev" +optional = false +python-versions = "*" + +[package.dependencies] +ujson = ">=3.0.0" + +[package.extras] +test = ["pylint", "pycodestyle", "pyflakes", "pytest", "pytest-cov", "coverage"] + +[[package]] +name = "python-lsp-server" +version = "1.4.1" +description = "Python Language Server for the Language Server Protocol" +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +jedi = ">=0.17.2,<0.19.0" +pluggy = ">=1.0.0" +python-lsp-jsonrpc = ">=1.0.0" +ujson = ">=3.0.0" + +[package.extras] +all = ["autopep8 (>=1.6.0,<1.7.0)", "flake8 (>=4.0.0,<4.1.0)", "mccabe (>=0.6.0,<0.7.0)", "pycodestyle (>=2.8.0,<2.9.0)", "pydocstyle (>=2.0.0)", "pyflakes (>=2.4.0,<2.5.0)", "pylint (>=2.5.0)", "rope (>=0.10.5)", "yapf"] +autopep8 = ["autopep8 (>=1.6.0,<1.7.0)"] +flake8 = ["flake8 (>=4.0.0,<4.1.0)"] +mccabe = ["mccabe (>=0.6.0,<0.7.0)"] +pycodestyle = ["pycodestyle (>=2.8.0,<2.9.0)"] +pydocstyle = ["pydocstyle (>=2.0.0)"] +pyflakes = ["pyflakes (>=2.4.0,<2.5.0)"] +pylint = ["pylint (>=2.5.0)"] +rope = ["rope (>0.10.5)"] +test = ["pylint (>=2.5.0)", "pytest", "pytest-cov", "coverage", "numpy", "pandas", "matplotlib", "pyqt5", "flaky"] +yapf = ["yapf"] + [[package]] name = "pytz" version = "2022.1" @@ -220,6 +362,14 @@ category = "main" optional = false python-versions = "*" +[[package]] +name = "toml" +version = "0.10.2" +description = "Python Library for Tom's Obvious, Minimal Language" +category = "dev" +optional = false +python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" + [[package]] name = "tomli" version = "2.0.1" @@ -228,6 +378,22 @@ category = "dev" optional = false python-versions = ">=3.7" +[[package]] +name = "typing-extensions" +version = "4.3.0" +description = "Backported and Experimental Type Hints for Python 3.7+" +category = "dev" +optional = false +python-versions = ">=3.7" + +[[package]] +name = "ujson" +version = "5.4.0" +description = "Ultra fast JSON encoder and decoder for Python" +category = "dev" +optional = false +python-versions = ">=3.7" + [[package]] name = "yarl" version = "1.7.2" @@ -243,12 +409,12 @@ multidict = ">=4.0" [metadata] lock-version = "1.1" python-versions = "^3.10" -content-hash = "efa0e2c5d3b8f77a22478a52ca869113f970e18c77d8da40a7d020c0eb572a0a" +content-hash = "d45de286b7d24be6148463e2c4e8466545ef88c228dbdf905946480d1b002db7" [metadata.files] aiogram = [ - {file = "aiogram-2.20-py3-none-any.whl", hash = "sha256:5281bd5fac2dcc81f2bd1edad45c0d8dfe209733878a2fff00bb63f658e28aae"}, - {file = "aiogram-2.20.tar.gz", hash = "sha256:20a0a8b18a2a656dc6efce40947019dc558bd4d5f8217452994c75d8e79bb6d7"}, + {file = "aiogram-2.21-py3-none-any.whl", hash = "sha256:33ee61db550f6fc455e2d74d8911af31108e3c398eda03c2f91b0a7cb32a97d9"}, + {file = "aiogram-2.21.tar.gz", hash = "sha256:390ac56a629cd0d151d544e3b87d539ee49f734ccc7a1a7e375c33f436e556e0"}, ] aiohttp = [ {file = "aiohttp-3.8.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:1ed0b6477896559f17b9eaeb6d38e07f7f9ffe40b9f0f9627ae8b9926ae260a8"}, @@ -340,46 +506,22 @@ babel = [ {file = "Babel-2.9.1-py2.py3-none-any.whl", hash = "sha256:ab49e12b91d937cd11f0b67cb259a57ab4ad2b59ac7a3b41d6c06c0ac5b0def9"}, {file = "Babel-2.9.1.tar.gz", hash = "sha256:bc0c176f9f6a994582230df350aa6e05ba2ebe4b3ac317eab29d9be5d2768da0"}, ] -black = [ - {file = "black-22.3.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:2497f9c2386572e28921fa8bec7be3e51de6801f7459dffd6e62492531c47e09"}, - {file = "black-22.3.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:5795a0375eb87bfe902e80e0c8cfaedf8af4d49694d69161e5bd3206c18618bb"}, - {file = "black-22.3.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:e3556168e2e5c49629f7b0f377070240bd5511e45e25a4497bb0073d9dda776a"}, - {file = "black-22.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:67c8301ec94e3bcc8906740fe071391bce40a862b7be0b86fb5382beefecd968"}, - {file = "black-22.3.0-cp310-cp310-win_amd64.whl", hash = "sha256:fd57160949179ec517d32ac2ac898b5f20d68ed1a9c977346efbac9c2f1e779d"}, - {file = "black-22.3.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:cc1e1de68c8e5444e8f94c3670bb48a2beef0e91dddfd4fcc29595ebd90bb9ce"}, - {file = "black-22.3.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6d2fc92002d44746d3e7db7cf9313cf4452f43e9ea77a2c939defce3b10b5c82"}, - {file = "black-22.3.0-cp36-cp36m-win_amd64.whl", hash = "sha256:a6342964b43a99dbc72f72812bf88cad8f0217ae9acb47c0d4f141a6416d2d7b"}, - {file = "black-22.3.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:328efc0cc70ccb23429d6be184a15ce613f676bdfc85e5fe8ea2a9354b4e9015"}, - {file = "black-22.3.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:06f9d8846f2340dfac80ceb20200ea5d1b3f181dd0556b47af4e8e0b24fa0a6b"}, - {file = "black-22.3.0-cp37-cp37m-win_amd64.whl", hash = "sha256:ad4efa5fad66b903b4a5f96d91461d90b9507a812b3c5de657d544215bb7877a"}, - {file = "black-22.3.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:e8477ec6bbfe0312c128e74644ac8a02ca06bcdb8982d4ee06f209be28cdf163"}, - {file = "black-22.3.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:637a4014c63fbf42a692d22b55d8ad6968a946b4a6ebc385c5505d9625b6a464"}, - {file = "black-22.3.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:863714200ada56cbc366dc9ae5291ceb936573155f8bf8e9de92aef51f3ad0f0"}, - {file = "black-22.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:10dbe6e6d2988049b4655b2b739f98785a884d4d6b85bc35133a8fb9a2233176"}, - {file = "black-22.3.0-cp38-cp38-win_amd64.whl", hash = "sha256:cee3e11161dde1b2a33a904b850b0899e0424cc331b7295f2a9698e79f9a69a0"}, - {file = "black-22.3.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:5891ef8abc06576985de8fa88e95ab70641de6c1fca97e2a15820a9b69e51b20"}, - {file = "black-22.3.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:30d78ba6bf080eeaf0b7b875d924b15cd46fec5fd044ddfbad38c8ea9171043a"}, - {file = "black-22.3.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:ee8f1f7228cce7dffc2b464f07ce769f478968bfb3dd1254a4c2eeed84928aad"}, - {file = "black-22.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6ee227b696ca60dd1c507be80a6bc849a5a6ab57ac7352aad1ffec9e8b805f21"}, - {file = "black-22.3.0-cp39-cp39-win_amd64.whl", hash = "sha256:9b542ced1ec0ceeff5b37d69838106a6348e60db7b8fdd245294dc1d26136265"}, - {file = "black-22.3.0-py3-none-any.whl", hash = "sha256:bc58025940a896d7e5356952228b68f793cf5fcb342be703c3a2669a1488cb72"}, - {file = "black-22.3.0.tar.gz", hash = "sha256:35020b8886c022ced9282b51b5a875b6d1ab0c387b31a065b84db7c33085ca79"}, -] +black = [] certifi = [ - {file = "certifi-2021.10.8-py2.py3-none-any.whl", hash = "sha256:d62a0163eb4c2344ac042ab2bdf75399a71a2d8c7d47eac2e2ee91b9d6339569"}, - {file = "certifi-2021.10.8.tar.gz", hash = "sha256:78884e7c1d4b00ce3cea67b44566851c4343c120abd683433ce934a68ea58872"}, + {file = "certifi-2022.6.15-py3-none-any.whl", hash = "sha256:fe86415d55e84719d75f8b69414f6438ac3547d2078ab91b67e779ef69378412"}, + {file = "certifi-2022.6.15.tar.gz", hash = "sha256:84c85a9078b11105f04f3036a9482ae10e4621616db313fe045dd24743a0820d"}, ] charset-normalizer = [ - {file = "charset-normalizer-2.0.12.tar.gz", hash = "sha256:2857e29ff0d34db842cd7ca3230549d1a697f96ee6d3fb071cfa6c7393832597"}, - {file = "charset_normalizer-2.0.12-py3-none-any.whl", hash = "sha256:6881edbebdb17b39b4eaaa821b438bf6eddffb4468cf344f09f89def34a8b1df"}, + {file = "charset-normalizer-2.1.0.tar.gz", hash = "sha256:575e708016ff3a5e3681541cb9d79312c416835686d054a23accb873b254f413"}, + {file = "charset_normalizer-2.1.0-py3-none-any.whl", hash = "sha256:5189b6f22b01957427f35b6a08d9a0bc45b46d3788ef5a92e978433c7a35f8a5"}, ] click = [ - {file = "click-8.1.2-py3-none-any.whl", hash = "sha256:24e1a4a9ec5bf6299411369b208c1df2188d9eb8d916302fe6bf03faed227f1e"}, - {file = "click-8.1.2.tar.gz", hash = "sha256:479707fe14d9ec9a0757618b7a100a0ae4c4e236fac5b7f80ca68028141a1a72"}, + {file = "click-8.1.3-py3-none-any.whl", hash = "sha256:bb4d8133cb15a609f44e8213d9b391b0809795062913b383c62be0ee95b1db48"}, + {file = "click-8.1.3.tar.gz", hash = "sha256:7682dc8afb30297001674575ea00d1814d808d6a36af415a82bd481d37ba7b8e"}, ] colorama = [ - {file = "colorama-0.4.4-py2.py3-none-any.whl", hash = "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"}, - {file = "colorama-0.4.4.tar.gz", hash = "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b"}, + {file = "colorama-0.4.5-py2.py3-none-any.whl", hash = "sha256:854bf444933e37f5824ae7bfc1e98d5bce2ebe4160d46b5edf346a89358e99da"}, + {file = "colorama-0.4.5.tar.gz", hash = "sha256:e6c6b4334fc50988a639d9b98aa429a0b57da6e17b9a44f0451f930b6967b7a4"}, ] frozenlist = [ {file = "frozenlist-1.3.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:d2257aaba9660f78c7b1d8fea963b68f3feffb1a9d5d05a18401ca9eb3e8d0a3"}, @@ -450,9 +592,11 @@ isort = [ {file = "isort-5.10.1-py3-none-any.whl", hash = "sha256:6f62d78e2f89b4500b080fe3a81690850cd254227f27f75c3a0c491a1f351ba7"}, {file = "isort-5.10.1.tar.gz", hash = "sha256:e8443a5e7a020e9d7f97f1d7d9cd17c88bcb3bc7e218bf9cf5095fe550be2951"}, ] -"mc.py" = [ - {file = "mc.py-3.1.1.tar.gz", hash = "sha256:eaa4436add72c578c1d6dd257c13d6a802ebb8a997f50293176aa46676a2e5dd"}, +jedi = [ + {file = "jedi-0.18.1-py2.py3-none-any.whl", hash = "sha256:637c9635fcf47945ceb91cd7f320234a7be540ded6f3e99a50cb6febdfd1ba8d"}, + {file = "jedi-0.18.1.tar.gz", hash = "sha256:74137626a64a99c8eb6ae5832d99b3bdd7d29a3850fe2aa80a4126b2a7d949ab"}, ] +"mc.py" = [] multidict = [ {file = "multidict-6.0.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:0b9e95a740109c6047602f4db4da9949e6c5945cefbad34a1299775ddc9a62e2"}, {file = "multidict-6.0.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:ac0e27844758d7177989ce406acc6a83c16ed4524ebc363c1f748cba184d89d3"}, @@ -514,10 +658,36 @@ multidict = [ {file = "multidict-6.0.2-cp39-cp39-win_amd64.whl", hash = "sha256:4bae31803d708f6f15fd98be6a6ac0b6958fcf68fda3c77a048a4f9073704aae"}, {file = "multidict-6.0.2.tar.gz", hash = "sha256:5ff3bd75f38e4c43f1f470f2df7a4d430b821c4ce22be384e1459cb57d6bb013"}, ] +mypy = [ + {file = "mypy-0.961-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:697540876638ce349b01b6786bc6094ccdaba88af446a9abb967293ce6eaa2b0"}, + {file = "mypy-0.961-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:b117650592e1782819829605a193360a08aa99f1fc23d1d71e1a75a142dc7e15"}, + {file = "mypy-0.961-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:bdd5ca340beffb8c44cb9dc26697628d1b88c6bddf5c2f6eb308c46f269bb6f3"}, + {file = "mypy-0.961-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:3e09f1f983a71d0672bbc97ae33ee3709d10c779beb613febc36805a6e28bb4e"}, + {file = "mypy-0.961-cp310-cp310-win_amd64.whl", hash = "sha256:e999229b9f3198c0c880d5e269f9f8129c8862451ce53a011326cad38b9ccd24"}, + {file = "mypy-0.961-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:b24be97351084b11582fef18d79004b3e4db572219deee0212078f7cf6352723"}, + {file = "mypy-0.961-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:f4a21d01fc0ba4e31d82f0fff195682e29f9401a8bdb7173891070eb260aeb3b"}, + {file = "mypy-0.961-cp36-cp36m-win_amd64.whl", hash = "sha256:439c726a3b3da7ca84a0199a8ab444cd8896d95012c4a6c4a0d808e3147abf5d"}, + {file = "mypy-0.961-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:5a0b53747f713f490affdceef835d8f0cb7285187a6a44c33821b6d1f46ed813"}, + {file = "mypy-0.961-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:0e9f70df36405c25cc530a86eeda1e0867863d9471fe76d1273c783df3d35c2e"}, + {file = "mypy-0.961-cp37-cp37m-win_amd64.whl", hash = "sha256:b88f784e9e35dcaa075519096dc947a388319cb86811b6af621e3523980f1c8a"}, + {file = "mypy-0.961-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:d5aaf1edaa7692490f72bdb9fbd941fbf2e201713523bdb3f4038be0af8846c6"}, + {file = "mypy-0.961-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:9f5f5a74085d9a81a1f9c78081d60a0040c3efb3f28e5c9912b900adf59a16e6"}, + {file = "mypy-0.961-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:f4b794db44168a4fc886e3450201365c9526a522c46ba089b55e1f11c163750d"}, + {file = "mypy-0.961-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:64759a273d590040a592e0f4186539858c948302c653c2eac840c7a3cd29e51b"}, + {file = "mypy-0.961-cp38-cp38-win_amd64.whl", hash = "sha256:63e85a03770ebf403291ec50097954cc5caf2a9205c888ce3a61bd3f82e17569"}, + {file = "mypy-0.961-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:5f1332964963d4832a94bebc10f13d3279be3ce8f6c64da563d6ee6e2eeda932"}, + {file = "mypy-0.961-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:006be38474216b833eca29ff6b73e143386f352e10e9c2fbe76aa8549e5554f5"}, + {file = "mypy-0.961-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:9940e6916ed9371809b35b2154baf1f684acba935cd09928952310fbddaba648"}, + {file = "mypy-0.961-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:a5ea0875a049de1b63b972456542f04643daf320d27dc592d7c3d9cd5d9bf950"}, + {file = "mypy-0.961-cp39-cp39-win_amd64.whl", hash = "sha256:1ece702f29270ec6af25db8cf6185c04c02311c6bb21a69f423d40e527b75c56"}, + {file = "mypy-0.961-py3-none-any.whl", hash = "sha256:03c6cc893e7563e7b2949b969e63f02c000b32502a1b4d1314cabe391aa87d66"}, + {file = "mypy-0.961.tar.gz", hash = "sha256:f730d56cb924d371c26b8eaddeea3cc07d78ff51c521c6d04899ac6904b75492"}, +] mypy-extensions = [ {file = "mypy_extensions-0.4.3-py2.py3-none-any.whl", hash = "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d"}, {file = "mypy_extensions-0.4.3.tar.gz", hash = "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"}, ] +parso = [] pathspec = [ {file = "pathspec-0.9.0-py2.py3-none-any.whl", hash = "sha256:7d15c4ddb0b5c802d161efc417ec1a2558ea2653c2e8ad9c19098201dc1c993a"}, {file = "pathspec-0.9.0.tar.gz", hash = "sha256:e564499435a2673d586f6b2130bb5b95f04a3ba06f81b8f895b651a3c76aabb1"}, @@ -526,14 +696,32 @@ platformdirs = [ {file = "platformdirs-2.5.2-py3-none-any.whl", hash = "sha256:027d8e83a2d7de06bbac4e5ef7e023c02b863d7ea5d079477e722bb41ab25788"}, {file = "platformdirs-2.5.2.tar.gz", hash = "sha256:58c8abb07dcb441e6ee4b11d8df0ac856038f944ab98b7be6b27b2a3c7feef19"}, ] +pluggy = [ + {file = "pluggy-1.0.0-py2.py3-none-any.whl", hash = "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3"}, + {file = "pluggy-1.0.0.tar.gz", hash = "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159"}, +] +pyls-isort = [] +pylsp-mypy = [] +python-lsp-black = [] +python-lsp-jsonrpc = [] +python-lsp-server = [] pytz = [ {file = "pytz-2022.1-py2.py3-none-any.whl", hash = "sha256:e68985985296d9a66a881eb3193b0906246245294a881e7c8afe623866ac6a5c"}, {file = "pytz-2022.1.tar.gz", hash = "sha256:1e760e2fe6a8163bc0b3d9a19c4f84342afa0a2affebfaa84b01b978a02ecaa7"}, ] +toml = [ + {file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"}, + {file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"}, +] tomli = [ {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, ] +typing-extensions = [ + {file = "typing_extensions-4.3.0-py3-none-any.whl", hash = "sha256:25642c956049920a5aa49edcdd6ab1e06d7e5d467fc00e0506c44ac86fbfca02"}, + {file = "typing_extensions-4.3.0.tar.gz", hash = "sha256:e6d2677a32f47fc7eb2795db1dd15c1f34eff616bcaf2cfb5e997f854fa1c4a6"}, +] +ujson = [] yarl = [ {file = "yarl-1.7.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:f2a8508f7350512434e41065684076f640ecce176d262a7d54f0da41d99c5a95"}, {file = "yarl-1.7.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:da6df107b9ccfe52d3a48165e48d72db0eca3e3029b5b8cb4fe6ee3cb870ba8b"}, diff --git a/pyproject.toml b/pyproject.toml index 36f6956..f8b07d7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,6 +13,10 @@ aiogram = "^2.20" [tool.poetry.dev-dependencies] black = "^22.3.0" isort = "^5.10.1" +python-lsp-server = "^1.4.1" +pylsp-mypy = "^0.6.2" +pyls-isort = "^0.2.2" +python-lsp-black = "^1.2.1" [tool.black] line-length = 90 diff --git a/requirements.txt b/requirements.txt index 234bc0b..ab8da8b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ -aiogram==2.20; python_version >= "3.7" \ - --hash=sha256:5281bd5fac2dcc81f2bd1edad45c0d8dfe209733878a2fff00bb63f658e28aae \ - --hash=sha256:20a0a8b18a2a656dc6efce40947019dc558bd4d5f8217452994c75d8e79bb6d7 +aiogram==2.21; python_version >= "3.7" \ + --hash=sha256:33ee61db550f6fc455e2d74d8911af31108e3c398eda03c2f91b0a7cb32a97d9 \ + --hash=sha256:390ac56a629cd0d151d544e3b87d539ee49f734ccc7a1a7e375c33f436e556e0 aiohttp==3.8.1; python_version >= "3.7" \ --hash=sha256:1ed0b6477896559f17b9eaeb6d38e07f7f9ffe40b9f0f9627ae8b9926ae260a8 \ --hash=sha256:7dadf3c307b31e0e61689cbf9e06be7a867c563d5a63ce9dca578f956609abf8 \ @@ -86,12 +86,12 @@ attrs==21.4.0; python_version >= "3.7" and python_full_version < "3.0.0" or pyth babel==2.9.1; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7" \ --hash=sha256:ab49e12b91d937cd11f0b67cb259a57ab4ad2b59ac7a3b41d6c06c0ac5b0def9 \ --hash=sha256:bc0c176f9f6a994582230df350aa6e05ba2ebe4b3ac317eab29d9be5d2768da0 -certifi==2021.10.8; python_version >= "3.7" \ - --hash=sha256:d62a0163eb4c2344ac042ab2bdf75399a71a2d8c7d47eac2e2ee91b9d6339569 \ - --hash=sha256:78884e7c1d4b00ce3cea67b44566851c4343c120abd683433ce934a68ea58872 -charset-normalizer==2.0.12; python_full_version >= "3.5.0" and python_version >= "3.7" \ - --hash=sha256:2857e29ff0d34db842cd7ca3230549d1a697f96ee6d3fb071cfa6c7393832597 \ - --hash=sha256:6881edbebdb17b39b4eaaa821b438bf6eddffb4468cf344f09f89def34a8b1df +certifi==2022.6.15; python_version >= "3.7" \ + --hash=sha256:fe86415d55e84719d75f8b69414f6438ac3547d2078ab91b67e779ef69378412 \ + --hash=sha256:84c85a9078b11105f04f3036a9482ae10e4621616db313fe045dd24743a0820d +charset-normalizer==2.1.0; python_full_version >= "3.6.0" and python_version >= "3.7" \ + --hash=sha256:575e708016ff3a5e3681541cb9d79312c416835686d054a23accb873b254f413 \ + --hash=sha256:5189b6f22b01957427f35b6a08d9a0bc45b46d3788ef5a92e978433c7a35f8a5 frozenlist==1.3.0; python_version >= "3.7" \ --hash=sha256:d2257aaba9660f78c7b1d8fea963b68f3feffb1a9d5d05a18401ca9eb3e8d0a3 \ --hash=sha256:4a44ebbf601d7bac77976d429e9bdb5a4614f9f4027777f9e54fd765196e9d3b \ @@ -155,8 +155,7 @@ frozenlist==1.3.0; python_version >= "3.7" \ idna==3.3; python_version >= "3.7" \ --hash=sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff \ --hash=sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d -mc.py==3.1.1; python_version >= "3.6" \ - --hash=sha256:eaa4436add72c578c1d6dd257c13d6a802ebb8a997f50293176aa46676a2e5dd +mc.py==3.1.1; python_version >= "3.6" multidict==6.0.2; python_version >= "3.7" \ --hash=sha256:0b9e95a740109c6047602f4db4da9949e6c5945cefbad34a1299775ddc9a62e2 \ --hash=sha256:ac0e27844758d7177989ce406acc6a83c16ed4524ebc363c1f748cba184d89d3 \ diff --git a/shared/__init__.py b/shared/__init__.py index e69de29..9153c94 100644 --- a/shared/__init__.py +++ b/shared/__init__.py @@ -0,0 +1,4 @@ +# isort: skip_file +from . import config +from . import instances +from . import commands diff --git a/shared/config.py b/shared/config.py new file mode 100644 index 0000000..6b973d3 --- /dev/null +++ b/shared/config.py @@ -0,0 +1,3 @@ +from os import environ as env + +token = env["TOKEN"] diff --git a/shared/instances.py b/shared/instances.py index c1234b2..3ffec5e 100644 --- a/shared/instances.py +++ b/shared/instances.py @@ -1,7 +1,7 @@ from aiogram import Bot, Dispatcher -from config import token +from shared.config import token bot = Bot(token=token) dp = Dispatcher(bot) -gen_chance = {} +gen_chance: dict[int, int] = {} diff --git a/utils/filters.py b/utils/filters.py index 58442ce..90b908a 100644 --- a/utils/filters.py +++ b/utils/filters.py @@ -10,8 +10,6 @@ from shared import instances as ins class message: is_chat = f.ChatTypeFilter((t.ChatType.GROUP, t.ChatType.SUPERGROUP)) - is_private = f.ChatTypeFilter(t.ChatType.PRIVATE) - is_reply = f.IsReplyFilter(True) @staticmethod def chance(msg: t.Message): -- cgit v1.2.3