def is_user_fed_admin(fed_id, user_id): fed_admins = sql.all_fed_users(fed_id) if fed_admins is False: return False if int(user_id) in fed_admins or int(user_id) == OWNER_ID: return True else: return False
async def info(event): if not event.is_private: if not await is_admin(event, event.sender_id): return await event.reply( "This command can only be used in private.") input = event.pattern_match.group(1) fedowner = sql.get_user_owner_fed_full(event.sender_id) if not input: if not fedowner: return await event.reply( "You need to give me a FedID to check, or be a federation creator to use this command!" ) if input: fed_id = input info = sql.get_fed_info(fed_id) if not info: return await event.reply("There is no federation with this FedID.") name = info["fname"] elif fedowner: for f in fedowner: fed_id = f["fed_id"] name = f["fed"]["fname"] info = sql.get_fed_info(fed_id) if info: owner = int(info["owner"]) getfban = sql.get_all_fban_users(fed_id) getfchat = sql.all_fed_chats(fed_id) FEDADMIN = sql.all_fed_users(fed_id) TotalAdminFed = len(FEDADMIN) caption = "Fed info:\n" caption += f"FedID: `{fed_id}`\n" caption += f"Name: {name}\n" caption += f"Creator: [this person](tg://user?id={owner}) (`{owner}`)\n" caption += f"Number of admins: `{TotalAdminFed}`\n" caption += f"Number of bans: `{len(getfban)}`\n" caption += f"Number of connected chats: `{len(getfchat)}`\n" try: subs = sql.get_subscriber(fed_id) except: subs = [] caption += f"Number of subscribed feds: `{len(subs)}`" try: getmy = sql.get_mysubs(fed_id) except: getmy = [] if len(getmy) == 0: caption += "\n\nThis federation is not subscribed to any other feds." else: caption += "\n\nSubscribed to the following feds:" for x in getmy: nfo = sql.get_fed_info(x) nme = nfo["fname"] caption += f"\n- {nme} (`{x}`)" buttons = Button.inline("Check Fed Admins", data="fedadm_{}".format(fed_id)) await tbot.send_message(event.chat_id, caption, buttons=buttons)