Beispiel #1
0
def generate_image():
    print(request.values)
    topText = request.form['topText']
    botText = request.form['botText']
    image_path = request.form['image_path']
    output_name = create_meme(topText, botText, image_path)
    return jsonify({"output_name": output_name})
Beispiel #2
0
    def meme( self, mess, args):
        """Create a meme, for the lulz"""
        user = self.get_sender_username(mess)
        if user in self.users:
            try:
                # FIXME: Parse this better
                commands = args.split(' ')
                meme_id = commands[0]
                if meme_id in ('help', '', None):
                    memes = meme.list_memes()
                    help_msg = "usage: ,meme meme 'top text' 'button text' [nyanit] where meme is %s. nyanit is an optional param to create more lulz" % memes 
                    return help_msg

                parsed = args.split('\'')
                (top, button) = (parsed[1], parsed[3])
                meme_url = meme.create_meme(meme_id, top, button)
                try:
                    if commands[3] in ('nyanit',):
                        meme_url = meme_url.replace('http://', meme.nyanurl)
                except IndexError, e:
                    pass # no nyanit
                self.message_queue.append('_%s created a meme %s _' %(self.users[user], meme_url))
                self.log.info( '%s created a meme, for the lulz' % user)

            except Exception:
                self.log.info( '%s tried to create a meme, but failed' % user)
Beispiel #3
0
    def meme(self, mess, args):
        """Create a meme, for the lulz"""
        user = self.get_sender_username(mess)
        if user in self.users:
            try:
                # FIXME: Parse this better
                commands = args.split(' ')
                meme_id = commands[0]
                if meme_id in ('help', '', None):
                    memes = meme.list_memes()
                    help_msg = "usage: ,meme meme 'top text' 'button text' [nyanit] where meme is %s. nyanit is an optional param to create more lulz" % memes
                    return help_msg

                parsed = args.split('\'')
                (top, button) = (parsed[1], parsed[3])
                meme_url = meme.create_meme(meme_id, top, button)
                try:
                    if commands[3] in ('nyanit', ):
                        meme_url = meme_url.replace('http://', meme.nyanurl)
                except IndexError, e:
                    pass  # no nyanit
                self.message_queue.append('_%s created a meme %s _' %
                                          (self.users[user], meme_url))
                self.log.info('%s created a meme, for the lulz' % user)

            except Exception:
                self.log.info('%s tried to create a meme, but failed' % user)
Beispiel #4
0
def memegen(inp, nick='', chan='', say=None):
    ".meme list <pattern> <n1-12> -- searches memegenerator.net" \
    " | .meme list - <n1-12> -- lists popular meme characters" \
    " | .meme gen|g|-|generate <name> <line1> <line2> -- generates meme" \
    " | .meme fuzzy <pattern> <line1> <line2> -- generate using first match"

    errormsg = "improperly formatted -- do `.help memegen` for help"

    parts = shlex.split(inp.encode('ascii'))
    cmd = parts[0]
    argc = len(parts)

    if cmd == 'list':
        pattern = None
        number = None

        if argc > 1:
            pattern = parts[1]
        if argc > 2:
            number = int(parts[2])

        if pattern and pattern in ['-', 'pop', 'popular', '--']:
            pattern = None

        matches = meme.list_memes(pattern)

        if number and number > len(matches):
            number = None

        if len(matches) == 0:
            result = "no meme characters match search"
        elif not number:
            result = ' '.join([
                "[%d] %s:%s" % (k + 1, v['title'], v['score'])
                for k, v in enumerate(matches)
            ])
        else:
            match = matches[number - 1]
            result = "%s [%s]: %s (%d/%d)" % (
                match['title'],
                match['score'],
                "%s/%s" % (meme.IMAGES, match['image']),
                number,
                len(matches),
            )
    elif cmd in ['gen', 'g', 'generate', '-', 'fuzzy']:
        if argc < 4:
            result = errormsg
        else:
            title = parts[1]
            lines = parts[2:4]
            if cmd == 'fuzzy':
                matches = meme.list_memes(title)
                title = matches[0]['title']
            try:
                result = meme.create_meme(title, lines)
            except Exception, e:
                result = 'error: %s' % e
Beispiel #5
0
def memegen(inp, nick='', chan='', say=None):
    ".meme list <pattern> <n1-12> -- searches memegenerator.net" \
    " | .meme list - <n1-12> -- lists popular meme characters" \
    " | .meme gen|g|-|generate <name> <line1> <line2> -- generates meme" \
    " | .meme fuzzy <pattern> <line1> <line2> -- generate using first match"

    errormsg = "improperly formatted -- do `.help memegen` for help"

    parts = shlex.split(inp.encode('ascii'))
    cmd = parts[0]
    argc = len(parts)

    if cmd == 'list':
        pattern = None
        number = None

        if argc > 1:
            pattern = parts[1]
        if argc > 2:
            number = int(parts[2])

        if pattern and pattern in ['-', 'pop', 'popular', '--']:
            pattern = None

        matches = meme.list_memes(pattern)

        if number and number > len(matches):
            number = None

        if len(matches) == 0:
            result = "no meme characters match search"
        elif not number:
            result = ' '.join(["[%d] %s:%s" % (k+1, v['title'], v['score'])
                              for k, v in enumerate(matches)])
        else:
            match = matches[number-1]
            result = "%s [%s]: %s (%d/%d)" % (
                match['title'],
                match['score'],
                "%s/%s" % (meme.IMAGES, match['image']),
                number,
                len(matches),
            )
    elif cmd in ['gen', 'g', 'generate', '-', 'fuzzy']:
        if argc < 4:
            result = errormsg
        else:
            title = parts[1]
            lines = parts[2:4]
            if cmd == 'fuzzy':
                matches = meme.list_memes(title)
                title = matches[0]['title']
            try:
                result = meme.create_meme(title, lines)
            except Exception, e:
                result = 'error: %s' % e
Beispiel #6
0
    def meme( self, mess, args):
        """Create a meme, for the lulz"""
        user = self.get_sender_username(mess)
        if user in self.users:
            try:
                meme_id = args.split(' ')[0]
                if meme_id in ('help', '', None):
                    memes = meme.list_memes()
                    help_msg = "usage: ,meme meme 'top text' 'button text' where meme is %s" % memes 
                    return help_msg

                parsed = args.split('\'')
                (top, button) = (parsed[1], parsed[3])
                meme_url = meme.create_meme(meme_id, top, button)
                self.message_queue.append('_%s created a meme %s _' %(self.users[user], meme_url))
                self.log.info( '%s created a meme, for the lulz' % user)

            except Exception:
                self.log.info( '%s tried to create a meme, but failed' % user)
#!/usr/bin/env python3
import yaml
import subprocess
from meme import create_meme

with open("./memes.yaml") as f:
    memes = yaml.safe_load(f)

    for i, (filename, meme) in enumerate(memes.items()):
        print(f"completed {i+1} of {len(memes)} memes to render")
        texts = [f"text {i}" for i in range(len(meme['text_points']))]
        create_meme(meme["identifier"], texts, f"./samples/sample-{filename}")
        texts = [
            f"text some super long text over here lol just text text text texty texty texty mmm something something something {i}"
            for i in range(len(meme['text_points']))
        ]
        create_meme(meme["identifier"], texts,
                    f"./samples/sample-longtext-{filename}")

with open("./meme-samples.md", "w") as f:
    f.write("# meme samples\n")
    f.write("samples for the provided memeing options\n")
    f.write("\n\n\n")
    for i, (filename, meme) in enumerate(memes.items()):
        f.write(f"## {i}, {meme['identifier']}\n\n")
        f.write(
            f"![{meme['identifier']} sample](./samples/sample-{filename})\n")
        f.write(
            f"![{meme['identifier']} sample](./samples/sample-longtext-{filename})\n\n\n\n"
        )