mirror of https://github.com/coddrago/Heroku
1.2.6
- Fix processing of `# scope: hikka_min` - Add `forbid_joins.py` (to use it, download module from official repo with the same name)pull/1/head
parent
6f7fde5e6a
commit
879aefa1ed
|
@ -1,5 +1,10 @@
|
|||
# Hikka Changelog
|
||||
|
||||
## 🌑 Hikka 1.2.6
|
||||
|
||||
- Fix processing of `# scope: hikka_min`
|
||||
- Add `forbid_joins.py` (to use it, download module from official repo with the same name)
|
||||
|
||||
## 🌑 Hikka 1.2.5
|
||||
|
||||
- Add additional exit on restart to avoid port block
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
from telethon import TelegramClient
|
||||
from telethon.utils import is_list_like
|
||||
|
||||
import inspect
|
||||
import logging
|
||||
|
||||
from . import loader
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# ⚠️⚠️ WARNING! ⚠️⚠️
|
||||
# If you are a module developer, and you'll try to bypass this protection to
|
||||
# force user join your channel, you will be added to SCAM modules
|
||||
# list and you will be banned from Hikka federation.
|
||||
# Let USER decide, which channel he will follow. Do not be so petty
|
||||
# I hope, you understood me.
|
||||
# Thank you
|
||||
|
||||
|
||||
def install_join_forbidder(client: TelegramClient) -> TelegramClient:
|
||||
if hasattr(client, "_forbid_join_tag"):
|
||||
return client
|
||||
|
||||
old_call = client._call
|
||||
|
||||
async def new_call(
|
||||
sender: "MTProtoSender", # type: ignore
|
||||
request: "TLRequest", # type: ignore
|
||||
ordered: bool = False,
|
||||
flood_sleep_threshold: int = None,
|
||||
):
|
||||
not_tuple = False
|
||||
if not is_list_like(request):
|
||||
not_tuple = True
|
||||
request = (request,)
|
||||
|
||||
new_request = []
|
||||
|
||||
for item in request:
|
||||
if item.CONSTRUCTOR_ID == 615851205:
|
||||
if next(
|
||||
frame_info.frame.f_locals["self"]
|
||||
for frame_info in inspect.stack()
|
||||
if hasattr(frame_info, "frame")
|
||||
and hasattr(frame_info.frame, "f_locals")
|
||||
and isinstance(frame_info.frame.f_locals, dict)
|
||||
and "self" in frame_info.frame.f_locals
|
||||
and isinstance(frame_info.frame.f_locals["self"], loader.Module)
|
||||
).__class__.__name__ not in {"HelpMod", "LoaderMod"}:
|
||||
logger.debug(
|
||||
f"🎉 I protected you from unintented JoinChannelRequest ({item})!"
|
||||
)
|
||||
continue
|
||||
|
||||
new_request += [item]
|
||||
|
||||
if not new_request:
|
||||
return
|
||||
|
||||
return await old_call(
|
||||
sender,
|
||||
new_request[0] if not_tuple else tuple(new_request),
|
||||
ordered,
|
||||
flood_sleep_threshold,
|
||||
)
|
||||
|
||||
client._call = new_call
|
||||
client._joins_forbidden = True
|
||||
logger.debug("🎉 JoinForbidder installed!")
|
||||
return client
|
|
@ -552,7 +552,7 @@ class LoaderMod(loader.Module):
|
|||
},
|
||||
{
|
||||
"text": self.lookup("updater").strings("cancel"),
|
||||
"callback": self.lookup("updater").inline_close,
|
||||
"action": "close",
|
||||
},
|
||||
],
|
||||
)
|
||||
|
@ -942,6 +942,19 @@ class LoaderMod(loader.Module):
|
|||
|
||||
async def _update_modules(self):
|
||||
todo = await self._get_modules_to_load()
|
||||
|
||||
# ⚠️⚠️ WARNING! ⚠️⚠️
|
||||
# If you are a module developer, and you'll try to bypass this protection to
|
||||
# force user join your channel, you will be added to SCAM modules
|
||||
# list and you will be banned from Hikka federation.
|
||||
# Let USER decide, which channel he will follow. Do not be so petty
|
||||
# I hope, you understood me.
|
||||
# Thank you
|
||||
|
||||
if "https://mods.hikariatama.ru/forbid_joins.py" in todo.values():
|
||||
from ..forbid_joins import install_join_forbidder
|
||||
install_join_forbidder(self._client)
|
||||
|
||||
for mod in todo.values():
|
||||
await self.download_and_install(mod)
|
||||
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
"""Represents current userbot version"""
|
||||
__version__ = (1, 2, 5)
|
||||
__version__ = (1, 2, 6)
|
||||
|
|
Loading…
Reference in New Issue