Exemplo n.º 1
0
def run_bot(sub):
    subreddit = r.get_subreddit(sub)
    comments = subreddit.get_comments(limit = 25)
    print "Grabbing comments..."
    for comment in comments:
        if comment.id not in cache and syllables.haikuviable(comment.body.lower()):
            print "Match found! Comment id:" + comment.id
            haikulist = syllables.generatehaiku(comment.body)
            fulcomment = '  \n'.join(haikulist)
            fullcomment = "Hmm... that reminds me of a haiku...  \n  \n" + fulcomment
            comment.reply(fullcomment)
            cache.append(comment.id)
Exemplo n.º 2
0
def test_generatehaiku():
    assert syllables.generatehaiku('Despite the weather, Arabella went running. She soon fell over') == ['Despite the weather,', 'Arabella went running.', 'She soon fell over']