From 6371cb039869d4e6e6ebca693ba6711f3f220881 Mon Sep 17 00:00:00 2001 From: Igor Tolmachov Date: Wed, 20 Apr 2022 09:14:39 +0900 Subject: Поправил ночные комиты MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handlers/__init__.py | 1 + handlers/gen.py | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ poetry.lock | 13 ++++++++++++- pyproject.toml | 1 + requirements.txt | 2 ++ shared/commands.py | 10 ++++------ 6 files changed, 71 insertions(+), 7 deletions(-) create mode 100644 handlers/gen.py diff --git a/handlers/__init__.py b/handlers/__init__.py index 16c0fe7..ab759fd 100644 --- a/handlers/__init__.py +++ b/handlers/__init__.py @@ -1,5 +1,6 @@ from . import leave from . import msg +from . import gen from . import poll from . import member from . import system diff --git a/handlers/gen.py b/handlers/gen.py new file mode 100644 index 0000000..822b4ad --- /dev/null +++ b/handlers/gen.py @@ -0,0 +1,51 @@ +import mc +from aiogram import types as t + +from shared import instances as ins +from shared.instances import dp, bot +from utils import filters as f + + +@dp.message_handler(f.message.is_chat, commands=["gen"]) +async def сгенерировать_хуету(msg: t.Message): + await msg.answer(получить_говно()) + + +@dp.message_handler(f.message.is_chat, commands=["del"]) +async def удалить_хуету(msg: t.Message): + await msg.delete() + + if msg.reply_to_message: + if msg.reply_to_message.from_user.id in [bot.id, msg.from_user.id]: + await msg.reply_to_message.delete() + else: + await msg.answer("Ты умник, можно только свои или мои удалять") + else: + await msg.answer("Ты умник, ответь на сообщение") + + +@dp.message_handler(commands=["chance"]) +async def изменить_шанс_срания(msg: t.Message): + if msg.get_args(): + try: + chance = int(msg.get_args().split()[0]) + if 0 <= chance <= 100: + ins.gen_chance = chance + else: + raise RuntimeError() + + await msg.answer(f"Теперь я сру с шансом в: {chance}%") + except Exception: + await msg.answer("Я хз что не так, но я знаю что ты дебил \n /chance <ЧИСЛО ОТ 0 ДО 100>") + else: + await msg.answer(f"Я сру с шансом в: {ins.gen_chance}%") + + +@dp.message_handler(f.message.chance, f.message.is_chat, content_types=[t.ContentType.ANY]) +async def срать_сообщение_с_шансом(msg: t.Message): + await msg.answer(получить_говно()) + + +def получить_говно() -> str: + samples = mc.util.load_txt_samples('samples.txt', separator='§') + return mc.StringGenerator(samples=samples).generate_string().capitalize() diff --git a/poetry.lock b/poetry.lock index d9af2da..90c31a4 100644 --- a/poetry.lock +++ b/poetry.lock @@ -168,6 +168,14 @@ requirements_deprecated_finder = ["pipreqs", "pip-api"] colors = ["colorama (>=0.4.3,<0.5.0)"] plugins = ["setuptools"] +[[package]] +name = "mc.py" +version = "3.1.1" +description = "String generator based on Markov process" +category = "main" +optional = false +python-versions = ">=3.6" + [[package]] name = "multidict" version = "6.0.2" @@ -235,7 +243,7 @@ multidict = ">=4.0" [metadata] lock-version = "1.1" python-versions = "^3.10" -content-hash = "7c3c7f7de5b6df6ab3796df7636aa4eeb7de8f8ca136ec686aaf9cc4ae88cd6c" +content-hash = "efa0e2c5d3b8f77a22478a52ca869113f970e18c77d8da40a7d020c0eb572a0a" [metadata.files] aiogram = [ @@ -442,6 +450,9 @@ 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"}, +] 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"}, diff --git a/pyproject.toml b/pyproject.toml index ab2fe99..489bed2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,6 +8,7 @@ license = "GPL-3.0-only" [tool.poetry.dependencies] python = "^3.10" aiogram = "^2.20" +"mc.py" = "3.1.1" [tool.poetry.dev-dependencies] black = "^22.3.0" diff --git a/requirements.txt b/requirements.txt index 3a51d36..234bc0b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -155,6 +155,8 @@ 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 multidict==6.0.2; python_version >= "3.7" \ --hash=sha256:0b9e95a740109c6047602f4db4da9949e6c5945cefbad34a1299775ddc9a62e2 \ --hash=sha256:ac0e27844758d7177989ce406acc6a83c16ed4524ebc363c1f748cba184d89d3 \ diff --git a/shared/commands.py b/shared/commands.py index a54a770..bf1a6cb 100644 --- a/shared/commands.py +++ b/shared/commands.py @@ -4,11 +4,9 @@ from aiogram.types import BotCommandScopeAllPrivateChats as private commands = { group(): [ - cmd("gen", "Высрвть текст"), - cmd("del", "Смыть говно"), - cmd("pin", "Повесить говно на стенку"), - cmd("gif", "Превратить картинку в gif"), - cmd("chance", "Установить шанс высирания говна"), + cmd("gen", "Покакать текстом"), + cmd("del", "Убрать говно"), + cmd("pin", "Закрепить говно"), + cmd("chance", "Установить шанс покакать в туалет"), ], - private(): [cmd("gif", "Превратить картинку в gif")], } -- cgit v1.2.3