Example #1
0
def on_channel_pm(irc, user_mask, user, channel, message):
    command = message.split()
    
    if command[0].lower() == '!setlocation':  
        if len(command) >= 2:
            command = message.split(' ', 1)
            irc.send_private_message(channel, "3SUCESS: You have changed your location.")
            irc.user_info[user.lower()]['location'] = str(command[1])
            userDatabase.save_user_database(irc)
        else:
            irc.send_private_message(channel, "USAGE: !setlocation (Location)")
Example #2
0
def on_channel_pm(bot, user_mask, user, channel, message):
    command = message.split()

    if command[0].lower() == "!join":
        if bot.user_info[user.lower()]["access_level"] >= 1:
            if len(command) == 2:
                bot.join(command[1])
            elif len(command) == 3:
                bot.join(command[1], command[2])
            else:
                bot.send_private_message(channel, "USAGE: !join (Channel) [(Key)]")

    elif command[0].lower() == "!part":
        if bot.user_info[user.lower()]["access_level"] >= 2:
            if len(command) == 2:
                command = message.split(" ", 1)
                bot.part(command[1])
            elif len(command) > 2:
                command = message.split(" ", 2)
                bot.part(command[1], command[2])
            else:
                bot.send_private_message(channel, "USAGE: !part (Channel) [(Message)]")

    elif command[0].lower() == "!cycle":
        if bot.user_info[user.lower()]["access_level"] >= 1:
            if len(command) == 2:
                command = message.split(" ", 1)
                bot.cycle(command[1])
            elif len(command) > 2:
                command = message.split(" ", 2)
                bot.cycle(command[1], command[2])
            else:
                bot.send_private_message(channel, "USAGE: !cycle (Channel) [(Key)]")

    elif command[0].lower() == "!identify":
        if bot.user_info[user.lower()]["access_level"] >= 3:
            if len(command) == 1:
                bot.identify()
            elif len(command) == 2:
                bot.identify(command[1])
            else:
                bot.send_private_message(channel, "USAGE: !identify [(Password)]")

    elif command[0].lower() == "!say":
        if bot.user_info[user.lower()]["access_level"] >= 2:
            if len(command) >= 3:
                command = message.split(" ", 2)
                if len(command[1]) > 0 and len(command[2]) > 0:
                    bot.send_private_message(command[1], command[2])
                else:
                    bot.send_private_message(channel, "USAGE: !say (Channel) (Message)")
            else:
                bot.send_private_message(channel, "USAGE: !say (Channel) (Message)")

    elif command[0].lower() == "!action":
        if bot.user_info[user.lower()]["access_level"] >= 2:
            if len(command) >= 3:
                command = message.split(" ", 2)
                if len(command[1]) > 0 and len(command[2]) > 0:
                    bot.send_private_message(command[1], "\001ACTION " + str(command[2]) + "\001")
                else:
                    bot.send_private_message(channel, "USAGE: !action (Channel) (Action Message)")
            else:
                bot.send_private_message(channel, "USAGE: !action (Channel) (Action Message)")

    elif command[0].lower() == "!spam":
        if bot.user_info[user.lower()]["access_level"] >= 3:
            command = message.split(" ", 3)
            if len(command) == 4:
                if len(command[1]) > 1 and len(command[2]) > 0 and len(command[3]) > 0:
                    if command[2].isdigit():
                        if int(command[2]) in range(0, MAX_SPAM + 1):
                            for i in range(int(command[2])):
                                bot.send_private_message(command[1], command[3])
                            return
            bot.send_private_message(channel, "USAGE: !spam (Channel/Recipient) (Repetition Number) (Message)")

    elif command[0].lower() == "!raw":
        if bot.user_info[user.lower()]["access_level"] >= 3:
            if len(command) >= 2:
                command = message.split(" ", 1)
                if len(command[1]) > 0:
                    if command[1].lower().startswith("quit"):
                        bot.send_private_message(
                            channel, "ERROR: You cannot disconnect the bot with the RAW command. Please use !quit."
                        )
                    elif command[1].lower().startswith("ns drop") or command[1].lower().startswith("msg nickserv drop"):
                        bot.send_private_message(channel, "ERROR: You cannot drop this nick via RAW command.")
                    else:
                        bot.sendRawMessage(command[1])
                    return
            bot.send_private_message(channel, "USAGE: !raw (Server Message)")

    elif command[0].lower() == "!nick":
        if bot.user_info[user.lower()]["access_level"] >= 2:
            if len(command) == 2:
                command = message.split(" ", 1)
                if len(command[1]) > 0:
                    bot.changeNickname(command[1])
                    return
            bot.send_private_message(channel, "USAGE: !nick (Nickname)")

    elif command[0].lower() == "!quit":
        if bot.user_info[user.lower()]["access_level"] >= 3:
            if len(command) == 2 and len(command[1]) > 0:
                command = message.split(" ", 1)
                bot.quit(command[1])
            else:
                bot.quit()

    elif command[0].lower() == "!setbotlevel" or command[0].lower() == "!sbl":
        if bot.user_info[user.lower()]["access_level"] >= 3:
            if len(command) != 3:
                bot.send_private_message(channel, "USAGE: !s[et]b[ot]l[evel] (Nickname) (Bot Level[0-3])")
                return

            command = message.split(" ", 2)
            if not command[2].isdigit():
                bot.send_private_message(channel, "USAGE: !s[et]b[ot]l[evel] (Nickname) (Bot Level[0-3]")
                return

            if command[1].lower() == user.lower() and bot.user_info[user.lower()]["access_level"] < 3:
                bot.send_private_message(channel, "5ERROR: You cannot set your own bot level.")
                return

            if int(command[2]) < 0 or int(command[2]) > 3:
                bot.send_private_message(channel, "5ERROR: Access level must be between 0-3.")
                return

            if command[1].lower() in bot.user_info:
                old_access_level = bot.user_info[command[1].lower()]["access_level"]
                if old_access_level != int(command[2]):
                    bot.user_info[command[1].lower()]["access_level"] = int(command[2])
                    userDatabase.save_user_database(bot)
                    bot.send_private_message(
                        channel,
                        "\u00033SUCESS: Bot Level has changed for {0} from {1} to {2}.".format(
                            str(bot.user_info[command[1].lower()]["ircNickName"]),
                            str(old_access_level),
                            str(command[2]),
                        ),
                    )
                else:
                    bot.send_private_message(
                        channel,
                        "\u00035ERROR: {0} is already set at that level.".format(
                            str(bot.user_info[command[1].lower()]["ircNickName"])
                        ),
                    )
            else:
                bot.send_private_message(channel, "5ERROR: '" + str(command[1]) + "' does not exist.")

    elif command[0].lower() == "!botadmins":
        if bot.user_info[user.lower()]["access_level"] >= 1:
            client_admin_list = dict()
            for nick in bot.user_info:
                if bot.user_info[nick]["access_level"] > 0:
                    client_admin_list[bot.user_info[nick]["nick_name"]] = bot.user_info[nick]["access_level"]

            for users_ranks in sorted(client_admin_list.items(), key=lambda x: x[1], reverse=True):
                nick, level = users_ranks
                if level == 1:
                    bot.send_private_message(channel, str(nick) + ", Trusted User")
                elif level == 2:
                    bot.send_private_message(channel, str(nick) + ", Bot Admin")
                elif level == 3:
                    bot.send_private_message(channel, str(nick) + ", Bot Owner")

    elif command[0].lower() == "!loadmodule":
        if bot.user_info[user.lower()]["access_level"] >= 3:
            bot.send_private_message(
                channel,
                "USAGE: To load a new module, add an import statement into the "
                "modules's __init__.py file, then type !reloadmodules. "
                "This will refresh all modules and import new modules.",
            )

    elif command[0].lower() == "!reloadmodule":
        if bot.user_info[user.lower()]["access_level"] >= 3:
            if len(command) != 2:
                bot.send_private_message(channel, "USAGE: !reloadmodule (Module Name)")
                return

            is_reloaded = bot.reload_module(command[1])
            if is_reloaded:
                bot.send_private_message(channel, "3SUCCESS: Module loaded.")
            else:
                bot.send_private_message(channel, "5ERROR: Module is already loaded or does not exist.")

    elif command[0].lower() == "!unloadmodule":
        if bot.user_info[user.lower()]["access_level"] >= 3:
            if len(command) != 2:
                bot.send_private_message(channel, "USAGE: !unloadmodule (Module Name)")
                return

            is_unloaded = bot.unload_module(command[1])
            if is_unloaded:
                bot.send_private_message(channel, "3SUCCESS: Module unloaded.")
            else:
                bot.send_private_message(channel, "5ERROR: Module is already unloaded or does not exist.")

    elif command[0].lower() == "!reloadallmodules":
        if bot.user_info[user.lower()]["access_level"] >= 3:
            if len(command) == 1:
                is_reloaded = bot.reload_all_modules()
                if is_reloaded:
                    bot.send_private_message(channel, "3SUCCESS: All modules reloaded/reimported.")
                else:
                    bot.send_private_message(
                        channel,
                        "5ERROR: Could not reload all modules. Possibly a compiler error occured with recently modified code.",
                    )

    elif command[0].lower() == ">>":
        if bot.user_info[user.lower()]["access_level"] >= 3:
            if len(command) >= 2:
                command = message.split(" ", 1)

                if command[1].lower().find("quit") != -1:
                    bot.send_private_message(
                        channel, "5ERROR: You cannot quit bot using the console command. You must !quit."
                    )
                    return
                elif command[1].lower().find("ns drop") != -1 or command[1].lower().find("msg nickserv drop") != -1:
                    bot.send_private_message(channel, "5ERROR: You cannot drop this nick.")
                    return

                # create file-like string to capture output
                code_out = StringIO()
                code_err = StringIO()

                # capture output and errors
                sys.stdout = code_out
                sys.stderr = code_err

                try:
                    exec(command[1])
                except Exception as err_str:
                    bot.send_private_message(channel, "ERROR: " + str(err_str))

                # restore stdout and stderr
                sys.stdout = sys.__stdout__
                sys.stderr = sys.__stderr__

                errors = code_err.getvalue()
                results = code_out.getvalue()

                code_out.close()
                code_err.close()

                if len(errors) > 0:
                    bot.send_private_message(channel, "ERROR (via stderr): " + str(errors))

                if len(results) > 0:
                    if results.find("\n") != -1:
                        results = results.split("\n")
                    else:
                        results = results.split(" ")
                    for result in results:
                        bot.send_private_message(channel, str(result))
Example #3
0
def on_channel_pm(irc, user_mask, user, channel, message):
    command = message.split()

    if command[0].lower() == '!setwhatpulse' or command[0].lower() == '!setwp':
        if len(command) != 2:
            irc.send_private_message(channel, "USAGE: !setw[hat]p[ulse] (WhatPulse ID/WhatPulse Username)")
            return
        if command[1].isdigit():
            irc.send_private_message(channel, "USAGE: !setw[hat]p[ulse] (WhatPulse ID/WhatPulse Username)")
            return

        irc.send_private_message(channel, "3SUCCESS: Your WhatPulse ID has been changed.")
        irc.user_info[user.lower()]['whatpulse'] = str(command[1])
        userDatabase.save_user_database(irc)

    elif command[0].lower() == '!whatpulse' or command[0].lower() == '!wp':
        param = str()
        if len(command) == 1:
            param = str(irc.userData[user.lower()]['whatpulse'])
            if irc.userData[user.lower()]['whatpulse'] == "":
                irc.send_private_message(channel, "5ERROR: You have not set your WhatPulse ID yet.")
                irc.send_private_message(channel,
                                         "USAGE: !w[hat]p[ulse] (WhatPulse ID/WhatPulse Username/IRC Nickname)")
                irc.send_private_message(channel, "USAGE: !setw[hat]p[ulse] (WhatPulse ID)")
                return
        elif len(command) == 2:
            command = message.split(' ', 1)
            param = str(command[1])
            if command[1].lower() in irc.user_info:
                if irc.user_infoData[command[1].lower()]['whatpulse'] != "":
                    param = str(irc.userData[command[1].lower()]['whatpulse'])

        try:
            response = urllib.request.urlopen(get_what_pulse_url(param))
            html_source = response.read().decode('utf-8')
            response.close()
        except IOError:
            irc.send_private_message(channel, "5ERROR: The WhatPulse service is currently unavailable.")
            return

        try:
            whatpulse_info = json.loads(html_source)
        except ValueError:
            irc.send_private_message(channel, '5ERROR: An unknown WhatPulse Username/ID was given.')
            return

        if 'error' in whatpulse_info:
            irc.send_private_message(channel, '5ERROR: An unknown WhatPulse Username/ID was given.')
            return

        account_name = whatpulse_info['AccountName']  # Username
        user_id = whatpulse_info['UserID']  # ID
        country = whatpulse_info['Country']  # User's Country
        joined_date = whatpulse_info['DateJoined']  # Date Joined
        last_pulse_date = whatpulse_info['LastPulse']  # Last Pulsed
        pulses = whatpulse_info['Pulses']  # Pulses
        total_key_count = whatpulse_info['Keys']  # Total Key Count
        total_mouse_clicks = whatpulse_info['Clicks']  # Total Mouse Clicks
        avg_kpp = whatpulse_info['AvKeysPerPulse']  # Average Keys Per Pulse
        avg_cpp = whatpulse_info['AvClicksPerPulse']  # Average Clicks Per Pulse
        avg_kps = whatpulse_info['AvKPS']  # Average Keys Per Second
        avg_cps = whatpulse_info['AvCPS']  # Average Clicks Per Second
        # Ranks
        clicks_rank = whatpulse_info['Ranks']['Clicks']
        keys_rank = whatpulse_info['Ranks']['Keys']
        uptime_rank = whatpulse_info['Ranks']['Uptime']
        irc.send_private_message(channel,
                                 "\u000310WhatPulse:\u0003 {0}(ID:{1}) \u000310Country:\u0003 {2} "
                                 "\u000310Date Joined:\u0003 {3} \u000310LastPulsed:\u0003 {4} "
                                 "\u000310Pulses:\u0003 {5} \u000310Keys:\u0003 {6} \u000310Clicks:\u0003 {7} "
                                 "\u000310AvKeysPerPulse:\u0003 {8} \u000310AvClicksPerPulse:\u0003 {9} "
                                 "\u000310AvKeyPerSecond:\u0003 {10} \u000310AvClicksPerSecond:\u0003 {11} "
                                 "\u000310Rank: Clicks:\u0003 {12} \u000310Keys:\u0003 {13} "
                                 "\u000310Uptime:\u0003 {14}".format(
                                     str(account_name), str(user_id), str(country), str(joined_date),
                                     str(last_pulse_date),
                                     str(pulses), str(total_key_count), str(total_mouse_clicks), str(avg_kpp),
                                     str(avg_cpp),
                                     str(avg_kps), str(avg_cps), str(clicks_rank), str(keys_rank), str(uptime_rank)))
Example #4
0
def on_channel_pm(irc, user_mask, user, channel, message):
    global tmp_quiz_data, quiz_data

    command = message.split()

    for chan in tmp_quiz_data:
        if message.lower() in tmp_quiz_data[chan]["wrongAnswers"] or message.lower() == tmp_quiz_data[chan]["rightAnswer"]:
            if user.lower() not in tmp_quiz_data[chan]['players']:
                tmp_quiz_data[chan]['players'][user.lower()] = 0

            if tmp_quiz_data[chan]['players'][user.lower()] == 0:
                if message.lower() == tmp_quiz_data[chan]["rightAnswer"].lower():
                    real_time_secs = time.time()
                    irc.userData[user.lower()]["quiz"]["correct"] += 1
                    userDatabase.save_user_database(irc)
                    irc.send_private_message(channel,
                                             '3Congrats 1' + user + ', 3You have correctly answered the question.')
                    quiz_id = tmp_quiz_data[channel.lower()]['id']

                    if round(real_time_secs - tmp_quiz_data[chan]["startTime"], 2) < \
                            quiz_data["questions"][quiz_id]["bestTime"][1]:
                        time_dif = quiz_data["questions"][quiz_id]["bestTime"][1] - (
                            real_time_secs - tmp_quiz_data[chan]["startTime"])
                        quiz_data["questions"][quiz_id]["bestTime"][1] = round(
                            real_time_secs - tmp_quiz_data[chan]["startTime"], 2)
                        quiz_data["questions"][quiz_id]["bestTime"][0] = user
                        irc.send_private_message(channel, user + '3 has just set the new best time of ' + str(
                            quiz_data["questions"][quiz_id]["bestTime"][
                                1]) + ' 3secs. ' + user + ' 3beat the old best time by ' + str(
                            round(time_dif, 2)) + ' 3secs.')

                    elif quiz_data["questions"][quiz_id]["bestTime"][0] == "":
                        quiz_data["questions"][quiz_id]["bestTime"][1] = round(
                            real_time_secs - tmp_quiz_data[chan]["startTime"], 2)
                        quiz_data["questions"][quiz_id]["bestTime"][0] = user
                        irc.send_private_message(channel, user + '3 has just set the new best time of ' + str(
                            quiz_data["questions"][quiz_id]["bestTime"][1]) + ' 3secs.')

                    quiz_data["questions"][quiz_id]["answeredCorrect"] += 1
                    save_quiz_database()
                    del tmp_quiz_data[chan]
                else:
                    quiz_id = tmp_quiz_data[channel.lower()]['id']
                    irc.send_private_message(channel,
                                             '5Sorry 1' + user + ', 5that is the wrong answer. You cannot attempt anymore for this round.')
                    tmp_quiz_data[chan]["players"][user.lower()] += 1
                    quiz_data["questions"][quiz_id]["answeredIncorrect"] += 1
                    irc.user_info[user.lower()]["quiz"]["incorrect"] += 1

                irc.userData[user.lower()]["quiz"]["participated"] += 1
                userDatabase.save_user_database(irc)
                return

    if command[0].lower() == '!quizhelp':
        irc.send_private_message(channel,
                                 user + ', basically you get given a multi-choice question and your job is to carefully type in what you think is the right answer before the time runs out and before any other IRC users guess the right answer. You can only guess once, so double check that you are right. So what are you waiting for? start a !quiz.')

    elif command[0].lower() == '!quiz':
        if len(quiz_data['questions']) == 0:
            irc.send_private_message(channel, '5ERROR: No quiz questions in database.')
            return

        #if len(quiz_data['questions']) in range(0, 10):
        #    irc.send_private_message(channel,
        #                             '5ERROR: There are only a few quiz questions in database. Until more are added, the quiz will be unavailable.')
        #    return

        if channel in tmp_quiz_data:
            return

        random_quiz_id = random.randint(0, len(quiz_data['questions']))

        # print quizQuestionID
        # print "creating tmp data"
        tmp_quiz_data[channel] = dict()
        tmp_quiz_data[channel]['isActive'] = False
        tmp_quiz_data[channel]["numOfPlayers"] = 0
        tmp_quiz_data[channel]["players"] = {}
        tmp_quiz_data[channel]["timePeriod"] = float(quiz_data['questions'][random_quiz_id]["timePeriod"])
        tmp_quiz_data[channel]["rightAnswer"] = quiz_data['questions'][random_quiz_id]['answers'][0].lower()
        tmp_quiz_data[channel]["wrongAnswers"] = []

        for i in range(1, len(quiz_data['questions'][random_quiz_id]['answers'])):
            tmp_quiz_data[channel]["wrongAnswers"].append(quiz_data['questions'][random_quiz_id]['answers'][i].lower())

        tmp_quiz_data[channel]["startTime"] = round(time.time(), 1)
        tmp_quiz_data[channel]['id'] = random_quiz_id
        # print "creating tmp data (part 2)"

        quiz_answers = quiz_data['questions'][random_quiz_id]['answers']
        quiz_answers = sorted(quiz_answers, key=lambda k: random.random())

        tmp_quiz_data[channel.lower()]['isActive'] = True
        irc.send_private_message(channel, '6Question: "' + str(
            quiz_data['questions'][random_quiz_id]["question"]) + '" 6Answers: ' + str(quiz_answers).strip(
            '[]') + '.')
        if quiz_data['questions'][random_quiz_id]["bestTime"][0] != "":
            irc.send_private_message(channel,
                                     '\u00036Best time set by\u0003 {0} \u00036in\u0003 {1} \u00036secs.'.format(
                                         str(quiz_data['questions'][random_quiz_id]["bestTime"][0]),
                                         str(quiz_data['questions'][random_quiz_id]["bestTime"][1])))

    elif command[0].lower() == '!numberofquizquestions':
        irc.send_private_message(channel,
                                 "There are " + str(len(quiz_data['questions'])) + " questions in the Quiz database.")

    elif command[0].lower() == '!createquizquestion' or command[0].lower() == '!cqq':
        if irc.user_info[user.lower()]["access_level"] >= 1:
            question_re = re.compile("!c(?:(?:reate)?)q(?:(?:uiz)?)q(?:(?:uestion)?)\s(.*\?)\s([0-9]+[0-9]?)\s(.*)",
                                     re.IGNORECASE)
            match = question_re.match(message)
            if match:
                command_params = question_re.findall(message)[0]
                print(command_params)
                question = command_params[0]
                time_period = command_params[1]
                answer_str = command_params[2]

                if re.match('"([\w\s]*)"', answer_str):
                    answers = re.findall('"([\w\s]*)"', answer_str)
                else:
                    irc.send_private_message(channel, "USAGE: !c[reate]q[uiz]q[uestion] (Question)? "
                                                      "(Question Time Period (in Secs)) \"(Correct Answer)\" "
                                                      "\"(Wrong Answer)\" [\"(Wrong Answer)\" \"(...)\"]")
                    irc.send_private_message(channel, "EXAMPLE: !cqq 1 + 1 = ? 2 1 3 4 5")
                    return

                if int(time_period) < 5 or int(time_period) > 60:
                    irc.send_private_message(channel,
                                             '5ERROR: The time period is not pratical. Set a more appropriate time period (between 5 - 60 seconds).')
                    return

                for question_data in quiz_data['questions']:
                    if question_data['question'].lower() == question.lower():
                        irc.send_private_message(channel, '5ERROR: The question has already been created.')
                        return

                question_data = {"question": question,
                                 "answers": [],
                                 "bestTime": ["", 0.0],
                                 "answeredCorrect": 0,
                                 "answeredIncorrect": 0,
                                 "answeredCorrectMessage": "",
                                 "showAnswers": True,
                                 "timePeriod": float(time_period),
                                 "creator": user,
                                 "createdTime": time.time()
                                 }

                for i in range(0, len(answers)):
                    question_data['answers'].append(answers[i])

                quiz_data['questions'].append(question_data)
                save_quiz_database()

                irc.send_private_message(channel, '3SUCCESS: Quiz Question, "' + question + '" (ID: ' + str(
                    len(quiz_data['questions']) - 1) + ') has been added into the quiz database.')
            else:
                irc.send_private_message(channel, "USAGE: !c[reate]q[uiz]q[uestion] (Question)? "
                                                  "(Question Time Period (in Secs)) \"(Correct Answer)\" "
                                                  "\"(Wrong Answer)\" [\"(Wrong Answer)\" \"(...)\"]")
                irc.send_private_message(channel, "EXAMPLE: !cqq 1 + 1 = ? 2 1 3 4 5")
Example #5
0
def on_channel_pm(irc, user_mask, user, channel, message):
    command = message.split()

    if command[0].lower() == "!steam":
        steam_url = str()
        if len(command) == 1:
            if len(irc.user_info[user.lower()]["steam64"]) > 0:
                steam_url = (
                    "http://steamcommunity.com/profiles/" + str(irc.user_info[user.lower()]["steam64"]) + "/?xml=1"
                )
            else:
                irc.send_private_message(channel, "USAGE: !steam (Custom URL/Steam64ID)")
                irc.send_private_message(channel, "USAGE: !setsteamid (Steam64ID)")
                return
        elif len(command) == 2:
            if command[1].lower() in irc.user_info:
                if len(irc.user_info[command[1].lower()]["steam64"]) > 0:
                    steam_url = (
                        "http://steamcommunity.com/profiles/"
                        + str(irc.user_info[command[1].lower()]["steam64"])
                        + "/?xml=1"
                    )
                else:
                    irc.send_private_message(
                        channel,
                        str(irc.user_info[command[1].lower()]["ircNickName"])
                        + " hasn't their steam64ID yet. Attempting to process anyways...",
                    )
                    steam_url = "http://steamcommunity.com/id/" + str(command[1]) + "/?xml=1"
            else:
                if len(command[1]) == 17 and command[1].isdigit():
                    steam_url = "http://steamcommunity.com/profiles/" + str(command[1]) + "/?xml=1"
                else:
                    steam_url = "http://steamcommunity.com/id/" + str(command[1]) + "/?xml=1"

        print(1)
        try:
            response = urllib.request.urlopen(steam_url)
            html_source = response.read().decode("utf-8")
            response.close()
        except IOError:
            irc.send_private_message(channel, "5ERROR: The Steam API is currently unavailable.")
            return
        print(2)
        root = Et.fromstring(html_source)
        if root.tag == "response":
            if root[0].tag == "error":
                irc.send_private_message(channel, "5ERROR: " + str(root[0][0].text))
            return
        else:
            if root.tag == "profile":
                pass

            # steam_id64 = root.find('[steamID64]').text
            steam_id = root.find("steamID").text
            online_state = root.find("onlineState").text
            state_message = root.find("stateMessage").text
            vac_status = root.find("vacBanned").text
            if vac_status == "1":
                vac_status = "4Banned"
            else:
                vac_status = "3Not Banned"
            register_date = root.find("memberSince").text
            ranking = root.find("steamRating").text
            location = root.find("location").text
            # real_name = root.find('[realname]').text
            most_played_games = str()
            for most_played_game in root.find("mostPlayedGames").findall("mostPlayedGame"):
                game_name = most_played_game.find("gameName").text
                if len(most_played_games) == 0:
                    most_played_games += game_name
                else:
                    most_played_games += ", " + game_name

            irc.send_private_message(
                channel,
                "10SteamID:1 "
                + str(steam_id)
                + " 10Online State:1 "
                + str(online_state.capitalize())
                + " 10General State:1 '"
                + str(state_message)
                + "' 10VAC Banned:1 "
                + str(vac_status)
                + " 10Steam Member Since:1 "
                + str(register_date)
                + " 10Steam Rating:1 "
                + str(ranking)
                + " 10Location:1 "
                + str(location)
                + " 10Most Played Games: 1"
                + str(most_played_games),
            )

    if command[0].lower() == "!setsteamid":
        if len(command) != 2:
            irc.send_private_message(channel, "USAGE: !setsteamid (Steam64ID)")
            irc.send_private_message(channel, "USAGE: To find your Steam64ID, go to http://steamidconverter.com/")
            return

        if not command[1].isdigit():
            irc.send_private_message(channel, "USAGE: !setsteamid (Steam64ID)")
            irc.send_private_message(channel, "USAGE: To find your Steam64ID, go to http://steamidconverter.com/")
            return

        irc.send_private_message(channel, "3SUCESS: You have changed your SteamID(64-Bit).")
        irc.user_info[user.lower()]["steam64"] = str(command[1])
        userDatabase.save_user_database(irc)