+ magenta('We have connection problem with twitter stream API right now :('))
+ detail_twitter_error(e)
+ sys.stdout.write(g['decorated_name'](g['PREFIX']))
+ sys.stdout.flush()
+ except (URLError):
+ printNicely(
+ magenta('There seems to be a connection problem.'))
+ save_history()
+ sys.exit()
+
+
+def spawn_public_stream(args, keyword=None):
+ """
+ Spawn a new public stream
+ """
+ # Only set keyword if specified
+ if keyword:
+ if keyword[0] == '#':
+ keyword = keyword[1:]
+ args.track_keywords = keyword
+ g['keyword'] = keyword
+ else:
+ g['keyword'] = 'Global'
+ g['PREFIX'] = u2str(emojize(format_prefix(keyword=g['keyword'])))
+ g['listname'] = ''
+ # Start new thread
+ th = threading.Thread(
+ target=stream,
+ args=(
+ c['PUBLIC_DOMAIN'],
+ args))
+ th.daemon = True
+ th.start()
+
+
+def spawn_list_stream(args, stuff=None):
+ """
+ Spawn a new list stream
+ """
+ try:
+ owner, slug = check_slug(stuff)
+ except:
+ owner, slug = get_slug()
+
+ # Force python 2 not redraw readline buffer
+ listname = '/'.join([owner, slug])
+ # Set the listname variable
+ # and reset tracked keyword
+ g['listname'] = listname
+ g['keyword'] = ''
+ g['PREFIX'] = g['cmd'] = u2str(emojize(format_prefix(
+ listname=g['listname']
+ )))
+ 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
+ # 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('Include: ' + str(len(args.filter)) + ' people.'))
+ if args.ignore:
+ printNicely(red('Ignore: ' + str(len(args.ignore)) + ' people.'))
+ printNicely('')
+
+
+def spawn_personal_stream(args, stuff=None):
+ """
+ Spawn a new personal stream
+ """
+ # Reset the tracked keyword and listname
+ g['keyword'] = g['listname'] = ''
+ # Reset prefix
+ g['PREFIX'] = u2str(emojize(format_prefix()))
+ # Start new thread
+ th = threading.Thread(
+ target=stream,
+ args=(
+ c['USER_DOMAIN'],
+ args,
+ g['original_name']))
+ th.daemon = True
+ th.start()