def registerog(bot, update, args):
    """ User Input: /adminaccess <password>"""
    """ args[0] = <password> """
    """ Adds user to admin whitelist """
    OG_IDS = int(args[0])
    if len(args) != 1:
        update.message.reply_text(
            'Register your OG telegram group using the following format:\n/registerog <OG #>'
        )
    else:
        if OG_IDS not in list(range(1, 25)):
            update.message.reply_text("Please enter a OG Number from 1-24!")
            return
        if str(OG_IDS) in list(pb.pb_read("OG_IDS").keys()):
            update.message.reply_text("Sorry, that OG is already registered!")
            return

        # Gets the group ID
        user_id = update.message.chat.id

        # Adds the group ID to the list of OGL GROUP ID in pyrebase
        pb.pb_write(OG_IDS, user_id, "OG_IDS")

        # Feedback message
        update.message.reply_text("OG Registered!")
def addpoints(bot, update, args):
    """ User Input: /addpoints <OG> <Points> """
    """ args[0] = <OG> args[1] = <Points> """
    """ Updates points in firebase """
    if _checkadmin(update, 1) == False:
        return

    og = args[0]
    points = args[1]

    if len(args) != 2 or og.isdigit() == False or points.isdigit() == False:
        update.message.reply_text(
            'Please update points in the following format:\n/addpoints <OG> <Points>'
        )
    else:
        current_points = int(pb.pb_read(og, "Points"))
        current_points += int(points)

        pb.pb_write(int(og), current_points, "Points")

        # Feedback to the command sender
        update.message.reply_text('Added {} points to OG {}!'.format(
            points, og))

        # Feedback to the OG
        try:
            bot.send_message(
                chat_id=OG_IDS_D[og],
                text="You have been awarded {} points!".format(points))
        except KeyError:
            update.message.reply_text('⚠️ OG IS NOT REGISTERED! ⚠️')
Beispiel #3
0
def registerog(bot, update, args):
    """ User Input: /registerog <OG>"""
    """ args[0] = <OG> """
    """ Registers OG to the system """
    OG_IDS = int(args[0])

    # Check correct number of arguments
    if len(args) != 1:

        # Feedback if wrong number of arguments
        update.message.reply_text(
            'Register your OG telegram group using the following format:\n/registerog <OG #>'
        )
    else:

        # Check if OG is a allowed number (1-24)
        if OG_IDS not in list(range(1, 25)):
            update.message.reply_text("Please enter a OG Number from 1-24!")
            return

        # Check if OG is already registered
        if str(OG_IDS) in list(pb.pb_read("OG_IDS")):
            update.message.reply_text("Sorry, that OG is already registered!")
            return

        # Gets the group ID
        user_id = update.message.chat.id

        # Adds the group ID to the list of OGL GROUP ID in pyrebase
        pb.pb_write(OG_IDS, user_id, "OG_IDS")

        # Feedback message
        update.message.reply_text("OG Registered!")
Beispiel #4
0
def adminaccess(bot, update, args):
    """ User Input: /adminaccess <password>"""
    """ args[0] = <password> """
    """ Adds user to admin/execs whitelist """

    # Check correct number of arguments
    if len(args) != 1:

        # Feedback if wrong number of arguments
        update.message.reply_text(
            'Request admin by the following format:\n/adminaccess <password>')
    else:
        # Feedback if correct number of arguments
        # Get command sender user id
        user_id = update.message.chat.id

        # Grant Admin access
        if args[0] == "adminme9999":
            pb.pb_write(user_id, user_id, "Admins")
            update.message.reply_text("You are granted Level 2 Access")

        # Grant Exec Access
        elif args[0] == "adminme0905":
            pb.pb_write(user_id, user_id, "Execs")
            update.message.reply_text("You are granted Level 1 Access")

        # Invalid Password
        else:
            update.message.reply_text("Invalid Password!")
def adminaccess(bot, update, args):
    """ User Input: /adminaccess <password>"""
    """ args[0] = <password> """
    """ Adds user to admin/execs whitelist """

    if len(args) != 1:
        update.message.reply_text(
            'Request admin by the following format:\n/adminaccess <password>')
    else:
        user_id = update.message.from_user.id
        if args[0] == "adminme9090":
            pb.pb_write(user_id, user_id, "Admins")
            update.message.reply_text("You are granted Level 2 Access")
        elif args[0] == "adminme0905":
            pb.pb_write(user_id, user_id, "Execs")
            update.message.reply_text("You are granted Level 1 Access")
        else:
            update.message.reply_text("Invalid Password!")
Beispiel #6
0
def addpointsh(bot, update, args):
    """ User Input: /addpoints <house> <Points> """
    """ args[0] = <OG> args[1] = <Points> """
    """ Updates house points in firebase """
    houses_d = {
        'fira': [1, 2, 3, 4, 5, 6],
        'silo': [7, 8, 9, 10, 11, 12],
        'kepa': [13, 14, 15, 16, 17, 18],
        'egro': [19, 20, 21, 22, 23, 24]
    }

    houses = ['fira', 'silo', 'kepa', 'egro']

    err_msg = 'Please update points to house in the following format:\n/addpointsh <house> <Points>'

    # Check admin privileges
    if _checkadmin(update, 1) == False:
        return

    # Input Validation
    if len(args) != 2:
        update.message.reply_text(err_msg)
        return

    house = args[0]
    points = args[1]

    # Convert input to integer
    # Input Validation
    try:
        points = int(points)
    except ValueError:
        update.message.reply_text(err_msg)

    # Input Validation
    if len(args) != 2 or house not in houses or type(points) != int:
        update.message.reply_text(err_msg)
        return
    else:
        # Add/Minus points to firebase
        current_points = int(pb.pb_read(house, "Points_H"))
        current_points += int(points)
        pb.pb_write(house, current_points, "Points_H")

        # Message to the command sender
        if points >= 0:
            if points == 1:
                msg = '+{} point to {}!'
            else:
                msg = '+{} points to {}!'

        if points < 0:
            if points == -1:
                msg = '{} point from {}!'
            else:
                msg = '{} points from {}!'

        # Feedback to command sender
        update.message.reply_text(msg.format(points, house))

        # Feedback to all OGs in House (only if added points)
        try:
            if points > 0:
                for i in houses_d[house]:
                    bot.send_message(
                        chat_id=OG_IDS_D[i],
                        text="{} has been awarded {} points!".format(
                            house, points))
        except KeyError:
            update.message.reply_text('⚠️ OG IS NOT REGISTERED! ⚠️')
Beispiel #7
0
def addpoints(bot, update, args):
    """ User Input: /addpoints <OG> <Points> """
    """ args[0] = <OG> args[1] = <Points> """
    """ Updates points in firebase """

    # Check admin privileges
    if _checkadmin(update, 1) == False:
        return

    # Input Validation
    if len(args) != 2:
        update.message.reply_text(
            'Please update points in the following format:\n/addpoints <OG> <Points>'
        )
        return

    # Label variables
    og = args[0]
    points = args[1]

    # Convert points input to integer
    # Input Validation
    try:
        points = int(points)
    except ValueError:
        update.message.reply_text(
            'Please update points in the following format:\n/addpoints <OG> <Points>'
        )
        return

    # Input Validation
    if len(args) != 2 or og.isdigit() == False or type(points) != int:
        update.message.reply_text(
            'Please update points in the following format:\n/addpoints <OG> <Points>'
        )
        return
    else:

        # Add points to firebase
        current_points = int(pb.pb_read(og, "Points"))
        current_points += int(points)
        pb.pb_write(int(og), current_points, "Points")

        # Feedback to the command sender
        # + POINTS
        if points >= 0:
            if points == 1:
                msg = '+{} point to OG {}!'
            else:
                msg = '+{} points to OG {}!'

        # - POINTS
        if points < 0:
            if points == -1:
                msg = '{} point from OG {}!'
            else:
                msg = '{} points from OG {}!'

        # Feedback message to sender
        update.message.reply_text(msg.format(points, og))

        # Feedback to the OG (only if added points)
        try:
            if points > 0:
                bot.send_message(
                    chat_id=OG_IDS_D[int(og)],
                    text="You have been awarded {} points!".format(points))
        except KeyError:
            # Feedback message to sender if OG is not registered.
            update.message.reply_text('⚠️ OG IS NOT REGISTERED! ⚠️')