Exemplo n.º 1
0
def waifuregister(user_id, username, name, gender):
    config = configparser.RawConfigParser(allow_no_value=True)
    config.read(settings['settings'])
    help_urls = (dict(config.items('Help URLs')))
    if config_get('Websites', 'sankakucomplex') == "False":
        m = "Some websites are offline. Try again later!"
        if gender == 0:
            gender = "Waifu"
        elif gender == 1:
            gender = "Husbando"
        remove_one_limit(user_id, gender.lower() + "register", username)
        return m, False
    if name == "":
        m = "You forgot to include a name! Help: {0}".format(
            config_get('Help URLs', 'include_name'))
        return m, False
    elif len(name) >= 41:
        return False, False
    elif len(name) == 1:
        return False, False
    name = name.replace("+", "")
    name = name.replace("( ", "(").replace(" )", ")")

    register_object = WaifuRegisterClass(
            user_id, username, name, gender)
    if register_object.offline:
        remove_one_limit(user_id, gender.lower() + "register")
        return "Some websites are offline. Try again later!"
    if register_object.disable:
        warn_user(user_id, "Banned Register - {0}".format(name))
        return False, False
    else:
        # Everything is fine so far
        register_object.start()
        if register_object.multinames:
            return register_object.multinames, False
        elif register_object.noimages:
            return "No images found for \"{0}\"! Help: {1}".format(
                capwords(register_object.org_name),
                help_urls['no_imgs_found']), False
        elif register_object.notenough:
            return "Not enough images found for \"{0}\"! Help: {1}".format(
                capwords(register_object.org_name),
                help_urls['not_enough_imgs']), False
    m, tweet_image = mywaifu(user_id, gender)
    return m, tweet_image
Exemplo n.º 2
0
def mywaifu(user_id, gender):
    if gender == 0:
        gender = "Waifu"
        filename = "users_waifus.json"
    else:
        gender = "Husbando"
        filename = "users_husbandos.json"
    user_waifus_file = open(
        os.path.join(settings['list_loc'], filename), 'r',
        encoding='utf-8')
    user_waifus = json.load(user_waifus_file)
    user_waifus_file.close()
    for user in user_waifus['users']:
        if int(user['twitter_id']) == user_id:
            break
    if int(user['twitter_id']) != user_id:
        count_trigger("mywaifu")
        m = ("I don't know who your {0} is!\n"
             "Use {1}Register!\n"
             "Help: {2}").format(gender, gender,
                                 config_get('Help URLs', 'include_name'))
        return m, False
    tags = user['name'] + user['tags']
    if user.get('max_page'):
        max_page = user['max_page']
    else:
        max_page = 20
    path_name = slugify(user['name'],
                        word_boundary=True, separator="_")
    path = os.path.join(settings['image_loc'],
                        gender.lower(), path_name)
    ignore_list = "user_ignore/{0}".format(user['twitter_id'])
    tweet_image = utils.get_image_online(tags, user['web_index'],
                                         max_page, ignore_list)
    if not tweet_image:
        tweet_image = utils.get_image(path, ignore_list)
    if not tweet_image:
        m = ("Failed to get an image (website could be offline).\n"
             "Help: {0}").format(config_get('Help URLs', 'website_offline'))
        remove_one_limit(user_id, "my" + gender.lower())
        return m, False
    if datetime.datetime.now().isoweekday() == 3:
        m = "#{0}Wednesday".format(gender)
    else:
        m = "#{0}AnyDay".format(gender)
    return m, tweet_image
Exemplo n.º 3
0
def waifuregister(user_id, username, name, gender):
    config = configparser.RawConfigParser(allow_no_value=True)
    config.read(settings['settings'])
    help_urls = (dict(config.items('Help URLs')))
    if config_get('Websites', 'sankakucomplex') == "False":
        m = "Some websites are offline. Try again later!"
        if gender == 0:
            gender = "Waifu"
        elif gender == 1:
            gender = "Husbando"
        remove_one_limit(user_id, gender.lower() + "register", username)
        return m, False
    if name == "":
        m = "You forgot to include a name! Help: {0}".format(
            config_get('Help URLs', 'include_name'))
        return m, False
    elif len(name) >= 41:
        return False, False
    elif len(name) == 1:
        return False, False
    name = name.replace("+", "")
    name = name.replace("( ", "(").replace(" )", ")")

    register_object = WaifuRegisterClass(user_id, username, name, gender)
    if register_object.offline:
        remove_one_limit(user_id, gender.lower() + "register")
        return "Some websites are offline. Try again later!"
    if register_object.disable:
        warn_user(user_id, "Banned Register - {0}".format(name))
        return False, False
    else:
        # Everything is fine so far
        register_object.start()
        if register_object.multinames:
            return register_object.multinames, False
        elif register_object.noimages:
            return "No images found for \"{0}\"! Help: {1}".format(
                capwords(register_object.org_name),
                help_urls['no_imgs_found']), False
        elif register_object.notenough:
            return "Not enough images found for \"{0}\"! Help: {1}".format(
                capwords(register_object.org_name),
                help_urls['not_enough_imgs']), False
    m, tweet_image = mywaifu(user_id, gender)
    return m, tweet_image
Exemplo n.º 4
0
def mywaifu(user_id, gender):
    if gender == 0:
        gender = "Waifu"
        filename = "users_waifus.json"
    else:
        gender = "Husbando"
        filename = "users_husbandos.json"
    user_waifus_file = open(os.path.join(settings['list_loc'], filename),
                            'r',
                            encoding='utf-8')
    user_waifus = json.load(user_waifus_file)
    user_waifus_file.close()
    for user in user_waifus['users']:
        if int(user['twitter_id']) == user_id:
            break
    if int(user['twitter_id']) != user_id:
        count_trigger("mywaifu")
        m = ("I don't know who your {0} is!\n"
             "Use {1}Register!\n"
             "Help: {2}").format(gender, gender,
                                 config_get('Help URLs', 'include_name'))
        return m, False
    tags = user['name'] + user['tags']
    if user.get('max_page'):
        max_page = user['max_page']
    else:
        max_page = 20
    path_name = slugify(user['name'], word_boundary=True, separator="_")
    path = os.path.join(settings['image_loc'], gender.lower(), path_name)
    ignore_list = "user_ignore/{0}".format(user['twitter_id'])
    tweet_image = utils.get_image_online(tags, user['web_index'], max_page,
                                         ignore_list)
    if not tweet_image:
        tweet_image = utils.get_image(path, ignore_list)
    if not tweet_image:
        m = ("Failed to get an image (website could be offline).\n"
             "Help: {0}").format(config_get('Help URLs', 'website_offline'))
        remove_one_limit(user_id, "my" + gender.lower())
        return m, False
    if datetime.datetime.now().isoweekday() == 3:
        m = "#{0}Wednesday".format(gender)
    else:
        m = "#{0}AnyDay".format(gender)
    return m, tweet_image
Exemplo n.º 5
0
def mywaifu(user_id, gender, DISCORD=False, SKIP_DUP_CHECK=False):
    tweet_image = False
    if gender == 0:
        gender = "Waifu"
        filename = "users_waifus.json"
    else:
        gender = "Husbando"
        filename = "users_husbandos.json"
    user_waifus_file = open(
        os.path.join(settings['list_loc'], filename), 'r',
        encoding='utf-8')
    user_waifus = json.load(user_waifus_file)
    user_waifus_file.close()
    for user in user_waifus['users']:
        if int(user['twitter_id']) == int(user_id):
            break
    if int(user['twitter_id']) != int(user_id):
        count_trigger("mywaifu")
        m = ("I don't know who your {0} is!\n"
             "Use {1}Register!\n"
             "Help: {2}").format(gender, gender,
                                 config_get('Help URLs', 'include_name'))
        return m, False
    tags = user['name'] + user['tags']
    if user.get('max_page'):
        max_page = user['max_page']
    else:
        max_page = 20
    path_name = slugify(user['name'],
                        word_boundary=True, separator="_")
    path = os.path.join(settings['image_loc'],
                        gender.lower(), path_name)
    if DISCORD:
        ignore_list = "user_ignore/discord_{0}".format(user['twitter_id'])
        tweet_image = utils.get_image(path, ignore_list)
    else:
        ignore_list = "user_ignore/{0}".format(user['twitter_id'])

    if not DISCORD:
        tweet_image = utils.get_image_online(tags, user['web_index'],
                                             max_page, ignore_list,
                                             path=path)
    if not tweet_image:
        tweet_image = utils.get_image(path, ignore_list)

    if not tweet_image and SKIP_DUP_CHECK:
        tweet_image = utils.get_image(path)

    if not tweet_image:
        m = ("Failed to grab a new image!\nThe main image website could be offline.\n"
             "Help: {0}").format(config_get('Help URLs', 'website_offline'))
        remove_one_limit(user_id, "my" + gender.lower())
        return m, False
    if datetime.datetime.now().isoweekday() == 3:
        # TODO: Remember hashtags here
        m = "{0}Wednesday".format(gender)
    else:
        m = "{0}AnyDay".format(gender)
    if DISCORD:
        # @user's x is x
        m = " {gender} is {name}!".format(
            gender=gender, name=user['name'].replace("_", " ").title())
    return m, tweet_image
Exemplo n.º 6
0
def mywaifu(user_id, gender, DISCORD=False,
            SKIP_DUP_CHECK=False, repeat_for=1):
    tweet_image = False
    if gender == 0:
        gender = "Waifu"
        filename = "users_waifus.json"
    else:
        gender = "Husbando"
        filename = "users_husbandos.json"
    user_waifus_file = open(
        os.path.join(settings['list_loc'], filename), 'r',
        encoding='utf-8')
    user_waifus = json.load(user_waifus_file)
    user_waifus_file.close()
    for user in user_waifus['users']:
        if int(user['twitter_id']) == int(user_id):
            break
    if int(user['twitter_id']) != int(user_id):
        count_trigger("mywaifu")
        m = ("I don't know who your {0} is!\n"
             "Use {1}Register!\n"
             "or just try say \"{1}\"!\n"
             "Help: {2}").format(gender, gender,
                                 config_get('Help URLs', 'include_name'))
        return m, False
    tags = user['name'] + user['tags']
    if user.get('max_page'):
        max_page = user['max_page']
    else:
        max_page = 20
    path_name = slugify(user['name'],
                        word_boundary=True, separator="_")
    path = os.path.join(settings['image_loc'],
                        gender.lower(), path_name)
    tweet_image_list = []
    for x in range(0, repeat_for):
        if DISCORD:
            ignore_list = "user_ignore/discord_{0}".format(user['twitter_id'])
            tweet_image = utils.get_image(path, ignore_list)
        else:
            ignore_list = "user_ignore/{0}".format(user['twitter_id'])

        if not DISCORD:
            tweet_image = utils.get_image_online(tags, user['web_index'],
                                                 max_page, ignore_list,
                                                 path=path)
        if not tweet_image:
            tweet_image = utils.get_image(path, ignore_list)

        if not tweet_image and SKIP_DUP_CHECK:
            tweet_image = utils.get_image(path)

        if not tweet_image:
            m = ("Failed to grab a new image!\n"
                 "The main image website could be offline.\n"
                 "Help: {0}").format(config_get('Help URLs',
                                                'website_offline'))
            remove_one_limit(user_id, "my" + gender.lower())
            return m, False
        tweet_image_list.append(tweet_image)

    if datetime.datetime.now().isoweekday() == 3:
        m = "#{0}Wednesday".format(gender)
    else:
        m = ""
    if DISCORD:
        # @user's x is x
        m = " {gender} is {name}!".format(
            gender=gender, name=user['name'].replace("_", " ").title())
    if len(tweet_image_list) > 1:
        return m, tweet_image_list
    return m, tweet_image