예제 #1
0
파일: test.py 프로젝트: nicklewis/brittbot
def justxthingshandler(jenni, msg):
    from modules.brittbot.pil import justxthings
    from modules.find import load_db

    hashtag = msg.groups()[1]
    quote = msg.groups()[0]

    if not quote:
        quotes = load_db().get(msg.sender)
        if quotes and 'last_said' in quotes:
            quotes['last_said'] = [quote for quote in quotes['last_said'] if not re.match(r'(.*)(#\S+\w)$', quote)]
            quote = ''.join(quotes['last_said'][-1].split(':')[1:])

    if quote[0] in ['!'] or 'http' in quote:
        return

    if hashtag.startswith("##"):
        return
    if len(quote.split(' ')) > 25:
        return
    url = "http://brittbot.brittg.com/{}".format(justxthings.generate_image(
        str(quote),
        hashtag,
    ))
    jenni.reply(url)
예제 #2
0
파일: test.py 프로젝트: nicklewis/brittbot
def justxthingslistener(jenni, msg):
    from modules.brittbot.pil import justxthings
    if msg.sender not in [
        "#internship",
        "#r/kansascity",
        "#reddit-stlouis",
        "demophoon",
    ]:
        return
    if 'last_action' not in jenni.brain:
        jenni.brain['last_action'] = {}
    if msg.sender not in jenni.brain['last_action']:
        jenni.brain['last_action'][msg.sender] = 0
    if time.time() < jenni.brain['last_action'][msg.sender] + 3600:
        return
    if len(msg.split(' ')) == 1 or len(msg.split(' ')) > 20:
        return
    try:
        if str(msg)[0] in ['!']:
            return
    except Exception:
        return

    if random.choice(range(175)) == 0:
        url = "http://brittbot.brittg.com/{}".format(justxthings.generate_image(
            str(msg),
            "#just{}things".format(msg.nick)
        ))
        jenni.say(url)
        jenni.brain['last_action'][msg.sender] = time.time()
예제 #3
0
파일: test.py 프로젝트: HAIL9000/brittbot
def justxthingslistener(jenni, msg):
    from modules.brittbot.pil import justxthings
    if 'last_action' not in jenni.brain:
        jenni.brain['last_action'] = {}
    if msg.sender not in jenni.brain['last_action']:
        jenni.brain['last_action'][msg.sender] = 0
    if time.time() < jenni.brain['last_action'][msg.sender] + 3600:
        return
    if len(msg.split(' ')) == 1 or len(msg.split(' ')) > 20:
        return
    try:
        if str(msg)[0] in ['!']:
            return
    except Exception:
        return
    if "action" in msg.lower():
        return

    if random.choice(range(175)) == 0:
        url = "http://brittbot.brittg.com/{}".format(justxthings.generate_image(
            str(msg),
            "#just{}things".format(msg.nick)
        ))
        jenni.say(url)
        jenni.brain['last_action'][msg.sender] = time.time()
예제 #4
0
파일: test.py 프로젝트: HAIL9000/brittbot
def justxthingshandler(jenni, msg):
    from modules.brittbot.pil import justxthings
    from modules.find import load_db

    hashtag = msg.groups()[1]
    quote = msg.groups()[0]

    if not quote:
        quotes = load_db().get(msg.sender)
        if quotes and 'last_said' in quotes:
            quotes['last_said'] = [quote for quote in quotes['last_said'] if not re.match(r'(.*)(#\S+\w)$', quote)]
            quote = ''.join(quotes['last_said'][-1].split(':')[1:])

    if quote[0] in ['!'] or 'http' in quote:
        return
    if hashtag.startswith("##"):
        return
    if "action" in msg.lower():
        return
    if len(quote.split(' ')) > 25:
        return
    url = "http://brittbot.brittg.com/{}".format(justxthings.generate_image(
        str(quote),
        hashtag,
    ))
    jenni.reply(url)
예제 #5
0
파일: test.py 프로젝트: branan/brittbot
def justxthingshandler(jenni, msg):
    from modules.brittbot.pil import justxthings
    hashtag = msg.groups()[1]
    quote = msg.groups()[0]

    if quote[0] in ['!']:
        return
    if hashtag.startswith("##"):
        return
    url = "http://brittbot.brittg.com/%s" % justxthings.generate_image(
        str(quote),
        hashtag,
    )
    jenni.reply(url)
예제 #6
0
def justxthingshandler(jenni, msg):
    from modules.brittbot.pil import justxthings
    from modules.find import load_db

    hashtag = msg.groups()[1]
    quote = msg.groups()[0]

    if not quote:
        quotes = load_db().get(msg.sender)
        if quotes and "last_said" in quotes:
            quotes["last_said"] = [quote for quote in quotes["last_said"] if not re.match(r"(.*)(#\S+\w)$", quote)]
            quote = "".join(quotes["last_said"][-1].split(":")[1:])

    if quote[0] in ["!"] or "http" in quote:
        return

    if hashtag.startswith("##"):
        return
    if len(quote.split(" ")) > 25:
        return
    url = "http://brittbot.brittg.com/{}".format(justxthings.generate_image(str(quote), hashtag))
    jenni.reply(url)
예제 #7
0
def justxthingslistener(jenni, msg):
    if 'last_action' not in jenni.brain:
        jenni.brain['last_action'] = {}
    if msg.sender not in jenni.brain['last_action']:
        jenni.brain['last_action'][msg.sender] = 0
    if time.time() < jenni.brain['last_action'][msg.sender] + 3600:
        return
    if len(msg.split(' ')) == 1 or len(msg.split(' ')) > 20:
        return
    try:
        if str(msg)[0] in ['!']:
            return
    except Exception:
        return
    if "action" in msg.lower():
        return

    if random.choice(range(175)) == 0:
        url = "http://brittbot.brittg.com/{}".format(justxthings.generate_image(
            str(msg),
            "#just{}things".format(msg.nick)
        ))
        jenni.say(url)
        jenni.brain['last_action'][msg.sender] = time.time()