minor fix
[rainbowstream.git] / rainbowstream / util.py
index e8d3c74c0b4ba454ffc7fa4cf6c28824477bd66b..292a7e5b408687f88f1f134500032302f011b810 100644 (file)
@@ -2,6 +2,7 @@ import json
 
 from twitter.util import printNicely
 from .colors import *
+from .config import *
 
 
 def detail_twitter_error(twitterException):
@@ -18,3 +19,35 @@ def detail_twitter_error(twitterException):
     except:
         info = "Error: " + twitterException.response_data.decode('utf8')
         printNicely(yellow(info))
+
+
+def format_prefix(listname='', keyword=''):
+    """
+    Format the custom prefix
+    """
+    formattedPrefix = c['PREFIX']
+    owner = '@' + c['original_name']
+    place = ''
+    # Public stream
+    if keyword:
+        formattedPrefix = ''.join(formattedPrefix.split('#owner'))
+        formattedPrefix = ''.join(formattedPrefix.split('#place'))
+        formattedPrefix = ''.join(formattedPrefix.split('#me'))
+    # List stream
+    elif listname:
+        formattedPrefix = ''.join(formattedPrefix.split('#keyword'))
+        formattedPrefix = ''.join(formattedPrefix.split('#me'))
+        owner, place = listname.split('/')
+        place = '/' + place
+    # Personal stream
+    else:
+        formattedPrefix = ''.join(formattedPrefix.split('#keyword'))
+        formattedPrefix = ''.join(formattedPrefix.split('#owner'))
+        formattedPrefix = ''.join(formattedPrefix.split('#place'))
+
+    formattedPrefix = formattedPrefix.replace('#owner', owner)
+    formattedPrefix = formattedPrefix.replace('#place', place)
+    formattedPrefix = formattedPrefix.replace('#keyword', keyword)
+    formattedPrefix = formattedPrefix.replace('#me', '@' + c['original_name'])
+
+    return formattedPrefix