-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathlongread.py
executable file
·87 lines (73 loc) · 2.79 KB
/
longread.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
__version__ = (1, 0, 2)
# █ █ ▀ █▄▀ ▄▀█ █▀█ ▀
# █▀█ █ █ █ █▀█ █▀▄ █
# © Copyright 2022
# https://t.me/hikariatama
#
# 🔒 Licensed under the GNU AGPLv3
# 🌐 https://www.gnu.org/licenses/agpl-3.0.html
# meta pic: https://static.dan.tatar/longread_icon.png
# meta banner: https://mods.hikariatama.ru/badges/longread.jpg
# meta developer: @hikarimods
# scope: inline
# scope: hikka_only
# scope: hikka_min 1.2.10
from telethon.tl.types import Message
from .. import loader, utils
from ..inline.types import InlineCall, InlineQuery
@loader.tds
class LongReadMod(loader.Module):
"""Pack longreads under button spoilers"""
strings = {
"name": "LongRead",
"no_text": "🚫 <b>Please, specify text to hide</b>",
"longread": (
"🗄 <b>This is long read</b>\n<i>Click button to show text!\nThis button is"
" active within 6 hours</i>"
),
}
strings_ru = {
"no_text": "🚫 <b>Укажи текст, который надо спрятать</b>",
"longread": (
"🗄 <b>Это - лонгрид</b>\n<i>Нажми на кнопку, чтобы показать текст!\nОна"
" активна в течение 6 часов</i>"
),
"_cmd_doc_lr": "<text> - Создать лонгрид",
"_cls_doc": "Пакует лонгриды под спойлеры",
}
async def lrcmd(self, message: Message):
"""<text> - Create new hidden message"""
args = utils.get_args_raw(message)
if not args:
return
await self.inline.form(
self.strings("longread"),
message,
reply_markup={
"text": "📖 Open spoiler",
"callback": self._handler,
"args": (args,),
},
disable_security=True,
)
async def lr_inline_handler(self, query: InlineQuery):
"""Create new hidden message"""
text = query.args
if not text:
return await query.e400()
return {
"title": "Create new longread",
"description": "ℹ This will create button-spoiler",
"thumb": "https://img.icons8.com/external-wanicon-flat-wanicon/64/000000/external-read-free-time-wanicon-flat-wanicon.png",
"message": self.strings("longread"),
"reply_markup": {
"text": "📖 Open spoiler",
"callback": self._handler,
"args": (text,),
"disable_security": True,
},
}
async def _handler(self, call: InlineCall, text: str):
"""Process button presses"""
await call.edit(text)
await call.answer()