Unfuck tweetorator

This commit is contained in:
Paal Braathen committed 2016-09-09 15:42:27 +02:00
1 parent 5e9d62e425
commit 4e56067d82
1 file changed
+28 -38
+28 -38
View File
@@ -1,5 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
#coding: utf-8 #coding: utf-8
import ConfigParser
import sys import sys
import twitter import twitter
import logging import logging
@@ -19,19 +20,18 @@ initialized = False
def init(): def init():
global _api global _api
# TWITTER IS FUCKED. paalbra 2016-06-08 cfg = ConfigParser.RawConfigParser()
# cfg = ConfigParser.RawConfigParser() cfg.read("tweetorator.cfg")
# cfg.read("tweetorator.cfg") consumer_key = cfg.get("twitter", "consumer_key")
# consumer_key = cfg.get("twitter", "consumer_key") consumer_secret = cfg.get("twitter", "consumer_secret")
# consumer_secret = cfg.get("twitter", "consumer_secret") access_token_key = cfg.get("twitter", "access_token_key")
# access_token_key = cfg.get("twitter", "access_token_key") access_token_secret = cfg.get("twitter", "access_token_secret")
# access_token_secret = cfg.get("twitter", "access_token_secret") _api = twitter.Api(consumer_key = consumer_key,
# _api = twitter.Api(consumer_key = consumer_key, consumer_secret = consumer_secret,
# consumer_secret = consumer_secret, access_token_key = access_token_key,
# access_token_key = access_token_key, access_token_secret = access_token_secret)
# access_token_secret = access_token_secret)
# logging.debug("VerifyCredentials: %s" % _api.VerifyCredentials())
# logging.debug("VerifyCredentials: %s" % _api.VerifyCredentials())
tldb.loadCfg('tldb.cfg') tldb.loadCfg('tldb.cfg')
@@ -46,28 +46,18 @@ def post_confession(text):
if not initialized: if not initialized:
init() init()
## UNFUCK START if len(text) > 140:
logging.info("Adding unfucked confession") logging.info("Adding confession longer than 140")
try: try:
tldb.addConfession(text) tldb.addConfession(text)
except: except:
logging.error("%s, 0, text was >>%s<<" % (sys.exc_info()[0], text)) logging.error("%s, 1, text was >>%s<<" % (sys.exc_info()[0], text))
pass pass
## UNFUCK END else:
logging.info("Adding confession shorter than 140")
# THIS IS FUCKED BEFAUSE TWITTER IS FUCKED. paalbra 2016-06-08 try:
# if len(text) > 140: status = _api.PostUpdate(text)
# logging.info("Adding confession longer than 140") tldb.addConfession(text, status.AsJsonString())
# try: except:
# tldb.addConfession(text) logging.error("%s, 2, text was >>%s<<" % (sys.exc_info()[0], text))
# except: pass
# logging.error("%s, 1, text was >>%s<<" % (sys.exc_info()[0], text))
# pass
# else:
# logging.info("Adding confession shorter than 140")
# try:
# status = _api.PostUpdate(text)
# tldb.addConfession(text, status.AsJsonString())
# except:
# logging.error("%s, 2, text was >>%s<<" % (sys.exc_info()[0], text))
# pass