Allow Markov bot to tweet exactly at 0/15/30/45
This commit is contained in:
parent
1b77e73da4
commit
a7be36e3cf
1 changed files with 11 additions and 1 deletions
12
markov.py
12
markov.py
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue