15 from io
import BytesIO
16 from twitter
.stream
import TwitterStream
, Timeout
, HeartbeatTimeout
, Hangup
17 from twitter
.api
import *
18 from twitter
.oauth
import OAuth
, read_token_file
19 from twitter
.oauth_dance
import oauth_dance
20 from twitter
.util
import printNicely
25 from .consumer
import *
26 from .interactive
import *
27 from .c_image
import *
28 from .py3patch
import *
36 StreamLock
= threading
.Lock()
39 def parse_arguments():
43 parser
= argparse
.ArgumentParser(description
=__doc__
or "")
48 help='Default stream after program start. (Default: mine)')
52 help='Timeout for the stream (seconds).')
56 help='Search the stream for specific text.')
60 help='Filter specific screen_name.')
64 help='Ignore specific screen_name.')
69 help='Display all image on terminal.')
73 help='Use HTTP/SOCKS proxy for network connections.')
78 help='HTTP/SOCKS proxy port (Default: 8080).')
83 help='Proxy type (HTTP, SOCKS4, SOCKS5; Default: SOCKS5).')
84 return parser
.parse_args()
87 def proxy_connect(args
):
89 Connect to specified proxy
92 # Setup proxy by monkeypatching the standard lib
93 if args
.proxy_type
.lower() == "socks5" or not args
.proxy_type
:
94 socks
.set_default_proxy(
95 socks
.SOCKS5
, args
.proxy_host
,
97 elif args
.proxy_type
.lower() == "http":
98 socks
.set_default_proxy(
99 socks
.HTTP
, args
.proxy_host
,
100 int(args
.proxy_port
))
101 elif args
.proxy_type
.lower() == "socks4":
102 socks
.set_default_proxy(
103 socks
.SOCKS4
, args
.proxy_host
,
104 int(args
.proxy_port
))
107 magenta('Sorry, wrong proxy type specified! Aborting...'))
109 socket
.socket
= socks
.socksocket
114 Authenticate with Twitter OAuth
116 # When using rainbow stream you must authorize.
117 twitter_credential
= os
.environ
.get(
121 '')) + os
.sep
+ '.rainbow_oauth'
122 if not os
.path
.exists(twitter_credential
):
123 oauth_dance('Rainbow Stream',
127 oauth_token
, oauth_token_secret
= read_token_file(twitter_credential
)
135 def build_mute_dict(dict_data
=False):
139 t
= Twitter(auth
=authen())
142 screen_name_list
= []
145 while next_cursor
!= 0:
146 list = t
.mutes
.users
.list(
147 screen_name
=g
['original_name'],
150 include_entities
=False,
152 screen_name_list
+= ['@' + u
['screen_name'] for u
in list['users']]
153 name_list
+= [u
['name'] for u
in list['users']]
154 next_cursor
= list['next_cursor']
155 # Return dict or list
157 return dict(zip(screen_name_list
, name_list
))
159 return screen_name_list
164 Save traceback when run in debug mode
167 g
['traceback'].append(traceback
.format_exc())
170 def upgrade_center():
172 Check latest and notify to upgrade
175 current
= pkg_resources
.get_distribution('rainbowstream').version
176 url
= 'https://raw.githubusercontent.com/DTVD/rainbowstream/master/setup.py'
177 readme
= requests
.get(url
).text
178 latest
= readme
.split('version = \'')[1].split('\'')[0]
179 if current
!= latest
:
180 notice
= light_magenta('RainbowStream latest version is ')
181 notice
+= light_green(latest
)
182 notice
+= light_magenta(' while your current version is ')
183 notice
+= light_yellow(current
) + '\n'
184 notice
+= light_magenta('You should upgrade with ')
185 notice
+= light_green('pip install -U rainbowstream')
188 notice
= light_yellow('You are running latest version (')
189 notice
+= light_green(current
)
190 notice
+= light_yellow(')')
201 ctrl_c_handler
= lambda signum
, frame
: quit()
202 signal
.signal(signal
.SIGINT
, ctrl_c_handler
)
206 t
= Twitter(auth
=authen())
207 credential
= t
.account
.verify_credentials()
208 screen_name
= '@' + credential
['screen_name']
209 name
= credential
['name']
210 c
['original_name'] = g
['original_name'] = screen_name
[1:]
211 g
['listname'] = g
['keyword'] = ''
212 g
['PREFIX'] = u2str(emojize(format_prefix()))
213 g
['full_name'] = name
214 g
['decorated_name'] = lambda x
: color_func(
215 c
['DECORATED_NAME'])('[' + x
+ ']: ', rl
=True)
217 files
= os
.listdir(os
.path
.dirname(__file__
) + '/colorset')
218 themes
= [f
.split('.')[0] for f
in files
if f
.split('.')[-1] == 'json']
221 g
['message_threads'] = {}
224 # Debug option default = True
231 # Init tweet dict and message dict
233 c
['message_dict'] = []
235 c
['IMAGE_ON_TERM'] = args
.image_on_term
236 set_config('IMAGE_ON_TERM', str(c
['IMAGE_ON_TERM']))
237 # Check type of ONLY_LIST and IGNORE_LIST
238 if not isinstance(c
['ONLY_LIST'], list):
239 printNicely(red('ONLY_LIST is not a valid list value.'))
241 if not isinstance(c
['IGNORE_LIST'], list):
242 printNicely(red('IGNORE_LIST is not a valid list value.'))
243 c
['IGNORE_LIST'] = []
245 c
['IGNORE_LIST'] += build_mute_dict()
252 t
= Twitter(auth
=authen())
253 # Get country and town
255 country
= g
['stuff'].split()[0]
259 town
= g
['stuff'].split()[1]
262 avail
= t
.trends
.available()
265 trends
= t
.trends
.place(_id
=1)[0]['trends']
268 for location
in avail
:
269 # Search for country and Town
271 if location
['countryCode'] == country \
272 and location
['placeType']['name'] == 'Town' \
273 and location
['name'] == town
:
274 trends
= t
.trends
.place(_id
=location
['woeid'])[0]['trends']
276 # Search for country only
278 if location
['countryCode'] == country \
279 and location
['placeType']['name'] == 'Country':
280 trends
= t
.trends
.place(_id
=location
['woeid'])[0]['trends']
288 t
= Twitter(auth
=authen())
289 num
= c
['HOME_TWEET_NUM']
290 if g
['stuff'].isdigit():
291 num
= int(g
['stuff'])
292 for tweet
in reversed(t
.statuses
.home_timeline(count
=num
)):
302 for e
in c
['events']:
306 printNicely(magenta('Nothing at this time.'))
313 t
= Twitter(auth
=authen())
314 num
= c
['HOME_TWEET_NUM']
315 if g
['stuff'].isdigit():
316 num
= int(g
['stuff'])
317 for tweet
in reversed(t
.statuses
.mentions_timeline(count
=num
)):
324 Show profile of a specific user
326 t
= Twitter(auth
=authen())
328 screen_name
= g
['stuff'].split()[0]
330 printNicely(red('Sorry I can\'t understand.'))
332 if screen_name
.startswith('@'):
335 screen_name
=screen_name
[1:],
336 include_entities
=False)
340 printNicely(red('No user.'))
342 printNicely(red('A name should begin with a \'@\''))
349 t
= Twitter(auth
=authen())
351 user
= g
['stuff'].split()[0]
353 printNicely(red('Sorry I can\'t understand.'))
357 num
= int(g
['stuff'].split()[1])
359 num
= c
['HOME_TWEET_NUM']
360 for tweet
in reversed(
361 t
.statuses
.user_timeline(count
=num
, screen_name
=user
[1:])):
365 printNicely(red('A name should begin with a \'@\''))
372 t
= Twitter(auth
=authen())
374 query
= g
['stuff'].strip()
376 printNicely(red('Sorry I can\'t understand.'))
378 type = c
['SEARCH_TYPE']
379 if type not in ['mixed', 'recent', 'popular']:
381 max_record
= c
['SEARCH_MAX_RECORD']
382 count
= min(max_record
, 100)
384 rel
= t
.search
.tweets(
391 printNicely('Newest tweets:')
392 for i
in reversed(xrange(count
)):
393 draw(t
=rel
[i
], keyword
=query
)
396 printNicely(magenta('I\'m afraid there is no result'))
403 t
= Twitter(auth
=authen())
404 t
.statuses
.update(status
=g
['stuff'])
411 t
= Twitter(auth
=authen())
413 id = int(g
['stuff'].split()[0])
415 printNicely(red('Sorry I can\'t understand.'))
417 tid
= c
['tweet_dict'][id]
418 t
.statuses
.retweet(id=tid
, include_entities
=False, trim_user
=True)
426 t
= Twitter(auth
=authen())
428 id = int(g
['stuff'].split()[0])
430 printNicely(red('Sorry I can\'t understand.'))
432 tid
= c
['tweet_dict'][id]
433 tweet
= t
.statuses
.show(id=tid
)
435 formater
= format_quote(tweet
)
439 prefix
= light_magenta('Compose your ', rl
=True) + \
440 light_green('#comment: ', rl
=True)
441 comment
= raw_input(prefix
)
443 quote
= comment
.join(formater
.split('#comment'))
444 t
.statuses
.update(status
=quote
)
446 printNicely(light_magenta('No text added.'))
453 t
= Twitter(auth
=authen())
456 id = int(g
['stuff'].split()[0])
458 printNicely(red('Sorry I can\'t understand.'))
460 tid
= c
['tweet_dict'][id]
461 # Get display num if exist
463 num
= int(g
['stuff'].split()[1])
465 num
= c
['RETWEETS_SHOW_NUM']
466 # Get result and display
467 rt_ary
= t
.statuses
.retweets(id=tid
, count
=num
)
469 printNicely(magenta('This tweet has no retweet.'))
471 for tweet
in reversed(rt_ary
):
480 t
= Twitter(auth
=authen())
482 id = int(g
['stuff'].split()[0])
484 printNicely(red('Sorry I can\'t understand.'))
486 tid
= c
['tweet_dict'][id]
487 tweet
= t
.statuses
.show(id=tid
)
488 limit
= c
['CONVERSATION_MAX']
490 thread_ref
.append(tweet
)
491 prev_tid
= tweet
['in_reply_to_status_id']
492 while prev_tid
and limit
:
494 tweet
= t
.statuses
.show(id=prev_tid
)
495 prev_tid
= tweet
['in_reply_to_status_id']
496 thread_ref
.append(tweet
)
498 for tweet
in reversed(thread_ref
):
507 t
= Twitter(auth
=authen())
509 id = int(g
['stuff'].split()[0])
511 printNicely(red('Sorry I can\'t understand.'))
513 tid
= c
['tweet_dict'][id]
514 user
= t
.statuses
.show(id=tid
)['user']['screen_name']
515 status
= ' '.join(g
['stuff'].split()[1:])
516 status
= '@' + user
+ ' ' + str2u(status
)
517 t
.statuses
.update(status
=status
, in_reply_to_status_id
=tid
)
524 t
= Twitter(auth
=authen())
526 id = int(g
['stuff'].split()[0])
528 printNicely(red('Sorry I can\'t understand.'))
530 tid
= c
['tweet_dict'][id]
531 original_tweet
= t
.statuses
.show(id=tid
)
532 text
= original_tweet
['text']
533 owner
= '@' + original_tweet
['user']['screen_name']
534 nick_ary
= ['@' + re
.sub('[\W_]', '', w
)
535 for w
in text
.split() if w
.startswith('@')] + [owner
]
536 status
= ' '.join(g
['stuff'].split()[1:])
537 status
= ' '.join(nick_ary
) + ' ' + str2u(status
)
538 t
.statuses
.update(status
=status
, in_reply_to_status_id
=tid
)
545 t
= Twitter(auth
=authen())
547 id = int(g
['stuff'].split()[0])
549 printNicely(red('Sorry I can\'t understand.'))
551 tid
= c
['tweet_dict'][id]
552 t
.favorites
.create(_id
=tid
, include_entities
=False)
553 printNicely(green('Favorited.'))
554 draw(t
.statuses
.show(id=tid
))
562 t
= Twitter(auth
=authen())
564 id = int(g
['stuff'].split()[0])
566 printNicely(red('Sorry I can\'t understand.'))
568 tid
= c
['tweet_dict'][id]
569 t
.favorites
.destroy(_id
=tid
)
570 printNicely(green('Okay it\'s unfavorited.'))
571 draw(t
.statuses
.show(id=tid
))
577 Copy url of a tweet to clipboard
579 t
= Twitter(auth
=authen())
581 id = int(g
['stuff'].split()[0])
582 tid
= c
['tweet_dict'][id]
584 printNicely(red('Tweet id is not valid.'))
586 tweet
= t
.statuses
.show(id=tid
)
587 url
= 'https://twitter.com/' + \
588 tweet
['user']['screen_name'] + '/status/' + str(tid
)
590 if platform
.system().lower() == 'darwin':
591 os
.system("echo '%s' | pbcopy" % url
)
592 printNicely(green('Copied tweet\'s url to clipboard.'))
594 printNicely('Direct link: ' + yellow(url
))
601 t
= Twitter(auth
=authen())
603 id = int(g
['stuff'].split()[0])
605 printNicely(red('Sorry I can\'t understand.'))
607 tid
= c
['tweet_dict'][id]
608 t
.statuses
.destroy(id=tid
)
609 printNicely(green('Okay it\'s gone.'))
616 t
= Twitter(auth
=authen())
618 target
= g
['stuff'].split()[0]
619 if target
!= 'image':
621 id = int(g
['stuff'].split()[1])
622 tid
= c
['tweet_dict'][id]
623 tweet
= t
.statuses
.show(id=tid
)
624 media
= tweet
['entities']['media']
626 res
= requests
.get(m
['media_url'])
627 img
= Image
.open(BytesIO(res
.content
))
631 printNicely(red('Sorry I can\'t show this image.'))
638 t
= Twitter(auth
=authen())
640 if not g
['stuff'].isdigit():
642 tid
= c
['tweet_dict'][int(g
['stuff'])]
643 tweet
= t
.statuses
.show(id=tid
)
644 link_prefix
= ('http://', 'https://')
645 link_ary
= [u
for u
in tweet
['text'].split()
646 if u
.startswith(link_prefix
)]
648 printNicely(light_magenta('No url here @.@!'))
650 for link
in link_ary
:
651 webbrowser
.open(link
)
654 printNicely(red('Sorry I can\'t open url in this tweet.'))
661 t
= Twitter(auth
=authen())
662 num
= c
['MESSAGES_DISPLAY']
663 if g
['stuff'].isdigit():
669 inbox
= inbox
+ t
.direct_messages(
672 include_entities
=False,
677 inbox
= inbox
+ t
.direct_messages(
680 include_entities
=False,
684 num
= c
['MESSAGES_DISPLAY']
685 if g
['stuff'].isdigit():
690 sent
= sent
+ t
.direct_messages
.sent(
693 include_entities
=False,
698 sent
= sent
+ t
.direct_messages
.sent(
701 include_entities
=False,
706 uniq_inbox
= list(set(
707 [(m
['sender_screen_name'], m
['sender']['name']) for m
in inbox
]
709 uniq_sent
= list(set(
710 [(m
['recipient_screen_name'], m
['recipient']['name']) for m
in sent
]
712 for partner
in uniq_inbox
:
713 inbox_ary
= [m
for m
in inbox
if m
['sender_screen_name'] == partner
[0]]
715 m
for m
in sent
if m
['recipient_screen_name'] == partner
[0]]
716 d
[partner
] = inbox_ary
+ sent_ary
717 for partner
in uniq_sent
:
720 m
for m
in sent
if m
['recipient_screen_name'] == partner
[0]]
721 g
['message_threads'] = print_threads(d
)
726 View a thread of message
729 thread_id
= int(g
['stuff'])
731 g
['message_threads'][thread_id
],
736 printNicely(red('No such thread.'))
741 Send a direct message
743 t
= Twitter(auth
=authen())
745 user
= g
['stuff'].split()[0]
746 if user
[0].startswith('@'):
747 content
= ' '.join(g
['stuff'].split()[1:])
748 t
.direct_messages
.new(
749 screen_name
=user
[1:],
752 printNicely(green('Message sent.'))
754 printNicely(red('A name should begin with a \'@\''))
757 printNicely(red('Sorry I can\'t understand.'))
764 t
= Twitter(auth
=authen())
766 id = int(g
['stuff'].split()[0])
768 printNicely(red('Sorry I can\'t understand.'))
769 mid
= c
['message_dict'][id]
770 t
.direct_messages
.destroy(id=mid
)
771 printNicely(green('Message deleted.'))
776 List friends for followers
778 t
= Twitter(auth
=authen())
781 name
= g
['stuff'].split()[1]
782 if name
.startswith('@'):
785 printNicely(red('A name should begin with a \'@\''))
786 raise Exception('Invalid name')
788 name
= g
['original_name']
789 # Get list followers or friends
791 target
= g
['stuff'].split()[0]
793 printNicely(red('Omg some syntax is wrong.'))
796 d
= {'fl': 'followers', 'fr': 'friends'}
800 while next_cursor
!= 0:
801 list = getattr(t
, d
[target
]).list(
805 include_entities
=False,
807 for u
in list['users']:
808 rel
[u
['name']] = '@' + u
['screen_name']
809 next_cursor
= list['next_cursor']
811 printNicely('All: ' + str(len(rel
)) + ' ' + d
[target
] + '.')
813 user
= ' ' + cycle_color(name
)
814 user
+= color_func(c
['TWEET']['nick'])(' ' + rel
[name
] + ' ')
822 t
= Twitter(auth
=authen())
823 screen_name
= g
['stuff'].split()[0]
824 if screen_name
.startswith('@'):
825 t
.friendships
.create(screen_name
=screen_name
[1:], follow
=True)
826 printNicely(green('You are following ' + screen_name
+ ' now!'))
828 printNicely(red('A name should begin with a \'@\''))
835 t
= Twitter(auth
=authen())
836 screen_name
= g
['stuff'].split()[0]
837 if screen_name
.startswith('@'):
838 t
.friendships
.destroy(
839 screen_name
=screen_name
[1:],
840 include_entities
=False)
841 printNicely(green('Unfollow ' + screen_name
+ ' success!'))
843 printNicely(red('A name should begin with a \'@\''))
850 t
= Twitter(auth
=authen())
852 screen_name
= g
['stuff'].split()[0]
854 printNicely(red('A name should be specified. '))
856 if screen_name
.startswith('@'):
858 rel
= t
.mutes
.users
.create(screen_name
=screen_name
[1:])
859 if isinstance(rel
, dict):
860 printNicely(green(screen_name
+ ' is muted.'))
861 c
['IGNORE_LIST'] += [unc(screen_name
)]
862 c
['IGNORE_LIST'] = list(set(c
['IGNORE_LIST']))
864 printNicely(red(rel
))
867 printNicely(red('Something is wrong, can not mute now :('))
869 printNicely(red('A name should begin with a \'@\''))
876 t
= Twitter(auth
=authen())
878 screen_name
= g
['stuff'].split()[0]
880 printNicely(red('A name should be specified. '))
882 if screen_name
.startswith('@'):
884 rel
= t
.mutes
.users
.destroy(screen_name
=screen_name
[1:])
885 if isinstance(rel
, dict):
886 printNicely(green(screen_name
+ ' is unmuted.'))
887 c
['IGNORE_LIST'].remove(screen_name
)
889 printNicely(red(rel
))
891 printNicely(red('Maybe you are not muting this person ?'))
893 printNicely(red('A name should begin with a \'@\''))
900 # Get dict of muting users
901 md
= build_mute_dict(dict_data
=True)
902 printNicely('All: ' + str(len(md
)) + ' people.')
904 user
= ' ' + cycle_color(md
[name
])
905 user
+= color_func(c
['TWEET']['nick'])(' ' + name
+ ' ')
907 # Update from Twitter
908 c
['IGNORE_LIST'] = [n
for n
in md
]
915 t
= Twitter(auth
=authen())
916 screen_name
= g
['stuff'].split()[0]
917 if screen_name
.startswith('@'):
919 screen_name
=screen_name
[1:],
920 include_entities
=False,
922 printNicely(green('You blocked ' + screen_name
+ '.'))
924 printNicely(red('A name should begin with a \'@\''))
931 t
= Twitter(auth
=authen())
932 screen_name
= g
['stuff'].split()[0]
933 if screen_name
.startswith('@'):
935 screen_name
=screen_name
[1:],
936 include_entities
=False,
938 printNicely(green('Unblock ' + screen_name
+ ' success!'))
940 printNicely(red('A name should begin with a \'@\''))
945 Report a user as a spam account
947 t
= Twitter(auth
=authen())
948 screen_name
= g
['stuff'].split()[0]
949 if screen_name
.startswith('@'):
951 screen_name
=screen_name
[1:])
952 printNicely(green('You reported ' + screen_name
+ '.'))
954 printNicely(red('Sorry I can\'t understand.'))
962 list_name
= raw_input(
963 light_magenta('Give me the list\'s name ("@owner/list_name"): ', rl
=True))
964 # Get list name and owner
966 owner
, slug
= list_name
.split('/')
967 if slug
.startswith('@'):
972 light_magenta('List name should follow "@owner/list_name" format.'))
973 raise Exception('Wrong list name')
976 def check_slug(list_name
):
980 # Get list name and owner
982 owner
, slug
= list_name
.split('/')
983 if slug
.startswith('@'):
988 light_magenta('List name should follow "@owner/list_name" format.'))
989 raise Exception('Wrong list name')
996 rel
= t
.lists
.list(screen_name
=g
['original_name'])
1000 printNicely(light_magenta('You belong to no lists :)'))
1007 owner
, slug
= get_slug()
1008 res
= t
.lists
.statuses(
1010 owner_screen_name
=owner
,
1011 count
=c
['LIST_MAX'],
1012 include_entities
=False)
1013 for tweet
in reversed(res
):
1018 def list_members(t
):
1022 owner
, slug
= get_slug()
1026 while next_cursor
!= 0:
1027 m
= t
.lists
.members(
1029 owner_screen_name
=owner
,
1031 include_entities
=False)
1032 for u
in m
['users']:
1033 rel
[u
['name']] = '@' + u
['screen_name']
1034 next_cursor
= m
['next_cursor']
1035 printNicely('All: ' + str(len(rel
)) + ' members.')
1037 user
= ' ' + cycle_color(name
)
1038 user
+= color_func(c
['TWEET']['nick'])(' ' + rel
[name
] + ' ')
1042 def list_subscribers(t
):
1046 owner
, slug
= get_slug()
1050 while next_cursor
!= 0:
1051 m
= t
.lists
.subscribers(
1053 owner_screen_name
=owner
,
1055 include_entities
=False)
1056 for u
in m
['users']:
1057 rel
[u
['name']] = '@' + u
['screen_name']
1058 next_cursor
= m
['next_cursor']
1059 printNicely('All: ' + str(len(rel
)) + ' subscribers.')
1061 user
= ' ' + cycle_color(name
)
1062 user
+= color_func(c
['TWEET']['nick'])(' ' + rel
[name
] + ' ')
1068 Add specific user to a list
1070 owner
, slug
= get_slug()
1072 user_name
= raw_input(
1074 'Give me name of the newbie: ',
1076 if user_name
.startswith('@'):
1077 user_name
= user_name
[1:]
1079 t
.lists
.members
.create(
1081 owner_screen_name
=owner
,
1082 screen_name
=user_name
)
1083 printNicely(green('Added.'))
1086 printNicely(light_magenta('I\'m sorry we can not add him/her.'))
1091 Remove specific user from a list
1093 owner
, slug
= get_slug()
1095 user_name
= raw_input(
1097 'Give me name of the unlucky one: ',
1099 if user_name
.startswith('@'):
1100 user_name
= user_name
[1:]
1102 t
.lists
.members
.destroy(
1104 owner_screen_name
=owner
,
1105 screen_name
=user_name
)
1106 printNicely(green('Gone.'))
1109 printNicely(light_magenta('I\'m sorry we can not remove him/her.'))
1112 def list_subscribe(t
):
1116 owner
, slug
= get_slug()
1119 t
.lists
.subscribers
.create(
1121 owner_screen_name
=owner
)
1122 printNicely(green('Done.'))
1126 light_magenta('I\'m sorry you can not subscribe to this list.'))
1129 def list_unsubscribe(t
):
1133 owner
, slug
= get_slug()
1136 t
.lists
.subscribers
.destroy(
1138 owner_screen_name
=owner
)
1139 printNicely(green('Done.'))
1143 light_magenta('I\'m sorry you can not unsubscribe to this list.'))
1152 while next_cursor
!= 0:
1153 res
= t
.lists
.ownerships(
1154 screen_name
=g
['original_name'],
1157 next_cursor
= res
['next_cursor']
1161 printNicely(light_magenta('You own no lists :)'))
1168 name
= raw_input(light_magenta('New list\'s name: ', rl
=True))
1171 'New list\'s mode (public/private): ',
1173 description
= raw_input(
1175 'New list\'s description: ',
1181 description
=description
)
1182 printNicely(green(name
+ ' list is created.'))
1185 printNicely(red('Oops something is wrong with Twitter :('))
1194 'Your list that you want to update: ',
1198 'Update name (leave blank to unchange): ',
1200 mode
= raw_input(light_magenta('Update mode (public/private): ', rl
=True))
1201 description
= raw_input(light_magenta('Update description: ', rl
=True))
1205 slug
='-'.join(slug
.split()),
1206 owner_screen_name
=g
['original_name'],
1209 description
=description
)
1213 owner_screen_name
=g
['original_name'],
1215 description
=description
)
1216 printNicely(green(slug
+ ' list is updated.'))
1219 printNicely(red('Oops something is wrong with Twitter :('))
1228 'Your list that you want to delete: ',
1232 slug
='-'.join(slug
.split()),
1233 owner_screen_name
=g
['original_name'])
1234 printNicely(green(slug
+ ' list is deleted.'))
1237 printNicely(red('Oops something is wrong with Twitter :('))
1244 t
= Twitter(auth
=authen())
1245 # List all lists or base on action
1247 g
['list_action'] = g
['stuff'].split()[0]
1254 'all_mem': list_members
,
1255 'all_sub': list_subscribers
,
1258 'sub': list_subscribe
,
1259 'unsub': list_unsubscribe
,
1262 'update': list_update
,
1266 return action_ary
[g
['list_action']](t
)
1268 printNicely(red('Please try again.'))
1276 target
= g
['stuff'].split()[0]
1278 args
= parse_arguments()
1280 if g
['stuff'].split()[-1] == '-f':
1281 guide
= 'To ignore an option, just hit Enter key.'
1282 printNicely(light_magenta(guide
))
1283 only
= raw_input('Only nicks [Ex: @xxx,@yy]: ')
1284 ignore
= raw_input('Ignore nicks [Ex: @xxx,@yy]: ')
1285 args
.filter = filter(None, only
.split(','))
1286 args
.ignore
= filter(None, ignore
.split(','))
1288 printNicely(red('Sorry, wrong format.'))
1291 g
['stream_stop'] = True
1293 stuff
= g
['stuff'].split()[1]
1298 'public': spawn_public_stream
,
1299 'list': spawn_list_stream
,
1300 'mine': spawn_personal_stream
,
1302 spawn_dict
.get(target
)(args
, stuff
)
1305 printNicely(red('Sorry I can\'t understand.'))
1310 Unix's command `cal`
1313 rel
= os
.popen('cal').read().split('\n')
1316 show_calendar(month
, date
, rel
)
1321 List and change theme
1325 for theme
in g
['themes']:
1326 line
= light_magenta(theme
)
1327 if c
['THEME'] == theme
:
1328 line
= ' ' * 2 + light_yellow('* ') + line
1330 line
= ' ' * 4 + line
1336 c
['THEME'] = reload_theme(g
['stuff'], c
['THEME'])
1337 # Redefine decorated_name
1338 g
['decorated_name'] = lambda x
: color_func(
1339 c
['DECORATED_NAME'])(
1341 printNicely(green('Theme changed.'))
1343 printNicely(red('No such theme exists.'))
1348 Browse and change config
1350 all_config
= get_all_config()
1351 g
['stuff'] = g
['stuff'].strip()
1354 for k
in all_config
:
1356 green(k
) + ': ' + light_yellow(str(all_config
[k
]))
1358 guide
= 'Detailed explanation can be found at ' + \
1359 color_func(c
['TWEET']['link'])(
1360 'http://rainbowstream.readthedocs.org/en/latest/#config-explanation')
1362 # Print specific config
1363 elif len(g
['stuff'].split()) == 1:
1364 if g
['stuff'] in all_config
:
1367 green(k
) + ': ' + light_yellow(str(all_config
[k
]))
1370 printNicely(red('No such config key.'))
1371 # Print specific config's default value
1372 elif len(g
['stuff'].split()) == 2 and g
['stuff'].split()[-1] == 'default':
1373 key
= g
['stuff'].split()[0]
1375 value
= get_default_config(key
)
1376 line
= ' ' * 2 + green(key
) + ': ' + light_magenta(value
)
1380 printNicely(red('Just can not get the default.'))
1381 # Delete specific config key in config file
1382 elif len(g
['stuff'].split()) == 2 and g
['stuff'].split()[-1] == 'drop':
1383 key
= g
['stuff'].split()[0]
1386 printNicely(green('Config key is dropped.'))
1389 printNicely(red('Just can not drop the key.'))
1390 # Set specific config
1391 elif len(g
['stuff'].split()) == 3 and g
['stuff'].split()[1] == '=':
1392 key
= g
['stuff'].split()[0]
1393 value
= g
['stuff'].split()[-1]
1394 if key
== 'THEME' and not validate_theme(value
):
1395 printNicely(red('Invalid theme\'s value.'))
1398 set_config(key
, value
)
1399 # Keys that needs to be apply immediately
1401 c
['THEME'] = reload_theme(value
, c
['THEME'])
1402 g
['decorated_name'] = lambda x
: color_func(
1403 c
['DECORATED_NAME'])('[' + x
+ ']: ')
1404 elif key
== 'PREFIX':
1405 g
['PREFIX'] = u2str(emojize(format_prefix(
1406 listname
=g
['listname'],
1407 keyword
=g
['keyword']
1410 printNicely(green('Updated successfully.'))
1413 printNicely(red('Just can not set the key.'))
1415 printNicely(light_magenta('Sorry I can\'s understand.'))
1418 def help_discover():
1423 # Discover the world
1425 usage
+= s
+ grey(u
'\u266A' + ' Discover the world \n')
1426 usage
+= s
* 2 + light_green('trend') + ' will show global trending topics. ' + \
1427 'You can try ' + light_green('trend US') + ' or ' + \
1428 light_green('trend JP Tokyo') + '.\n'
1429 usage
+= s
* 2 + light_green('home') + ' will show your timeline. ' + \
1430 light_green('home 7') + ' will show 7 tweets.\n'
1432 light_green('notification') + ' will show your recent notification.\n'
1433 usage
+= s
* 2 + light_green('mentions') + ' will show mentions timeline. ' + \
1434 light_green('mentions 7') + ' will show 7 mention tweets.\n'
1435 usage
+= s
* 2 + light_green('whois @mdo') + ' will show profile of ' + \
1436 magenta('@mdo') + '.\n'
1437 usage
+= s
* 2 + light_green('view @mdo') + \
1438 ' will show ' + magenta('@mdo') + '\'s home.\n'
1439 usage
+= s
* 2 + light_green('s AKB48') + ' will search for "' + \
1440 light_yellow('AKB48') + '" and return 5 newest tweet. ' + \
1441 'Search can be performed with or without hashtag.\n'
1452 usage
+= s
+ grey(u
'\u266A' + ' Tweets \n')
1453 usage
+= s
* 2 + light_green('t oops ') + \
1454 'will tweet "' + light_yellow('oops') + '" immediately.\n'
1456 light_green('rt 12 ') + ' will retweet to tweet with ' + \
1457 light_yellow('[id=12]') + '.\n'
1459 light_green('quote 12 ') + ' will quote the tweet with ' + \
1460 light_yellow('[id=12]') + '. If no extra text is added, ' + \
1461 'the quote will be canceled.\n'
1463 light_green('allrt 12 20 ') + ' will list 20 newest retweet of the tweet with ' + \
1464 light_yellow('[id=12]') + '.\n'
1465 usage
+= s
* 2 + light_green('conversation 12') + ' will show the chain of ' + \
1466 'replies prior to the tweet with ' + light_yellow('[id=12]') + '.\n'
1467 usage
+= s
* 2 + light_green('rep 12 oops') + ' will reply "' + \
1468 light_yellow('oops') + '" to the owner of the tweet with ' + \
1469 light_yellow('[id=12]') + '.\n'
1470 usage
+= s
* 2 + light_green('repall 12 oops') + ' will reply "' + \
1471 light_yellow('oops') + '" to all people in the tweet with ' + \
1472 light_yellow('[id=12]') + '.\n'
1474 light_green('fav 12 ') + ' will favorite the tweet with ' + \
1475 light_yellow('[id=12]') + '.\n'
1477 light_green('ufav 12 ') + ' will unfavorite tweet with ' + \
1478 light_yellow('[id=12]') + '.\n'
1480 light_green('share 12 ') + ' will get the direct link of the tweet with ' + \
1481 light_yellow('[id=12]') + '.\n'
1483 light_green('del 12 ') + ' will delete tweet with ' + \
1484 light_yellow('[id=12]') + '.\n'
1485 usage
+= s
* 2 + light_green('show image 12') + ' will show image in tweet with ' + \
1486 light_yellow('[id=12]') + ' in your OS\'s image viewer.\n'
1487 usage
+= s
* 2 + light_green('open 12') + ' will open url in tweet with ' + \
1488 light_yellow('[id=12]') + ' in your OS\'s default browser.\n'
1492 def help_messages():
1499 usage
+= s
+ grey(u
'\u266A' + ' Direct messages \n')
1500 usage
+= s
* 2 + light_green('inbox') + ' will show inbox messages. ' + \
1501 light_green('inbox 7') + ' will show newest 7 messages.\n'
1502 usage
+= s
* 2 + light_green('thread 2') + ' will show full thread with ' + \
1503 light_yellow('[thread_id=2]') + '.\n'
1504 usage
+= s
* 2 + light_green('mes @dtvd88 hi') + ' will send a "hi" messege to ' + \
1505 magenta('@dtvd88') + '.\n'
1506 usage
+= s
* 2 + light_green('trash 5') + ' will remove message with ' + \
1507 light_yellow('[message_id=5]') + '.\n'
1511 def help_friends_and_followers():
1513 Friends and Followers
1516 # Follower and following
1518 usage
+= s
+ grey(u
'\u266A' + ' Friends and followers \n')
1520 light_green('ls fl') + \
1521 ' will list all followers (people who are following you).\n'
1523 light_green('ls fr') + \
1524 ' will list all friends (people who you are following).\n'
1525 usage
+= s
* 2 + light_green('fl @dtvd88') + ' will follow ' + \
1526 magenta('@dtvd88') + '.\n'
1527 usage
+= s
* 2 + light_green('ufl @dtvd88') + ' will unfollow ' + \
1528 magenta('@dtvd88') + '.\n'
1529 usage
+= s
* 2 + light_green('mute @dtvd88') + ' will mute ' + \
1530 magenta('@dtvd88') + '.\n'
1531 usage
+= s
* 2 + light_green('unmute @dtvd88') + ' will unmute ' + \
1532 magenta('@dtvd88') + '.\n'
1533 usage
+= s
* 2 + light_green('muting') + ' will list muting users.\n'
1534 usage
+= s
* 2 + light_green('block @dtvd88') + ' will block ' + \
1535 magenta('@dtvd88') + '.\n'
1536 usage
+= s
* 2 + light_green('unblock @dtvd88') + ' will unblock ' + \
1537 magenta('@dtvd88') + '.\n'
1538 usage
+= s
* 2 + light_green('report @dtvd88') + ' will report ' + \
1539 magenta('@dtvd88') + ' as a spam account.\n'
1550 usage
+= s
+ grey(u
'\u266A' + ' Twitter list\n')
1551 usage
+= s
* 2 + light_green('list') + \
1552 ' will show all lists you are belong to.\n'
1553 usage
+= s
* 2 + light_green('list home') + \
1554 ' will show timeline of list. You will be asked for list\'s name.\n'
1555 usage
+= s
* 2 + light_green('list all_mem') + \
1556 ' will show list\'s all members.\n'
1557 usage
+= s
* 2 + light_green('list all_sub') + \
1558 ' will show list\'s all subscribers.\n'
1559 usage
+= s
* 2 + light_green('list add') + \
1560 ' will add specific person to a list owned by you.' + \
1561 ' You will be asked for list\'s name and person\'s name.\n'
1562 usage
+= s
* 2 + light_green('list rm') + \
1563 ' will remove specific person from a list owned by you.' + \
1564 ' You will be asked for list\'s name and person\'s name.\n'
1565 usage
+= s
* 2 + light_green('list sub') + \
1566 ' will subscribe you to a specific list.\n'
1567 usage
+= s
* 2 + light_green('list unsub') + \
1568 ' will unsubscribe you from a specific list.\n'
1569 usage
+= s
* 2 + light_green('list own') + \
1570 ' will show all list owned by you.\n'
1571 usage
+= s
* 2 + light_green('list new') + \
1572 ' will create a new list.\n'
1573 usage
+= s
* 2 + light_green('list update') + \
1574 ' will update a list owned by you.\n'
1575 usage
+= s
* 2 + light_green('list del') + \
1576 ' will delete a list owned by you.\n'
1587 usage
+= s
+ grey(u
'\u266A' + ' Switching streams \n')
1588 usage
+= s
* 2 + light_green('switch public #AKB') + \
1589 ' will switch to public stream and follow "' + \
1590 light_yellow('AKB') + '" keyword.\n'
1591 usage
+= s
* 2 + light_green('switch mine') + \
1592 ' will switch to your personal stream.\n'
1593 usage
+= s
* 2 + light_green('switch mine -f ') + \
1594 ' will prompt to enter the filter.\n'
1595 usage
+= s
* 3 + light_yellow('Only nicks') + \
1596 ' filter will decide nicks will be INCLUDE ONLY.\n'
1597 usage
+= s
* 3 + light_yellow('Ignore nicks') + \
1598 ' filter will decide nicks will be EXCLUDE.\n'
1599 usage
+= s
* 2 + light_green('switch list') + \
1600 ' will switch to a Twitter list\'s stream. You will be asked for list name\n'
1609 h
, w
= os
.popen('stty size', 'r').read().split()
1612 usage
+= s
+ 'Hi boss! I\'m ready to serve you right now!\n'
1613 usage
+= s
+ '-' * (int(w
) - 4) + '\n'
1614 usage
+= s
+ 'You are ' + \
1615 light_yellow('already') + ' on your personal stream.\n'
1616 usage
+= s
+ 'Any update from Twitter will show up ' + \
1617 light_yellow('immediately') + '.\n'
1618 usage
+= s
+ 'In addition, following commands are available right now:\n'
1619 # Twitter help section
1621 usage
+= s
+ grey(u
'\u266A' + ' Twitter help\n')
1622 usage
+= s
* 2 + light_green('h discover') + \
1623 ' will show help for discover commands.\n'
1624 usage
+= s
* 2 + light_green('h tweets') + \
1625 ' will show help for tweets commands.\n'
1626 usage
+= s
* 2 + light_green('h messages') + \
1627 ' will show help for messages commands.\n'
1628 usage
+= s
* 2 + light_green('h friends_and_followers') + \
1629 ' will show help for friends and followers commands.\n'
1630 usage
+= s
* 2 + light_green('h list') + \
1631 ' will show help for list commands.\n'
1632 usage
+= s
* 2 + light_green('h stream') + \
1633 ' will show help for stream commands.\n'
1636 usage
+= s
+ grey(u
'\u266A' + ' Smart shell\n')
1637 usage
+= s
* 2 + light_green('111111 * 9 / 7') + ' or any math expression ' + \
1638 'will be evaluate by Python interpreter.\n'
1639 usage
+= s
* 2 + 'Even ' + light_green('cal') + ' will show the calendar' + \
1640 ' for current month.\n'
1643 usage
+= s
+ grey(u
'\u266A' + ' Config \n')
1644 usage
+= s
* 2 + light_green('theme') + ' will list available theme. ' + \
1645 light_green('theme monokai') + ' will apply ' + light_yellow('monokai') + \
1646 ' theme immediately.\n'
1647 usage
+= s
* 2 + light_green('config') + ' will list all config.\n'
1649 light_green('config ASCII_ART') + ' will output current value of ' +\
1650 light_yellow('ASCII_ART') + ' config key.\n'
1652 light_green('config TREND_MAX default') + ' will output default value of ' + \
1653 light_yellow('TREND_MAX') + ' config key.\n'
1655 light_green('config CUSTOM_CONFIG drop') + ' will drop ' + \
1656 light_yellow('CUSTOM_CONFIG') + ' config key.\n'
1658 light_green('config IMAGE_ON_TERM = true') + ' will set value of ' + \
1659 light_yellow('IMAGE_ON_TERM') + ' config key to ' + \
1660 light_yellow('True') + '.\n'
1663 usage
+= s
+ grey(u
'\u266A' + ' Screening \n')
1664 usage
+= s
* 2 + light_green('h') + ' will show this help again.\n'
1665 usage
+= s
* 2 + light_green('p') + ' will pause the stream.\n'
1666 usage
+= s
* 2 + light_green('r') + ' will unpause the stream.\n'
1667 usage
+= s
* 2 + light_green('c') + ' will clear the screen.\n'
1668 usage
+= s
* 2 + light_green('v') + ' will show version info.\n'
1669 usage
+= s
* 2 + light_green('q') + ' will quit.\n'
1672 usage
+= s
+ '-' * (int(w
) - 4) + '\n'
1673 usage
+= s
+ 'Have fun and hang tight! \n'
1676 'discover': help_discover
,
1677 'tweets': help_tweets
,
1678 'messages': help_messages
,
1679 'friends_and_followers': help_friends_and_followers
,
1681 'stream': help_stream
,
1686 lambda: printNicely(red('No such command.'))
1694 Pause stream display
1697 printNicely(green('Stream is paused'))
1705 printNicely(green('Stream is running back now'))
1721 printNicely(green('See you next time :)'))
1729 Reset prefix of line
1732 if c
.get('USER_JSON_ERROR'):
1733 printNicely(red('Your ~/.rainbow_config.json is messed up:'))
1734 printNicely(red('>>> ' + c
['USER_JSON_ERROR']))
1736 printNicely(magenta('Need tips ? Type "h" and hit Enter key!'))
1739 printNicely(str(eval(g
['cmd'])))
1792 # Handle function set
1845 return dict(zip(cmdset
, funcset
)).get(cmd
, reset
)
1850 Listen to user's input
1855 ['public', 'mine', 'list'], # switch
1874 ['image'], # show image
1876 ['fl', 'fr'], # list
1878 [i
for i
in g
['message_threads']], # sent
1903 [key
for key
in dict(get_all_config())], # config
1904 g
['themes'], # theme
1909 'friends_and_followers',
1920 init_interactive_shell(d
)
1927 # Only use PREFIX as a string with raw_input
1928 line
= raw_input(g
['decorated_name'](g
['PREFIX']))
1931 # Save cmd to compare with readline buffer
1932 g
['cmd'] = line
.strip()
1933 # Get short cmd to pass to handle function
1935 cmd
= line
.split()[0]
1938 # Lock the semaphore
1940 # Save cmd to global variable and call process
1941 g
['stuff'] = ' '.join(line
.split()[1:])
1942 # Process the command
1945 if cmd
in ['switch', 't', 'rt', 'rep']:
1949 # Release the semaphore lock
1955 printNicely(red('OMG something is wrong with Twitter right now.'))
1958 def reconn_notice():
1960 Notice when Hangup or Timeout
1962 guide
= light_magenta('You can use ') + \
1963 light_green('switch') + \
1964 light_magenta(' command to return to your stream.\n')
1965 guide
+= light_magenta('Type ') + \
1966 light_green('h stream') + \
1967 light_magenta(' for more details.')
1969 sys
.stdout
.write(g
['decorated_name'](g
['PREFIX']))
1973 def stream(domain
, args
, name
='Rainbow Stream'):
1979 c
['USER_DOMAIN']: name
,
1980 c
['PUBLIC_DOMAIN']: args
.track_keywords
or 'Global',
1981 c
['SITE_DOMAIN']: name
,
1984 ascii_art(art_dict
.get(domain
, name
))
1985 # These arguments are optional:
1987 timeout
=0.5, # To check g['stream_stop'] after each 0.5 s
1989 heartbeat_timeout
=c
['HEARTBEAT_TIMEOUT'] * 60)
1992 if args
.track_keywords
:
1993 query_args
['track'] = args
.track_keywords
1995 stream
= TwitterStream(
2000 if domain
== c
['USER_DOMAIN']:
2001 tweet_iter
= stream
.user(**query_args
)
2002 elif domain
== c
['SITE_DOMAIN']:
2003 tweet_iter
= stream
.site(**query_args
)
2005 if args
.track_keywords
:
2006 tweet_iter
= stream
.statuses
.filter(**query_args
)
2008 tweet_iter
= stream
.statuses
.sample()
2009 # Block new stream until other one exits
2010 StreamLock
.acquire()
2011 g
['stream_stop'] = False
2012 last_tweet_time
= time
.time()
2013 for tweet
in tweet_iter
:
2015 printNicely('-- None --')
2016 elif tweet
is Timeout
:
2017 # Because the stream check for each 0.3s
2018 # so we shouldn't output anything here
2019 if(g
['stream_stop']):
2020 StreamLock
.release()
2022 elif tweet
is HeartbeatTimeout
:
2023 printNicely('-- Heartbeat Timeout --')
2025 StreamLock
.release()
2027 elif tweet
is Hangup
:
2028 printNicely('-- Hangup --')
2030 StreamLock
.release()
2032 elif tweet
.get('text'):
2033 # Slow down the stream by STREAM_DELAY config key
2034 if time
.time() - last_tweet_time
< c
['STREAM_DELAY']:
2036 last_tweet_time
= time
.time()
2037 # Check the semaphore pause and lock (stream process only)
2045 keyword
=args
.track_keywords
,
2050 # Current readline buffer
2051 current_buffer
= readline
.get_line_buffer().strip()
2052 # There is an unexpected behaviour in MacOSX readline + Python 2:
2053 # after completely delete a word after typing it,
2054 # somehow readline buffer still contains
2055 # the 1st character of that word
2056 if current_buffer
and g
['cmd'] != current_buffer
:
2058 g
['decorated_name'](g
['PREFIX']) + current_buffer
)
2060 elif not c
['HIDE_PROMPT']:
2061 sys
.stdout
.write(g
['decorated_name'](g
['PREFIX']))
2063 elif tweet
.get('direct_message'):
2064 # Check the semaphore pause and lock (stream process only)
2069 print_message(tweet
['direct_message'])
2070 elif tweet
.get('event'):
2071 c
['events'].append(tweet
)
2073 except TwitterHTTPError
as e
:
2076 magenta('We have connection problem with twitter stream API right now :('))
2077 detail_twitter_error(e
)
2078 sys
.stdout
.write(g
['decorated_name'](g
['PREFIX']))
2080 except (URLError
, ConnectionResetError
):
2082 magenta('There seems to be a connection problem.'))
2087 def spawn_public_stream(args
, keyword
=None):
2089 Spawn a new public stream
2091 # Only set keyword if specified
2093 if keyword
[0] == '#':
2094 keyword
= keyword
[1:]
2095 args
.track_keywords
= keyword
2096 g
['keyword'] = keyword
2098 g
['keyword'] = 'Global'
2099 g
['PREFIX'] = u2str(emojize(format_prefix(keyword
=g
['keyword'])))
2102 th
= threading
.Thread(
2111 def spawn_list_stream(args
, stuff
=None):
2113 Spawn a new list stream
2116 owner
, slug
= check_slug(stuff
)
2118 owner
, slug
= get_slug()
2120 # Force python 2 not redraw readline buffer
2121 listname
= '/'.join([owner
, slug
])
2122 # Set the listname variable
2123 # and reset tracked keyword
2124 g
['listname'] = listname
2126 g
['PREFIX'] = g
['cmd'] = u2str(emojize(format_prefix(
2127 listname
=g
['listname']
2129 printNicely(light_yellow('getting list members ...'))
2131 t
= Twitter(auth
=authen())
2134 while next_cursor
!= 0:
2135 m
= t
.lists
.members(
2137 owner_screen_name
=owner
,
2139 include_entities
=False)
2140 for u
in m
['users']:
2141 members
.append('@' + u
['screen_name'])
2142 next_cursor
= m
['next_cursor']
2143 printNicely(light_yellow('... done.'))
2144 # Build thread filter array
2145 args
.filter = members
2147 th
= threading
.Thread(
2157 printNicely(cyan('Include: ' + str(len(args
.filter)) + ' people.'))
2159 printNicely(red('Ignore: ' + str(len(args
.ignore
)) + ' people.'))
2163 def spawn_personal_stream(args
, stuff
=None):
2165 Spawn a new personal stream
2167 # Reset the tracked keyword and listname
2168 g
['keyword'] = g
['listname'] = ''
2170 g
['PREFIX'] = u2str(emojize(format_prefix()))
2172 th
= threading
.Thread(
2177 g
['original_name']))
2187 args
= parse_arguments()
2191 # Twitter API connection problem
2192 except TwitterHTTPError
as e
:
2195 magenta('We have connection problem with twitter REST API right now :('))
2196 detail_twitter_error(e
)
2199 # Proxy connection problem
2200 except (socks
.ProxyConnectionError
, URLError
):
2202 magenta('There seems to be a connection problem.'))
2204 magenta('You might want to check your proxy settings (host, port and type)!'))
2208 # Spawn stream thread
2209 target
= args
.stream
.split()[0]
2210 if target
== 'mine' :
2211 spawn_personal_stream(args
)
2214 stuff
= args
.stream
.split()[1]
2218 'public': spawn_public_stream
,
2219 'list': spawn_list_stream
,
2221 spawn_dict
.get(target
)(args
, stuff
)
2223 # Start listen process