# █ █ ▀ █▄▀ ▄▀█ █▀█ ▀ # █▀█ █ █ █ █▀█ █▀▄ █ # © 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/hw_icon.png # meta banner: https://mods.hikariatama.ru/badges/hw.jpg # meta developer: @hikarimods # scope: hikka_only # scope: hikka_min 1.2.10 from random import randint from telethon.tl.types import Message from .. import loader, utils @loader.tds class HomeworkMod(loader.Module): """Simple Homework planner""" strings = { "name": "HomeWork", "no_hometask": "🚫 You haven't provided hometask", "new_hometask": "Hometask #{}:\n
{}
", "not_found": "🚫 Hometask not found✅ Hometask removed", } strings_ru = { "no_hometask": "🚫 Укажи домашнее задание", "new_hometask": "Домашнее задание #{}:\n
{}
", "not_found": "🚫 Домашнее задание не найдено✅ Домашнее задание удалено", "_cmd_doc_hw": " - Новое домашнее задание", "_cmd_doc_hwl": "Список домашних заданий", "_cmd_doc_uhw": " - Удалить домашнее задание", "_cls_doc": "Простой планнер домашних заданий", } async def client_ready(self, client, db): self.hw = self.get("hw", {}) async def hwcmd(self, message: Message): """ - New hometask""" args = utils.get_args_raw(message) reply = await message.get_reply_message() if args == "" and not reply: await utils.answer(message, self.strings("no_hometask")) return if args == "": args = reply.text random_id = str(randint(10000, 99999)) self.hw[random_id] = args self.set("hw", self.hw) await utils.answer( message, self.strings("new_hometask").format(random_id, str(args)), ) @loader.unrestricted async def hwlcmd(self, message: Message): """List of hometasks""" res = "#HW:\n\n" for item_id, item in self.hw.items(): res += f"🔸 .uhw {item_id}: {item}" + "\n" await utils.answer(message, res) async def uhwcmd(self, message: Message): """ - Remove hometask""" args = utils.get_args_raw(message) if args.startswith("#"): args = args[1:] if args not in self.hw: await utils.answer(message, self.strings("not_found")) return del self.hw[args] self.set("hw", self.hw) await utils.answer(message, self.strings("removed"))