twitools/markov.py
Klaus-Uwe Mitterer 33331181d2 Fix markov bot
2017-02-15 19:16:19 +01:00

19 lines
501 B
Python
Executable file
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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