diff --git a/filters/markov.py.dist b/filters/markov.py.dist new file mode 100644 index 0000000..4b9cd24 --- /dev/null +++ b/filters/markov.py.dist @@ -0,0 +1,14 @@ +""" +This file allows you to add your own hooks to the markov.py script without +having to mess around with the code. +""" + +def textFilter(text): + """ + Code to be executed when a new tweet has been generated. + + :param text: Text of the new tweet as String + :return: True if the text may be tweeted, else False + """ + + return True diff --git a/markov.py b/markov.py index dff8d8f..a42854d 100755 --- a/markov.py +++ b/markov.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -import dbtools, setuptools, twitools +import dbtools, setuptools, twitools, filters.markov import argparse, datetime, html, markovify, nltk, operator, os, random, re, string, sys, time class Possy(markovify.NewlineText): @@ -45,5 +45,6 @@ def getTime(now = datetime.datetime.now()): if __name__ == "__main__": text = markovifyText(getText()) - time.sleep(getTime()) - twitools.tweet(text, section = setuptools.MARKOV) + if filters.markov.textFilter(text): + time.sleep(getTime()) + twitools.tweet(text, section = setuptools.MARKOV) diff --git a/setup.py b/setup.py index 1945f6f..6355dcc 100755 --- a/setup.py +++ b/setup.py @@ -7,6 +7,9 @@ os.makedirs("media", exist_ok=True) if not os.path.isfile("filters/filler.py"): shutil.copyfile("filters/filler.py.dist", "filters/filler.py") +if not os.path.isfile("filters/markov.py"): + shutil.copyfile("filters/markov.py.dist", "filters/markov.py") + if os.path.isfile("config.cfg"): print("config.cfg already exists. Please remove it before running this script.") exit(1)