twitools/markov.py

20 lines
501 B
Python
Raw Normal View History

2017-02-15 18:09:48 +00:00
#!/usr/bin/env python3
import dbtools, twitools
import argparse, markovify, operator, random, re, sys
def getText(db = dbtools.dbHelper()):
2017-02-15 18:16:19 +00:00
text = ""
for string in db.executeQuery("SELECT text FROM tweets;"):
text += string[0] + "\n"
return text
2017-02-15 18:09:48 +00:00
2017-02-15 18:16:19 +00:00
def markovifyText(text):
2017-02-15 18:09:48 +00:00
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__":
2017-02-15 18:16:19 +00:00
tweet(markovifyText(getText()))