From d6b95f504c7cd012a772e50e68a199c8c810a023 Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Mitterer Date: Wed, 15 Feb 2017 19:09:48 +0100 Subject: [PATCH] Markov bot --- markov.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 markov.py diff --git a/markov.py b/markov.py new file mode 100755 index 0000000..9b04af3 --- /dev/null +++ b/markov.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python3 + +import dbtools, twitools +import argparse, markovify, operator, random, re, sys + +def getText(db = dbtools.dbHelper()): + return '\n'.join(db.executeQuery("SELECT text FROM tweets;")) + +def markovify(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()))