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.')
74 help='Display images using 24bit color codes.')
78 help='Use HTTP/SOCKS proxy for network connections.')
83 help='HTTP/SOCKS proxy port (Default: 8080).')
88 help='Proxy type (HTTP, SOCKS4, SOCKS5; Default: SOCKS5).')
89 return parser
.parse_args()
92 def proxy_connect(args
):
94 Connect to specified proxy
97 # Setup proxy by monkeypatching the standard lib
98 if args
.proxy_type
.lower() == "socks5" or not args
.proxy_type
:
99 socks
.set_default_proxy(
100 socks
.SOCKS5
, args
.proxy_host
,
101 int(args
.proxy_port
))
102 elif args
.proxy_type
.lower() == "http":
103 socks
.set_default_proxy(
104 socks
.HTTP
, args
.proxy_host
,
105 int(args
.proxy_port
))
106 elif args
.proxy_type
.lower() == "socks4":
107 socks
.set_default_proxy(
108 socks
.SOCKS4
, args
.proxy_host
,
109 int(args
.proxy_port
))
112 magenta('Sorry, wrong proxy type specified! Aborting...'))
114 socket
.socket
= socks
.socksocket
119 Authenticate with Twitter OAuth
121 # When using rainbow stream you must authorize.
122 twitter_credential
= os
.environ
.get(
126 '')) + os
.sep
+ '.rainbow_oauth'
127 if not os
.path
.exists(twitter_credential
):
128 oauth_dance('Rainbow Stream',
132 oauth_token
, oauth_token_secret
= read_token_file(twitter_credential
)
140 def build_mute_dict(dict_data
=False):
144 t
= Twitter(auth
=authen())
147 screen_name_list
= []
150 while next_cursor
!= 0:
151 list = t
.mutes
.users
.list(
152 screen_name
=g
['original_name'],
155 include_entities
=False,
157 screen_name_list
+= ['@' + u
['screen_name'] for u
in list['users']]
158 name_list
+= [u
['name'] for u
in list['users']]
159 next_cursor
= list['next_cursor']
160 # Return dict or list
162 return dict(zip(screen_name_list
, name_list
))
164 return screen_name_list
169 Save traceback when run in debug mode
172 g
['traceback'].append(traceback
.format_exc())
175 def upgrade_center():
177 Check latest and notify to upgrade
180 current
= pkg_resources
.get_distribution('rainbowstream').version
181 url
= 'https://raw.githubusercontent.com/DTVD/rainbowstream/master/setup.py'
182 readme
= requests
.get(url
).text
183 latest
= readme
.split('version = \'')[1].split('\'')[0]
184 if current
!= latest
:
185 notice
= light_magenta('RainbowStream latest version is ')
186 notice
+= light_green(latest
)
187 notice
+= light_magenta(' while your current version is ')
188 notice
+= light_yellow(current
) + '\n'
189 notice
+= light_magenta('You should upgrade with ')
190 notice
+= light_green('pip install -U rainbowstream')
193 notice
= light_yellow('You are running latest version (')
194 notice
+= light_green(current
)
195 notice
+= light_yellow(')')
206 ctrl_c_handler
= lambda signum
, frame
: quit()
207 signal
.signal(signal
.SIGINT
, ctrl_c_handler
)
211 t
= Twitter(auth
=authen())
212 credential
= t
.account
.verify_credentials()
213 screen_name
= '@' + credential
['screen_name']
214 name
= credential
['name']
215 c
['original_name'] = g
['original_name'] = screen_name
[1:]
216 g
['listname'] = g
['keyword'] = ''
217 g
['PREFIX'] = u2str(emojize(format_prefix()))
218 g
['full_name'] = name
219 g
['decorated_name'] = lambda x
: color_func(
220 c
['DECORATED_NAME'])('[' + x
+ ']: ', rl
=True)
222 files
= os
.listdir(os
.path
.dirname(__file__
) + '/colorset')
223 themes
= [f
.split('.')[0] for f
in files
if f
.split('.')[-1] == 'json']
226 g
['message_threads'] = {}
229 # Debug option default = True
236 # Init tweet dict and message dict
238 c
['message_dict'] = []
240 c
['IMAGE_ON_TERM'] = args
.image_on_term
241 set_config('IMAGE_ON_TERM', str(c
['IMAGE_ON_TERM']))
243 c
['24BIT'] = args
.color_24bit
244 # Check type of ONLY_LIST and IGNORE_LIST
245 if not isinstance(c
['ONLY_LIST'], list):
246 printNicely(red('ONLY_LIST is not a valid list value.'))
248 if not isinstance(c
['IGNORE_LIST'], list):
249 printNicely(red('IGNORE_LIST is not a valid list value.'))
250 c
['IGNORE_LIST'] = []
252 c
['IGNORE_LIST'] += build_mute_dict()
259 t
= Twitter(auth
=authen())
260 # Get country and town
262 country
= g
['stuff'].split()[0]
266 town
= g
['stuff'].split()[1]
269 avail
= t
.trends
.available()
272 trends
= t
.trends
.place(_id
=1)[0]['trends']
275 for location
in avail
:
276 # Search for country and Town
278 if location
['countryCode'] == country \
279 and location
['placeType']['name'] == 'Town' \
280 and location
['name'] == town
:
281 trends
= t
.trends
.place(_id
=location
['woeid'])[0]['trends']
283 # Search for country only
285 if location
['countryCode'] == country \
286 and location
['placeType']['name'] == 'Country':
287 trends
= t
.trends
.place(_id
=location
['woeid'])[0]['trends']
295 t
= Twitter(auth
=authen())
296 num
= c
['HOME_TWEET_NUM']
297 if g
['stuff'].isdigit():
298 num
= int(g
['stuff'])
299 for tweet
in reversed(t
.statuses
.home_timeline(count
=num
)):
309 for e
in c
['events']:
313 printNicely(magenta('Nothing at this time.'))
320 t
= Twitter(auth
=authen())
321 num
= c
['HOME_TWEET_NUM']
322 if g
['stuff'].isdigit():
323 num
= int(g
['stuff'])
324 for tweet
in reversed(t
.statuses
.mentions_timeline(count
=num
)):
331 Show profile of a specific user
333 t
= Twitter(auth
=authen())
335 screen_name
= g
['stuff'].split()[0]
337 printNicely(red('Sorry I can\'t understand.'))
339 if screen_name
.startswith('@'):
342 screen_name
=screen_name
[1:],
343 include_entities
=False)
347 printNicely(red('No user.'))
349 printNicely(red('A name should begin with a \'@\''))
356 t
= Twitter(auth
=authen())
358 user
= g
['stuff'].split()[0]
360 printNicely(red('Sorry I can\'t understand.'))
364 num
= int(g
['stuff'].split()[1])
366 num
= c
['HOME_TWEET_NUM']
367 for tweet
in reversed(
368 t
.statuses
.user_timeline(count
=num
, screen_name
=user
[1:])):
372 printNicely(red('A name should begin with a \'@\''))
379 t
= Twitter(auth
=authen())
381 query
= g
['stuff'].strip()
383 printNicely(red('Sorry I can\'t understand.'))
385 type = c
['SEARCH_TYPE']
386 if type not in ['mixed', 'recent', 'popular']:
388 max_record
= c
['SEARCH_MAX_RECORD']
389 count
= min(max_record
, 100)
391 rel
= t
.search
.tweets(
398 printNicely('Newest tweets:')
399 for i
in reversed(xrange(count
)):
400 draw(t
=rel
[i
], keyword
=query
)
403 printNicely(magenta('I\'m afraid there is no result'))
410 t
= Twitter(auth
=authen())
411 t
.statuses
.update(status
=g
['stuff'])
418 t
= Twitter(auth
=authen())
420 id = int(g
['stuff'].split()[0])
422 printNicely(red('Sorry I can\'t understand.'))
424 tid
= c
['tweet_dict'][id]
425 t
.statuses
.retweet(id=tid
, include_entities
=False, trim_user
=True)
433 t
= Twitter(auth
=authen())
435 id = int(g
['stuff'].split()[0])
437 printNicely(red('Sorry I can\'t understand.'))
439 tid
= c
['tweet_dict'][id]
440 tweet
= t
.statuses
.show(id=tid
)
442 formater
= format_quote(tweet
)
446 prefix
= light_magenta('Compose your ', rl
=True) + \
447 light_green('#comment: ', rl
=True)
448 comment
= raw_input(prefix
)
450 quote
= comment
.join(formater
.split('#comment'))
451 t
.statuses
.update(status
=quote
)
453 printNicely(light_magenta('No text added.'))
460 t
= Twitter(auth
=authen())
463 id = int(g
['stuff'].split()[0])
465 printNicely(red('Sorry I can\'t understand.'))
467 tid
= c
['tweet_dict'][id]
468 # Get display num if exist
470 num
= int(g
['stuff'].split()[1])
472 num
= c
['RETWEETS_SHOW_NUM']
473 # Get result and display
474 rt_ary
= t
.statuses
.retweets(id=tid
, count
=num
)
476 printNicely(magenta('This tweet has no retweet.'))
478 for tweet
in reversed(rt_ary
):
487 t
= Twitter(auth
=authen())
489 id = int(g
['stuff'].split()[0])
491 printNicely(red('Sorry I can\'t understand.'))
493 tid
= c
['tweet_dict'][id]
494 tweet
= t
.statuses
.show(id=tid
)
495 limit
= c
['CONVERSATION_MAX']
497 thread_ref
.append(tweet
)
498 prev_tid
= tweet
['in_reply_to_status_id']
499 while prev_tid
and limit
:
501 tweet
= t
.statuses
.show(id=prev_tid
)
502 prev_tid
= tweet
['in_reply_to_status_id']
503 thread_ref
.append(tweet
)
505 for tweet
in reversed(thread_ref
):
514 t
= Twitter(auth
=authen())
516 id = int(g
['stuff'].split()[0])
518 printNicely(red('Sorry I can\'t understand.'))
520 tid
= c
['tweet_dict'][id]
521 user
= t
.statuses
.show(id=tid
)['user']['screen_name']
522 status
= ' '.join(g
['stuff'].split()[1:])
523 status
= '@' + user
+ ' ' + str2u(status
)
524 t
.statuses
.update(status
=status
, in_reply_to_status_id
=tid
)
531 t
= Twitter(auth
=authen())
533 id = int(g
['stuff'].split()[0])
535 printNicely(red('Sorry I can\'t understand.'))
537 tid
= c
['tweet_dict'][id]
538 original_tweet
= t
.statuses
.show(id=tid
)
539 text
= original_tweet
['text']
540 nick_ary
= [original_tweet
['user']['screen_name']]
541 for user
in list(original_tweet
['entities']['user_mentions']):
542 if user
['screen_name'] not in nick_ary \
543 and user
['screen_name'] != g
['original_name']:
544 nick_ary
.append(user
['screen_name'])
545 status
= ' '.join(g
['stuff'].split()[1:])
546 status
= ' '.join(['@' + nick
for nick
in nick_ary
]) + ' ' + str2u(status
)
547 t
.statuses
.update(status
=status
, in_reply_to_status_id
=tid
)
554 t
= Twitter(auth
=authen())
556 id = int(g
['stuff'].split()[0])
558 printNicely(red('Sorry I can\'t understand.'))
560 tid
= c
['tweet_dict'][id]
561 t
.favorites
.create(_id
=tid
, include_entities
=False)
562 printNicely(green('Favorited.'))
563 draw(t
.statuses
.show(id=tid
))
571 t
= Twitter(auth
=authen())
573 id = int(g
['stuff'].split()[0])
575 printNicely(red('Sorry I can\'t understand.'))
577 tid
= c
['tweet_dict'][id]
578 t
.favorites
.destroy(_id
=tid
)
579 printNicely(green('Okay it\'s unfavorited.'))
580 draw(t
.statuses
.show(id=tid
))
586 Copy url of a tweet to clipboard
588 t
= Twitter(auth
=authen())
590 id = int(g
['stuff'].split()[0])
591 tid
= c
['tweet_dict'][id]
593 printNicely(red('Tweet id is not valid.'))
595 tweet
= t
.statuses
.show(id=tid
)
596 url
= 'https://twitter.com/' + \
597 tweet
['user']['screen_name'] + '/status/' + str(tid
)
599 if platform
.system().lower() == 'darwin':
600 os
.system("echo '%s' | pbcopy" % url
)
601 printNicely(green('Copied tweet\'s url to clipboard.'))
603 printNicely('Direct link: ' + yellow(url
))
610 t
= Twitter(auth
=authen())
612 id = int(g
['stuff'].split()[0])
614 printNicely(red('Sorry I can\'t understand.'))
616 tid
= c
['tweet_dict'][id]
617 t
.statuses
.destroy(id=tid
)
618 printNicely(green('Okay it\'s gone.'))
625 t
= Twitter(auth
=authen())
627 target
= g
['stuff'].split()[0]
628 if target
!= 'image':
630 id = int(g
['stuff'].split()[1])
631 tid
= c
['tweet_dict'][id]
632 tweet
= t
.statuses
.show(id=tid
)
633 media
= tweet
['entities']['media']
635 res
= requests
.get(m
['media_url'])
636 img
= Image
.open(BytesIO(res
.content
))
640 printNicely(red('Sorry I can\'t show this image.'))
647 t
= Twitter(auth
=authen())
649 if not g
['stuff'].isdigit():
651 tid
= c
['tweet_dict'][int(g
['stuff'])]
652 tweet
= t
.statuses
.show(id=tid
)
653 link_prefix
= ('http://', 'https://')
654 link_ary
= [u
for u
in tweet
['text'].split()
655 if u
.startswith(link_prefix
)]
657 printNicely(light_magenta('No url here @.@!'))
659 for link
in link_ary
:
660 webbrowser
.open(link
)
663 printNicely(red('Sorry I can\'t open url in this tweet.'))
670 t
= Twitter(auth
=authen())
671 num
= c
['MESSAGES_DISPLAY']
672 if g
['stuff'].isdigit():
678 inbox
= inbox
+ t
.direct_messages(
681 include_entities
=False,
686 inbox
= inbox
+ t
.direct_messages(
689 include_entities
=False,
693 num
= c
['MESSAGES_DISPLAY']
694 if g
['stuff'].isdigit():
699 sent
= sent
+ t
.direct_messages
.sent(
702 include_entities
=False,
707 sent
= sent
+ t
.direct_messages
.sent(
710 include_entities
=False,
715 uniq_inbox
= list(set(
716 [(m
['sender_screen_name'], m
['sender']['name']) for m
in inbox
]
718 uniq_sent
= list(set(
719 [(m
['recipient_screen_name'], m
['recipient']['name']) for m
in sent
]
721 for partner
in uniq_inbox
:
722 inbox_ary
= [m
for m
in inbox
if m
['sender_screen_name'] == partner
[0]]
724 m
for m
in sent
if m
['recipient_screen_name'] == partner
[0]]
725 d
[partner
] = inbox_ary
+ sent_ary
726 for partner
in uniq_sent
:
729 m
for m
in sent
if m
['recipient_screen_name'] == partner
[0]]
730 g
['message_threads'] = print_threads(d
)
735 View a thread of message
738 thread_id
= int(g
['stuff'])
740 g
['message_threads'][thread_id
],
745 printNicely(red('No such thread.'))
750 Send a direct message
752 t
= Twitter(auth
=authen())
754 user
= g
['stuff'].split()[0]
755 if user
[0].startswith('@'):
756 content
= ' '.join(g
['stuff'].split()[1:])
757 t
.direct_messages
.new(
758 screen_name
=user
[1:],
761 printNicely(green('Message sent.'))
763 printNicely(red('A name should begin with a \'@\''))
766 printNicely(red('Sorry I can\'t understand.'))
773 t
= Twitter(auth
=authen())
775 id = int(g
['stuff'].split()[0])
777 printNicely(red('Sorry I can\'t understand.'))
778 mid
= c
['message_dict'][id]
779 t
.direct_messages
.destroy(id=mid
)
780 printNicely(green('Message deleted.'))
785 List friends for followers
787 t
= Twitter(auth
=authen())
790 name
= g
['stuff'].split()[1]
791 if name
.startswith('@'):
794 printNicely(red('A name should begin with a \'@\''))
795 raise Exception('Invalid name')
797 name
= g
['original_name']
798 # Get list followers or friends
800 target
= g
['stuff'].split()[0]
802 printNicely(red('Omg some syntax is wrong.'))
805 d
= {'fl': 'followers', 'fr': 'friends'}
809 while next_cursor
!= 0:
810 list = getattr(t
, d
[target
]).list(
814 include_entities
=False,
816 for u
in list['users']:
817 rel
[u
['name']] = '@' + u
['screen_name']
818 next_cursor
= list['next_cursor']
820 printNicely('All: ' + str(len(rel
)) + ' ' + d
[target
] + '.')
822 user
= ' ' + cycle_color(name
)
823 user
+= color_func(c
['TWEET']['nick'])(' ' + rel
[name
] + ' ')
831 t
= Twitter(auth
=authen())
832 screen_name
= g
['stuff'].split()[0]
833 if screen_name
.startswith('@'):
834 t
.friendships
.create(screen_name
=screen_name
[1:], follow
=True)
835 printNicely(green('You are following ' + screen_name
+ ' now!'))
837 printNicely(red('A name should begin with a \'@\''))
844 t
= Twitter(auth
=authen())
845 screen_name
= g
['stuff'].split()[0]
846 if screen_name
.startswith('@'):
847 t
.friendships
.destroy(
848 screen_name
=screen_name
[1:],
849 include_entities
=False)
850 printNicely(green('Unfollow ' + screen_name
+ ' success!'))
852 printNicely(red('A name should begin with a \'@\''))
859 t
= Twitter(auth
=authen())
861 screen_name
= g
['stuff'].split()[0]
863 printNicely(red('A name should be specified. '))
865 if screen_name
.startswith('@'):
867 rel
= t
.mutes
.users
.create(screen_name
=screen_name
[1:])
868 if isinstance(rel
, dict):
869 printNicely(green(screen_name
+ ' is muted.'))
870 c
['IGNORE_LIST'] += [unc(screen_name
)]
871 c
['IGNORE_LIST'] = list(set(c
['IGNORE_LIST']))
873 printNicely(red(rel
))
876 printNicely(red('Something is wrong, can not mute now :('))
878 printNicely(red('A name should begin with a \'@\''))
885 t
= Twitter(auth
=authen())
887 screen_name
= g
['stuff'].split()[0]
889 printNicely(red('A name should be specified. '))
891 if screen_name
.startswith('@'):
893 rel
= t
.mutes
.users
.destroy(screen_name
=screen_name
[1:])
894 if isinstance(rel
, dict):
895 printNicely(green(screen_name
+ ' is unmuted.'))
896 c
['IGNORE_LIST'].remove(screen_name
)
898 printNicely(red(rel
))
900 printNicely(red('Maybe you are not muting this person ?'))
902 printNicely(red('A name should begin with a \'@\''))
909 # Get dict of muting users
910 md
= build_mute_dict(dict_data
=True)
911 printNicely('All: ' + str(len(md
)) + ' people.')
913 user
= ' ' + cycle_color(md
[name
])
914 user
+= color_func(c
['TWEET']['nick'])(' ' + name
+ ' ')
916 # Update from Twitter
917 c
['IGNORE_LIST'] = [n
for n
in md
]
924 t
= Twitter(auth
=authen())
925 screen_name
= g
['stuff'].split()[0]
926 if screen_name
.startswith('@'):
928 screen_name
=screen_name
[1:],
929 include_entities
=False,
931 printNicely(green('You blocked ' + screen_name
+ '.'))
933 printNicely(red('A name should begin with a \'@\''))
940 t
= Twitter(auth
=authen())
941 screen_name
= g
['stuff'].split()[0]
942 if screen_name
.startswith('@'):
944 screen_name
=screen_name
[1:],
945 include_entities
=False,
947 printNicely(green('Unblock ' + screen_name
+ ' success!'))
949 printNicely(red('A name should begin with a \'@\''))
954 Report a user as a spam account
956 t
= Twitter(auth
=authen())
957 screen_name
= g
['stuff'].split()[0]
958 if screen_name
.startswith('@'):
960 screen_name
=screen_name
[1:])
961 printNicely(green('You reported ' + screen_name
+ '.'))
963 printNicely(red('Sorry I can\'t understand.'))
971 list_name
= raw_input(
972 light_magenta('Give me the list\'s name ("@owner/list_name"): ', rl
=True))
973 # Get list name and owner
975 owner
, slug
= list_name
.split('/')
976 if slug
.startswith('@'):
981 light_magenta('List name should follow "@owner/list_name" format.'))
982 raise Exception('Wrong list name')
985 def check_slug(list_name
):
989 # Get list name and owner
991 owner
, slug
= list_name
.split('/')
992 if slug
.startswith('@'):
997 light_magenta('List name should follow "@owner/list_name" format.'))
998 raise Exception('Wrong list name')
1005 rel
= t
.lists
.list(screen_name
=g
['original_name'])
1009 printNicely(light_magenta('You belong to no lists :)'))
1016 owner
, slug
= get_slug()
1017 res
= t
.lists
.statuses(
1019 owner_screen_name
=owner
,
1020 count
=c
['LIST_MAX'],
1021 include_entities
=False)
1022 for tweet
in reversed(res
):
1027 def list_members(t
):
1031 owner
, slug
= get_slug()
1035 while next_cursor
!= 0:
1036 m
= t
.lists
.members(
1038 owner_screen_name
=owner
,
1040 include_entities
=False)
1041 for u
in m
['users']:
1042 rel
[u
['name']] = '@' + u
['screen_name']
1043 next_cursor
= m
['next_cursor']
1044 printNicely('All: ' + str(len(rel
)) + ' members.')
1046 user
= ' ' + cycle_color(name
)
1047 user
+= color_func(c
['TWEET']['nick'])(' ' + rel
[name
] + ' ')
1051 def list_subscribers(t
):
1055 owner
, slug
= get_slug()
1059 while next_cursor
!= 0:
1060 m
= t
.lists
.subscribers(
1062 owner_screen_name
=owner
,
1064 include_entities
=False)
1065 for u
in m
['users']:
1066 rel
[u
['name']] = '@' + u
['screen_name']
1067 next_cursor
= m
['next_cursor']
1068 printNicely('All: ' + str(len(rel
)) + ' subscribers.')
1070 user
= ' ' + cycle_color(name
)
1071 user
+= color_func(c
['TWEET']['nick'])(' ' + rel
[name
] + ' ')
1077 Add specific user to a list
1079 owner
, slug
= get_slug()
1081 user_name
= raw_input(
1083 'Give me name of the newbie: ',
1085 if user_name
.startswith('@'):
1086 user_name
= user_name
[1:]
1088 t
.lists
.members
.create(
1090 owner_screen_name
=owner
,
1091 screen_name
=user_name
)
1092 printNicely(green('Added.'))
1095 printNicely(light_magenta('I\'m sorry we can not add him/her.'))
1100 Remove specific user from a list
1102 owner
, slug
= get_slug()
1104 user_name
= raw_input(
1106 'Give me name of the unlucky one: ',
1108 if user_name
.startswith('@'):
1109 user_name
= user_name
[1:]
1111 t
.lists
.members
.destroy(
1113 owner_screen_name
=owner
,
1114 screen_name
=user_name
)
1115 printNicely(green('Gone.'))
1118 printNicely(light_magenta('I\'m sorry we can not remove him/her.'))
1121 def list_subscribe(t
):
1125 owner
, slug
= get_slug()
1128 t
.lists
.subscribers
.create(
1130 owner_screen_name
=owner
)
1131 printNicely(green('Done.'))
1135 light_magenta('I\'m sorry you can not subscribe to this list.'))
1138 def list_unsubscribe(t
):
1142 owner
, slug
= get_slug()
1145 t
.lists
.subscribers
.destroy(
1147 owner_screen_name
=owner
)
1148 printNicely(green('Done.'))
1152 light_magenta('I\'m sorry you can not unsubscribe to this list.'))
1161 while next_cursor
!= 0:
1162 res
= t
.lists
.ownerships(
1163 screen_name
=g
['original_name'],
1166 next_cursor
= res
['next_cursor']
1170 printNicely(light_magenta('You own no lists :)'))
1177 name
= raw_input(light_magenta('New list\'s name: ', rl
=True))
1180 'New list\'s mode (public/private): ',
1182 description
= raw_input(
1184 'New list\'s description: ',
1190 description
=description
)
1191 printNicely(green(name
+ ' list is created.'))
1194 printNicely(red('Oops something is wrong with Twitter :('))
1203 'Your list that you want to update: ',
1207 'Update name (leave blank to unchange): ',
1209 mode
= raw_input(light_magenta('Update mode (public/private): ', rl
=True))
1210 description
= raw_input(light_magenta('Update description: ', rl
=True))
1214 slug
='-'.join(slug
.split()),
1215 owner_screen_name
=g
['original_name'],
1218 description
=description
)
1222 owner_screen_name
=g
['original_name'],
1224 description
=description
)
1225 printNicely(green(slug
+ ' list is updated.'))
1228 printNicely(red('Oops something is wrong with Twitter :('))
1237 'Your list that you want to delete: ',
1241 slug
='-'.join(slug
.split()),
1242 owner_screen_name
=g
['original_name'])
1243 printNicely(green(slug
+ ' list is deleted.'))
1246 printNicely(red('Oops something is wrong with Twitter :('))
1253 t
= Twitter(auth
=authen())
1254 # List all lists or base on action
1256 g
['list_action'] = g
['stuff'].split()[0]
1263 'all_mem': list_members
,
1264 'all_sub': list_subscribers
,
1267 'sub': list_subscribe
,
1268 'unsub': list_unsubscribe
,
1271 'update': list_update
,
1275 return action_ary
[g
['list_action']](t
)
1277 printNicely(red('Please try again.'))
1285 target
= g
['stuff'].split()[0]
1287 args
= parse_arguments()
1289 if g
['stuff'].split()[-1] == '-f':
1290 guide
= 'To ignore an option, just hit Enter key.'
1291 printNicely(light_magenta(guide
))
1292 only
= raw_input('Only nicks [Ex: @xxx,@yy]: ')
1293 ignore
= raw_input('Ignore nicks [Ex: @xxx,@yy]: ')
1294 args
.filter = filter(None, only
.split(','))
1295 args
.ignore
= filter(None, ignore
.split(','))
1297 printNicely(red('Sorry, wrong format.'))
1300 g
['stream_stop'] = True
1302 stuff
= g
['stuff'].split()[1]
1307 'public': spawn_public_stream
,
1308 'list': spawn_list_stream
,
1309 'mine': spawn_personal_stream
,
1311 spawn_dict
.get(target
)(args
, stuff
)
1314 printNicely(red('Sorry I can\'t understand.'))
1319 Unix's command `cal`
1322 rel
= os
.popen('cal').read().split('\n')
1325 show_calendar(month
, date
, rel
)
1330 List and change theme
1334 for theme
in g
['themes']:
1335 line
= light_magenta(theme
)
1336 if c
['THEME'] == theme
:
1337 line
= ' ' * 2 + light_yellow('* ') + line
1339 line
= ' ' * 4 + line
1345 c
['THEME'] = reload_theme(g
['stuff'], c
['THEME'])
1346 # Redefine decorated_name
1347 g
['decorated_name'] = lambda x
: color_func(
1348 c
['DECORATED_NAME'])(
1350 printNicely(green('Theme changed.'))
1352 printNicely(red('No such theme exists.'))
1357 Browse and change config
1359 all_config
= get_all_config()
1360 g
['stuff'] = g
['stuff'].strip()
1363 for k
in all_config
:
1365 green(k
) + ': ' + light_yellow(str(all_config
[k
]))
1367 guide
= 'Detailed explanation can be found at ' + \
1368 color_func(c
['TWEET']['link'])(
1369 'http://rainbowstream.readthedocs.org/en/latest/#config-explanation')
1371 # Print specific config
1372 elif len(g
['stuff'].split()) == 1:
1373 if g
['stuff'] in all_config
:
1376 green(k
) + ': ' + light_yellow(str(all_config
[k
]))
1379 printNicely(red('No such config key.'))
1380 # Print specific config's default value
1381 elif len(g
['stuff'].split()) == 2 and g
['stuff'].split()[-1] == 'default':
1382 key
= g
['stuff'].split()[0]
1384 value
= get_default_config(key
)
1385 line
= ' ' * 2 + green(key
) + ': ' + light_magenta(value
)
1389 printNicely(red('Just can not get the default.'))
1390 # Delete specific config key in config file
1391 elif len(g
['stuff'].split()) == 2 and g
['stuff'].split()[-1] == 'drop':
1392 key
= g
['stuff'].split()[0]
1395 printNicely(green('Config key is dropped.'))
1398 printNicely(red('Just can not drop the key.'))
1399 # Set specific config
1400 elif len(g
['stuff'].split()) == 3 and g
['stuff'].split()[1] == '=':
1401 key
= g
['stuff'].split()[0]
1402 value
= g
['stuff'].split()[-1]
1403 if key
== 'THEME' and not validate_theme(value
):
1404 printNicely(red('Invalid theme\'s value.'))
1407 set_config(key
, value
)
1408 # Keys that needs to be apply immediately
1410 c
['THEME'] = reload_theme(value
, c
['THEME'])
1411 g
['decorated_name'] = lambda x
: color_func(
1412 c
['DECORATED_NAME'])('[' + x
+ ']: ')
1413 elif key
== 'PREFIX':
1414 g
['PREFIX'] = u2str(emojize(format_prefix(
1415 listname
=g
['listname'],
1416 keyword
=g
['keyword']
1419 printNicely(green('Updated successfully.'))
1422 printNicely(red('Just can not set the key.'))
1424 printNicely(light_magenta('Sorry I can\'s understand.'))
1427 def help_discover():
1432 # Discover the world
1434 usage
+= s
+ grey(u
'\u266A' + ' Discover the world \n')
1435 usage
+= s
* 2 + light_green('trend') + ' will show global trending topics. ' + \
1436 'You can try ' + light_green('trend US') + ' or ' + \
1437 light_green('trend JP Tokyo') + '.\n'
1438 usage
+= s
* 2 + light_green('home') + ' will show your timeline. ' + \
1439 light_green('home 7') + ' will show 7 tweets.\n'
1441 light_green('notification') + ' will show your recent notification.\n'
1442 usage
+= s
* 2 + light_green('mentions') + ' will show mentions timeline. ' + \
1443 light_green('mentions 7') + ' will show 7 mention tweets.\n'
1444 usage
+= s
* 2 + light_green('whois @mdo') + ' will show profile of ' + \
1445 magenta('@mdo') + '.\n'
1446 usage
+= s
* 2 + light_green('view @mdo') + \
1447 ' will show ' + magenta('@mdo') + '\'s home.\n'
1448 usage
+= s
* 2 + light_green('s AKB48') + ' will search for "' + \
1449 light_yellow('AKB48') + '" and return 5 newest tweet. ' + \
1450 'Search can be performed with or without hashtag.\n'
1461 usage
+= s
+ grey(u
'\u266A' + ' Tweets \n')
1462 usage
+= s
* 2 + light_green('t oops ') + \
1463 'will tweet "' + light_yellow('oops') + '" immediately.\n'
1465 light_green('rt 12 ') + ' will retweet to tweet with ' + \
1466 light_yellow('[id=12]') + '.\n'
1468 light_green('quote 12 ') + ' will quote the tweet with ' + \
1469 light_yellow('[id=12]') + '. If no extra text is added, ' + \
1470 'the quote will be canceled.\n'
1472 light_green('allrt 12 20 ') + ' will list 20 newest retweet of the tweet with ' + \
1473 light_yellow('[id=12]') + '.\n'
1474 usage
+= s
* 2 + light_green('conversation 12') + ' will show the chain of ' + \
1475 'replies prior to the tweet with ' + light_yellow('[id=12]') + '.\n'
1476 usage
+= s
* 2 + light_green('rep 12 oops') + ' will reply "' + \
1477 light_yellow('oops') + '" to the owner of the tweet with ' + \
1478 light_yellow('[id=12]') + '.\n'
1479 usage
+= s
* 2 + light_green('repall 12 oops') + ' will reply "' + \
1480 light_yellow('oops') + '" to all people in the tweet with ' + \
1481 light_yellow('[id=12]') + '.\n'
1483 light_green('fav 12 ') + ' will favorite the tweet with ' + \
1484 light_yellow('[id=12]') + '.\n'
1486 light_green('ufav 12 ') + ' will unfavorite tweet with ' + \
1487 light_yellow('[id=12]') + '.\n'
1489 light_green('share 12 ') + ' will get the direct link of the tweet with ' + \
1490 light_yellow('[id=12]') + '.\n'
1492 light_green('del 12 ') + ' will delete tweet with ' + \
1493 light_yellow('[id=12]') + '.\n'
1494 usage
+= s
* 2 + light_green('show image 12') + ' will show image in tweet with ' + \
1495 light_yellow('[id=12]') + ' in your OS\'s image viewer.\n'
1496 usage
+= s
* 2 + light_green('open 12') + ' will open url in tweet with ' + \
1497 light_yellow('[id=12]') + ' in your OS\'s default browser.\n'
1501 def help_messages():
1508 usage
+= s
+ grey(u
'\u266A' + ' Direct messages \n')
1509 usage
+= s
* 2 + light_green('inbox') + ' will show inbox messages. ' + \
1510 light_green('inbox 7') + ' will show newest 7 messages.\n'
1511 usage
+= s
* 2 + light_green('thread 2') + ' will show full thread with ' + \
1512 light_yellow('[thread_id=2]') + '.\n'
1513 usage
+= s
* 2 + light_green('mes @dtvd88 hi') + ' will send a "hi" messege to ' + \
1514 magenta('@dtvd88') + '.\n'
1515 usage
+= s
* 2 + light_green('trash 5') + ' will remove message with ' + \
1516 light_yellow('[message_id=5]') + '.\n'
1520 def help_friends_and_followers():
1522 Friends and Followers
1525 # Follower and following
1527 usage
+= s
+ grey(u
'\u266A' + ' Friends and followers \n')
1529 light_green('ls fl') + \
1530 ' will list all followers (people who are following you).\n'
1532 light_green('ls fr') + \
1533 ' will list all friends (people who you are following).\n'
1534 usage
+= s
* 2 + light_green('fl @dtvd88') + ' will follow ' + \
1535 magenta('@dtvd88') + '.\n'
1536 usage
+= s
* 2 + light_green('ufl @dtvd88') + ' will unfollow ' + \
1537 magenta('@dtvd88') + '.\n'
1538 usage
+= s
* 2 + light_green('mute @dtvd88') + ' will mute ' + \
1539 magenta('@dtvd88') + '.\n'
1540 usage
+= s
* 2 + light_green('unmute @dtvd88') + ' will unmute ' + \
1541 magenta('@dtvd88') + '.\n'
1542 usage
+= s
* 2 + light_green('muting') + ' will list muting users.\n'
1543 usage
+= s
* 2 + light_green('block @dtvd88') + ' will block ' + \
1544 magenta('@dtvd88') + '.\n'
1545 usage
+= s
* 2 + light_green('unblock @dtvd88') + ' will unblock ' + \
1546 magenta('@dtvd88') + '.\n'
1547 usage
+= s
* 2 + light_green('report @dtvd88') + ' will report ' + \
1548 magenta('@dtvd88') + ' as a spam account.\n'
1559 usage
+= s
+ grey(u
'\u266A' + ' Twitter list\n')
1560 usage
+= s
* 2 + light_green('list') + \
1561 ' will show all lists you are belong to.\n'
1562 usage
+= s
* 2 + light_green('list home') + \
1563 ' will show timeline of list. You will be asked for list\'s name.\n'
1564 usage
+= s
* 2 + light_green('list all_mem') + \
1565 ' will show list\'s all members.\n'
1566 usage
+= s
* 2 + light_green('list all_sub') + \
1567 ' will show list\'s all subscribers.\n'
1568 usage
+= s
* 2 + light_green('list add') + \
1569 ' will add specific person to a list owned by you.' + \
1570 ' You will be asked for list\'s name and person\'s name.\n'
1571 usage
+= s
* 2 + light_green('list rm') + \
1572 ' will remove specific person from a list owned by you.' + \
1573 ' You will be asked for list\'s name and person\'s name.\n'
1574 usage
+= s
* 2 + light_green('list sub') + \
1575 ' will subscribe you to a specific list.\n'
1576 usage
+= s
* 2 + light_green('list unsub') + \
1577 ' will unsubscribe you from a specific list.\n'
1578 usage
+= s
* 2 + light_green('list own') + \
1579 ' will show all list owned by you.\n'
1580 usage
+= s
* 2 + light_green('list new') + \
1581 ' will create a new list.\n'
1582 usage
+= s
* 2 + light_green('list update') + \
1583 ' will update a list owned by you.\n'
1584 usage
+= s
* 2 + light_green('list del') + \
1585 ' will delete a list owned by you.\n'
1596 usage
+= s
+ grey(u
'\u266A' + ' Switching streams \n')
1597 usage
+= s
* 2 + light_green('switch public #AKB') + \
1598 ' will switch to public stream and follow "' + \
1599 light_yellow('AKB') + '" keyword.\n'
1600 usage
+= s
* 2 + light_green('switch mine') + \
1601 ' will switch to your personal stream.\n'
1602 usage
+= s
* 2 + light_green('switch mine -f ') + \
1603 ' will prompt to enter the filter.\n'
1604 usage
+= s
* 3 + light_yellow('Only nicks') + \
1605 ' filter will decide nicks will be INCLUDE ONLY.\n'
1606 usage
+= s
* 3 + light_yellow('Ignore nicks') + \
1607 ' filter will decide nicks will be EXCLUDE.\n'
1608 usage
+= s
* 2 + light_green('switch list') + \
1609 ' will switch to a Twitter list\'s stream. You will be asked for list name\n'
1618 h
, w
= os
.popen('stty size', 'r').read().split()
1621 usage
+= s
+ 'Hi boss! I\'m ready to serve you right now!\n'
1622 usage
+= s
+ '-' * (int(w
) - 4) + '\n'
1623 usage
+= s
+ 'You are ' + \
1624 light_yellow('already') + ' on your personal stream.\n'
1625 usage
+= s
+ 'Any update from Twitter will show up ' + \
1626 light_yellow('immediately') + '.\n'
1627 usage
+= s
+ 'In addition, following commands are available right now:\n'
1628 # Twitter help section
1630 usage
+= s
+ grey(u
'\u266A' + ' Twitter help\n')
1631 usage
+= s
* 2 + light_green('h discover') + \
1632 ' will show help for discover commands.\n'
1633 usage
+= s
* 2 + light_green('h tweets') + \
1634 ' will show help for tweets commands.\n'
1635 usage
+= s
* 2 + light_green('h messages') + \
1636 ' will show help for messages commands.\n'
1637 usage
+= s
* 2 + light_green('h friends_and_followers') + \
1638 ' will show help for friends and followers commands.\n'
1639 usage
+= s
* 2 + light_green('h list') + \
1640 ' will show help for list commands.\n'
1641 usage
+= s
* 2 + light_green('h stream') + \
1642 ' will show help for stream commands.\n'
1645 usage
+= s
+ grey(u
'\u266A' + ' Smart shell\n')
1646 usage
+= s
* 2 + light_green('111111 * 9 / 7') + ' or any math expression ' + \
1647 'will be evaluate by Python interpreter.\n'
1648 usage
+= s
* 2 + 'Even ' + light_green('cal') + ' will show the calendar' + \
1649 ' for current month.\n'
1652 usage
+= s
+ grey(u
'\u266A' + ' Config \n')
1653 usage
+= s
* 2 + light_green('theme') + ' will list available theme. ' + \
1654 light_green('theme monokai') + ' will apply ' + light_yellow('monokai') + \
1655 ' theme immediately.\n'
1656 usage
+= s
* 2 + light_green('config') + ' will list all config.\n'
1658 light_green('config ASCII_ART') + ' will output current value of ' +\
1659 light_yellow('ASCII_ART') + ' config key.\n'
1661 light_green('config TREND_MAX default') + ' will output default value of ' + \
1662 light_yellow('TREND_MAX') + ' config key.\n'
1664 light_green('config CUSTOM_CONFIG drop') + ' will drop ' + \
1665 light_yellow('CUSTOM_CONFIG') + ' config key.\n'
1667 light_green('config IMAGE_ON_TERM = true') + ' will set value of ' + \
1668 light_yellow('IMAGE_ON_TERM') + ' config key to ' + \
1669 light_yellow('True') + '.\n'
1672 usage
+= s
+ grey(u
'\u266A' + ' Screening \n')
1673 usage
+= s
* 2 + light_green('h') + ' will show this help again.\n'
1674 usage
+= s
* 2 + light_green('p') + ' will pause the stream.\n'
1675 usage
+= s
* 2 + light_green('r') + ' will unpause the stream.\n'
1676 usage
+= s
* 2 + light_green('c') + ' will clear the screen.\n'
1677 usage
+= s
* 2 + light_green('v') + ' will show version info.\n'
1678 usage
+= s
* 2 + light_green('q') + ' will quit.\n'
1681 usage
+= s
+ '-' * (int(w
) - 4) + '\n'
1682 usage
+= s
+ 'Have fun and hang tight! \n'
1685 'discover': help_discover
,
1686 'tweets': help_tweets
,
1687 'messages': help_messages
,
1688 'friends_and_followers': help_friends_and_followers
,
1690 'stream': help_stream
,
1695 lambda: printNicely(red('No such command.'))
1703 Pause stream display
1706 printNicely(green('Stream is paused'))
1714 printNicely(green('Stream is running back now'))
1730 printNicely(green('See you next time :)'))
1738 Reset prefix of line
1741 if c
.get('USER_JSON_ERROR'):
1742 printNicely(red('Your ~/.rainbow_config.json is messed up:'))
1743 printNicely(red('>>> ' + c
['USER_JSON_ERROR']))
1745 printNicely(magenta('Need tips ? Type "h" and hit Enter key!'))
1748 printNicely(str(eval(g
['cmd'])))
1801 # Handle function set
1854 return dict(zip(cmdset
, funcset
)).get(cmd
, reset
)
1859 Listen to user's input
1864 ['public', 'mine', 'list'], # switch
1883 ['image'], # show image
1885 ['fl', 'fr'], # list
1887 [i
for i
in g
['message_threads']], # sent
1912 [key
for key
in dict(get_all_config())], # config
1913 g
['themes'], # theme
1918 'friends_and_followers',
1929 init_interactive_shell(d
)
1936 # Only use PREFIX as a string with raw_input
1937 line
= raw_input(g
['decorated_name'](g
['PREFIX']))
1940 # Save cmd to compare with readline buffer
1941 g
['cmd'] = line
.strip()
1942 # Get short cmd to pass to handle function
1944 cmd
= line
.split()[0]
1947 # Lock the semaphore
1949 # Save cmd to global variable and call process
1950 g
['stuff'] = ' '.join(line
.split()[1:])
1951 # Process the command
1954 if cmd
in ['switch', 't', 'rt', 'rep']:
1958 # Release the semaphore lock
1964 printNicely(red('OMG something is wrong with Twitter right now.'))
1967 def reconn_notice():
1969 Notice when Hangup or Timeout
1971 guide
= light_magenta('You can use ') + \
1972 light_green('switch') + \
1973 light_magenta(' command to return to your stream.\n')
1974 guide
+= light_magenta('Type ') + \
1975 light_green('h stream') + \
1976 light_magenta(' for more details.')
1978 sys
.stdout
.write(g
['decorated_name'](g
['PREFIX']))
1982 def stream(domain
, args
, name
='Rainbow Stream'):
1988 c
['USER_DOMAIN']: name
,
1989 c
['PUBLIC_DOMAIN']: args
.track_keywords
or 'Global',
1990 c
['SITE_DOMAIN']: name
,
1993 ascii_art(art_dict
.get(domain
, name
))
1994 # These arguments are optional:
1996 timeout
=0.5, # To check g['stream_stop'] after each 0.5 s
1998 heartbeat_timeout
=c
['HEARTBEAT_TIMEOUT'] * 60)
2001 if args
.track_keywords
:
2002 query_args
['track'] = args
.track_keywords
2004 stream
= TwitterStream(
2009 if domain
== c
['USER_DOMAIN']:
2010 tweet_iter
= stream
.user(**query_args
)
2011 elif domain
== c
['SITE_DOMAIN']:
2012 tweet_iter
= stream
.site(**query_args
)
2014 if args
.track_keywords
:
2015 tweet_iter
= stream
.statuses
.filter(**query_args
)
2017 tweet_iter
= stream
.statuses
.sample()
2018 # Block new stream until other one exits
2019 StreamLock
.acquire()
2020 g
['stream_stop'] = False
2021 last_tweet_time
= time
.time()
2022 for tweet
in tweet_iter
:
2024 printNicely('-- None --')
2025 elif tweet
is Timeout
:
2026 # Because the stream check for each 0.3s
2027 # so we shouldn't output anything here
2028 if(g
['stream_stop']):
2029 StreamLock
.release()
2031 elif tweet
is HeartbeatTimeout
:
2032 printNicely('-- Heartbeat Timeout --')
2034 StreamLock
.release()
2036 elif tweet
is Hangup
:
2037 printNicely('-- Hangup --')
2039 StreamLock
.release()
2041 elif tweet
.get('text'):
2042 # Slow down the stream by STREAM_DELAY config key
2043 if time
.time() - last_tweet_time
< c
['STREAM_DELAY']:
2045 last_tweet_time
= time
.time()
2046 # Check the semaphore pause and lock (stream process only)
2054 keyword
=args
.track_keywords
,
2059 # Current readline buffer
2060 current_buffer
= readline
.get_line_buffer().strip()
2061 # There is an unexpected behaviour in MacOSX readline + Python 2:
2062 # after completely delete a word after typing it,
2063 # somehow readline buffer still contains
2064 # the 1st character of that word
2065 if current_buffer
and g
['cmd'] != current_buffer
:
2067 g
['decorated_name'](g
['PREFIX']) + current_buffer
)
2069 elif not c
['HIDE_PROMPT']:
2070 sys
.stdout
.write(g
['decorated_name'](g
['PREFIX']))
2072 elif tweet
.get('direct_message'):
2073 # Check the semaphore pause and lock (stream process only)
2078 print_message(tweet
['direct_message'])
2079 elif tweet
.get('event'):
2080 c
['events'].append(tweet
)
2082 except TwitterHTTPError
as e
:
2085 magenta('We have connection problem with twitter stream API right now :('))
2086 detail_twitter_error(e
)
2087 sys
.stdout
.write(g
['decorated_name'](g
['PREFIX']))
2091 magenta('There seems to be a connection problem.'))
2096 def spawn_public_stream(args
, keyword
=None):
2098 Spawn a new public stream
2100 # Only set keyword if specified
2102 if keyword
[0] == '#':
2103 keyword
= keyword
[1:]
2104 args
.track_keywords
= keyword
2105 g
['keyword'] = keyword
2107 g
['keyword'] = 'Global'
2108 g
['PREFIX'] = u2str(emojize(format_prefix(keyword
=g
['keyword'])))
2111 th
= threading
.Thread(
2120 def spawn_list_stream(args
, stuff
=None):
2122 Spawn a new list stream
2125 owner
, slug
= check_slug(stuff
)
2127 owner
, slug
= get_slug()
2129 # Force python 2 not redraw readline buffer
2130 listname
= '/'.join([owner
, slug
])
2131 # Set the listname variable
2132 # and reset tracked keyword
2133 g
['listname'] = listname
2135 g
['PREFIX'] = g
['cmd'] = u2str(emojize(format_prefix(
2136 listname
=g
['listname']
2138 printNicely(light_yellow('getting list members ...'))
2140 t
= Twitter(auth
=authen())
2143 while next_cursor
!= 0:
2144 m
= t
.lists
.members(
2146 owner_screen_name
=owner
,
2148 include_entities
=False)
2149 for u
in m
['users']:
2150 members
.append('@' + u
['screen_name'])
2151 next_cursor
= m
['next_cursor']
2152 printNicely(light_yellow('... done.'))
2153 # Build thread filter array
2154 args
.filter = members
2156 th
= threading
.Thread(
2166 printNicely(cyan('Include: ' + str(len(args
.filter)) + ' people.'))
2168 printNicely(red('Ignore: ' + str(len(args
.ignore
)) + ' people.'))
2172 def spawn_personal_stream(args
, stuff
=None):
2174 Spawn a new personal stream
2176 # Reset the tracked keyword and listname
2177 g
['keyword'] = g
['listname'] = ''
2179 g
['PREFIX'] = u2str(emojize(format_prefix()))
2181 th
= threading
.Thread(
2186 g
['original_name']))
2196 args
= parse_arguments()
2200 # Twitter API connection problem
2201 except TwitterHTTPError
as e
:
2204 magenta('We have connection problem with twitter REST API right now :('))
2205 detail_twitter_error(e
)
2208 # Proxy connection problem
2209 except (socks
.ProxyConnectionError
, URLError
):
2211 magenta('There seems to be a connection problem.'))
2213 magenta('You might want to check your proxy settings (host, port and type)!'))
2217 # Spawn stream thread
2218 target
= args
.stream
.split()[0]
2219 if target
== 'mine' :
2220 spawn_personal_stream(args
)
2223 stuff
= args
.stream
.split()[1]
2227 'public': spawn_public_stream
,
2228 'list': spawn_list_stream
,
2230 spawn_dict
.get(target
)(args
, stuff
)
2232 # Start listen process