add retweet of my tweet to notification
[rainbowstream.git] / rainbowstream / rainbow.py
index fa66626634ab1f68061374f0d8892ae10e9cbf60..08cdcb7409cac73a65a3c2486fa138af92ce6678 100644 (file)
@@ -133,8 +133,12 @@ def init(args):
     g['themes'] = themes
     g['pause'] = False
     g['message_threads'] = {}
+    # Events
+    g['events'] = []
     # Startup cmd
     g['cmd'] = ''
+    # Retweet of mine events
+    c['events'] = []
     # Semaphore init
     c['lock'] = False
     # Init tweet dict and message dict
@@ -196,6 +200,19 @@ def home():
     printNicely('')
 
 
+def notification():
+    """
+    Show notifications
+    """
+    g['events'] = g['events'] + c['events']
+    if g['events']:
+        for e in g['events']:
+            print_event(e)
+        printNicely('')
+    else:
+        printNicely(magenta('Nothing at this time.'))
+
+
 def mentions():
     """
     Mentions timeline
@@ -1226,6 +1243,8 @@ def help_discover():
         light_green('trend JP Tokyo') + '.\n'
     usage += s * 2 + light_green('home') + ' will show your timeline. ' + \
         light_green('home 7') + ' will show 7 tweets.\n'
+    usage += s * 2 + \
+        light_green('notification') + ' will show your recent notification.\n'
     usage += s * 2 + light_green('mentions') + ' will show mentions timeline. ' + \
         light_green('mentions 7') + ' will show 7 mention tweets.\n'
     usage += s * 2 + light_green('whois @mdo') + ' will show profile  of ' + \
@@ -1535,6 +1554,7 @@ cmdset = [
     'switch',
     'trend',
     'home',
+    'notification',
     'view',
     'mentions',
     't',
@@ -1579,6 +1599,7 @@ funcset = [
     switch,
     trend,
     home,
+    notification,
     view,
     mentions,
     tweet,
@@ -1636,6 +1657,7 @@ def listen():
             ['public', 'mine'],  # switch
             [],  # trend
             [],  # home
+            [],  # notification
             ['@'],  # view
             [],  # mentions
             [],  # tweet
@@ -1825,6 +1847,9 @@ def stream(domain, args, name='Rainbow Stream'):
                 while c['lock']:
                     time.sleep(0.5)
                 print_message(tweet['direct_message'])
+            elif tweet.get('event'):
+                g['events'].append(tweet)
+                print_event(tweet)
     except TwitterHTTPError:
         printNicely('')
         printNicely(