Beispiel #1
0
def user_join_fed(bot: Bot, update: Update, args: List[str]):

        chat = update.effective_chat  # type: Optional[Chat]
        user = update.effective_user  # type: Optional[User]
        fed_id = sql.get_fed_id(chat.id)

        if is_user_fed_owner(fed_id, user.id) == False:
                update.effective_message.reply_text("Only fed owner can do this!")
                return

        msg = update.effective_message  # type: Optional[Message]
        user_id = extract_user(msg, args)
        if user_id:
                user = bot.get_chat(user_id)

        elif not msg.reply_to_message and not args:
                user = msg.from_user

        elif not msg.reply_to_message and (not args or (
                len(args) >= 1 and not args[0].startswith("@") and not args[0].isdigit() and not msg.parse_entities(
                [MessageEntity.TEXT_MENTION]))):
                msg.reply_text("I can't extract a user from this.")
                return

        else:
                return

        print(sql.search_user_in_fed(fed_id, user_id))

        if not sql.search_user_in_fed(fed_id, user_id) == False:
                update.effective_message.reply_text("I can't promote user which already a fed admin! But I can demote him.")
                return

        res = sql.user_join_fed(fed_id, user_id)
        update.effective_message.reply_text("Joined to fed!")
Beispiel #2
0
def user_join_fed(bot: Bot, update: Update, args: List[str]):

        chat = update.effective_chat  # type: Optional[Chat]
        user = update.effective_user  # type: Optional[User]
        fed_id = sql.get_fed_id(chat.id)

        if is_user_fed_owner(fed_id, user.id) == False:
                update.effective_message.reply_text(tld(chat.id, "Only fed owner can do this!"))
                return

        msg = update.effective_message  # type: Optional[Message]
        user_id = extract_user(msg, args)
        if user_id:
                user = bot.get_chat(user_id)

        elif not msg.reply_to_message and not args:
                user = msg.from_user

        elif not msg.reply_to_message and (not args or (
                len(args) >= 1 and not args[0].startswith("@") and not args[0].isdigit() and not msg.parse_entities(
                [MessageEntity.TEXT_MENTION]))):
                msg.reply_text(tld(chat.id, "I can't extract a user from this."))
                return

        else:
            return

        print(sql.search_user_in_fed(fed_id, user_id))

        #if user_id == user_id:
        #        update.effective_message.reply_text(tld(chat.id, "Are you gonna promote yourself?"))
        #        return

        fed_id = sql.get_fed_id(chat.id)
        info = sql.get_fed_info(fed_id)
        OW = bot.get_chat(info.owner_id)
        HAHA = OW.id
        if user_id == HAHA:
                update.effective_message.reply_text(tld(chat.id, "Why are you trying to promote federation owner!?"))
                return

        if not sql.search_user_in_fed(fed_id, user_id) == False:
                update.effective_message.reply_text(tld(chat.id, "I can't promote user which is already a fed admin! But I can demote them."))
                return

        if user_id == bot.id:
                update.effective_message.reply_text(tld(chat.id, "I am already the federation admin and the one that manage it!"))
                return

        #else:
        #        return

        res = sql.user_join_fed(fed_id, user_id)
        if not res:
                update.effective_message.reply_text(tld(chat.id, "Failed to promoted! It might be because you are admin in another federation! Our code is still buggy, We are sorry for that!"))
                return

        update.effective_message.reply_text(tld(chat.id, "Promoted Successfully!"))
Beispiel #3
0
def user_demote_fed(bot: Bot, update: Update, args: List[str]):
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user  # type: Optional[User]
    fed_id = sql.get_fed_id(chat.id)

    if is_user_fed_owner(fed_id, user.id) == False:
        update.effective_message.reply_text(
            tld(chat.id, "Only fed owner can do this!"))
        return

    msg = update.effective_message  # type: Optional[Message]
    user_id = extract_user(msg, args)
    if user_id:
        user = bot.get_chat(user_id)

    elif not msg.reply_to_message and not args:
        user = msg.from_user

    elif not msg.reply_to_message and (
            not args or
        (len(args) >= 1 and not args[0].startswith("@")
         and not args[0].isdigit()
         and not msg.parse_entities([MessageEntity.TEXT_MENTION]))):
        msg.reply_text(tld(chat.id, "I can't extract a user from this."))
        return

    #else:
    #        return

    if user_id == bot.id:
        update.effective_message.reply_text(
            tld(
                chat.id,
                "What are you trying to do? Demoting me from your federation?")
        )
        return

    if sql.search_user_in_fed(fed_id, user_id) == False:
        update.effective_message.reply_text(
            tld(
                chat.id,
                "I can't demote user which is not a fed admin! If you wanna bring him to tears, promote him first!"
            ))
        return

    res = sql.user_demote_fed(fed_id, user_id)
    if res == True:
        update.effective_message.reply_text(tld(chat.id, "Get out of here!"))
    else:
        update.effective_message.reply_text(
            tld(chat.id, "I can not remove him, I am powerless!"))
Beispiel #4
0
def user_join_fed(bot: Bot, update: Update, args: List[str]):
	spam = spamfilters(update.effective_message.text, update.effective_message.from_user.id, update.effective_chat.id)
	if spam == True:
		return update.effective_message.reply_text("Spammer detected! Ignoring user.")

	chat = update.effective_chat  # type: Optional[Chat]
	user = update.effective_user  # type: Optional[User]
	msg = update.effective_message  # type: Optional[Message]
	fed_id = sql.get_fed_id(chat.id)

	if is_user_fed_owner(fed_id, user.id):
		user_id = extract_user(msg, args)
		if user_id:
			user = bot.get_chat(user_id)
		elif not msg.reply_to_message and not args:
			user = msg.from_user
		elif not msg.reply_to_message and (not args or (
			len(args) >= 1 and not args[0].startswith("@") and not args[0].isdigit() and not msg.parse_entities(
			[MessageEntity.TEXT_MENTION]))):
			msg.reply_text("I cannot extract users from this message")
			return
		else:
			LOGGER.warning('error')
		getuser = sql.search_user_in_fed(fed_id, user_id)
		fed_id = sql.get_fed_id(chat.id)
		info = sql.get_fed_info(fed_id)
		get_owner = eval(info['fusers'])['owner']
		get_owner = bot.get_chat(get_owner).id
		if user_id == get_owner:
			update.effective_message.reply_text("Why are you trying to promote a federation owner?")
			return
		if getuser:
			update.effective_message.reply_text("I cannot promote users who are already federation admins! But I can remove them if you want!")
			return
		if user_id == bot.id:
			update.effective_message.reply_text("I already am a federation admin in all federations!")
			return
		res = sql.user_join_fed(fed_id, user_id)
		if res:
			update.effective_message.reply_text("💖 Successfully Promoted!")
		else:
			update.effective_message.reply_text("Failed to promote!")
	else:
		update.effective_message.reply_text("Only federation owners can do this!")
Beispiel #5
0
def user_demote_fed(bot: Bot, update: Update, args: List[str]):
	spam = spamfilters(update.effective_message.text, update.effective_message.from_user.id, update.effective_chat.id)
	if spam == True:
		return update.effective_message.reply_text("Spammer detected! Ignoring user.")

	chat = update.effective_chat  # type: Optional[Chat]
	user = update.effective_user  # type: Optional[User]
	fed_id = sql.get_fed_id(chat.id)

	if is_user_fed_owner(fed_id, user.id):
		msg = update.effective_message  # type: Optional[Message]
		user_id = extract_user(msg, args)
		if user_id:
			user = bot.get_chat(user_id)

		elif not msg.reply_to_message and not args:
			user = msg.from_user

		elif not msg.reply_to_message and (not args or (
			len(args) >= 1 and not args[0].startswith("@") and not args[0].isdigit() and not msg.parse_entities(
			[MessageEntity.TEXT_MENTION]))):
			msg.reply_text("I cannot extract users from this message")
			return
		else:
			LOGGER.warning('error')

		if user_id == bot.id:
			update.effective_message.reply_text("Are you trying to demote me as a federation admin? Do you think I am stupid?")
			return

		if sql.search_user_in_fed(fed_id, user_id) == False:
			update.effective_message.reply_text("I cannot demote people who are not federation admins!")
			return

		res = sql.user_demote_fed(fed_id, user_id)
		if res == True:
			update.effective_message.reply_text("Get out of here!")
		else:
			update.effective_message.reply_text("Demotion failed!")
	else:
		update.effective_message.reply_text("Only federation owners can do this!")
		return
Beispiel #6
0
def user_join_fed(bot: Bot, update: Update, args: List[str]):
	chat = update.effective_chat  # type: Optional[Chat]
	user = update.effective_user  # type: Optional[User]
	msg = update.effective_message  # type: Optional[Message]
	fed_id = sql.get_fed_id(chat.id)

	if is_user_fed_owner(fed_id, user.id):
		user_id = extract_user(msg, args)
		if user_id:
			user = bot.get_chat(user_id)
		elif not msg.reply_to_message and not args:
			user = msg.from_user
		elif not msg.reply_to_message and (not args or (
			len(args) >= 1 and not args[0].startswith("@") and not args[0].isdigit() and not msg.parse_entities(
			[MessageEntity.TEXT_MENTION]))):
			msg.reply_text("I cannot extract users from this message.")
			return
		else:
			LOGGER.warning('error')
		getuser = sql.search_user_in_fed(fed_id, user_id)
		fed_id = sql.get_fed_id(chat.id)
		info = sql.get_fed_info(fed_id)
		get_owner = eval(info['fusers'])['owner']
		get_owner = bot.get_chat(get_owner).id
		if user_id == get_owner:
			update.effective_message.reply_text("Why are you trying to promote the federation owner?")
			return
		if getuser:
			update.effective_message.reply_text("This user is already an admin of the federation!")
			return
		if user_id == bot.id:
			update.effective_message.reply_text("Hah, you're really funny.")
			return
		res = sql.user_join_fed(fed_id, user_id)
		if res:
			update.effective_message.reply_text("Successfully Promoted!")
		else:
			update.effective_message.reply_text("Failed to promote!")
	else:
		update.effective_message.reply_text("Only federation owners can do this!")
Beispiel #7
0
def user_demote_fed(bot: Bot, update: Update, args: List[str]):
	chat = update.effective_chat  # type: Optional[Chat]
	user = update.effective_user  # type: Optional[User]
	fed_id = sql.get_fed_id(chat.id)

	if is_user_fed_owner(fed_id, user.id):
		msg = update.effective_message  # type: Optional[Message]
		user_id = extract_user(msg, args)
		if user_id:
			user = bot.get_chat(user_id)

		elif not msg.reply_to_message and not args:
			user = msg.from_user

		elif not msg.reply_to_message and (not args or (
			len(args) >= 1 and not args[0].startswith("@") and not args[0].isdigit() and not msg.parse_entities(
			[MessageEntity.TEXT_MENTION]))):
			msg.reply_text("I cannot extract users from this message.")
			return
		else:
			LOGGER.warning('error')

		if user_id == bot.id:
			update.effective_message.reply_text("Boi, what are you even trying to do?")
			return

		if sql.search_user_in_fed(fed_id, user_id) == False:
			update.effective_message.reply_text("This user isn't even a federation admin!")
			return

		res = sql.user_demote_fed(fed_id, user_id)
		if res == True:
			update.effective_message.reply_text("Get out of here!")
		else:
			update.effective_message.reply_text("Failed to demote!")
	else:
		update.effective_message.reply_text("Only federation owners can do this!")
		return