Allow Markov bot to tweet exactly at 0/15/30/45
This commit is contained in:
parent
1ce7470fac
commit
b0f6f1a14c
12
markov.py
12
markov.py
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import dbtools, setuptools, twitools
|
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):
|
class Possy(markovify.NewlineText):
|
||||||
def word_split(self, sentence):
|
def word_split(self, sentence):
|
||||||
|
@ -36,6 +36,16 @@ def getText(db = dbtools.dbHelper()):
|
||||||
def markovifyText(text):
|
def markovifyText(text):
|
||||||
return Possy(text).make_short_sentence(130).replace("@", "@")
|
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__":
|
if __name__ == "__main__":
|
||||||
os.nice(5)
|
os.nice(5)
|
||||||
|
time.sleep(getTime())
|
||||||
twitools.tweet(markovifyText(getText()), section = setuptools.MARKOV)
|
twitools.tweet(markovifyText(getText()), section = setuptools.MARKOV)
|
||||||
|
|
Loading…
Reference in a new issue