from module_interface import ModuleInterface from mipac.models import Note class Friend(ModuleInterface): def __init__(self): super().__init__() self.name = "Friend" self.regex_pattern = ".*TestAreWeFriend" self.funcs["dec_like"] = self._dec_like self.funcs["inc_like"] = self._inc_like self.funcs["get_like"] = self._get_like self.funcs["is_friend_async"] = self._is_friend_async print("[Friend] Friend DB system, Friend V1 loaded.") async def execute_module(self, ctx: Note): await ctx.api.action.reply( "1" if await self._is_friend_async(ctx.author.id) else "0" ) def _dec_like(self, userid: str): pass def _inc_like(self, userid: str): pass def _get_like(self, userid: str): return self._get_db(self.name, userid)["like"] async def _is_friend_async(self, userid: str): target = await self.manager.bot.user.api.action.get(userid) return target.is_followed and target.is_following def module_ready(self): if self.manager != None: self._get_db = self.manager.require("MinyaDB").get_func("get_module_db") self._set_db = self.manager.require("MinyaDB").get_func("set_module_db") else: raise (Exception("Couldn't find manager")) print("[Friend] Module Ready.")