diff --git a/hikka/inline.py b/hikka/inline.py
index 9554c4c..4475ccb 100755
--- a/hikka/inline.py
+++ b/hikka/inline.py
@@ -196,7 +196,9 @@ async def custom_back_handler(
self._galleries[gallery_uid]["current_index"] = 0
self._galleries[gallery_uid]["current_index"] -= 1
- new_url = self._galleries[gallery_uid]["photos"][self._galleries[gallery_uid]["current_index"]]
+ new_url = self._galleries[gallery_uid]["photos"][
+ self._galleries[gallery_uid]["current_index"]
+ ]
markup = InlineKeyboardMarkup()
markup.add(
@@ -251,7 +253,9 @@ async def custom_next_handler(
) -> None:
if self._galleries[gallery_uid]["current_index"] < -1:
self._galleries[gallery_uid]["current_index"] += 1
- new_url = self._galleries[gallery_uid]["photos"][self._galleries[gallery_uid]["current_index"]]
+ new_url = self._galleries[gallery_uid]["photos"][
+ self._galleries[gallery_uid]["current_index"]
+ ]
else:
try:
new_url = await func()
@@ -270,9 +274,9 @@ async def custom_next_handler(
self._galleries[gallery_uid]["photos"] += [new_url]
if len(self._galleries[gallery_uid]["photos"]) > 15:
- self._galleries[gallery_uid]["photos"] = self._galleries[gallery_uid]["photos"][
- -15:
- ]
+ self._galleries[gallery_uid]["photos"] = self._galleries[gallery_uid][
+ "photos"
+ ][-15:]
markup = InlineKeyboardMarkup()
markup.add(
@@ -1020,9 +1024,15 @@ class InlineManager:
):
markup = InlineKeyboardMarkup()
markup.add(
- InlineKeyboardButton("⬅️", callback_data=gallery["btn_call_data"][0]),
- InlineKeyboardButton("❌", callback_data=gallery["btn_call_data"][1]),
- InlineKeyboardButton("➡️", callback_data=gallery["btn_call_data"][2]),
+ InlineKeyboardButton(
+ "⬅️", callback_data=gallery["btn_call_data"][0]
+ ),
+ InlineKeyboardButton(
+ "❌", callback_data=gallery["btn_call_data"][1]
+ ),
+ InlineKeyboardButton(
+ "➡️", callback_data=gallery["btn_call_data"][2]
+ ),
)
caption = gallery["caption"]
diff --git a/hikka/loader.py b/hikka/loader.py
index 172366e..df2b808 100755
--- a/hikka/loader.py
+++ b/hikka/loader.py
@@ -226,7 +226,7 @@ class Modules:
self._initial_registration = True
self.added_modules = None
- def register_all(self, mods=None):
+ def register_all(self, db, mods=None):
"""Load all modules in the module directory"""
if self._compat_layer is None:
from . import compat # noqa
@@ -242,6 +242,7 @@ class Modules:
and x[-3:] == ".py"
and x[0] != "_"
and ("OKTETO" in os.environ or x != "okteto.py")
+ and (not db.get("hikka", "disable_quickstart", False) or x != "quickstart.py")
),
os.listdir(os.path.join(utils.get_base_dir(), MODULES_NAME)),
)
diff --git a/hikka/main.py b/hikka/main.py
index 41b0773..bc95757 100755
--- a/hikka/main.py
+++ b/hikka/main.py
@@ -524,7 +524,7 @@ class Hikka:
babelfish = Translator([], [], self.arguments.data_root)
await babelfish.init(client)
- modules.register_all()
+ modules.register_all(db)
modules.send_config(db, babelfish)
await modules.send_ready(client, db, self.clients)
@@ -594,7 +594,7 @@ class Hikka:
if not web_only:
await self._add_dispatcher(client, modules, db)
- modules.register_all(to_load)
+ modules.register_all(db, to_load)
modules.send_config(db, babelfish)
await modules.send_ready(client, db, self.clients)
diff --git a/hikka/modules/quickstart.py b/hikka/modules/quickstart.py
new file mode 100644
index 0000000..ad701aa
--- /dev/null
+++ b/hikka/modules/quickstart.py
@@ -0,0 +1,120 @@
+# █ █ ▀ █▄▀ ▄▀█ █▀█ ▀ ▄▀█ ▀█▀ ▄▀█ █▀▄▀█ ▄▀█
+# █▀█ █ █ █ █▀█ █▀▄ █ ▄ █▀█ █ █▀█ █ ▀ █ █▀█
+#
+# © Copyright 2022
+#
+# https://t.me/hikariatama
+#
+# 🔒 Licensed under the GNU GPLv3
+# 🌐 https://www.gnu.org/licenses/agpl-3.0.html
+
+from .. import loader
+import logging
+from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery
+from random import choice
+
+logger = logging.getLogger(__name__)
+imgs = [
+ "https://pa1.narvii.com/6644/16e88ec137d2ad2583937e7909b6a166c70f3f2a_hq.gif",
+ "https://c.tenor.com/O3qIam1dAQQAAAAC/hug-cuddle.gif",
+ "https://pa1.narvii.com/6853/8efac13a077dac28e6a500a5dd2a7f97dec668fd_hq.gif",
+ "https://static.tumblr.com/ef1af4bfc7f5a5be30a24539d536e1ce/cehtffd/k3Hpiifhs/tumblr_static_tumblr_static__focused_v3.gif",
+ "https://i.gifer.com/W9IO.gif",
+ "https://c.tenor.com/6w7XKLSqFEUAAAAC/anime-hug.gif",
+ "https://i2.wp.com/metanorn.net/wp-content/uploads/2011/08/NS3-04b.gif",
+]
+
+
+@loader.tds
+class QuickstartMod(loader.Module):
+ """Notifies user about userbot installation"""
+
+ strings = {
+ "name": "Quickstart",
+ "quickstart": "👩🎤🇬🇧 Hello. You've just installed Hikka userbot.\n\n❓ Need help? Feel free to join our support chat. We help everyone.\n\n📼 Official modules sources: \n▫️ @hikarimods\n▫️ @hikarimods_database\n▫️ .dlmod
",
+ "quickstart_ru": "👩🎤🇷🇺 Привет. Твой юзербот Hikka установлен.\n\n❓ Нужна помощь? Вступай в наш чат поддержки. Мы помогаем всем\n\n📼 Официальные источники модулей: \n▫️ @hikarimods\n▫️ @hikarimods_database\n▫️ .dlmod
",
+ }
+
+ def get(self, *args) -> dict:
+ return self._db.get(self.strings["name"], *args)
+
+ def set(self, *args) -> None:
+ return self._db.set(self.strings["name"], *args)
+
+ async def client_ready(self, client, db) -> None:
+ self._me = (await client.get_me()).id
+
+ mark = InlineKeyboardMarkup()
+ mark.add(
+ InlineKeyboardButton(
+ "🥷 Support chat",
+ url="https://t.me/hikka_talks",
+ ),
+ )
+
+ mark.add(
+ InlineKeyboardButton(
+ "🇷🇺 Русский",
+ callback_data="hikka_qs_sw_lng_ru",
+ ),
+ )
+
+ await self.inline.bot.send_animation(
+ self._me,
+ animation=choice(imgs),
+ caption=self.strings("quickstart"),
+ parse_mode="HTML",
+ reply_markup=mark,
+ )
+
+ db.set("hikka", "disable_quickstart", True)
+
+ async def quickstart_callback_handler(self, call: CallbackQuery) -> None:
+ if not call.data.startswith("hikka_qs_sw_lng_"):
+ return
+
+ lang = call.data.split("_")[-1]
+ if lang == "ru":
+ mark = InlineKeyboardMarkup()
+ mark.add(
+ InlineKeyboardButton(
+ "🥷 Чат помощи",
+ url="https://t.me/hikka_talks",
+ ),
+ )
+ mark.add(
+ InlineKeyboardButton(
+ "🇬🇧 English",
+ callback_data="hikka_qs_sw_lng_en",
+ ),
+ )
+
+ await self.inline.bot.edit_message_caption(
+ chat_id=call.message.chat.id,
+ message_id=call.message.message_id,
+ caption=self.strings("quickstart_ru"),
+ parse_mode="HTML",
+ reply_markup=mark,
+ )
+ elif lang == "en":
+ mark = InlineKeyboardMarkup()
+ mark.add(
+ InlineKeyboardButton(
+ "🥷 Support chat",
+ url="https://t.me/hikka_talks",
+ ),
+ )
+ mark.add(
+ InlineKeyboardButton(
+ "🇷🇺 Русский",
+ callback_data="hikka_qs_sw_lng_ru",
+ ),
+ )
+
+ await self.inline.bot.edit_message_caption(
+ chat_id=call.message.chat.id,
+ message_id=call.message.message_id,
+ caption=self.strings("quickstart"),
+ parse_mode="HTML",
+ reply_markup=mark,
+ )
diff --git a/hikka/version.py b/hikka/version.py
index 737f027..31a8f81 100644
--- a/hikka/version.py
+++ b/hikka/version.py
@@ -1 +1 @@
-__version__ = (1, 0, 5)
+__version__ = (1, 0, 6)