예제 #1
0
def run_tests():
    print("Login Test:")
    print(functions.login())
    print("\nGet Level Test:")
    print(functions.get_level(123))
    print("\nRandom Waifu Test:")
    print(functions.waifu(0))
    print("\nRandom Husbando Test:")
    print(functions.waifu(1))
    # Name should be flipped
    print("\nWaifuRegister Test:")
    print(functions.waifuregister(123, "Test Username", "rin shibuya", 0))
    # Name should return "not enough images"
    print("\nHusbandoReigster Paste Test:")
    print(functions.waifuregister(123, "Test Username", "admiral", 1))
    # Name should work
    print("\nHusbandoReigster Test:")
    print(
        functions.waifuregister(123, "Test Username",
                                "admiral (kantai collection)", 1))
    print("\nMyWaifu Test:")
    print(functions.mywaifu(123, 0))
    print("\nMyHusbando Test:")
    print(functions.mywaifu(123, 1))
    print("\nRemoveWaifu Test:")
    print(functions.waifuremove(123, 0))
    print("\nRemoveHusbando Test:")
    print(functions.waifuremove(123, 1))
    print("\nRandom OTP Test:")
    print(functions.otp(""))
    print("\nRandom List Shipgirl Test:")
    print(functions.random_list("Shipgirl", ""))
    print("\nRandom List Imouto Test:")
    print(functions.random_list("Imouto", ""))
    print("\nRandom List Shota Test:")
    print(functions.random_list("Shota", ""))
    print("Sleeping for 10 seconds...")
    time.sleep(10)
    print("\nRandom List Sensei Test:")
    print(functions.random_list("Sensei", ""))
    print("\nRandom List Senpai Test:")
    print(functions.random_list("Senpai", ""))
    print("\nRandom List Kouhai Test:")
    print(functions.random_list("Kouhai", ""))
    print("\nRandom List Kouhai Male Test:")
    print(functions.random_list("Kouhai", "male"))
    print("\nAiring Test:")
    print(functions.airing("One Piece"))
    print("\nFinished all Tests!")
예제 #2
0
def run_tests():
    print("Login Test:")
    print(functions.login())
    print("\nGet Level Test:")
    print(functions.get_level(123))
    print("\nRandom Waifu Test:")
    print(functions.waifu(0))
    print("\nRandom Husbando Test:")
    print(functions.waifu(1))
    # Name should be flipped
    print("\nWaifuRegister Test:")
    print(functions.waifuregister(123, "Test Username", "rin shibuya", 0))
    # Name should return "not enough images"
    print("\nHusbandoReigster Paste Test:")
    print(functions.waifuregister(123, "Test Username", "admiral", 1))
    # Name should work
    print("\nHusbandoReigster Test:")
    print(functions.waifuregister(123, "Test Username",
                                       "admiral (kantai collection)", 1))
    print("\nMyWaifu Test:")
    print(functions.mywaifu(123, 0))
    print("\nMyHusbando Test:")
    print(functions.mywaifu(123, 1))
    print("\nRemoveWaifu Test:")
    print(functions.waifuremove(123, 0))
    print("\nRemoveHusbando Test:")
    print(functions.waifuremove(123, 1))
    print("\nRandom OTP Test:")
    print(functions.otp(""))
    print("\nRandom List Shipgirl Test:")
    print(functions.random_list("Shipgirl", ""))
    print("\nRandom List Imouto Test:")
    print(functions.random_list("Imouto", ""))
    print("\nRandom List Shota Test:")
    print(functions.random_list("Shota", ""))
    print("Sleeping for 10 seconds...")
    time.sleep(10)
    print("\nRandom List Sensei Test:")
    print(functions.random_list("Sensei", ""))
    print("\nRandom List Senpai Test:")
    print(functions.random_list("Senpai", ""))
    print("\nRandom List Kouhai Test:")
    print(functions.random_list("Kouhai", ""))
    print("\nRandom List Kouhai Male Test:")
    print(functions.random_list("Kouhai", "male"))
    print("\nAiring Test:")
    print(functions.airing("One Piece"))
    print("\nFinished all Tests!")
예제 #3
0
def run_tests():
    print("Login Test:")
    api = functions.login()
    print(api)
    print("\nTest Tweet")
    msg = "@AceStatusBot Running Tests..."
    api.update_status(status=msg)
    print("\nGet Level Test:")
    print(functions.get_level(123))
    print("\nRandom Waifu Test:")
    print(functions.waifu(0))
    print("\nRandom Husbando Test:")
    print(functions.waifu(1))
    # Name should be flipped
    print("\nWaifuRegister Test:")
    print(functions.waifuregister(123, "Test Username", "rin shibuya", 0))
    # Name should return "not enough images"
    print("\nHusbandoReigster Paste Test:")
    print(functions.waifuregister(123, "Test Username", "admiral", 1))
    # Name should work
    print("\nHusbandoReigster Test:")
    print(
        functions.waifuregister(123, "Test Username",
                                "admiral (kantai collection)", 1))
    print("\nMyWaifu Test:")
    print(functions.mywaifu(123, 0))
    print("\nMyHusbando Test:")
    print(functions.mywaifu(123, 1))
    print("\nRemoveWaifu Test:")
    print(functions.waifuremove(123, 0))
    print("\nRemoveHusbando Test:")
    print(functions.waifuremove(123, 1))
    print("\nRandom OTP Test:")
    print(functions.otp(""))
    print("\nRandom List Shipgirl Test:")
    m, i = functions.random_list("Shipgirl", "")
    print(m, i)
    print("\nRandom List Imouto Test:")
    m, ii = functions.random_list("Imouto", "")
    if not i:
        i = ii
    print(m, ii)
    print("\nRandom List Shota Test:")
    print(functions.random_list("Shota", ""))
    print("Sleeping for 10 seconds...")
    time.sleep(10)
    print("\nRandom List Sensei Test:")
    print(functions.random_list("Sensei", ""))
    print("\nRandom List Senpai Test:")
    m, ii = functions.random_list("Senpai", "")
    if not i:
        i = ii
    print(m, ii)
    print("\nRandom List Kouhai Test:")
    print(functions.random_list("Kouhai", ""))
    print("\nRandom List Kouhai Male Test:")
    print(functions.random_list("Kouhai", "male"))
    print("\nAiring Test:")
    print(functions.airing("One Piece"))
    print("\nTest Tweet (with Image)")
    msg = "@AceStatusBot Test Tweet with Image..."
    api.update_with_media(i, status=msg)
    print("\nTest Tweet (with Video)")
    tags = [
        "rating:safe", "webm", "-extremely_large_filesize", "-large_filesize",
        "-no_audio"
    ]
    i = get_image_online(tags, 0, 1, "")
    msg = "@AceStatusBot Test Tweet with Video..."
    api.update_with_media(i, status=msg)
    print("\nFinished all Tests!")
예제 #4
0
def tweet_command(_API, status, tweet, command):
    tweet_image = False
    user = status.user

    # Mod command
    is_mod = [True if user.id in MOD_IDS else False][0]
    if command == "DelLimits":
        if is_mod:
            their_id, cmd = tweet.split(' ', 2)
            remove_all_limit(their_id, cmd)
            print("[INFO] Removed limits for {0} - {1}".format(their_id, cmd))
        return False, False

    if not is_mod:
        user_is_limited = user_spam_check(user.id, user.screen_name, command)
        if isinstance(user_is_limited, str):
            # User hit limit, tweet warning
            command = ""
            tweet = user_is_limited
        elif not user_is_limited:
            # User is limited, return
            print("[{0}] User is limited! Ignoring...".format(
                time.strftime("%Y-%m-%d %H:%M")))
            return False
    if settings['count_on']:
        func.count_trigger(command, user.id)

    # Joke Commands
    if command == "spook":
        tweet, tweet_image = func.spookjoke()
    if command == "Spoiler":
        tweet = random.choice(
            utils.file_to_list(
                os.path.join(settings['list_loc'], "spoilers.txt")))
    elif command == "!Level":
        tweet = func.get_level(user.id)

    # Main Commands
    if command == "Waifu":
        tweet, tweet_image = func.waifu(0, tweet)
    elif command == "Husbando":
        tweet, tweet_image = func.waifu(1, tweet)

    gender = utils.gender(status.text)
    if "Register" in command:
        follow_result = is_following(user.id)
        if follow_result == "Limited":
            tweet = ("The bot is currently limited on checking stuff.\n"
                     "Try again in 15 minutes!")
            if gender == 0:
                gender = "waifu"
            else:
                gender = "husbando"
            func.remove_one_limit(user.id, gender.lower() + "register")
        elif follow_result == "Not Genuine":
            tweet = ("Your account wasn't found to be genuine.\n"
                     "Help: {url}").format(
                         url=func.config_get('Help URLs', 'not_genuine'))
        elif not follow_result:
            tweet = ("You must follow @AcePictureBot to register!\n"
                     "Help: {url}").format(
                         url=func.config_get('Help URLs', 'must_follow'))
        else:
            tweet, tweet_image = func.waifuregister(user.id, user.screen_name,
                                                    tweet, gender)

    if "My" in command:
        tweet, tweet_image = func.mywaifu(user.id, gender)

    if "Remove" in command:
        tweet = func.waifuremove(user.id, gender)

    if command == "OTP":
        tweet, tweet_image = func.otp(tweet)

    # TODO: Remove this over sometime and change kohai to kouhai on the site
    if command == "Kohai":
        command = "Kouhai"
    list_cmds = [
        "Shipgirl", "Touhou", "Vocaloid", "Imouto", "Idol", "Shota", "Onii",
        "Onee", "Sensei", "Monstergirl", "Witchgirl", "Tankgirl", "Senpai",
        "Kouhai"
    ]
    if command in list_cmds:
        tweet, tweet_image = func.random_list(command, tweet)

    if command == "Airing":
        tweet = func.airing(tweet)
        # No results found.
        if not tweet:
            return False

    if command == "Source":
        tweet = func.source(_API, status)

    if tweet:
        tweet = "@{0} {1}".format(user.screen_name, tweet)
        post_tweet(_API, tweet, tweet_image, command, status)
예제 #5
0
def tweet_command(_API, status, tweet, command):
    tweet_image = False
    user = status.user
    # Mod command
    is_mod = [True if str(user.id) in MOD_IDS else False][0]
    if command == "DelLimits":
        if is_mod:
            their_id, cmd = tweet.split(' ', 2)
            remove_all_limit(their_id, cmd)
            print("[INFO] Removed limits for {0} - {1}".format(
                their_id, cmd))
        return False, False
    if str(user.id) not in PATREON_IDS:
        if not is_mod:
            user_is_limited = user_spam_check(user.id,
                                              user.screen_name, command)
            if isinstance(user_is_limited, str):
                # User hit limit, tweet warning
                command = ""
                tweet = user_is_limited
            elif not user_is_limited:
                # User is limited, return
                print("[{0}] User is limited! Ignoring...".format(
                    time.strftime("%Y-%m-%d %H:%M")))
                return False
    if settings['count_on']:
        func.count_trigger(command, user.id)

    if command == "DiscordConnect":
        tweet = func.DiscordConnect(tweet, user.id)

    if command == "DiscordJoin":
        tweet = re.sub('http\S+', '', tweet).strip()
        for url in status.entities['urls']:
            tweet += "" + url['expanded_url']
            break
        tweet = func.DiscordJoin(tweet)

    # Joke Commands
    if command == "spook":
        tweet, tweet_image = func.spookjoke()
    if command == "Spoiler":
        tweet = random.choice(utils.file_to_list(
            os.path.join(settings['list_loc'],
                         "spoilers.txt")))
    elif command == "!Level":
        tweet = func.get_level(user.id)

    # Main Commands
    if command == "Waifu":
        tweet, tweet_image = func.waifu(0, tweet)
    elif command == "Husbando":
        tweet, tweet_image = func.waifu(1, tweet)

    gender = utils.gender(status.text)
    if gender == 0:
        g_str = "waifu"
    else:
        g_str = "husbando"
    if "Register" in command:
        follow_result = is_following(user.id)
        if follow_result == "Limited":
            tweet = ("The bot is currently limited on checking stuff.\n"
                     "Try again in 15 minutes!")
            func.remove_one_limit(user.id, g_str.lower() + "register")
        elif follow_result == "Not Genuine":
            tweet = ("Your account wasn't found to be genuine.\n"
                     "Help: {url}").format(
                url=func.config_get('Help URLs', 'not_genuine'))
        elif not follow_result:
            tweet = ("You must follow @AcePictureBot to register!\n"
                     "Help: {url}").format(
                url=func.config_get('Help URLs', 'must_follow'))
        else:
            tweet, tweet_image = func.waifuregister(user.id,
                                                    user.screen_name,
                                                    tweet, gender)

    if "My" in command:
        skip_dups = False
        if "my{g_str}+".format(g_str=g_str) in tweet.lower():
            skip_dups = True
        if "my{g_str}-".format(g_str=g_str) in tweet.lower():
            func.delete_used_imgs(str(user.id), False)
        tweet, tweet_image = func.mywaifu(user.id, gender, False, skip_dups)

    if "Remove" in command:
        tweet = func.waifuremove(user.id, gender)

    if command == "OTP":
        tweet, tweet_image = func.otp(tweet)

    # TODO: Remove this over sometime and change kohai to kouhai on the site
    if command == "Kohai":
        command = "Kouhai"
    list_cmds = ["Shipgirl", "Touhou", "Vocaloid",
                 "Imouto", "Idol", "Shota",
                 "Onii", "Onee", "Sensei",
                 "Monstergirl", "Witchgirl", "Tankgirl",
                 "Senpai", "Kouhai"]
    if command in list_cmds:
        tweet, tweet_image = func.random_list(command, tweet)

    if command == "Airing":
        tweet = func.airing(tweet)
        # No results found.
        if not tweet:
            return False

    if command == "Source":
        tweet = func.source(_API, status)

    if tweet:
        tweet = "@{0} {1}".format(user.screen_name, tweet)
        post_tweet(_API, tweet, tweet_image, command, status)
예제 #6
0
def tweet_command(API, status, message, command):
    tweet = False
    tweet_image = False
    user = status['user']
    # Mod command
    is_mod = [True if user['id_str'] in MOD_IDS else False][0]
    is_patreon = [True if user['id_str'] in PATREON_IDS else False][0]
    if command == "DelLimits":
        if is_mod:
            their_id, cmd = message.split(' ', 2)
            remove_all_limit(their_id, cmd)
            print("[INFO] Removed limits for {0} - {1}".format(
                their_id, cmd))
        return "Removed!", False
    if command == "AllowAcc":
        if is_mod:
            func.allow_user(message)
            print("[INFO] Allowing User {0} to register!".format(message))
            ALLOWED_IDS.append(message)
    if not is_patreon and not is_mod:
        user_is_limited = user_spam_check(user['id_str'],
                                          user['screen_name'], command)
        if isinstance(user_is_limited, str):
            # User hit limit, tweet warning
            command = ""
            tweet = user_is_limited
        elif not user_is_limited:
            # User is limited, return
            print("[{0}] User is limited! Ignoring...".format(
                time.strftime("%Y-%m-%d %H:%M")))
            return False

    if settings['count_on'] and command:
        func.count_command("Global", command, settings['count_file'])
        func.count_command("Commands", command,
                           os.path.join(settings['user_count_loc'],
                                        user['id_str']))

    if command == "PicTag":
        if is_mod or is_patreon:
            get_imgs = 1
            try:
                count = int(re.search(r'\d+', message).group())
            except (AttributeError):
                count = False
            if count:
                if count > 4:
                    get_imgs = 4
                elif count < 1:
                    get_imgs = 1
                else:
                    get_imgs = count
            tweet, tweet_image = func.pictag(message.replace(str(count), ""),
                                             repeat_for=get_imgs)

    if command == "DiscordConnect":
        tweet = func.DiscordConnect(message, user['id_str'])

    if command == "DiscordJoin":
        tweet = ("Invite the bot by using this: "
                 "https://discordapp.com/oauth2/authorize?"
                 "&client_id=170367887393947648&scope=bot")
    # Joke Commands
    if command == "spook":
        tweet, tweet_image = func.spookjoke()
    if command == "Spoiler":
        tweet = random.choice(utils.file_to_list(
            os.path.join(settings['list_loc'],
                         "spoilers.txt")))
    elif command == "!Level":
        tweet = func.get_level(twitter_id=user['id_str'])

    # Main Commands
    if command == "Waifu":
        tweet, tweet_image = func.waifu(0, message, user_id=user['id_str'])
    elif command == "Husbando":
        tweet, tweet_image = func.waifu(1, message, user_id=user['id_str'])

    gender = utils.gender(status['text'])
    if gender == 0:
        g_str = "waifu"
    else:
        g_str = "husbando"
    if "Register" in command:
        is_allowed = [True if user['id_str'] in ALLOWED_IDS else False][0]
        if is_mod:
            is_allowed = True
        follow_result = is_following(user['id_str'], is_allowed)
        if follow_result == "Limited":
            tweet = ("The bot is currently limited on checking stuff.\n"
                     "Try again in 15 minutes!")
            func.remove_one_limit(user['id_str'], g_str.lower() + "register")
        elif follow_result == "Not Genuine":
            tweet = ("Your account wasn't found to be genuine.\n"
                     "Help: {url}").format(
                url=func.config_get('Help URLs', 'not_genuine'))
        elif not follow_result:
            tweet = ("You must follow @AcePictureBot to register!\n"
                     "Help: {url}").format(
                url=func.config_get('Help URLs', 'must_follow'))
        else:
            tweet, tweet_image = func.waifuregister(user['id_str'],
                                                    user['screen_name'],
                                                    message, gender)

    if "My" in command:
        skip_dups = False
        get_imgs = 1
        if "my{g_str}+".format(g_str=g_str) in message.lower():
            skip_dups = True
        if "my{g_str}-".format(g_str=g_str) in message.lower():
            func.delete_used_imgs(user['id_str'], False)
        if is_mod or is_patreon:
            try:
                count = int(re.search(r'\d+', message).group())
            except (AttributeError):
                count = False
            if count:
                if count > 4:
                    get_imgs = 4
                elif count < 1:
                    get_imgs = 1
                else:
                    get_imgs = count

        tweet, tweet_image = func.mywaifu(user['id_str'], gender,
                                          False, skip_dups, get_imgs)

    if "Remove" in command:
        tweet = func.waifuremove(user['id_str'], gender)

    if command == "OTP":
        tweet, tweet_image = func.otp(message)

    list_cmds = ["Shipgirl", "Touhou", "Vocaloid",
                 "Imouto", "Idol", "Shota",
                 "Onii", "Onee", "Sensei",
                 "Monstergirl", "Witchgirl", "Tankgirl",
                 "Senpai", "Kouhai", "Granblue"]
    if command in list_cmds:
        tweet, tweet_image = func.random_list(command, message)

    if command == "Airing":
        tweet = func.airing(message)
        # No results found.
        if not tweet:
            return False

    if command == "Source":
        tweet = func.source(API, status)

    if tweet or tweet_image:
        tweet = "@{0} {1}".format(user['screen_name'], tweet)
        post_tweet(API, tweet, tweet_image, command, status)
예제 #7
0
def run_tests():
    print("Login Test:")
    api = functions.login()
    print(api)
    print("\nTest Tweet")
    msg = "@AceStatusBot Running Tests..."
    api.update_status(status=msg)
    print("\nGet Level Test:")
    print(functions.get_level(123))
    print("\nRandom Waifu Test:")
    print(functions.waifu(0))
    print("\nRandom Husbando Test:")
    print(functions.waifu(1))
    # Name should be flipped
    print("\nWaifuRegister Test:")
    print(functions.waifuregister(123, "Test Username", "rin shibuya", 0))
    # Name should return "not enough images"
    print("\nHusbandoReigster Paste Test:")
    print(functions.waifuregister(123, "Test Username", "admiral", 1))
    # Name should work
    print("\nHusbandoReigster Test:")
    print(functions.waifuregister(123, "Test Username",
                                       "admiral (kantai collection)", 1))
    print("\nMyWaifu Test:")
    print(functions.mywaifu(123, 0))
    print("\nMyHusbando Test:")
    print(functions.mywaifu(123, 1))
    print("\nRemoveWaifu Test:")
    print(functions.waifuremove(123, 0))
    print("\nRemoveHusbando Test:")
    print(functions.waifuremove(123, 1))
    print("\nRandom OTP Test:")
    print(functions.otp(""))
    print("\nRandom List Shipgirl Test:")
    m, i = functions.random_list("Shipgirl", "")
    print(m, i)
    print("\nRandom List Imouto Test:")
    m, ii = functions.random_list("Imouto", "")
    if not i:
        i = ii
    print(m, ii)
    print("\nRandom List Shota Test:")
    print(functions.random_list("Shota", ""))
    print("Sleeping for 10 seconds...")
    time.sleep(10)
    print("\nRandom List Sensei Test:")
    print(functions.random_list("Sensei", ""))
    print("\nRandom List Senpai Test:")
    m, ii = functions.random_list("Senpai", "")
    if not i:
        i = ii
    print(m, ii)
    print("\nRandom List Kouhai Test:")
    print(functions.random_list("Kouhai", ""))
    print("\nRandom List Kouhai Male Test:")
    print(functions.random_list("Kouhai", "male"))
    print("\nAiring Test:")
    print(functions.airing("One Piece"))
    print("\nTest Tweet (with Image)")
    msg = "@AceStatusBot Test Tweet with Image..."
    api.update_with_media(i, status=msg)
    print("\nTest Tweet (with Video)")
    tags = ["rating:safe", "webm", "-extremely_large_filesize",
            "-large_filesize", "-no_audio"]
    i = get_image_online(tags, 0, 1, "")
    msg = "@AceStatusBot Test Tweet with Video..."
    api.update_with_media(i, status=msg)
    print("\nFinished all Tests!")