Beispiel #1
0
def waifu(ctx, gender=None, search_for=None, is_otp=False):
    if ctx.command == "waifu" or gender == "waifu":
        list_name = "Waifu"
        end_tag = ["1girl", "solo"]
    else:
        list_name = "Husbando"
        end_tag = ["-1girl", "-female", "1boy", "solo"]
    result = ()
    path = os.path.join(ctx.bot.config_path, '{} List.yaml'.format(list_name))
    char_list = yaml_to_list(path, list_name.lower())
    # This is used so they can't get aroun dbeing limited with x cmd
    # Plus to the odd series to make people actually use other cmds 😠.
    ignore = ["high-school-dxd", "love-live",
              "aoki-hagane-no-arpeggio", "kantai-collection",
              "aikatsu", "akb0048", "idolmaster",
              "idolmaster-cinderella-girls"]
    matched = []
    if search_for is None:
        search_for = ctx.args
    if len(search_for) >= 5 and slugify(search_for) not in ignore:
        result = filter_per_series(char_list, search_for, 4)
    if not result:
        result = random.choice(char_list)
    name = re.sub("[\(\[].*?[\)\]]", "", result[0]).strip()  # Remove () and []
    series = result[1].get('series', None)
    otp_image = result[1].get('otp image', None)
    if is_otp:
        return name, series, otp_image
    start_path = settings.get('image_location', os.path.join(os.path.realpath(__file__), 'images'))
    path_name = os.path.join(start_path, list_name, slugify(result[0]))
    end_tag.append(name.replace(" ", "_"))
    reply_text = "Your {} is {} ({})".format(list_name, name, series)
    media_args = {'tags': end_tag}
    reply_media = get_media(path=path_name, ctx=ctx, media_args=media_args)
    return reply_text, reply_media
Beispiel #2
0
 def find_show(url):
     soup = scrape_website(url)
     if not soup:
         return "Sorry can't connect to livechart.me !"
     show_list = soup.find_all('h3', class_="main-title")
     today = datetime.today() + timedelta(hours=-1)
     reply_text = False
     for show in show_list:
         if slugify(show.text) != slugify(ctx.args):
             continue
         episode_number = show.find_next('div', attrs={'class': "episode-countdown"})
         if show != episode_number.find_previous('h3'):
             return "{anime}\nNo air date set!".format(anime=show.text)
         episode_time = episode_number.find_next('time')['datetime'].replace("T", " ").replace("Z", "")
         next_ep_time = datetime.strptime(episode_time, '%Y-%m-%d %H:%M:%S') - today
         episode_number = re.findall(r'\d+', episode_number.text.split(":")[0])[0]
         hours, remainder = divmod(int(next_ep_time.total_seconds()), 3600)
         minutes, seconds = divmod(remainder, 60)
         days, hours = divmod(hours, 24)
         if days < 0:
             reply_text = ("{anime}\nEpisode {episode} has recently aired!".format(anime=show.text, episode=episode_number))
             return reply_text
         if days:
             fmt = '{d} days, {h} hours, {m} minutes, and {s} seconds'
         else:
             fmt = '{h} hours, {m} minutes, and {s} seconds'        
         reply_text = ("{anime}\n"
                       "Episode {episode} airing in {fmt}".format(
                       anime=show.text, episode=episode_number,
                       fmt=fmt.format(d=days, h=hours, m=minutes, s=seconds)))
         return reply_text
Beispiel #3
0
def new_smiley():
    """ Input info for new user """
    in_use = []
    people = PeopleModel.all()
    for person in people:
        in_use.append(person.name)
    reservered = [u'new', u'debug', u'debug-people', u'home', u'about']

    form = PeopleForm()
    if form.validate_on_submit():
        person = PeopleModel(
                key_name = form.name.data.lower(),
                name = form.name.data.lower(),
                startdate = form.startdate.data,
                enddate = form.enddate.data,
                password = generate_password_hash(form.password.data)
                )
        person.name = slugify(person.name)
        if form.password.data == "":
            person.password = ""
        if unicode(person.name) not in in_use and (unicode(person.name) not in reservered):
                try:
                        person.put()
                        flash(unicode(person.name), 'success')
                        mail.send_mail(sender="Neuer Nutzer! <*****@*****.**>",\
                                to = "<*****@*****.**>", subject="Neuer Benutzer!", body=person.name)
                        return redirect(url_for('home') + person.name.encode("utf-8"))
                except CapabilityDisabledError:
                        flash(u'App Engine Datastore is currently in read-only mode.', 'failure')
                        return redirect(url_for('list_examples'))
        else:
            flash(u'Der Name ist leider schon reserviert, probiere doch einfach einen anderen')
            return redirect(url_for('new_smiley'))
    return render_template('setup.html', form=form)
Beispiel #4
0
 def find_show(url):
     soup = scrape_website(url)
     if not soup:
         return "Sorry can't connect to livechart.me !"
     show_list = soup.find_all('h3', class_="main-title")
     today = datetime.today() + timedelta(hours=-1)
     reply_text = False
     results = []
     for show in show_list:
         if slugify(ctx.args) not in slugify(show.text):
             continue
         episode_number = show.find_next('div', attrs={'class': "episode-countdown"})
         if show != episode_number.find_previous('h3'):
             return "{anime}\nNo air date set!".format(anime=show.text)
         episode_time = episode_number.find_next('time')['datetime'].replace("T", " ").replace("Z", "")
         next_ep_time = datetime.strptime(episode_time, '%Y-%m-%d %H:%M:%S') - today
         episode_number = re.findall(r'\d+', episode_number.text.split(":")[0])
         if episode_number:
             episode_number = episode_number[0]
         hours, remainder = divmod(int(next_ep_time.total_seconds()), 3600)
         minutes, seconds = divmod(remainder, 60)
         days, hours = divmod(hours, 24)
         if days < 0:
             reply_text = ("{anime}\nEpisode {episode} has recently aired!".format(anime=show.text, episode=episode_number))
             return reply_text
         if days:
             fmt = '{d} days, {h} hours, {m} minutes, and {s} seconds'
         else:
             fmt = '{h} hours, {m} minutes, and {s} seconds'
         if ctx.bot.source.name == "discord":
             results.append("**{anime}**\n"
                           "**Episode {episode}** - airing in {fmt}".format(
                           anime=show.text, episode=episode_number,
                           fmt=fmt.format(d=days, h=hours, m=minutes, s=seconds)))
         else:
             results.append("{anime}\n"
                           "Episode {episode} - airing in {fmt}".format(
                           anime=show.text, episode=episode_number,
                           fmt=fmt.format(d=days, h=hours, m=minutes, s=seconds)))
     return results
Beispiel #5
0
def waifu(ctx, gender=None, search_for=None, is_otp=False):
    """Get a random {OPTION}"""
    if ctx.command == "waifu" or gender == "waifu":
        list_name = "Waifu"
        end_tag = ["1girl", "solo"]
    else:
        list_name = "Husbando"
        end_tag = ["-1girl", "-genderbend", "1boy", "solo"]
    result = ()
    path = os.path.join(ctx.bot.config_path, '{} List.yaml'.format(list_name))
    if "video game" in ctx.args.lower() and list_name == "Waifu":
        char_list = yaml_to_list(path, "video game")
    else: 
        char_list = yaml_to_list(path, list_name.lower())
    # This is used so they can't get aroun dbeing limited with x cmd
    # Plus to the odd series to make people actually use other cmds 😠.
    ignore = ["high-school-dxd", "love-live", "love-live-sunshine"
              "aoki-hagane-no-arpeggio", "kantai-collection",
              "aikatsu", "akb0048", "idolmaster",
              "idolmaster-cinderella-girls"]
    matched = []
    if search_for is None:
        search_for = ctx.args
    if len(search_for) >= 5 and slugify(search_for) not in ignore:
        result = filter_per_series(char_list, search_for, 4)
    if not result:
        result = random.choice(char_list)
    name = re.sub("[\(\[].*?[\)\]]", "", result[0]).strip()  # Remove () and []
    series = result[1].get('series')
    otp_image = result[1].get('otp image')
    if is_otp:
        return name, series, otp_image
    start_path = settings.get('image_location', os.path.join(os.path.realpath(__file__), 'images'))
    path_name = os.path.join(start_path, list_name, slugify(result[0]))
    end_tag.append(result[0].replace(" ", "_"))
    reply_text = "Your {} is {} ({})".format(list_name, name, series)
    media_args = {'tags': end_tag}
    reply_media = get_media(path=path_name, ctx=ctx, media_args=media_args)
    return reply_text, reply_media
Beispiel #6
0
def fate_servant_cmd(ctx):
    # NOTE: Still not finished on the list side.
    start_path = settings.get('image_location', os.path.join(os.path.realpath(__file__), 'images'))
    team = []
    for x in range(0, 3):
        picked = False
        while True:
            rand = random.randint(0, 100)
            if rand <= 50:
                picked = random.choice(["Saber", "Archer", "Lancer"])
            elif 51 <= rand <= 70:
                picked = random.choice(["Rider", "Caster", "Assassin"])
            elif 71 <= rand <= 90:
                picked = random.choice(["Berserker", "Alter Ego", "Shielder"])
            elif 91 <= rand <= 100:
                picked = random.choice(["Ruler", "Avenger", "Moon Cancer"])
            if picked in team:
                continue
            team.append(picked)
            break

    final_entries = []
    final_images = []
    had_false = False
    for member in team:
        list_name = "Waifu"
        # temp no male 
        if member in ["Saber", "Archer", "Lancer", "Rider", "Caster", "Assassin"] and random.randint(0, 100) > 195:
            list_name = "Husbando"
        path = os.path.join(ctx.bot.config_path, '{} List.yaml'.format(list_name))
        char_list = yaml_to_list(path, "fate/servant/{}".format(member.lower().replace(" ", "_")))
        char = random.choice(char_list)
        path_name = os.path.join(start_path, list_name, slugify(char[0]))
        image = get_media(path=path_name, media_args={})
        if not image:
            had_false = True
        final_entries.append(char)
        final_images.append(image)

    reply_media = False
    if not had_false:
        reply_media = create_otp_image(otp_results=final_images, width_size=0, height_size=1000, is_otp=False)
    reply_text = "Your Fate/Grand Order Team is:\n{} ({})\n{} ({})\n{} ({})".format(
        re.sub("[\(\[].*?[\)\]]", "", final_entries[0][0]).strip(), team[0],
        re.sub("[\(\[].*?[\)\]]", "", final_entries[1][0]).strip(), team[1],
        re.sub("[\(\[].*?[\)\]]", "", final_entries[2][0]).strip(), team[2])
    return reply_text, reply_media
Beispiel #7
0
def OpenProfile(request, slug):
    """ user can only open his profile """

    ## first check he is logined
    if is_logined(request):

        ## check if he ask for his profile 
        # else see if he admin else redirect to his profile
        user    = request.user.username
        if slug == slugify(user):
            ## load his profile
            return load_profile(request, slug)
        else:
            if this_is_admin(request):
                ## load profile as admin give u access to create projects
                context = {'admin': True}
                return load_profile(request, slug, context)
                
            else:
                ## someone try to access other redirect him to his profile
                return redirect(profile)
    else:
        ## not logined has no access to any profile
        return redirect(log_in)
Beispiel #8
0
def random_list(ctx):
    # Male only lists.
    male_lists = ["shota", "onii"]
    # Both female and male can be under these.
    special_male_lists = ["idol", "sensei", "senpai", "kouhai", "yandere", "tsundere"]
    # Simple way to make sure to not load male list if one of these are used.
    possible_search = ["love", "idolmaster", "cinderella",
                       "akb0048", "wake", "aikatsu"] 
    # List of lists that don't need to show the series.
    ignore_series_lists = ["shipgirl", "touhou", "witchgirl", "tankgirl", "vocaloid"]
    list_name = "Waifu"
    end_tag = ["1girl", "solo"]
    args = ctx.message.lower()
    result = ()
    search_for = ""
    show_series = False if ctx.command in ignore_series_lists else True
    support_otp = False
    # Special per list stuff
    if ctx.command == "shipgirl":
        # Default shipgirl to kantai collection only
        search_for = "Kantai Collection"
        support_otp = True
        if "all" in args:
            search_for = ""
        elif "aoki" in args:
            search_for = "Aoki Hagane no Arpeggio"
    elif ctx.command == "idol":
        args = args.replace("!", "").replace("@", "a")
        if "love live sunshine" in args:
            search_for = "Love Live! Sunshine!!"
        elif "love live" in args:
            search_for = "Love Live!"
            support_otp = True
        elif "idolmaster" in args:
            search_for = "Idolmaster"
        elif "cinderella" in args:
            search_for = "Idolmaster Cinderella Girls"
        elif "akb0048" in args:
            search_for = "AKB0048"
        elif "wake up" in args:
            search_for = "Wake Up Girls!"
        elif "aikatsu" in args:
            search_for = "Aikatsu!"
    if (ctx.command in special_male_lists and "male" in args and not "female" in args and not search_for)\
        or ctx.command in male_lists:
            list_name = "Husbando"
            end_tag = ["-1girl", "-female", "1boy"]
    elif (ctx.command in special_male_lists and not "female" in args and not search_for):
        random_gender = random.randint(0, 10)
        if random_gender > 8:
            list_name = "Husbando"
            end_tag = ["-1girl", "-female", "1boy"]
    if ctx.command in male_lists:
        list_name = "Husbando"
        end_tag = ["-1girl", "-female", "1boy"]
    if support_otp and "otp" in args:
        list_name = "OTP"
    if ctx.command == "onee" or ctx.command == "onii":
        ctx.command = ctx.command + "-chan"
    path = os.path.join(ctx.bot.config_path, '{} List.yaml'.format(list_name))
    char_list = yaml_to_list(path, ctx.command.lower())
    if search_for:
        result = filter_per_series(char_list, search_for, 4)
    if not result:
        result = random.choice(char_list)
    series = result[1].get('series', None)
    otp_image = result[1].get('otp image', None)
    start_path = settings.get('image_location', os.path.join(os.path.realpath(__file__), 'images'))
    if list_name == "OTP":
        name_one, name_two = result[0].split("(x)")
        end_tag = ["2girls", "yuri", name_one.replace(" ", "_"), name_two.replace(" ", "_")]
        list_title = ctx.command.title() + " OTP"
        name = "{} x {}".format(re.sub("[\(\[].*?[\)\]]", "", name_one).strip(),
                                re.sub("[\(\[].*?[\)\]]", "", name_two).strip())
        path_name = os.path.join(start_path, list_name, slugify(name))
    else:
        list_title = ctx.command.title()
        name = re.sub("[\(\[].*?[\)\]]", "", result[0]).strip()  # Remove () and []
        end_tag.append(result[0].replace(" ", "_"))
        path_name = os.path.join(start_path, list_name, slugify(result[0]))
    if ctx.command == "granblue":
        reply_text = "{} has joined your party!".format(name)
    else:    
        reply_text = "Your {} is {}{}".format(
            list_title.replace("-C", "-c"),  # w/e
            name,
            "" if not show_series else " ({})".format(series))
    media_args = {'tags': end_tag}
    reply_media = get_media(path=path_name, ctx=ctx, media_args=media_args)
    return reply_text, reply_media
Beispiel #9
0
def mywaifu(ctx):
    if "waifu" in ctx.command:
        list_name = "Waifu"
    elif "idol" in ctx.command:
        list_name = "Idol"
    elif "otp" in ctx.command:
        list_name = "OTP"
    else:
        list_name = "Husbando"
    if not ctx.user_ids.get('twitter', False):
        # No twitter account connected.
        url_help = help_urls.get('mywaifu_connect_{}'.format(ctx.bot.source.name), False)
        reply_text = ("Couldn't find your {gender}, "
                      "register your {gender} on Twitter!"
                      "{url_help}".format(gender=list_name,
                                                    url_help="\nFollow: " + url_help if url_help else ""))
        return reply_text
    twitter_user_id = ctx.user_ids['twitter']
    if not ast.literal_eval(os.environ.get('gelbooru_online', 'True')) and\
       not ast.literal_eval(os.environ.get('safebooru_online', 'False')):
        if ctx and ctx.bot.source.name == "twitter":
            ctx.bot.check_rate_limit_per_cmd(ctx, remove=1)
        url_help = help_urls.get('waifuregister_websites_offline', False)
        reply_text = ("Websites are offline to get you your {}!\n"
                      "Try again later!{}".format(list_name,
            "\nHelp: " + url_help if url_help else ""))
        return reply_text
    user_file = os.path.join(ctx.bot.config_path, "Users {}Register.json".format(list_name))
    if not os.path.isfile(user_file):
        reply_text = ("I don't know who your {gender} is!\n"
                      "Use {gender}Register or try tweeting '{gender}'!".format(gender=list_name))
        return reply_text
    else:
        with open(user_file, 'r', encoding="utf-8") as f:
            user_reigster_list = json.load(f)
    user_entry = [user for user in user_reigster_list if user['twitter_id'] == twitter_user_id]
    if not user_entry:
        # No waifu registered
        reply_text = ("I don't know who your {gender} is!\n"
                      "Use {gender}Register or try tweeting '{gender}'!".format(gender=list_name))
        return reply_text
    user_entry = user_entry[0]
    skip_already_used = False
    if "my{}+".format(list_name.lower()) in ctx.message.lower():
        skip_already_used = True
    elif "my{}-".format(list_name.lower()) in ctx.message.lower():
        write_user_ignore_list(ctx.user_id, ctx.bot.source.name, clear=True)
    start_path = settings.get('image_location', os.path.join(os.path.realpath(__file__), 'images'))
    path_name = None
    if list_name == "Idol":
        path_name = os.path.join(start_path, "Waifu", slugify(user_entry['name'].replace("_", " ")))
        if not os.path.isdir(path_name):
            path_name = os.path.join(start_path, "Husbando", slugify(user_entry['name'].replace("_", " ")))
            if not os.path.isdir(path_name):
                path_name = os.path.join(start_path, list_name, slugify(user_entry['name'].replace("_", " ")))
    else:
        path_name = os.path.join(start_path, list_name, slugify(user_entry['name'].replace("_", " ")))
    if list_name == "OTP":
        tags = [user_entry['name'].replace(" ", "_").replace("(x)", "+")] + user_entry['tags'].split("+")
        clean_name = user_entry['name'].replace("_", " ")
    else:
        tags = [user_entry['name'].replace(" ", "_")] + user_entry['tags'].split("+")
        clean_name = re.sub("[\(\[].*?[\)\]]", "", user_entry['name'].replace("_", " ").title()).strip()
    tags = list(filter(None, tags))
    reply_text = ""
    if ctx.bot.source.name == "twitter":
        if datetime.now().isoweekday() == 3:
            reply_text = "#{0}Wednesday".format(list_name)
    else:
        reply_text = "{gender} is {name}".format(gender=list_name, name=clean_name)
    reply_media = []
    for x in range(0, ctx.media_repeat_for):
        media_args = {'ignore_used': skip_already_used}
        if ctx.bot.source.allow_new_mywaifu:
            media_args = {'tags': tags, 'random_page': True, 'return_url': ctx.bot.source.support_embedded,
                          'ignore_used': skip_already_used}
        image = get_media(path=path_name, ctx=ctx, media_args=media_args)
        if image:
            reply_media.append(image)
        if not reply_media:
            if ctx.bot.source.allow_new_mywaifu:
                if ctx and  ctx.bot.source.name == "twitter":
                    ctx.bot.check_rate_limit_per_cmd(ctx, remove=1)
                url_help = help_urls.get('mywaifu_no_image', False)
                reply_text = ("Failed to grab a new image!\n"
                              "The image websites could be offline.\n"
                              "Try again later!{}".format(
                    "\nHelp: " + url_help if url_help else ""))
            else:
                reply_text = ("Failed to grab a new image!\n"
                              "Use the command on Twitter to help the bot store more images!\n"
                              "You can also use My{gender}+ to skip checking for an already used image"
                              " or My{gender}- to start from fresh!".format(gender=list_name))
            if len(reply_media) < 1:
                return reply_text
            break
    return reply_text, reply_media
Beispiel #10
0
def mywaifu(ctx):
    if "waifu" in ctx.command:
        list_name = "Waifu"
    elif "idol" in ctx.command:
        list_name = "Idol"
    elif "otp" in ctx.command:
        list_name = "OTP"
    else:
        list_name = "Husbando"
    if not ctx.user_ids.get('twitter', False):
        # No twitter account connected.
        url_help = help_urls.get('mywaifu_connect_{}'.format(ctx.bot.source.name), False)
        reply_text = ("Couldn't find your {gender}, "
                      "register your {gender} on Twitter!"
                      "{url_help}".format(gender=list_name,
                                                    url_help="\nFollow: " + url_help if url_help else ""))
        return reply_text
    twitter_user_id = ctx.user_ids['twitter']
    if not ast.literal_eval(os.environ.get('gelbooru_online', 'True')) and\
       not ast.literal_eval(os.environ.get('safebooru_online', 'False')):
        if ctx and ctx.bot.source.name == "twitter":
            ctx.bot.check_rate_limit_per_cmd(ctx, remove=1)
        url_help = help_urls.get('waifuregister_websites_offline', False)
        reply_text = ("Websites are offline to get you your {}!\n"
                      "Try again later!{}".format(list_name,
            "\nHelp: " + url_help if url_help else ""))
        return reply_text
    user_file = os.path.join(ctx.bot.config_path, "Users {}Register.json".format(list_name))
    if not os.path.isfile(user_file):
        reply_text = ("I don't know who your {gender} is!\n"
                      "Use {gender}Register or try tweeting '{gender}'!".format(gender=list_name))
        return reply_text
    else:
        with open(user_file, 'r', encoding="utf-8") as f:
            user_reigster_list = json.load(f)
    user_entry = [user for user in user_reigster_list if user['twitter_id'] == twitter_user_id]
    if not user_entry:
        # No waifu registered
        reply_text = ("I don't know who your {gender} is!\n"
                      "Use {gender}Register or try tweeting '{gender}'!".format(gender=list_name))
        return reply_text
    user_entry = user_entry[0]
    skip_already_used = False
    if "my{}+".format(list_name.lower()) in ctx.message.lower():
        skip_already_used = True
    elif "my{}-".format(list_name.lower()) in ctx.message.lower():
        write_user_ignore_list(ctx.user_id, ctx.bot.source.name, clear=True)
    start_path = settings.get('image_location', os.path.join(os.path.realpath(__file__), 'images'))
    path_name = None
    if list_name == "Idol":
        path_name = os.path.join(start_path, "Waifu", slugify(user_entry['name'].replace("_", " ")))
        if not os.path.isdir(path_name):
            path_name = os.path.join(start_path, "Husbando", slugify(user_entry['name'].replace("_", " ")))
            if not os.path.isdir(path_name):
                path_name = os.path.join(start_path, list_name, slugify(user_entry['name'].replace("_", " ")))
    else:
        path_name = os.path.join(start_path, list_name, slugify(user_entry['name'].replace("_", " ")))
    if list_name == "OTP":
        tags = [user_entry['name'].replace(" ", "_").replace("(x)", "+")] + user_entry['tags'].split("+")
        clean_name = user_entry['name'].replace("_", " ")
    else:
        tags = [user_entry['name'].replace(" ", "_")] + user_entry['tags'].split("+")
        clean_name = re.sub("[\(\[].*?[\)\]]", "", user_entry['name'].replace("_", " ").title()).strip()
    tags = list(filter(None, tags))
    reply_text = ""
    if ctx.bot.source.name == "twitter" and datetime.now().isoweekday() == 3:
        reply_text = "#{0}Wednesday".format(list_name)
    elif ctx.bot.source.name == "twitter":
        reply_text = "#{0}AnyDay".format(list_name)
    else:
        reply_text = "{gender} is {name}".format(gender=list_name, name=clean_name)
    reply_media = []
    checked_main_dir = False
    media_args = {'ignore_used': skip_already_used}
    if ctx.bot.source.allow_new_mywaifu:
        media_args = {'tags': tags, 'random_page': True, 'return_url': ctx.bot.source.support_embedded,
                      'ignore_used': skip_already_used}
    for x in range(0, ctx.media_repeat_for):
        image = get_media(path=path_name, ctx=ctx, media_args=media_args)
        if not image and not checked_main_dir:
            checked_main_dir = True
            path_name = os.path.join(path_name, "My" + list_name)
        if image:
            reply_media.append(image)
        if not reply_media:
            if ctx.bot.source.allow_new_mywaifu:
                if ctx and  ctx.bot.source.name == "twitter":
                    ctx.bot.check_rate_limit_per_cmd(ctx, remove=1)
                url_help = help_urls.get('mywaifu_no_image', False)
                reply_text = ("Failed to grab a new image!\n"
                              "The image websites could be offline.\n"
                              "Try again later!{}".format(
                    "\nHelp: " + url_help if url_help else ""))
            else:
                reply_text = ("Failed to grab a new image!\n"
                              "Use the command on Twitter to help the bot store more images!\n"
                              "You can also use My{gender}+ to skip checking for an already used image"
                              " or My{gender}- to start from fresh!".format(gender=list_name))
            if len(reply_media) < 1:
                return reply_text
            break
    return reply_text, reply_media
Beispiel #11
0
def random_list(ctx):
    male_only_lists = ["shota", "onii"]
    # Both female and male can be under these.
    both_gender_lists = ["idol", "sensei", "senpai", "kouhai", "yandere", "tsundere"]
    # Simple way to make sure to not load male list if one of these are used.
    possible_search = ["love", "idolmaster", "cinderella",
                       "akb0048", "wake", "aikatsu"] 
    # List of lists that don't need to show the series.
    ignore_series_lists = ["shipgirl", "touhou", "witchgirl", "tankgirl", "vocaloid", "unwrap"]
    list_name = "Waifu"
    end_tag = ["1girl", "solo"]
    args = ctx.message.lower()
    result = ()
    search_for = ""
    show_series = False if ctx.command in ignore_series_lists else True
    support_otp = False
    skip_online = False
    # Special per list stuff
    if ctx.command == "shipgirl":
        # Default shipgirl to kantai collection only
        search_for = "Kantai Collection"
        support_otp = True
        if "all" in args:
            search_for = ""
        elif "aoki" in args:
            search_for = "Aoki Hagane no Arpeggio"
    elif ctx.command == "idol":
        args = args.replace("!", "").replace("@", "a")
        if "love live sunshine" in args:
            search_for = "Love Live! Sunshine!!"
        elif "love live" in args:
            search_for = "Love Live!"
            support_otp = True
        elif "idolmaster" in args:
            search_for = "Idolmaster"
        elif "cinderella" in args:
            search_for = "Idolmaster Cinderella Girls"
        elif "akb0048" in args:
            search_for = "AKB0048"
        elif "wake up" in args:
            search_for = "Wake Up Girls!"
        elif "aikatsu" in args:
            search_for = "Aikatsu!"
    elif ctx.command == "unwrap":
        show_series = True
        end_tag.append("santa_costume")
    if (ctx.command in both_gender_lists and "male" in args and not "female" in args and not search_for)\
        or ctx.command in male_only_lists:
            list_name = "Husbando"
            end_tag = ["-1girl", "-female", "1boy"]
    elif (ctx.command in both_gender_lists and not "female" in args and not search_for):
        random_gender = random.randint(0, 10)
        if random_gender > 8:
            list_name = "Husbando"
            end_tag = ["-1girl", "-female", "1boy"]
    if ctx.command in male_only_lists:
        list_name = "Husbando"
        end_tag = ["-1girl", "-female", "1boy"]
    if support_otp and "otp" in args:
        list_name = "OTP"
    if ctx.command == "onee" or ctx.command == "onii":
        ctx.command = ctx.command + "-chan"
    if ctx.command == "okaa":
        ctx.command = ctx.command + "-san"
    path = os.path.join(ctx.bot.config_path, '{} List.yaml'.format(list_name))
    char_list = yaml_to_list(path, ctx.command.lower())
    if search_for:
        result = filter_per_series(char_list, search_for, 4)
    if not result:
        result = random.choice(char_list)
    series = result[1].get('series')
    otp_image = result[1].get('otp image')
    start_path = settings.get('image_location', os.path.join(os.path.realpath(__file__), 'images'))
    if list_name == "OTP":
        name_one, name_two = result[0].split("(x)")
        end_tag = ["2girls", "yuri", name_one.replace(" ", "_"), name_two.replace(" ", "_")]
        list_title = ctx.command.title() + " OTP"
        name = "{} x {}".format(re.sub("[\(\[].*?[\)\]]", "", name_one).strip(),
                                re.sub("[\(\[].*?[\)\]]", "", name_two).strip())
        path_name = os.path.join(start_path, list_name, slugify(name))
    else:
        list_title = ctx.command.title()
        name = re.sub("[\(\[].*?[\)\]]", "", result[0]).strip()  # Remove () and []
        end_tag.append(result[0].replace(" ", "_"))
        path_name = os.path.join(start_path, list_name, slugify(result[0]))
        if ctx.command == "unwrap":
            path_name = os.path.join(path_name, "christmas")
    if ctx.command == "granblue":
        reply_text = "{} has joined your party!".format(name)
    elif ctx.command == "unwrap":
        merry_ran_end = ["Merry Christmas!", "Happy Holidays!", "Season's Greetings!", "Merii Kurisumasu!"]
        reply_text = "{} was in your present ({}). {}".format(name, series, random.choice(merry_ran_end))
    else:
        reply_text = "Your {} is {}{}".format(
            list_title.replace("-C", "-c").replace("-S", "-s"),  # w/e
            name,
            "" if not show_series else " ({})".format(series))
    media_args = {'tags': end_tag, 'skip_online': skip_online}
    reply_media = get_media(path=path_name, ctx=ctx, media_args=media_args)
    return reply_text, reply_media
Beispiel #12
0
def random_list(ctx):
    male_only_lists = ["shota", "onii"]
    # Both female and male can be under these.
    both_gender_lists = ["idol", "sensei", "senpai", "kouhai", "yandere", "tsundere", "fate/servant"]
    # Simple way to make sure to not load male list if one of these are used.
    possible_search = ["love", "idolmaster", "cinderella",
                       "akb0048", "wake", "aikatsu"] 
    # List of lists that don't need to show the series.
    ignore_series_lists = ["shipgirl", "touhou", "witchgirl", "tankgirl", "vocaloid", "unwrap"]
    list_name = "Waifu"
    end_tag = ["1girl", "solo"]
    args = ctx.message.lower()
    result = ()
    search_for = ""
    show_series = False if ctx.command in ignore_series_lists else True
    support_otp = False
    skip_online = False
    # Special per list stuff
    if ctx.command == "shipgirl":
        # Default shipgirl to kantai collection only
        search_for = "Kantai Collection"
        support_otp = True
        if "all" in args:
            search_for = ""
        elif "aoki" in args:
            search_for = "Aoki Hagane no Arpeggio"
    elif ctx.command == "idol":
        args = args.replace("!", "").replace("@", "a")
        if "love live sunshine" in args:
            search_for = "Love Live! Sunshine!!"
        elif "love live" in args:
            search_for = "Love Live!"
            support_otp = True
        elif "idolmaster" in args:
            search_for = "Idolmaster"
        elif "cinderella" in args:
            search_for = "Idolmaster Cinderella Girls"
        elif "akb0048" in args:
            search_for = "AKB0048"
        elif "wake up" in args:
            search_for = "Wake Up Girls!"
        elif "aikatsu" in args:
            search_for = "Aikatsu!"
    elif ctx.command == "unwrap":
        show_series = True
        end_tag.append("santa_costume")
    elif ctx.command == "fate/servant":
        skip_online = True
    if (ctx.command in both_gender_lists and "male" in args and not "female" in args and not search_for)\
        or ctx.command in male_only_lists:
            list_name = "Husbando"
            end_tag = ["-1girl", "-female", "1boy"]
    elif (ctx.command in both_gender_lists and not "female" in args and not search_for):
        random_gender = random.randint(0, 10)
        if random_gender > 8:
            list_name = "Husbando"
            end_tag = ["-1girl", "-female", "1boy"]
    if ctx.command in male_only_lists:
        list_name = "Husbando"
        end_tag = ["-1girl", "-female", "1boy"]
    if support_otp and "otp" in args:
        list_name = "OTP"
    if ctx.command == "onee" or ctx.command == "onii":
        ctx.command = ctx.command + "-chan"
    if ctx.command == "okaa":
        ctx.command = ctx.command + "-san"
    path = os.path.join(ctx.bot.config_path, '{} List.yaml'.format(list_name))
    char_list = yaml_to_list(path, ctx.command.lower())
    if search_for:
        result = filter_per_series(char_list, search_for, 4)
    if not result:
        if ctx.command == "fate/servant":
            rng = random.randint(1, 1000)
            if rng <= 700:
                card_rank = range(1, 4)
            elif 701 <= rng <= 900:
                card_rank = range(4, 5)
            elif rng >= 901:
                card_rank = range(5, 6)
            break_count = 0
            print("CARD RANK")
            print(card_rank)
            while True:
                if break_count == 10:
                    break
                result = random.choice(char_list)
                if result[1].get('get_rate', 1) in card_rank:
                    break
                break_count += 1
        else:
            result = random.choice(char_list)
    print(result)
    series = result[1].get('series')
    otp_image = result[1].get('otp image')
    start_path = settings.get('image_location', os.path.join(os.path.realpath(__file__), 'images'))
    if list_name == "OTP":
        name_one, name_two = result[0].split("(x)")
        end_tag = ["2girls", "yuri", name_one.replace(" ", "_"), name_two.replace(" ", "_")]
        list_title = ctx.command.title() + " OTP"
        name = "{} x {}".format(re.sub("[\(\[].*?[\)\]]", "", name_one).strip(),
                                re.sub("[\(\[].*?[\)\]]", "", name_two).strip())
        path_name = os.path.join(start_path, list_name, slugify(name))
    else:
        list_title = ctx.command.title()
        name = re.sub("[\(\[].*?[\)\]]", "", result[0]).strip()  # Remove () and []
        end_tag.append(result[0].replace(" ", "_"))
        path_name = os.path.join(start_path, list_name, slugify(result[0]))
        if ctx.command == "unwrap":
            path_name = os.path.join(path_name, "christmas")
    if ctx.command == "granblue":
        reply_text = "{} has joined your party!".format(name)
    elif ctx.command == "unwrap":
        merry_ran_end = ["Merry Christmas!", "Happy Holidays!", "Season's Greetings!", "Merii Kurisumasu!"]
        reply_text = "{} was in your present ({}). {}".format(name, series, random.choice(merry_ran_end))
    elif ctx.command == "fate/servant":
        reply_text = "Your {} is {} {}".format(list_title, name, "")
    else:
        reply_text = "Your {} is {}{}".format(
            list_title.replace("-C", "-c").replace("-S", "-s"),  # w/e
            name,
            "" if not show_series else " ({})".format(series))
    media_args = {'tags': end_tag, 'skip_online': skip_online}
    reply_media = get_media(path=path_name, ctx=ctx, media_args=media_args)
    return reply_text, reply_media