Create file for Markov bot filters#
This commit is contained in:
parent
eccd79c373
commit
ed4615c890
3 changed files with 21 additions and 3 deletions
14
filters/markov.py.dist
Normal file
14
filters/markov.py.dist
Normal file
|
@ -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
|
|
@ -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)
|
||||
|
|
3
setup.py
3
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)
|
||||
|
|
Loading…
Reference in a new issue