+def search():
+ """
+ Search
+ """
+ t = Twitter(auth=authen())
+ try:
+ if g['stuff'][0] == '#':
+ rel = t.search.tweets(q=g['stuff'])['statuses']
+ print('Newest', SEARCH_MAX_RECORD, 'tweet:')
+ for i in xrange(SEARCH_MAX_RECORD):
+ draw(t=rel[i], keyword=g['stuff'].strip()[1:])
+ printNicely('')
+ else:
+ print(red('A keyword should be a hashtag (like \'#AKB48\')'))
+ except:
+ print(red('Sorry I can\'t understand.'))
+
+
+def friend():
+ """
+ List of friend (following)
+ """
+ t = Twitter(auth=authen())
+ g['friends'] = t.friends.ids()['ids']
+ for i in g['friends']:
+ screen_name = t.users.lookup(user_id=i)[0]['screen_name']
+ user = cycle_color('@' + screen_name)
+ print(user, end=' ')
+ print('\n')
+
+
+def follower():
+ """
+ List of follower
+ """
+ t = Twitter(auth=authen())
+ g['followers'] = t.followers.ids()['ids']
+ for i in g['followers']:
+ screen_name = t.users.lookup(user_id=i)[0]['screen_name']
+ user = cycle_color('@' + screen_name)
+ print(user, end=' ')
+ print('\n')
+
+
+def help():
+ """
+ Help
+ """
+ usage = '''
+ Hi boss! I'm ready to serve you right now!
+ -------------------------------------------------------------
+ "home" will show your timeline. "home 7" will show 7 tweet.
+ "view @bob" will show your friend @bob's home.
+ "t oops" will tweet "oops" immediately.
+ "rt 12345" will retweet to tweet with id "12345".
+ "rep 12345 oops" will reply "oops" to tweet with id "12345".
+ "del 12345" will delete tweet with id "12345".
+ "s #AKB48" will search for "AKB48" and return 5 newest tweet.
+ "fr" will list out your following people.
+ "fl" will list out your followers.
+ "h" will show this help again.
+ "c" will clear the terminal.
+ "q" will exit.
+ -------------------------------------------------------------
+ Have fun and hang tight!
+ '''
+ printNicely(usage)
+
+
+def clear():
+ """
+ Clear screen
+ """
+ os.system('clear')
+
+
+def quit():
+ """
+ Exit all
+ """
+ os.system('rm -rf rainbow.db')
+ os.kill(g['stream_pid'], signal.SIGKILL)
+ sys.exit()
+
+
+def reset():
+ """
+ Reset prefix of line
+ """
+ g['prefix'] = True
+
+
+def process(cmd):
+ """
+ Process switch
+ """
+ return dict(zip(
+ cmdset,
+ [
+ home,
+ view,
+ tweet,
+ retweet,
+ reply,
+ delete,
+ search,
+ friend,
+ follower,
+ help,
+ clear,
+ quit
+ ]
+ )).get(cmd, reset)
+
+
+def listen():
+ init_interactive_shell(cmdset)
+ first = True
+ while True:
+ if g['prefix'] and not first:
+ line = raw_input(g['decorated_name'])
+ else:
+ line = raw_input()
+ try:
+ cmd = line.split()[0]
+ except:
+ cmd = ''
+ # Save cmd to global variable and call process
+ g['stuff'] = ' '.join(line.split()[1:])
+ process(cmd)()
+ first = False
+
+
+def stream():
+ """
+ Track the stream
+ """
+ args = parse_arguments()
+
+ # The Logo
+ ascii_art()