add feature switch to a list stream
authorOrakaro <nhatminh_179@hotmail.com>
Sat, 13 Sep 2014 15:22:35 +0000 (00:22 +0900)
committerOrakaro <nhatminh_179@hotmail.com>
Sat, 13 Sep 2014 15:22:35 +0000 (00:22 +0900)
.python-version [new file with mode: 0644]
docs/conf.py
docs/index.rst
rainbowstream/rainbow.py
setup.py

diff --git a/.python-version b/.python-version
new file mode 100644 (file)
index 0000000..47b322c
--- /dev/null
@@ -0,0 +1 @@
+3.4.1
index ad07f8a2ff879bb6576de3ca608db38a2a1954ee..d222facdb4f102b2005efff70bb7b3fcb8d9f4eb 100644 (file)
@@ -48,9 +48,9 @@ copyright = u'2014, Vu Nhat Minh'
 # built documents.
 #
 # The short X.Y version.
-version = '1.0.2'
+version = '1.0.3'
 # The full version, including alpha/beta/rc tags.
-release = '1.0.2'
+release = '1.0.3'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
index 0c96d2841a7d083ec64e70744c8aee8ad899d2f3..e652ecd89746a8898992ee255743c7b40f54c52d 100644 (file)
@@ -222,6 +222,8 @@ Here is full list of supported command:
 \r
 -  ``switch mine`` will switch current stream to personal stream. ``-f`` and ``-d`` will work as well.\r
 \r
+-  ``switch list`` will switch to a Twitter list's stream. You will be asked for list name.\r
+\r
 **Smart shell**\r
 \r
 - Put anything to terminal, the app will try to eval and display result as a python interactive shell.\r
index dd7fffcc950db8f85b8c4135572a6b7039c54ef6..74e7c2baf00629e45afee62f7153cff2f210d0c3 100644 (file)
@@ -841,10 +841,10 @@ def report():
 
 def get_slug():
     """
-    Get Slug Decorator
+    Get slug
     """
     # Get list name
-    list_name = raw_input(light_magenta('Give me the list\'s name: '))
+    list_name = raw_input(light_magenta('Give me the list\'s name ("@owner/list_name"): '))
     # Get list name and owner
     try:
         owner, slug = list_name.split('/')
@@ -1166,13 +1166,47 @@ def switch():
                     g['original_name']))
             th.daemon = True
             th.start()
+        # Stream base on list
+        elif target == 'list':
+            owner, slug = get_slug()
+            # Force python 2 not redraw readline buffer
+            g['cmd'] = '/'.join([owner,slug])
+            printNicely(light_yellow('getting list members ...'))
+            # Get members
+            t = Twitter(auth=authen())
+            members = []
+            next_cursor = -1
+            while next_cursor != 0:
+                m = t.lists.members(
+                    slug=slug,
+                    owner_screen_name=owner,
+                    cursor=next_cursor,
+                    include_entities=False)
+                for u in m['users']:
+                    members.append('@' + u['screen_name'])
+                next_cursor = m['next_cursor']
+            printNicely(light_yellow('... done.'))
+            # Build thread filter array
+            args.filter = members
+            # Kill old thread
+            g['stream_stop'] = True
+            # Start new thread
+            th = threading.Thread(
+                target=stream,
+                args=(
+                    c['USER_DOMAIN'],
+                    args,
+                    slug))
+            th.daemon = True
+            th.start()
         printNicely('')
         if args.filter:
-            printNicely(cyan('Only: ' + str(args.filter)))
+            printNicely(cyan('Include: ' + str(len(args.filter))) + ' people.')
         if args.ignore:
-            printNicely(red('Ignore: ' + str(args.ignore)))
+            printNicely(red('Ignore: ' + str(len(args.ignore))) + ' people.')
         printNicely('')
-    except:
+    except Exception:
+        debug_option()
         printNicely(red('Sorry I can\'t understand.'))
 
 
@@ -1455,6 +1489,8 @@ def help_stream():
         ' filter will decide nicks will be EXCLUDE.\n'
     usage += s * 2 + light_green('switch mine -d') + \
         ' will use the config\'s ONLY_LIST and IGNORE_LIST.\n'
+    usage += s * 2 + light_green('switch list') + \
+        ' will switch to a Twitter list\'s stream. You will be asked for list name\n'
     printNicely(usage)
 
 
@@ -1702,7 +1738,7 @@ def listen():
     d = dict(zip(
         cmdset,
         [
-            ['public', 'mine'],  # switch
+            ['public', 'mine', 'list'],  # switch
             [],  # trend
             [],  # home
             [],  # notification
index 72076aea33375908e2065361d08f453bdeb5f1e0..e20ec03c6d70a8908e66a2b62c22300d977b63b9 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -3,7 +3,7 @@ import os
 import os.path
 
 # Bumped version
-version = '1.0.2'
+version = '1.0.3'
 
 # Require
 install_requires = [