Skip to content

Commit 6fc4c58

Browse files
committed
1.6.2
- Remove default presets since they are the security risk - Update and extend Tatar translation pack - Restrict setting `s` as command prefix, since it will break command `setprefix` - Transfer all previously non-essential modules to core ones
1 parent 1093407 commit 6fc4c58

25 files changed

+2201
-421
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
- Fix proxy-pass
2828
- New core modules: `UnitHeta`, `Translator`
2929
- New watcher tags: `no_pm`, `no_channels`, `no_groups`, `no_inline`, `no_stickers`, `no_docs`, `no_audios`, `no_videos`, `no_photos`, `no_forwards`, `no_reply`, `no_mention`, `mention`, `only_reply`, `only_forwards`
30+
- Remove default presets since they are the security risk
31+
- Update and extend Tatar translation pack
32+
- Restrict setting `s` as command prefix, since it will break command `setprefix`
33+
- Transfer all previously non-essential modules to core ones
3034

3135
## 🌑 Hikka 1.6.1
3236

hikka/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def deps():
6060
try:
6161
import hikkatl # noqa: F811
6262

63-
if tuple(map(int, hikkatl.__version__.split("."))) < (2, 0, 2):
63+
if tuple(map(int, hikkatl.__version__.split("."))) < (2, 0, 3):
6464
raise ImportError
6565

6666
import hikkapyro

hikka/_local_storage.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def _ensure_dirs(self):
4141
def _get_path(self, repo: str, module_name: str) -> str:
4242
return os.path.join(
4343
self._path,
44-
hashlib.sha256(f"{repo}_{module_name}".encode("utf-8")).hexdigest() + ".py",
44+
hashlib.sha256(f"{repo}_{module_name}".encode()).hexdigest() + ".py",
4545
)
4646

4747
def save(self, repo: str, module_name: str, module_code: str):
@@ -104,7 +104,7 @@ async def preload_main_repo(self):
104104
code = self._local_storage.fetch(repo, module_name)
105105

106106
if code:
107-
sha = hashlib.sha256(code.encode("utf-8")).hexdigest()
107+
sha = hashlib.sha256(code.encode()).hexdigest()
108108
if sha != info["sha"]:
109109
logger.debug("Module %s from main repo is outdated.", name)
110110
code = None

hikka/loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ async def register_module(
699699
)
700700

701701
if origin == "<string>":
702-
Path(path).write_text(spec.loader.data.decode("utf-8"))
702+
Path(path).write_text(spec.loader.data.decode())
703703

704704
logger.debug("Saved class %s to path %s", cls_name, path)
705705

hikka/modules/api_protection.py

Lines changed: 66 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import logging
1111
import random
1212
import time
13+
import typing
1314

1415
from hikkatl.tl import functions
1516
from hikkatl.tl.tlobject import TLRequest
@@ -541,11 +542,64 @@ class APIRatelimiterMod(loader.Module):
541542
),
542543
}
543544

544-
_ratelimiter = []
545-
_suspend_until = 0
546-
_lock = False
545+
strings_tt = {
546+
"warning": (
547+
"⚠️ <b>ДИЯК!</b>\n\nАккаунт чыкты аныкларны кәйберле көрсәтелгән конфигтан"
548+
" ашты. Telegram API-ның флуд булдырыуыны тышкылау үчен, юзербот <b>тулы"
549+
" төшерелде</b> {} секунд. Өстәмә мәгълүмат файлда күрсәтелгән."
550+
" \n\nКулланучыны төшерү үчен, <code>{prefix}support</code> группасына"
551+
" мөмкинчәлек булса, көрсәтелгән группага кереп кулланыгыз!\n\nАгыллы"
552+
" булсаң, юзерботның бул белән бәйле тәртибен үзгәрткән үзгәрешләре булса,"
553+
" <code>{prefix}suspend_api_protect</code> &lt;секундлар саны&gt;"
554+
" кулланыгыз!"
555+
),
556+
"args_invalid": (
557+
"<emoji document_id=5312526098750252863>🚫</emoji> <b>Хаталы аргументлар</b>"
558+
),
559+
"suspended_for": (
560+
"<emoji document_id=5458450833857322148>👌</emoji> <b>API тышкылауы"
561+
" {} секундлар өчен төшерелде</b>"
562+
),
563+
"on": (
564+
"<emoji document_id=5458450833857322148>👌</emoji> <b>Тышкылау включена</b>"
565+
),
566+
"off": (
567+
"<emoji document_id=5458450833857322148>👌</emoji> <b>Тышкылау төшерелде</b>"
568+
),
569+
"u_sure": "<emoji document_id=5312383351217201533>⚠️</emoji> <b>Сез белем?</b>",
570+
"_cfg_time_sample": (
571+
"Йөклек вакыт аралыгы, мөмкин болса өчен сораулар санын табып берет"
572+
),
573+
"_cfg_threshold": (
574+
"Сораулар саны, үзгәртүлгән вакыт аралыгында күплегеннән күбрәк булса,"
575+
" мөмкин болса өчен җибәрелсен"
576+
),
577+
"_cfg_local_floodwait": (
578+
"Юзерботны үзеннән үзенә күбрәк сораулар булса, бу көндә күбрәк секундлар"
579+
" буенча үзенән үзенә күбрәк сораулар күрсәтелмәсе"
580+
),
581+
"_cfg_forbidden_methods": (
582+
"Барлык тышкы модулларда бу методларның исәпләүен тыя"
583+
),
584+
"btn_no": "🚫 Яңа",
585+
"btn_yes": "✅ Хәлә",
586+
"web_pin": (
587+
"🔓 <b>Пин кодын күйгә түшереп күрсәтегез, Werkzeug debug PIN кодын"
588+
" күрсәтегез. Уны башкаларына бирәргә башкаларына бирмәй.</b>"
589+
),
590+
"web_pin_btn": "🐞 Werkzeug PIN кодын күрсәтегез",
591+
"proxied_url": "⚜️ Проксиленнә URL",
592+
"local_url": "🏠 Локальнә URL",
593+
"debugger_disabled": (
594+
"<emoji document_id=5312526098750252863>🚫</emoji> <b>Веб төзәтүче инвалид,"
595+
" сылтама мөмкин түгел</b>"
596+
),
597+
}
547598

548599
def __init__(self):
600+
self._ratelimiter: typing.List[tuple] = []
601+
self._suspend_until = 0
602+
self._lock = False
549603
self.config = loader.ModuleConfig(
550604
loader.ConfigValue(
551605
"time_sample",
@@ -578,7 +632,8 @@ def __init__(self):
578632
),
579633
on_change=lambda: self._client.forbid_constructors(
580634
map(
581-
lambda x: CONSTRUCTORS[x], self.config["forbidden_constructors"]
635+
lambda x: CONSTRUCTORS[x],
636+
self.config["forbidden_constructors"],
582637
)
583638
),
584639
),
@@ -615,7 +670,7 @@ async def new_call(
615670
)
616671
):
617672
request_name = type(r).__name__
618-
self._ratelimiter += [[request_name, time.perf_counter()]]
673+
self._ratelimiter += [(request_name, time.perf_counter())]
619674

620675
self._ratelimiter = list(
621676
filter(
@@ -634,7 +689,7 @@ async def new_call(
634689
json.dumps(
635690
self._ratelimiter,
636691
indent=4,
637-
).encode("utf-8")
692+
).encode()
638693
)
639694
report.name = "local_fw_report.json"
640695

@@ -644,7 +699,7 @@ async def new_call(
644699
caption=self.inline.sanitise_text(
645700
self.strings("warning").format(
646701
self.config["local_floodwait"],
647-
prefix=self.get_prefix(),
702+
prefix=utils.escape_html(self.get_prefix()),
648703
)
649704
),
650705
)
@@ -675,12 +730,11 @@ async def on_unload(self):
675730
uz_doc="<soniya> - API himoyasini N soniya o'zgartirish",
676731
es_doc="<segundos> - Congela la protección de la API durante N segundos",
677732
kk_doc="<секунд> - API қорғауын N секундтік уақытта құлыптау",
733+
tt_doc="<секундларда вакыт> - N секунд өчен API саклауны туңдырыгыз",
678734
)
679735
async def suspend_api_protect(self, message: Message):
680736
"""<time in seconds> - Suspend API Ratelimiter for n seconds"""
681-
args = utils.get_args_raw(message)
682-
683-
if not args or not args.isdigit():
737+
if not (args := utils.get_args_raw(message)) or not args.isdigit():
684738
await utils.answer(message, self.strings("args_invalid"))
685739
return
686740

@@ -696,6 +750,7 @@ async def suspend_api_protect(self, message: Message):
696750
uz_doc="API himoyasini yoqish / o'chirish",
697751
es_doc="Activar / desactivar la protección de API",
698752
kk_doc="API қорғауын қосу / жою",
753+
tt_doc="API саклауын қосу / алып тастау",
699754
)
700755
async def api_fw_protection(self, message: Message):
701756
"""Toggle API Ratelimiter"""
@@ -724,6 +779,7 @@ async def _show_pin(self, call: InlineCall):
724779
uz_doc="PIN vositasi ko'rsatish",
725780
es_doc="Mostrar herramienta PIN",
726781
kk_doc="PIN құралын көрсету",
782+
tt_doc="PIN Werkzeug күрсәтегез",
727783
)
728784
async def debugger(self, message: Message):
729785
"""Show the Werkzeug PIN"""

hikka/modules/eval.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,6 @@ def _interpret(self, source: str):
123123
self.data[ptr] -= 1
124124
elif source[current] == ".":
125125
self.out += chr(self.data[ptr])
126-
elif source[current] == ",":
127-
value = input()
128-
if not value.isdigit():
129-
self._report_error("invalid input")
130-
131-
self.data[ptr] = value
132126
elif source[current] == "[":
133127
if self.data[ptr] == 0:
134128
while source[current] != "]":
@@ -376,7 +370,6 @@ class Evaluator(loader.Module):
376370
),
377371
}
378372

379-
@loader.owner
380373
@loader.command(
381374
ru_doc="Выполняет Python код",
382375
fr_doc="Évalue du code Python",
@@ -386,6 +379,7 @@ class Evaluator(loader.Module):
386379
uz_doc="Python kodini ishga tushiradi",
387380
es_doc="Ejecuta código Python",
388381
kk_doc="Python кодын орындау",
382+
tt_doc="Python кодын үзгәртү",
389383
alias="eval",
390384
)
391385
async def e(self, message: Message):
@@ -440,6 +434,7 @@ async def e(self, message: Message):
440434
uz_doc="C++ kodini ishga tushiradi",
441435
es_doc="Ejecuta código C++",
442436
kk_doc="C++ кодын орындау",
437+
tt_doc="C++ кодын үзгәртү",
443438
)
444439
async def ecpp(self, message: Message, c: bool = False):
445440
"""Evaluates C++ code"""
@@ -506,6 +501,7 @@ async def ecpp(self, message: Message, c: bool = False):
506501
uz_doc="C kodini ishga tushiradi",
507502
es_doc="Ejecuta código C",
508503
kk_doc="C кодын орындау",
504+
tt_doc="C кодын үзгәртү",
509505
)
510506
async def ec(self, message: Message):
511507
"""Evaluates C code"""
@@ -520,6 +516,7 @@ async def ec(self, message: Message):
520516
uz_doc="Node.js kodini ishga tushiradi",
521517
es_doc="Ejecuta código Node.js",
522518
kk_doc="Node.js кодын орындау",
519+
tt_doc="Node.js кодын үзгәртү",
523520
)
524521
async def enode(self, message: Message):
525522
"""Evaluates Node.js code"""
@@ -574,6 +571,7 @@ async def enode(self, message: Message):
574571
uz_doc="PHP kodini ishga tushiradi",
575572
es_doc="Ejecuta código PHP",
576573
kk_doc="PHP кодын орындау",
574+
tt_doc="PHP кодын үзгәртү",
577575
)
578576
async def ephp(self, message: Message):
579577
"""Evaluates PHP code"""
@@ -628,6 +626,7 @@ async def ephp(self, message: Message):
628626
uz_doc="Ruby kodini ishga tushiradi",
629627
es_doc="Ejecuta código Ruby",
630628
kk_doc="Ruby кодын орындау",
629+
tt_doc="Ruby кодын үзгәртү",
631630
)
632631
async def eruby(self, message: Message):
633632
"""Evaluates Ruby code"""
@@ -682,6 +681,7 @@ async def eruby(self, message: Message):
682681
uz_doc="Brainf*ck kodini ishga tushiradi",
683682
es_doc="Ejecuta código Brainf*ck",
684683
kk_doc="Brainf*ck кодын орындау",
684+
tt_doc="Brainf*ck кодын үзгәртү",
685685
)
686686
async def ebf(self, message: Message):
687687
"""Evaluates Brainf*ck code"""

0 commit comments

Comments
 (0)