# ©️ Dan Gazizullin, 2021-2023
# This file is a part of Hikka Userbot
# 🌐 https://github.com/hikariatama/Hikka
# You can redistribute it and/or modify it under the terms of the GNU AGPLv3
# 🔑 https://www.gnu.org/licenses/agpl-3.0.html
# ©️ Codrago, 2024-2025
# This file is a part of Heroku Userbot
# 🌐 https://github.com/coddrago/Heroku
# You can redistribute it and/or modify it under the terms of the GNU AGPLv3
# 🔑 https://www.gnu.org/licenses/agpl-3.0.html
import herokutl
from herokutl.extensions.html import CUSTOM_EMOJIS
from herokutl.tl.types import Message
from .. import loader, main, utils, version
from ..inline.types import InlineCall
import random
@loader.tds
class CoreMod(loader.Module):
"""Control core userbot settings"""
strings = {"name": "Settings"}
def __init__(self):
self.config = loader.ModuleConfig(
loader.ConfigValue(
"allow_nonstandart_prefixes",
False,
"Allow non-standard prefixes like premium emojis or multi-symbol prefixes",
validator=loader.validators.Boolean(),
),
loader.ConfigValue(
"alias_emoji",
"
"
+ "\n".join(
[
(self.config["alias_emoji"] + f" {i}
<- {y}")
for i, y in self.allmodules.aliases.items()
]
)
+ "
",
)
@loader.command()
async def addalias(self, message: Message):
if len(args := utils.get_args(message)) != 2:
await utils.answer(message, self.strings("alias_args"))
return
alias, cmd = args
if self.allmodules.add_alias(alias, cmd):
self.set(
"aliases",
{
**self.get("aliases", {}),
alias: cmd,
},
)
await utils.answer(
message,
self.strings("alias_created").format(utils.escape_html(alias)),
)
else:
await utils.answer(
message,
self.strings("no_command").format(utils.escape_html(cmd)),
)
@loader.command()
async def delalias(self, message: Message):
args = utils.get_args(message)
if len(args) != 1:
await utils.answer(message, self.strings("delalias_args"))
return
alias = args[0]
if not self.allmodules.remove_alias(alias):
await utils.answer(
message,
self.strings("no_alias").format(utils.escape_html(alias)),
)
return
current = self.get("aliases", {})
del current[alias]
self.set("aliases", current)
await utils.answer(
message,
self.strings("alias_removed").format(utils.escape_html(alias)),
)
@loader.command()
async def cleardb(self, message: Message):
await self.inline.form(
self.strings("confirm_cleardb"),
message,
reply_markup=[
{
"text": self.strings("cleardb_confirm"),
"callback": self._inline__cleardb,
},
{
"text": self.strings("cancel"),
"action": "close",
},
],
)
async def _inline__cleardb(self, call: InlineCall):
self._db.clear()
self._db.save()
await utils.answer(call, self.strings("db_cleared"))
async def installationcmd(self, message: Message):
"""| Guide of installation"""
args = utils.get_args_raw(message)
if (not args or args not in {'-v', '-r', '-jh', '-ms', '-u'}) and \
not (await self.inline.form(
self.strings("choose_installation"),
message,
reply_markup=self._markup,
photo="https://raw.githubusercontent.com/coddrago/assets/refs/heads/main/heroku/heroku_installation.png",
disable_security=True
)
):
await self.client.send_file(
message.peer_id,
"https://raw.githubusercontent.com/coddrago/assets/refs/heads/main/heroku/heroku_installation.png",
caption=self.strings["installation"], reply_to=getattr(message, "reply_to_msg_id", None),)
elif "-v" in args:
await utils.answer(message, self.strings["vds_install"])
elif "-jh" in args:
await utils.answer(message, self.strings["jamhost_install"])
elif "-u" in args:
await utils.answer(message, self.strings["userland_install"])
async def _inline__choose__installation(self, call: InlineCall, platform: str):
await call.edit(
text=self.strings(f'{platform}_install'),
reply_markup=self._markup,
)