From 33331181d25487b7e0706a018f9586b67cd81858 Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Mitterer Date: Wed, 15 Feb 2017 19:16:19 +0100 Subject: [PATCH] Fix markov bot --- markov.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/markov.py b/markov.py index 9b04af3..5424d94 100755 --- a/markov.py +++ b/markov.py @@ -4,13 +4,16 @@ import dbtools, twitools import argparse, markovify, operator, random, re, sys def getText(db = dbtools.dbHelper()): - return '\n'.join(db.executeQuery("SELECT text FROM tweets;")) + text = "" + for string in db.executeQuery("SELECT text FROM tweets;"): + text += string[0] + "\n" + return text -def markovify(text): +def markovifyText(text): return markovify.Text(text).make_short_sentence(130).replace("@", "@​") def tweet(text, ref = 0, two = twitools.twObject()): return two.tweet(text, ref).id if __name__ == "__main__": - tweet(markovify(getText())) + tweet(markovifyText(getText()))