aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--handlers/gen.py7
-rw-r--r--handlers/member.py4
-rw-r--r--handlers/pin.py9
-rw-r--r--shared/config.py21
-rw-r--r--shared/instances.py1
-rw-r--r--utils/filters.py4
6 files changed, 33 insertions, 13 deletions
diff --git a/handlers/gen.py b/handlers/gen.py
index d324049..43301c5 100644
--- a/handlers/gen.py
+++ b/handlers/gen.py
@@ -3,7 +3,7 @@ import os
3import mc 3import mc
4from aiogram import types as t 4from aiogram import types as t
5 5
6from shared import instances as ins 6from shared import config
7from shared.instances import bot, dp 7from shared.instances import bot, dp
8from utils import filters as f 8from utils import filters as f
9 9
@@ -43,7 +43,8 @@ async def изменить_шанс_срания(msg: t.Message):
43 try: 43 try:
44 chance = int(msg.get_args().split()[0]) 44 chance = int(msg.get_args().split()[0])
45 if 0 <= chance <= 100: 45 if 0 <= chance <= 100:
46 ins.gen_chance[msg.chat.id] = chance 46 config.chances[msg.chat.id] = chance
47 config.save()
47 else: 48 else:
48 raise RuntimeError() 49 raise RuntimeError()
49 50
@@ -53,7 +54,7 @@ async def изменить_шанс_срания(msg: t.Message):
53 "Я хз что не так, но я знаю что ты дебил \n /chance <ЧИСЛО ОТ 0 ДО 100>" 54 "Я хз что не так, но я знаю что ты дебил \n /chance <ЧИСЛО ОТ 0 ДО 100>"
54 ) 55 )
55 else: 56 else:
56 await msg.answer(f"Я сру с шансом в: {ins.gen_chance.get(msg.chat.id, 10)}%") 57 await msg.answer(f"Я сру с шансом в: {config.chances.get(msg.chat.id, 10)}%")
57 58
58 59
59@dp.message_handler(f.message.chance, content_types=[t.ContentType.ANY]) 60@dp.message_handler(f.message.chance, content_types=[t.ContentType.ANY])
diff --git a/handlers/member.py b/handlers/member.py
index 83fd39f..3cb1dd8 100644
--- a/handlers/member.py
+++ b/handlers/member.py
@@ -11,7 +11,7 @@ async def приём_запроса(cjr: t.ChatJoinRequest):
11 f'<a href="tg://user?id={cjr.from_user.id}">{cjr.from_user.mention}</a> хочет в чат', 11 f'<a href="tg://user?id={cjr.from_user.id}">{cjr.from_user.mention}</a> хочет в чат',
12 parse_mode=t.ParseMode.HTML, 12 parse_mode=t.ParseMode.HTML,
13 ) 13 )
14 await bot.send_poll( 14 await r.reply_poll(
15 cjr.chat.id, 15 cjr.chat.id,
16 "Пускаем ?", 16 "Пускаем ?",
17 [ 17 [
@@ -19,8 +19,6 @@ async def приём_запроса(cjr: t.ChatJoinRequest):
19 "Нет", 19 "Нет",
20 ], 20 ],
21 False, 21 False,
22 reply_to_message_id=r.message_id,
23 open_period=600,
24 reply_markup=t.InlineKeyboardMarkup().add( 22 reply_markup=t.InlineKeyboardMarkup().add(
25 t.InlineKeyboardButton( 23 t.InlineKeyboardButton(
26 "Проверить опрос", 24 "Проверить опрос",
diff --git a/handlers/pin.py b/handlers/pin.py
index abf7b86..fc81ed1 100644
--- a/handlers/pin.py
+++ b/handlers/pin.py
@@ -1,5 +1,3 @@
1from datetime import datetime, timedelta
2
3from aiogram import types as t 1from aiogram import types as t
4 2
5from shared.instances import bot, dp 3from shared.instances import bot, dp
@@ -16,8 +14,11 @@ async def закрепить_хуету(msg: t.Message):
16 ) 14 )
17 await r.reply_poll( 15 await r.reply_poll(
18 "Закрепить ?", 16 "Закрепить ?",
19 ["Да", "УДАЛИ НАХУЙ", "Нет"], 17 [
20 close_date=datetime.now() + timedelta(minutes=10), 18 "Да",
19 "УДАЛИ НАХУЙ",
20 "Нет",
21 ],
21 reply_markup=t.InlineKeyboardMarkup().add( 22 reply_markup=t.InlineKeyboardMarkup().add(
22 t.InlineKeyboardButton( 23 t.InlineKeyboardButton(
23 "Проверить опрос", 24 "Проверить опрос",
diff --git a/shared/config.py b/shared/config.py
index 6b973d3..d04a510 100644
--- a/shared/config.py
+++ b/shared/config.py
@@ -1,3 +1,24 @@
1from copy import deepcopy
2from json import dump, load
1from os import environ as env 3from os import environ as env
4from os import path
5from typing import Any
2 6
7if path.exists("data/settings.json"):
8 open("data/settings.json", "w").close()
9fields: dict[str, Any] = {
10 "chances": {},
11}
12
13settings: dict[str, Any] = load(open("data/settings.json", "r"))
14for key, default in fields.items():
15 settings[key] = settings.get(key, deepcopy(default))
16
17
18def save():
19 dump(settings, open("data/settings.json", "w"))
20
21
22# Configs
3token = env["TOKEN"] 23token = env["TOKEN"]
24chances = settings["chances"]
diff --git a/shared/instances.py b/shared/instances.py
index 3ffec5e..9ca0b2c 100644
--- a/shared/instances.py
+++ b/shared/instances.py
@@ -4,4 +4,3 @@ from shared.config import token
4 4
5bot = Bot(token=token) 5bot = Bot(token=token)
6dp = Dispatcher(bot) 6dp = Dispatcher(bot)
7gen_chance: dict[int, int] = {}
diff --git a/utils/filters.py b/utils/filters.py
index 90b908a..5dc280b 100644
--- a/utils/filters.py
+++ b/utils/filters.py
@@ -5,7 +5,7 @@ from random import randint
5from aiogram import filters as f 5from aiogram import filters as f
6from aiogram import types as t 6from aiogram import types as t
7 7
8from shared import instances as ins 8from shared import config
9 9
10 10
11class message: 11class message:
@@ -13,7 +13,7 @@ class message:
13 13
14 @staticmethod 14 @staticmethod
15 def chance(msg: t.Message): 15 def chance(msg: t.Message):
16 return ins.gen_chance.get(msg.chat.id, 10) >= randint(1, 100) 16 return config.chances.get(msg.chat.id, 10) >= randint(1, 100)
17 17
18 @staticmethod 18 @staticmethod
19 def has_text(msg: t.Message): 19 def has_text(msg: t.Message):