async def fd(event): if event.is_private: return await event.reply( "This command is made to be run in a group where the person you would like to promote is present." ) fedowner = sql.get_user_owner_fed_full(event.sender_id) if not fedowner: return await event.reply( "Only federation creators can promote people, and you don't seem to have a federation to promote to!" ) args = await get_user_from_event(event) if not args: return await event.reply( "I don't know who you're talking about, you're going to need to specify a user...!" ) chat = event.chat for f in fedowner: fed_id = f["fed_id"] name = f["fed"]["fname"] user_id = args.id if sql.search_user_in_fed(fed_id, user_id) is False: return await event.reply( f"This person isn't a federation admin for '{name} ', how could I demote them?" ) replied_user = await tbot(GetFullUserRequest(user_id)) fname = replied_user.user.first_name sql.user_demote_fed(fed_id, user_id) return await event.reply( f"User [{fname}](tg://user?id={user_id}) is no longer an admin of {name} ({fed_id})" )
async def fd(event): if not event.is_private: return await event.reply("This command is made to be used in PM.") input = event.pattern_match.group(1) if not input: return await event.reply( "You need to specify which federation you're asking about by giving me a FedID!" ) if len(input) < 8: return await event.reply("This isn't a valid FedID format!") 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"] user_id = event.sender_id if is_user_fed_owner(fed_id, int(user_id)) is True: return await event.reply( "You can't demote yourself from your own fed - who would be the owner?" ) if sql.search_user_in_fed(fed_id, user_id) is False: return await event.reply( f"You aren't an admin in '{name}' - how would I demote you?") sql.user_demote_fed(fed_id, user_id) await event.reply(f"You are no longer a fed admin in '{name}'")
async def smex_fed(event): chat = event.chat_id tata = event.pattern_match.group(1) data = tata.decode() input = data.split("_", 1)[1] user, owner= input.split("|") user = user.strip() cname = owner.strip() fedowner = sql.get_user_owner_fed_full(int(cname)) for f in fedowner: fed_id = f["fed_id"] name = f["fed"]["fname"] rt = await tbot(GetFullUserRequest(int(user))) tr = await tbot(GetFullUserRequest(int(cname))) fname = rt.user.first_name dname = tr.user.first_name if not event.sender_id == int(user): return await event.answer("This action is not intended for you!.") res = sql.tr_fed(fed_id, int(user)) if not res: return await event.edit("Fed transfer failed!") if res: ses = sql.user_join_fed(fed_id, int(cname)) sql.user_demote_fed(fed_id, int(user)) text = f"Congratulations! Federation {name} ({fed_id}) has successfully been transferred from [{dname}](tg://user?id={cname}) to [{fname}](tg://user?id={user})" await event.edit(text, buttons=None) sxa = "**Fed Transfer**\n" sxa += f"**Fed:** {name}\n" sxa += f"**New Fed Owner:** [{fname}](tg://user?id={user}) - `{user}`\n" sxa += f"**Old Fed Owner:** [{dname}](tg://user?id={cname}) - `{cname}`\n" sxa += f"\n[{fname}](tg://user?id={user}) is now the fed owner. They can promote/demote admins as they like." getfednotif = sql.user_feds_report(int(user)) await tbot.send_message(event.chat_id, sxa) if getfednotif: if int(info["owner"]) != int(chat): await tbot.send_message( int(info["owner"]), sxa) get_fedlog = sql.get_fed_log(fed_id) if get_fedlog: if int(get_fedlog) != int(chat): await tbot.send_message( int(get_fedlog), sxa)