aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--handlers/__init__.py7
-rw-r--r--handlers/all.py16
-rw-r--r--handlers/ananas_only.py2
-rw-r--r--handlers/gen.py51
-rw-r--r--handlers/generate.py92
-rw-r--r--handlers/gif.py41
-rw-r--r--handlers/msg.py (renamed from handlers/on_message.py)2
-rw-r--r--handlers/poll.py51
-rw-r--r--shared/commands.py11
-rw-r--r--test.py28
-rw-r--r--tmp/gif.jpgbin0 -> 7200 bytes
-rw-r--r--tmp/gif.mp40
12 files changed, 175 insertions, 126 deletions
diff --git a/handlers/__init__.py b/handlers/__init__.py
index bf57f77..05e50a2 100644
--- a/handlers/__init__.py
+++ b/handlers/__init__.py
@@ -1,3 +1,6 @@
1from . import ananas_only 1from . import ananas_only
2from . import on_message 2from . import msg
3from . import generate 3from . import poll
4from . import gif
5from . import gen
6from . import all
diff --git a/handlers/all.py b/handlers/all.py
new file mode 100644
index 0000000..10ba92d
--- /dev/null
+++ b/handlers/all.py
@@ -0,0 +1,16 @@
1from shared.instances import dp
2from aiogram import types as t
3
4
5@dp.errors_handler()
6async def errors_handler(upd: t.Update, err: Exception):
7 txt = "Я хз что произошло, но да \n"
8 txt += f" {err.__class__.__name__}: {' '.join(err.args)}"
9
10 if upd.message:
11 await upd.message.answer(txt)
12 elif upd.callback_query:
13 await upd.callback_query.answer(txt)
14 else:
15 return
16 return True
diff --git a/handlers/ananas_only.py b/handlers/ananas_only.py
index 7426593..a6ee13c 100644
--- a/handlers/ananas_only.py
+++ b/handlers/ananas_only.py
@@ -4,7 +4,7 @@ from utils import filters as f
4 4
5 5
6@dp.my_chat_member_handler(f.user.add_member) 6@dp.my_chat_member_handler(f.user.add_member)
7async def pososi(upd: t.ChatMemberUpdated): 7async def пососи(upd: t.ChatMemberUpdated):
8 if upd.chat.id not in (-1001444484622, -1001197098429): 8 if upd.chat.id not in (-1001444484622, -1001197098429):
9 await upd.bot.send_message(upd.chat.id, 'https://www.youtube.com/watch?v=xdDhmagsXrc') 9 await upd.bot.send_message(upd.chat.id, 'https://www.youtube.com/watch?v=xdDhmagsXrc')
10 await upd.chat.leave() 10 await upd.chat.leave()
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 @@
1import mc
2from aiogram import types as t
3
4from shared import instances as ins
5from shared.instances import dp, bot
6from utils import filters as f
7
8
9@dp.message_handler(f.message.is_chat, commands=["gen"])
10async def сгенерировать_хуету(msg: t.Message):
11 await msg.answer(получить_говно())
12
13
14@dp.message_handler(f.message.is_chat, commands=["del"])
15async def удалить_хуету(msg: t.Message):
16 await msg.delete()
17
18 if msg.reply_to_message:
19 if msg.reply_to_message.from_user.id in [bot.id, msg.from_user.id]:
20 await msg.reply_to_message.delete()
21 else:
22 await msg.answer("Ты умник, можно только свои или мои удалять")
23 else:
24 await msg.answer("Ты умник, ответь на сообщение")
25
26
27@dp.message_handler(commands=["chance"])
28async def изменить_шанс_срания(msg: t.Message):
29 if msg.get_args():
30 try:
31 chance = int(msg.get_args().split()[0])
32 if 0 <= chance <= 100:
33 ins.gen_chance = chance
34 else:
35 raise RuntimeError()
36
37 await msg.answer(f"Теперь я сру с шансом в: {chance}%")
38 except Exception:
39 await msg.answer("Я хз что не так, но я знаю что ты дебил \n /chance <ЧИСЛО ОТ 0 ДО 100>")
40 else:
41 await msg.answer(f"Я сру с шансом в: {ins.gen_chance}%")
42
43
44@dp.message_handler(f.message.chance, f.message.is_chat, content_types=[t.ContentType.ANY])
45async def срать_сообщение_с_шансом(msg: t.Message):
46 await msg.answer(получить_говно())
47
48
49def получить_говно() -> str:
50 samples = mc.util.load_txt_samples('samples.txt', separator='§')
51 return mc.StringGenerator(samples=samples).generate_string().capitalize()
diff --git a/handlers/generate.py b/handlers/generate.py
deleted file mode 100644
index 7f58185..0000000
--- a/handlers/generate.py
+++ /dev/null
@@ -1,92 +0,0 @@
1from datetime import datetime, timedelta
2
3import mc
4from shared.instances import dp, bot
5from aiogram import types as t
6from utils import filters as f
7from shared import instances as ins
8
9pin_reply_markup = t.InlineKeyboardMarkup().add(
10 t.InlineKeyboardButton("Проверить сейчас", callback_data="chek")
11)
12
13
14@dp.message_handler(f.message.is_chat, commands=['gen'])
15async def сгенерировать_хуету(msg: t.Message):
16 samples = mc.util.load_txt_samples('samples.txt', separator='§')
17 await msg.answer(mc.StringGenerator(samples=samples).generate_string())
18
19
20@dp.message_handler(f.message.is_chat, commands=["del"])
21async def удалить_хуету(msg: t.Message):
22 await msg.delete()
23
24 if msg.reply_to_message:
25 if msg.reply_to_message.from_user.id in [bot.id, msg.from_user.id]:
26 await msg.reply_to_message.delete()
27 else:
28 await msg.answer("Ты умник, можно только свои или мои удалять")
29 else:
30 await msg.answer("Ты умник, ответь на сообщение")
31
32
33@dp.message_handler(f.message.is_chat, commands=["pin"])
34async def закрепить_хуету(msg: t.Message):
35 await msg.delete()
36 if msg.reply_to_message:
37 await msg.reply_to_message.reply_poll(
38 "Закрепить ?",
39 [
40 "Да",
41 "УДАЛИ НАХУЙ",
42 "Нет"
43 ],
44 close_date=datetime.now() + timedelta(minutes=10),
45 reply_markup=pin_reply_markup
46 )
47 else:
48 await msg.answer("Ты умник, ответь на сообщение")
49
50
51@dp.message_handler(commands=["chance"])
52async def закрепить_хуту(msg: t.Message):
53 if msg.get_args():
54 try:
55 chance = int(msg.get_args().split()[0])
56 if 0 <= chance <= 100:
57 ins.gen_chance = chance
58 else:
59 raise RuntimeError()
60
61 await msg.answer(f"Теперь я сру с шансом в: {chance}%")
62 except Exception:
63 await msg.answer("Я хз что не так, но я знаю что ты дебил \n /chance <ЧИСЛО ОТ 0 ДО 100>")
64 else:
65 await msg.answer(f"Я сру с шансом в: {ins.gen_chance}%")
66
67
68@dp.message_handler(f.message.chance, f.message.is_chat, content_types=[t.ContentType.ANY])
69async def срать_сообщение_с_шансом(msg: t.Message):
70 await сгенерировать_хуету(msg)
71
72
73@dp.callback_query_handler(f.message.is_chat, lambda clb: clb.data == "chek")
74async def проверить_опрос(clb: t.CallbackQuery):
75 poll = clb.message.poll
76 msg = clb.message
77
78 if poll.total_voter_count <= 0:
79 await clb.answer("Видишь голоса? Вот и я невижу")
80 else:
81 if not poll.is_closed:
82 await bot.stop_poll(msg.chat.id, msg.message_id)
83 await msg.delete_reply_markup()
84
85 yes = poll.options[0].voter_count
86 delete = poll.options[1].voter_count
87 win = max(yes, delete)
88
89 if win == yes:
90 await msg.pin()
91 elif win == delete:
92 await msg.delete()
diff --git a/handlers/gif.py b/handlers/gif.py
new file mode 100644
index 0000000..3961502
--- /dev/null
+++ b/handlers/gif.py
@@ -0,0 +1,41 @@
1from os import system as run
2
3from aiogram import types as t
4from aiogram.dispatcher import filters
5
6from handlers.gen import получить_говно
7from shared.instances import dp
8
9
10@dp.message_handler(
11 filters.Command("gif", ignore_caption=False),
12 content_types=[t.ContentType.PHOTO, t.ContentType.DOCUMENT, t.ContentType.TEXT],
13 commands=["gif"]
14)
15async def высрать_гиф(msg: t.Message):
16 tmp = "tmp/"
17 inp = tmp + "gif.jpg"
18 out = tmp + "gif.mp4"
19
20 try:
21 if msg.text:
22 photo = msg.reply_to_message.photo
23 document = msg.reply_to_message.document
24 else:
25 photo = msg.photo
26 document = msg.document
27
28 if photo:
29 await photo[-1].download(destination_file=inp)
30 elif document:
31 await document.download(destination_file=inp)
32 else:
33 raise RuntimeError()
34 except Exception:
35 await msg.reply("Чел, ответь на фото или пришли мне его")
36 return
37
38 run(f"ffmpeg -loglevel quiet -y -i {inp} {out}")
39
40 with open(out, "rb") as file:
41 await msg.reply_animation(file, caption=получить_говно())
diff --git a/handlers/on_message.py b/handlers/msg.py
index 5a216e2..58f3213 100644
--- a/handlers/on_message.py
+++ b/handlers/msg.py
@@ -8,7 +8,7 @@ async def сосалка(msg: t.Message):
8 if text.startswith('/'): 8 if text.startswith('/'):
9 return False 9 return False
10 with open('samples.txt', 'a+') as file: 10 with open('samples.txt', 'a+') as file:
11 file.write(text.replace('§', '') + '§') 11 file.write(text.lower().replace('§', '') + '§')
12 return False 12 return False
13 13
14 14
diff --git a/handlers/poll.py b/handlers/poll.py
new file mode 100644
index 0000000..f6fb962
--- /dev/null
+++ b/handlers/poll.py
@@ -0,0 +1,51 @@
1from datetime import datetime, timedelta
2
3from shared.instances import dp, bot
4from utils import filters as f
5from aiogram import types as t
6
7pin_reply_markup = t.InlineKeyboardMarkup().add(
8 t.InlineKeyboardButton("Проверить сейчас", callback_data="chek")
9)
10
11
12@dp.message_handler(f.message.is_chat, commands=["pin"])
13async def закрепить_хуету(msg: t.Message):
14 await msg.delete()
15 if msg.reply_to_message:
16 await msg.reply_to_message.reply_poll(
17 "Закрепить ?",
18 [
19 "Да",
20 "УДАЛИ НАХУЙ",
21 "Нет"
22 ],
23 close_date=datetime.now() + timedelta(minutes=10),
24 reply_markup=pin_reply_markup
25 )
26 else:
27 await msg.answer("Ты умник, ответь на сообщение")
28
29
30@dp.callback_query_handler(f.message.is_chat, lambda clb: clb.data == "chek")
31async def проверить_опрос(clb: t.CallbackQuery):
32 poll = clb.message.poll
33 msg = clb.message
34
35 if poll.total_voter_count <= 0:
36 await clb.answer("Видишь голоса? Вот и я невижу")
37 else:
38 if not poll.is_closed:
39 await bot.stop_poll(msg.chat.id, msg.message_id)
40 poll.is_closed = True
41 yes = poll.options[0].voter_count
42 delete = poll.options[1].voter_count
43 win = max(yes, delete)
44
45 if win == yes:
46 await msg.reply_to_message.pin()
47 elif win == delete:
48 await msg.reply_to_message.delete()
49
50 if poll.is_closed:
51 await msg.delete()
diff --git a/shared/commands.py b/shared/commands.py
index 3f2e3b1..34f9dbb 100644
--- a/shared/commands.py
+++ b/shared/commands.py
@@ -1,10 +1,17 @@
1from aiogram.types import BotCommand as cmd, BotCommandScopeAllGroupChats as group 1from aiogram.types import \
2 BotCommand as cmd, \
3 BotCommandScopeAllGroupChats as group, \
4 BotCommandScopeAllPrivateChats as private
2 5
3commands = { 6commands = {
4 group(): [ 7 group(): [
5 cmd('gen', 'Высрвть текст'), 8 cmd('gen', 'Высрвть текст'),
6 cmd('del', 'Смыть говно'), 9 cmd('del', 'Смыть говно'),
7 cmd('pin', 'Повесить говно на стенку'), 10 cmd('pin', 'Повесить говно на стенку'),
8 cmd('chance', 'Установить шанс высирания говна'), 11 cmd('gif', 'Превратить картинку в gif'),
12 cmd('chance', 'Установить шанс высирания говна')
13 ],
14 private(): [
15 cmd('gif', 'Превратить картинку в gif')
9 ] 16 ]
10} 17}
diff --git a/test.py b/test.py
index d7ec5be..e69de29 100644
--- a/test.py
+++ b/test.py
@@ -1,28 +0,0 @@
1n = int(input())
2lt = []
3
4for i in range(n - 1):
5 lt += [list(map(str, input().split()))]
6
7lts = [lt[0]]
8l = lt[0][0]
9r = lt[0][1]
10lt.pop(0)
11
12for i in range(n - 2):
13 for j in range(len(lt)):
14 if lt[j][0] == r:
15 lts += [lt[j]]
16 lt.pop(j)
17 r = lts[-1][-1]
18 break
19 elif lt[j][1] == l:
20 lts = [lt[j]] + lts
21 lt.pop(j)
22 l = lts[0][0]
23 break
24
25for i in range(n - 2, -1, -1):
26 print(lts[i][1])
27
28print(lts[0][0])
diff --git a/tmp/gif.jpg b/tmp/gif.jpg
new file mode 100644
index 0000000..194c251
--- /dev/null
+++ b/tmp/gif.jpg
Binary files differ
diff --git a/tmp/gif.mp4 b/tmp/gif.mp4
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tmp/gif.mp4