notify config changed in draw
[rainbowstream.git] / rainbowstream / draw.py
index 66c2483b957e87f33c008e5e5b92457db14159be..8bd0c50cd759cb11c0fb57affa2ed1c44ff7246f 100644 (file)
@@ -20,11 +20,6 @@ db = RainbowDB()
 g = {}
 
 
-def unescape(s):
-    p = HTMLParser()
-    return p.unescape(s)
-
-
 def init_cycle():
     """
     Init the cycle
@@ -116,6 +111,19 @@ def show_calendar(month, date, rel):
         printNicely(' '.join(ary))
 
 
+def check_config():
+   """
+   Check if config is changed
+   """
+   changed = False
+   data = get_all_config()
+   for key in data:
+       if data[key] != c[key]:
+           changed = True
+   if changed:
+       reload_config()
+
+
 def check_theme():
     """
     Check current theme and update if necessary
@@ -150,9 +158,10 @@ def draw(t, iot=False, keyword=None, check_semaphore=False, fil=[], ig=[]):
     """
 
     check_theme()
+    check_config()
     # Retrieve tweet
     tid = t['id']
-    text = unescape(t['text'])
+    text = t['text']
     screen_name = t['user']['screen_name']
     name = t['user']['name']
     created_at = t['created_at']
@@ -161,6 +170,16 @@ def draw(t, iot=False, keyword=None, check_semaphore=False, fil=[], ig=[]):
     date = date - datetime.timedelta(seconds=time.timezone)
     clock = date.strftime('%Y/%m/%d %H:%M:%S')
 
+    # Pull extended retweet text
+    try:
+        text = 'RT @' + t['retweeted_status']['user']['screen_name'] + ': ' +\
+            t['retweeted_status']['text']
+    except:
+        pass
+
+    # Unescape HTML character
+    text = unescape(text)
+
     # Get expanded url
     try:
         expanded_url = []
@@ -227,7 +246,7 @@ def draw(t, iot=False, keyword=None, check_semaphore=False, fil=[], ig=[]):
     # Highlight keyword
     tweet = ' '.join(tweet)
     if keyword:
-        roj = re.search(keyword,tweet,re.IGNORECASE)
+        roj = re.search(keyword, tweet, re.IGNORECASE)
         if roj:
             occur = roj.group()
             ary = tweet.split(occur)