Allow specifying the location of the twitter oauth and pocket oauth files. This shoul...
[rainbowstream.git] / rainbowstream / util.py
index 292a7e5b408687f88f1f134500032302f011b810..a1a2a446123cd09c5ad08d9bc3aaa8b7b96b3810 100644 (file)
@@ -9,16 +9,12 @@ def detail_twitter_error(twitterException):
     """
     Display Twitter Errors nicely
     """
+    data = twitterException.response_data
     try:
-        # twitterException.response_data can be byte string on Python 3
-        # or nornal dict on Python 2
-        loadedJson = json.loads(twitterException.response_data.decode('utf8'))
-        for m in loadedJson.get('errors', dict()):
-            info = "Error " + str(m.get('code')) + ": " + m.get('message')
-            printNicely(yellow(info))
+        for m in data.get('errors', dict()):
+            printNicely(yellow(m.get('message')))
     except:
-        info = "Error: " + twitterException.response_data.decode('utf8')
-        printNicely(yellow(info))
+        printNicely(yellow(data))
 
 
 def format_prefix(listname='', keyword=''):
@@ -51,3 +47,12 @@ def format_prefix(listname='', keyword=''):
     formattedPrefix = formattedPrefix.replace('#me', '@' + c['original_name'])
 
     return formattedPrefix
+
+
+def add_tweetmode_parameter(kwargs):
+    """
+    Add support for extended mode to Twitter API calls unless explicitly stated in config
+    """
+    if not c.get('DISABLE_EXTENDED_TWEETS'):
+        kwargs['tweet_mode'] = 'extended'
+    return kwargs