Allow Markov bot to tweet exactly at 0/15/30/45

This commit is contained in:
Klaus-Uwe Mitterer 2017-02-21 22:22:44 +01:00
parent 1ce7470fac
commit b0f6f1a14c

View file

@ -1,7 +1,7 @@
#!/usr/bin/env python3
import dbtools, setuptools, twitools
import argparse, html, markovify, nltk, operator, os, random, re, string, sys
import argparse, datetime, html, markovify, nltk, operator, os, random, re, string, sys, time
class Possy(markovify.NewlineText):
def word_split(self, sentence):
@ -36,6 +36,16 @@ def getText(db = dbtools.dbHelper()):
def markovifyText(text):
return Possy(text).make_short_sentence(130).replace("@", "@")
def getTime():
now = datetime.datetime.now()
thenminute = 15 if now.minute < 15 else 30 if now.minute < 30 else 45 if now.minute < 45 else 0
thenhour = now.hour + 1 if thenminute == 0 else now.hour
then = datetime.datetime(now.year, now.month, now.day, thenhour, thenminute, 0)
return (then - now).seconds
if __name__ == "__main__":
os.nice(5)
time.sleep(getTime())
twitools.tweet(markovifyText(getText()), section = setuptools.MARKOV)