Ejemplo n.º 1
0
async def ft(event):
 if event.is_private:
   return await event.reply("This command is made to be used in group chats, not in pm!")
 fedowner = sql.get_user_owner_fed_full(event.sender_id)
 if not fedowner:
        return await event.reply("You don't have a fed to transfer!")
 for f in fedowner:
          fed_id = f["fed_id"]
          name = f["fed"]["fname"]
 user = await suck(event)
 user_id = user.id
 if user_id == BOT_ID:
   return await event.reply("Yeah I don't use Feds!")
 if user.bot:
  return await event.reply("Bots can't own federations.")
 fedora = sql.get_user_owner_fed_full(user_id)
 try:
  replied_user = await tbot(GetFullUserRequest(user))
  fname = replied_user.user.first_name
 except:
  fname = "User"
 if user_id == event.sender_id:
    return await event.reply("You can only transfer your fed to others!")
 if fedora:
   return await event.reply(f"[{fname}](tg://user?id={user_id}) already owns a federation - they can't own another.")
 getuser = sql.search_user_in_fed(fed_id, user_id)
 if not getuser:
  return await event.reply(f"[{fname}](tg://user?id={user_id}) isn't an admin in {name} -you can only give your fed to other admins.")
 mk = f"{user_id}|{event.sender_id}"
 km = f"{user_id}|{event.sender_id}"
 text = f"[{fname}](tg://user?id={user_id}), please confirm you would like to receive fed {name} (`{fed_id}`) from [{event.sender.first_name}](tg://user?id={event.sender_id})"
 buttons = [Button.inline('Accept', data="fkxd_{}".format(mk)),Button.inline('Decline', data="smewxy_{}".format(km))]
 await tbot.send_message(event.chat_id, text, buttons=buttons)
Ejemplo n.º 2
0
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})"
    )
Ejemplo n.º 3
0
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}'")
Ejemplo n.º 4
0
async def p(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
    fban, fbanreason, fbantime = sql.get_fban_user(fed_id, int(args.id))
    replied_user = await tbot(GetFullUserRequest(user_id))
    fname = replied_user.user.first_name
    if fban:
        if fbanreason != '':
            return await event.reply(
                f"User {fname} is fbanned in {name}. You should unfban them before promoting.\n\nReason:\n{fbanreason}"
            )
        else:
            return await event.reply(
                f"User {fname} is fbanned in {name}. You should unfban them before promoting."
            )
    getuser = sql.search_user_in_fed(fed_id, user_id)
    if getuser:
        return await event.reply(
            f"[{fname}](tg://user?id={args.id}) is already an admin in {name}!"
        )
    try:
        cdata = f"{user_id}|{event.sender_id}"
        await tbot.send_message(
            event.chat_id,
            f"Please get [{fname}](tg://user?id={args.id}) to confirm that they would like to be fed admin for {name}",
            buttons=[
                Button.inline("Confirm", data="fkfed_{}".format(cdata)),
                Button.inline("Cancel", data="smex_{}".format(cdata)),
            ],
        )
    except Exception as e:
        print(e)