Custom prefix with formatting
[rainbowstream.git] / rainbowstream / util.py
index e8d3c74c0b4ba454ffc7fa4cf6c28824477bd66b..1451aecdae4b441c6e13cf95ed010d5d50bd630f 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,25 @@ 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']
+    username = '@' + c['original_name']
+    place = ''
+    if keyword != '':
+        place = '/public'
+        keyword = '#' + keyword
+
+    if listname != '':
+        username, place = listname.split('/')
+        place = "/" + place
+
+    formattedPrefix = formattedPrefix.replace("#username", username)
+    formattedPrefix = formattedPrefix.replace("#place", place)
+    formattedPrefix = formattedPrefix.replace("#keyword", keyword)
+
+    return formattedPrefix