+def switch():
+ """
+ Switch stream
+ """
+ try:
+ target = g['stuff'].split()[0]
+
+ # Filter and ignore
+ args = parse_arguments()
+ try :
+ if g['stuff'].split()[-1] == '-f':
+ only = raw_input('Only nicks: ')
+ ignore = raw_input('Ignore nicks: ')
+ args.filter = only.split(',')
+ args.ignore = ignore.split(',')
+ elif g['stuff'].split()[-1] == '-d':
+ args.filter = ONLY_LIST
+ args.ignore = IGNORE_LIST
+ except:
+ printNicely(red('Sorry, wrong format.'))
+ return
+
+ # Public stream
+ if target == 'public':
+ keyword = g['stuff'].split()[1]
+ if keyword[0] == '#':
+ keyword = keyword[1:]
+ # Kill old process
+ os.kill(g['stream_pid'], signal.SIGKILL)
+ args.track_keywords = keyword
+ # Start new process
+ p = Process(
+ target=stream,
+ args=(
+ PUBLIC_DOMAIN,
+ args))
+ p.start()
+ g['stream_pid'] = p.pid
+
+ # Personal stream
+ elif target == 'mine':
+ # Kill old process
+ os.kill(g['stream_pid'], signal.SIGKILL)
+ # Start new process
+ p = Process(
+ target=stream,
+ args=(
+ USER_DOMAIN,
+ args,
+ g['original_name']))
+ p.start()
+ g['stream_pid'] = p.pid
+ printNicely('')
+ printNicely(green('Stream switched.'))
+ if args.filter:
+ printNicely(cyan('Only: ' + str(args.filter)))
+ if args.ignore:
+ printNicely(red('Ignore: ' + str(args.ignore)))
+ printNicely('')
+ except:
+ printNicely(red('Sorry I can\'t understand.'))
+ g['prefix'] = False
+
+
+def home():
+ """
+ Home
+ """
+ t = Twitter(auth=authen())
+ num = HOME_TWEET_NUM
+ if g['stuff'].isdigit():
+ num = g['stuff']
+ for tweet in reversed(t.statuses.home_timeline(count=num)):
+ draw(t=tweet)
+ printNicely('')
+
+
+def view():
+ """
+ Friend view
+ """
+ t = Twitter(auth=authen())
+ user = g['stuff'].split()[0]
+ if user[0] == '@':
+ try:
+ num = int(g['stuff'].split()[1])
+ except:
+ num = HOME_TWEET_NUM
+ for tweet in reversed(t.statuses.user_timeline(count=num, screen_name=user[1:])):
+ draw(t=tweet)
+ printNicely('')
+ else:
+ printNicely(red('A name should begin with a \'@\''))
+
+