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 c
['24BIT'] = args
.color_24bit
242 set_config('IMAGE_ON_TERM', str(c
['IMAGE_ON_TERM']))
243 # Check type of ONLY_LIST and IGNORE_LIST
244 if not isinstance(c
['ONLY_LIST'], list):
245 printNicely(red('ONLY_LIST is not a valid list value.'))
247 if not isinstance(c
['IGNORE_LIST'], list):
248 printNicely(red('IGNORE_LIST is not a valid list value.'))
249 c
['IGNORE_LIST'] = []
251 c
['IGNORE_LIST'] += build_mute_dict()
258 t
= Twitter(auth
=authen())
259 # Get country and town
261 country
= g
['stuff'].split()[0]
265 town
= g
['stuff'].split()[1]
268 avail
= t
.trends
.available()
271 trends
= t
.trends
.place(_id
=1)[0]['trends']
274 for location
in avail
:
275 # Search for country and Town
277 if location
['countryCode'] == country \
278 and location
['placeType']['name'] == 'Town' \
279 and location
['name'] == town
:
280 trends
= t
.trends
.place(_id
=location
['woeid'])[0]['trends']
282 # Search for country only
284 if location
['countryCode'] == country \
285 and location
['placeType']['name'] == 'Country':
286 trends
= t
.trends
.place(_id
=location
['woeid'])[0]['trends']
294 t
= Twitter(auth
=authen())
295 num
= c
['HOME_TWEET_NUM']
296 if g
['stuff'].isdigit():
297 num
= int(g
['stuff'])
298 for tweet
in reversed(t
.statuses
.home_timeline(count
=num
)):
308 for e
in c
['events']:
312 printNicely(magenta('Nothing at this time.'))
319 t
= Twitter(auth
=authen())
320 num
= c
['HOME_TWEET_NUM']
321 if g
['stuff'].isdigit():
322 num
= int(g
['stuff'])
323 for tweet
in reversed(t
.statuses
.mentions_timeline(count
=num
)):
330 Show profile of a specific user
332 t
= Twitter(auth
=authen())
334 screen_name
= g
['stuff'].split()[0]
336 printNicely(red('Sorry I can\'t understand.'))
338 if screen_name
.startswith('@'):
341 screen_name
=screen_name
[1:],
342 include_entities
=False)
346 printNicely(red('No user.'))
348 printNicely(red('A name should begin with a \'@\''))
355 t
= Twitter(auth
=authen())
357 user
= g
['stuff'].split()[0]
359 printNicely(red('Sorry I can\'t understand.'))
363 num
= int(g
['stuff'].split()[1])
365 num
= c
['HOME_TWEET_NUM']
366 for tweet
in reversed(
367 t
.statuses
.user_timeline(count
=num
, screen_name
=user
[1:])):
371 printNicely(red('A name should begin with a \'@\''))
378 t
= Twitter(auth
=authen())
380 query
= g
['stuff'].strip()
382 printNicely(red('Sorry I can\'t understand.'))
384 type = c
['SEARCH_TYPE']
385 if type not in ['mixed', 'recent', 'popular']:
387 max_record
= c
['SEARCH_MAX_RECORD']
388 count
= min(max_record
, 100)
390 rel
= t
.search
.tweets(
397 printNicely('Newest tweets:')
398 for i
in reversed(xrange(count
)):
399 draw(t
=rel
[i
], keyword
=query
)
402 printNicely(magenta('I\'m afraid there is no result'))
409 t
= Twitter(auth
=authen())
410 t
.statuses
.update(status
=g
['stuff'])
417 t
= Twitter(auth
=authen())
419 id = int(g
['stuff'].split()[0])
421 printNicely(red('Sorry I can\'t understand.'))
423 tid
= c
['tweet_dict'][id]
424 t
.statuses
.retweet(id=tid
, include_entities
=False, trim_user
=True)
432 t
= Twitter(auth
=authen())
434 id = int(g
['stuff'].split()[0])
436 printNicely(red('Sorry I can\'t understand.'))
438 tid
= c
['tweet_dict'][id]
439 tweet
= t
.statuses
.show(id=tid
)
441 formater
= format_quote(tweet
)
445 prefix
= light_magenta('Compose your ', rl
=True) + \
446 light_green('#comment: ', rl
=True)
447 comment
= raw_input(prefix
)
449 quote
= comment
.join(formater
.split('#comment'))
450 t
.statuses
.update(status
=quote
)
452 printNicely(light_magenta('No text added.'))
459 t
= Twitter(auth
=authen())
462 id = int(g
['stuff'].split()[0])
464 printNicely(red('Sorry I can\'t understand.'))
466 tid
= c
['tweet_dict'][id]
467 # Get display num if exist
469 num
= int(g
['stuff'].split()[1])
471 num
= c
['RETWEETS_SHOW_NUM']
472 # Get result and display
473 rt_ary
= t
.statuses
.retweets(id=tid
, count
=num
)
475 printNicely(magenta('This tweet has no retweet.'))
477 for tweet
in reversed(rt_ary
):
486 t
= Twitter(auth
=authen())
488 id = int(g
['stuff'].split()[0])
490 printNicely(red('Sorry I can\'t understand.'))
492 tid
= c
['tweet_dict'][id]
493 tweet
= t
.statuses
.show(id=tid
)
494 limit
= c
['CONVERSATION_MAX']
496 thread_ref
.append(tweet
)
497 prev_tid
= tweet
['in_reply_to_status_id']
498 while prev_tid
and limit
:
500 tweet
= t
.statuses
.show(id=prev_tid
)
501 prev_tid
= tweet
['in_reply_to_status_id']
502 thread_ref
.append(tweet
)
504 for tweet
in reversed(thread_ref
):
513 t
= Twitter(auth
=authen())
515 id = int(g
['stuff'].split()[0])
517 printNicely(red('Sorry I can\'t understand.'))
519 tid
= c
['tweet_dict'][id]
520 user
= t
.statuses
.show(id=tid
)['user']['screen_name']
521 status
= ' '.join(g
['stuff'].split()[1:])
522 status
= '@' + user
+ ' ' + str2u(status
)
523 t
.statuses
.update(status
=status
, in_reply_to_status_id
=tid
)
530 t
= Twitter(auth
=authen())
532 id = int(g
['stuff'].split()[0])
534 printNicely(red('Sorry I can\'t understand.'))
536 tid
= c
['tweet_dict'][id]
537 original_tweet
= t
.statuses
.show(id=tid
)
538 text
= original_tweet
['text']
539 nick_ary
= [original_tweet
['user']['screen_name']]
540 for user
in list(original_tweet
['entities']['user_mentions']):
541 if user
['screen_name'] not in nick_ary \
542 and user
['screen_name'] != g
['original_name']:
543 nick_ary
.append(user
['screen_name'])
544 status
= ' '.join(g
['stuff'].split()[1:])
545 status
= ' '.join(['@' + nick
for nick
in nick_ary
]) + ' ' + str2u(status
)
546 t
.statuses
.update(status
=status
, in_reply_to_status_id
=tid
)
553 t
= Twitter(auth
=authen())
555 id = int(g
['stuff'].split()[0])
557 printNicely(red('Sorry I can\'t understand.'))
559 tid
= c
['tweet_dict'][id]
560 t
.favorites
.create(_id
=tid
, include_entities
=False)
561 printNicely(green('Favorited.'))
562 draw(t
.statuses
.show(id=tid
))
570 t
= Twitter(auth
=authen())
572 id = int(g
['stuff'].split()[0])
574 printNicely(red('Sorry I can\'t understand.'))
576 tid
= c
['tweet_dict'][id]
577 t
.favorites
.destroy(_id
=tid
)
578 printNicely(green('Okay it\'s unfavorited.'))
579 draw(t
.statuses
.show(id=tid
))
585 Copy url of a tweet to clipboard
587 t
= Twitter(auth
=authen())
589 id = int(g
['stuff'].split()[0])
590 tid
= c
['tweet_dict'][id]
592 printNicely(red('Tweet id is not valid.'))
594 tweet
= t
.statuses
.show(id=tid
)
595 url
= 'https://twitter.com/' + \
596 tweet
['user']['screen_name'] + '/status/' + str(tid
)
598 if platform
.system().lower() == 'darwin':
599 os
.system("echo '%s' | pbcopy" % url
)
600 printNicely(green('Copied tweet\'s url to clipboard.'))
602 printNicely('Direct link: ' + yellow(url
))
609 t
= Twitter(auth
=authen())
611 id = int(g
['stuff'].split()[0])
613 printNicely(red('Sorry I can\'t understand.'))
615 tid
= c
['tweet_dict'][id]
616 t
.statuses
.destroy(id=tid
)
617 printNicely(green('Okay it\'s gone.'))
624 t
= Twitter(auth
=authen())
626 target
= g
['stuff'].split()[0]
627 if target
!= 'image':
629 id = int(g
['stuff'].split()[1])
630 tid
= c
['tweet_dict'][id]
631 tweet
= t
.statuses
.show(id=tid
)
632 media
= tweet
['entities']['media']
634 res
= requests
.get(m
['media_url'])
635 img
= Image
.open(BytesIO(res
.content
))
639 printNicely(red('Sorry I can\'t show this image.'))
646 t
= Twitter(auth
=authen())
648 if not g
['stuff'].isdigit():
650 tid
= c
['tweet_dict'][int(g
['stuff'])]
651 tweet
= t
.statuses
.show(id=tid
)
652 link_prefix
= ('http://', 'https://')
653 link_ary
= [u
for u
in tweet
['text'].split()
654 if u
.startswith(link_prefix
)]
656 printNicely(light_magenta('No url here @.@!'))
658 for link
in link_ary
:
659 webbrowser
.open(link
)
662 printNicely(red('Sorry I can\'t open url in this tweet.'))
669 t
= Twitter(auth
=authen())
670 num
= c
['MESSAGES_DISPLAY']
671 if g
['stuff'].isdigit():
677 inbox
= inbox
+ t
.direct_messages(
680 include_entities
=False,
685 inbox
= inbox
+ t
.direct_messages(
688 include_entities
=False,
692 num
= c
['MESSAGES_DISPLAY']
693 if g
['stuff'].isdigit():
698 sent
= sent
+ t
.direct_messages
.sent(
701 include_entities
=False,
706 sent
= sent
+ t
.direct_messages
.sent(
709 include_entities
=False,
714 uniq_inbox
= list(set(
715 [(m
['sender_screen_name'], m
['sender']['name']) for m
in inbox
]
717 uniq_sent
= list(set(
718 [(m
['recipient_screen_name'], m
['recipient']['name']) for m
in sent
]
720 for partner
in uniq_inbox
:
721 inbox_ary
= [m
for m
in inbox
if m
['sender_screen_name'] == partner
[0]]
723 m
for m
in sent
if m
['recipient_screen_name'] == partner
[0]]
724 d
[partner
] = inbox_ary
+ sent_ary
725 for partner
in uniq_sent
:
728 m
for m
in sent
if m
['recipient_screen_name'] == partner
[0]]
729 g
['message_threads'] = print_threads(d
)
734 View a thread of message
737 thread_id
= int(g
['stuff'])
739 g
['message_threads'][thread_id
],
744 printNicely(red('No such thread.'))
749 Send a direct message
751 t
= Twitter(auth
=authen())
753 user
= g
['stuff'].split()[0]
754 if user
[0].startswith('@'):
755 content
= ' '.join(g
['stuff'].split()[1:])
756 t
.direct_messages
.new(
757 screen_name
=user
[1:],
760 printNicely(green('Message sent.'))
762 printNicely(red('A name should begin with a \'@\''))
765 printNicely(red('Sorry I can\'t understand.'))
772 t
= Twitter(auth
=authen())
774 id = int(g
['stuff'].split()[0])
776 printNicely(red('Sorry I can\'t understand.'))
777 mid
= c
['message_dict'][id]
778 t
.direct_messages
.destroy(id=mid
)
779 printNicely(green('Message deleted.'))
784 List friends for followers
786 t
= Twitter(auth
=authen())
789 name
= g
['stuff'].split()[1]
790 if name
.startswith('@'):
793 printNicely(red('A name should begin with a \'@\''))
794 raise Exception('Invalid name')
796 name
= g
['original_name']
797 # Get list followers or friends
799 target
= g
['stuff'].split()[0]
801 printNicely(red('Omg some syntax is wrong.'))
804 d
= {'fl': 'followers', 'fr': 'friends'}
808 while next_cursor
!= 0:
809 list = getattr(t
, d
[target
]).list(
813 include_entities
=False,
815 for u
in list['users']:
816 rel
[u
['name']] = '@' + u
['screen_name']
817 next_cursor
= list['next_cursor']
819 printNicely('All: ' + str(len(rel
)) + ' ' + d
[target
] + '.')
821 user
= ' ' + cycle_color(name
)
822 user
+= color_func(c
['TWEET']['nick'])(' ' + rel
[name
] + ' ')
830 t
= Twitter(auth
=authen())
831 screen_name
= g
['stuff'].split()[0]
832 if screen_name
.startswith('@'):
833 t
.friendships
.create(screen_name
=screen_name
[1:], follow
=True)
834 printNicely(green('You are following ' + screen_name
+ ' now!'))
836 printNicely(red('A name should begin with a \'@\''))
843 t
= Twitter(auth
=authen())
844 screen_name
= g
['stuff'].split()[0]
845 if screen_name
.startswith('@'):
846 t
.friendships
.destroy(
847 screen_name
=screen_name
[1:],
848 include_entities
=False)
849 printNicely(green('Unfollow ' + screen_name
+ ' success!'))
851 printNicely(red('A name should begin with a \'@\''))
858 t
= Twitter(auth
=authen())
860 screen_name
= g
['stuff'].split()[0]
862 printNicely(red('A name should be specified. '))
864 if screen_name
.startswith('@'):
866 rel
= t
.mutes
.users
.create(screen_name
=screen_name
[1:])
867 if isinstance(rel
, dict):
868 printNicely(green(screen_name
+ ' is muted.'))
869 c
['IGNORE_LIST'] += [unc(screen_name
)]
870 c
['IGNORE_LIST'] = list(set(c
['IGNORE_LIST']))
872 printNicely(red(rel
))
875 printNicely(red('Something is wrong, can not mute now :('))
877 printNicely(red('A name should begin with a \'@\''))
884 t
= Twitter(auth
=authen())
886 screen_name
= g
['stuff'].split()[0]
888 printNicely(red('A name should be specified. '))
890 if screen_name
.startswith('@'):
892 rel
= t
.mutes
.users
.destroy(screen_name
=screen_name
[1:])
893 if isinstance(rel
, dict):
894 printNicely(green(screen_name
+ ' is unmuted.'))
895 c
['IGNORE_LIST'].remove(screen_name
)
897 printNicely(red(rel
))
899 printNicely(red('Maybe you are not muting this person ?'))
901 printNicely(red('A name should begin with a \'@\''))
908 # Get dict of muting users
909 md
= build_mute_dict(dict_data
=True)
910 printNicely('All: ' + str(len(md
)) + ' people.')
912 user
= ' ' + cycle_color(md
[name
])
913 user
+= color_func(c
['TWEET']['nick'])(' ' + name
+ ' ')
915 # Update from Twitter
916 c
['IGNORE_LIST'] = [n
for n
in md
]
923 t
= Twitter(auth
=authen())
924 screen_name
= g
['stuff'].split()[0]
925 if screen_name
.startswith('@'):
927 screen_name
=screen_name
[1:],
928 include_entities
=False,
930 printNicely(green('You blocked ' + screen_name
+ '.'))
932 printNicely(red('A name should begin with a \'@\''))
939 t
= Twitter(auth
=authen())
940 screen_name
= g
['stuff'].split()[0]
941 if screen_name
.startswith('@'):
943 screen_name
=screen_name
[1:],
944 include_entities
=False,
946 printNicely(green('Unblock ' + screen_name
+ ' success!'))
948 printNicely(red('A name should begin with a \'@\''))
953 Report a user as a spam account
955 t
= Twitter(auth
=authen())
956 screen_name
= g
['stuff'].split()[0]
957 if screen_name
.startswith('@'):
959 screen_name
=screen_name
[1:])
960 printNicely(green('You reported ' + screen_name
+ '.'))
962 printNicely(red('Sorry I can\'t understand.'))
970 list_name
= raw_input(
971 light_magenta('Give me the list\'s name ("@owner/list_name"): ', rl
=True))
972 # Get list name and owner
974 owner
, slug
= list_name
.split('/')
975 if slug
.startswith('@'):
980 light_magenta('List name should follow "@owner/list_name" format.'))
981 raise Exception('Wrong list name')
984 def check_slug(list_name
):
988 # Get list name and owner
990 owner
, slug
= list_name
.split('/')
991 if slug
.startswith('@'):
996 light_magenta('List name should follow "@owner/list_name" format.'))
997 raise Exception('Wrong list name')
1004 rel
= t
.lists
.list(screen_name
=g
['original_name'])
1008 printNicely(light_magenta('You belong to no lists :)'))
1015 owner
, slug
= get_slug()
1016 res
= t
.lists
.statuses(
1018 owner_screen_name
=owner
,
1019 count
=c
['LIST_MAX'],
1020 include_entities
=False)
1021 for tweet
in reversed(res
):
1026 def list_members(t
):
1030 owner
, slug
= get_slug()
1034 while next_cursor
!= 0:
1035 m
= t
.lists
.members(
1037 owner_screen_name
=owner
,
1039 include_entities
=False)
1040 for u
in m
['users']:
1041 rel
[u
['name']] = '@' + u
['screen_name']
1042 next_cursor
= m
['next_cursor']
1043 printNicely('All: ' + str(len(rel
)) + ' members.')
1045 user
= ' ' + cycle_color(name
)
1046 user
+= color_func(c
['TWEET']['nick'])(' ' + rel
[name
] + ' ')
1050 def list_subscribers(t
):
1054 owner
, slug
= get_slug()
1058 while next_cursor
!= 0:
1059 m
= t
.lists
.subscribers(
1061 owner_screen_name
=owner
,
1063 include_entities
=False)
1064 for u
in m
['users']:
1065 rel
[u
['name']] = '@' + u
['screen_name']
1066 next_cursor
= m
['next_cursor']
1067 printNicely('All: ' + str(len(rel
)) + ' subscribers.')
1069 user
= ' ' + cycle_color(name
)
1070 user
+= color_func(c
['TWEET']['nick'])(' ' + rel
[name
] + ' ')
1076 Add specific user to a list
1078 owner
, slug
= get_slug()
1080 user_name
= raw_input(
1082 'Give me name of the newbie: ',
1084 if user_name
.startswith('@'):
1085 user_name
= user_name
[1:]
1087 t
.lists
.members
.create(
1089 owner_screen_name
=owner
,
1090 screen_name
=user_name
)
1091 printNicely(green('Added.'))
1094 printNicely(light_magenta('I\'m sorry we can not add him/her.'))
1099 Remove specific user from a list
1101 owner
, slug
= get_slug()
1103 user_name
= raw_input(
1105 'Give me name of the unlucky one: ',
1107 if user_name
.startswith('@'):
1108 user_name
= user_name
[1:]
1110 t
.lists
.members
.destroy(
1112 owner_screen_name
=owner
,
1113 screen_name
=user_name
)
1114 printNicely(green('Gone.'))
1117 printNicely(light_magenta('I\'m sorry we can not remove him/her.'))
1120 def list_subscribe(t
):
1124 owner
, slug
= get_slug()
1127 t
.lists
.subscribers
.create(
1129 owner_screen_name
=owner
)
1130 printNicely(green('Done.'))
1134 light_magenta('I\'m sorry you can not subscribe to this list.'))
1137 def list_unsubscribe(t
):
1141 owner
, slug
= get_slug()
1144 t
.lists
.subscribers
.destroy(
1146 owner_screen_name
=owner
)
1147 printNicely(green('Done.'))
1151 light_magenta('I\'m sorry you can not unsubscribe to this list.'))
1160 while next_cursor
!= 0:
1161 res
= t
.lists
.ownerships(
1162 screen_name
=g
['original_name'],
1165 next_cursor
= res
['next_cursor']
1169 printNicely(light_magenta('You own no lists :)'))
1176 name
= raw_input(light_magenta('New list\'s name: ', rl
=True))
1179 'New list\'s mode (public/private): ',
1181 description
= raw_input(
1183 'New list\'s description: ',
1189 description
=description
)
1190 printNicely(green(name
+ ' list is created.'))
1193 printNicely(red('Oops something is wrong with Twitter :('))
1202 'Your list that you want to update: ',
1206 'Update name (leave blank to unchange): ',
1208 mode
= raw_input(light_magenta('Update mode (public/private): ', rl
=True))
1209 description
= raw_input(light_magenta('Update description: ', rl
=True))
1213 slug
='-'.join(slug
.split()),
1214 owner_screen_name
=g
['original_name'],
1217 description
=description
)
1221 owner_screen_name
=g
['original_name'],
1223 description
=description
)
1224 printNicely(green(slug
+ ' list is updated.'))
1227 printNicely(red('Oops something is wrong with Twitter :('))
1236 'Your list that you want to delete: ',
1240 slug
='-'.join(slug
.split()),
1241 owner_screen_name
=g
['original_name'])
1242 printNicely(green(slug
+ ' list is deleted.'))
1245 printNicely(red('Oops something is wrong with Twitter :('))
1252 t
= Twitter(auth
=authen())
1253 # List all lists or base on action
1255 g
['list_action'] = g
['stuff'].split()[0]
1262 'all_mem': list_members
,
1263 'all_sub': list_subscribers
,
1266 'sub': list_subscribe
,
1267 'unsub': list_unsubscribe
,
1270 'update': list_update
,
1274 return action_ary
[g
['list_action']](t
)
1276 printNicely(red('Please try again.'))
1284 target
= g
['stuff'].split()[0]
1286 args
= parse_arguments()
1288 if g
['stuff'].split()[-1] == '-f':
1289 guide
= 'To ignore an option, just hit Enter key.'
1290 printNicely(light_magenta(guide
))
1291 only
= raw_input('Only nicks [Ex: @xxx,@yy]: ')
1292 ignore
= raw_input('Ignore nicks [Ex: @xxx,@yy]: ')
1293 args
.filter = filter(None, only
.split(','))
1294 args
.ignore
= filter(None, ignore
.split(','))
1296 printNicely(red('Sorry, wrong format.'))
1299 g
['stream_stop'] = True
1301 stuff
= g
['stuff'].split()[1]
1306 'public': spawn_public_stream
,
1307 'list': spawn_list_stream
,
1308 'mine': spawn_personal_stream
,
1310 spawn_dict
.get(target
)(args
, stuff
)
1313 printNicely(red('Sorry I can\'t understand.'))
1318 Unix's command `cal`
1321 rel
= os
.popen('cal').read().split('\n')
1324 show_calendar(month
, date
, rel
)
1329 List and change theme
1333 for theme
in g
['themes']:
1334 line
= light_magenta(theme
)
1335 if c
['THEME'] == theme
:
1336 line
= ' ' * 2 + light_yellow('* ') + line
1338 line
= ' ' * 4 + line
1344 c
['THEME'] = reload_theme(g
['stuff'], c
['THEME'])
1345 # Redefine decorated_name
1346 g
['decorated_name'] = lambda x
: color_func(
1347 c
['DECORATED_NAME'])(
1349 printNicely(green('Theme changed.'))
1351 printNicely(red('No such theme exists.'))
1356 Browse and change config
1358 all_config
= get_all_config()
1359 g
['stuff'] = g
['stuff'].strip()
1362 for k
in all_config
:
1364 green(k
) + ': ' + light_yellow(str(all_config
[k
]))
1366 guide
= 'Detailed explanation can be found at ' + \
1367 color_func(c
['TWEET']['link'])(
1368 'http://rainbowstream.readthedocs.org/en/latest/#config-explanation')
1370 # Print specific config
1371 elif len(g
['stuff'].split()) == 1:
1372 if g
['stuff'] in all_config
:
1375 green(k
) + ': ' + light_yellow(str(all_config
[k
]))
1378 printNicely(red('No such config key.'))
1379 # Print specific config's default value
1380 elif len(g
['stuff'].split()) == 2 and g
['stuff'].split()[-1] == 'default':
1381 key
= g
['stuff'].split()[0]
1383 value
= get_default_config(key
)
1384 line
= ' ' * 2 + green(key
) + ': ' + light_magenta(value
)
1388 printNicely(red('Just can not get the default.'))
1389 # Delete specific config key in config file
1390 elif len(g
['stuff'].split()) == 2 and g
['stuff'].split()[-1] == 'drop':
1391 key
= g
['stuff'].split()[0]
1394 printNicely(green('Config key is dropped.'))
1397 printNicely(red('Just can not drop the key.'))
1398 # Set specific config
1399 elif len(g
['stuff'].split()) == 3 and g
['stuff'].split()[1] == '=':
1400 key
= g
['stuff'].split()[0]
1401 value
= g
['stuff'].split()[-1]
1402 if key
== 'THEME' and not validate_theme(value
):
1403 printNicely(red('Invalid theme\'s value.'))
1406 set_config(key
, value
)
1407 # Keys that needs to be apply immediately
1409 c
['THEME'] = reload_theme(value
, c
['THEME'])
1410 g
['decorated_name'] = lambda x
: color_func(
1411 c
['DECORATED_NAME'])('[' + x
+ ']: ')
1412 elif key
== 'PREFIX':
1413 g
['PREFIX'] = u2str(emojize(format_prefix(
1414 listname
=g
['listname'],
1415 keyword
=g
['keyword']
1418 printNicely(green('Updated successfully.'))
1421 printNicely(red('Just can not set the key.'))
1423 printNicely(light_magenta('Sorry I can\'s understand.'))
1426 def help_discover():
1431 # Discover the world
1433 usage
+= s
+ grey(u
'\u266A' + ' Discover the world \n')
1434 usage
+= s
* 2 + light_green('trend') + ' will show global trending topics. ' + \
1435 'You can try ' + light_green('trend US') + ' or ' + \
1436 light_green('trend JP Tokyo') + '.\n'
1437 usage
+= s
* 2 + light_green('home') + ' will show your timeline. ' + \
1438 light_green('home 7') + ' will show 7 tweets.\n'
1440 light_green('notification') + ' will show your recent notification.\n'
1441 usage
+= s
* 2 + light_green('mentions') + ' will show mentions timeline. ' + \
1442 light_green('mentions 7') + ' will show 7 mention tweets.\n'
1443 usage
+= s
* 2 + light_green('whois @mdo') + ' will show profile of ' + \
1444 magenta('@mdo') + '.\n'
1445 usage
+= s
* 2 + light_green('view @mdo') + \
1446 ' will show ' + magenta('@mdo') + '\'s home.\n'
1447 usage
+= s
* 2 + light_green('s AKB48') + ' will search for "' + \
1448 light_yellow('AKB48') + '" and return 5 newest tweet. ' + \
1449 'Search can be performed with or without hashtag.\n'
1460 usage
+= s
+ grey(u
'\u266A' + ' Tweets \n')
1461 usage
+= s
* 2 + light_green('t oops ') + \
1462 'will tweet "' + light_yellow('oops') + '" immediately.\n'
1464 light_green('rt 12 ') + ' will retweet to tweet with ' + \
1465 light_yellow('[id=12]') + '.\n'
1467 light_green('quote 12 ') + ' will quote the tweet with ' + \
1468 light_yellow('[id=12]') + '. If no extra text is added, ' + \
1469 'the quote will be canceled.\n'
1471 light_green('allrt 12 20 ') + ' will list 20 newest retweet of the tweet with ' + \
1472 light_yellow('[id=12]') + '.\n'
1473 usage
+= s
* 2 + light_green('conversation 12') + ' will show the chain of ' + \
1474 'replies prior to the tweet with ' + light_yellow('[id=12]') + '.\n'
1475 usage
+= s
* 2 + light_green('rep 12 oops') + ' will reply "' + \
1476 light_yellow('oops') + '" to the owner of the tweet with ' + \
1477 light_yellow('[id=12]') + '.\n'
1478 usage
+= s
* 2 + light_green('repall 12 oops') + ' will reply "' + \
1479 light_yellow('oops') + '" to all people in the tweet with ' + \
1480 light_yellow('[id=12]') + '.\n'
1482 light_green('fav 12 ') + ' will favorite the tweet with ' + \
1483 light_yellow('[id=12]') + '.\n'
1485 light_green('ufav 12 ') + ' will unfavorite tweet with ' + \
1486 light_yellow('[id=12]') + '.\n'
1488 light_green('share 12 ') + ' will get the direct link of the tweet with ' + \
1489 light_yellow('[id=12]') + '.\n'
1491 light_green('del 12 ') + ' will delete tweet with ' + \
1492 light_yellow('[id=12]') + '.\n'
1493 usage
+= s
* 2 + light_green('show image 12') + ' will show image in tweet with ' + \
1494 light_yellow('[id=12]') + ' in your OS\'s image viewer.\n'
1495 usage
+= s
* 2 + light_green('open 12') + ' will open url in tweet with ' + \
1496 light_yellow('[id=12]') + ' in your OS\'s default browser.\n'
1500 def help_messages():
1507 usage
+= s
+ grey(u
'\u266A' + ' Direct messages \n')
1508 usage
+= s
* 2 + light_green('inbox') + ' will show inbox messages. ' + \
1509 light_green('inbox 7') + ' will show newest 7 messages.\n'
1510 usage
+= s
* 2 + light_green('thread 2') + ' will show full thread with ' + \
1511 light_yellow('[thread_id=2]') + '.\n'
1512 usage
+= s
* 2 + light_green('mes @dtvd88 hi') + ' will send a "hi" messege to ' + \
1513 magenta('@dtvd88') + '.\n'
1514 usage
+= s
* 2 + light_green('trash 5') + ' will remove message with ' + \
1515 light_yellow('[message_id=5]') + '.\n'
1519 def help_friends_and_followers():
1521 Friends and Followers
1524 # Follower and following
1526 usage
+= s
+ grey(u
'\u266A' + ' Friends and followers \n')
1528 light_green('ls fl') + \
1529 ' will list all followers (people who are following you).\n'
1531 light_green('ls fr') + \
1532 ' will list all friends (people who you are following).\n'
1533 usage
+= s
* 2 + light_green('fl @dtvd88') + ' will follow ' + \
1534 magenta('@dtvd88') + '.\n'
1535 usage
+= s
* 2 + light_green('ufl @dtvd88') + ' will unfollow ' + \
1536 magenta('@dtvd88') + '.\n'
1537 usage
+= s
* 2 + light_green('mute @dtvd88') + ' will mute ' + \
1538 magenta('@dtvd88') + '.\n'
1539 usage
+= s
* 2 + light_green('unmute @dtvd88') + ' will unmute ' + \
1540 magenta('@dtvd88') + '.\n'
1541 usage
+= s
* 2 + light_green('muting') + ' will list muting users.\n'
1542 usage
+= s
* 2 + light_green('block @dtvd88') + ' will block ' + \
1543 magenta('@dtvd88') + '.\n'
1544 usage
+= s
* 2 + light_green('unblock @dtvd88') + ' will unblock ' + \
1545 magenta('@dtvd88') + '.\n'
1546 usage
+= s
* 2 + light_green('report @dtvd88') + ' will report ' + \
1547 magenta('@dtvd88') + ' as a spam account.\n'
1558 usage
+= s
+ grey(u
'\u266A' + ' Twitter list\n')
1559 usage
+= s
* 2 + light_green('list') + \
1560 ' will show all lists you are belong to.\n'
1561 usage
+= s
* 2 + light_green('list home') + \
1562 ' will show timeline of list. You will be asked for list\'s name.\n'
1563 usage
+= s
* 2 + light_green('list all_mem') + \
1564 ' will show list\'s all members.\n'
1565 usage
+= s
* 2 + light_green('list all_sub') + \
1566 ' will show list\'s all subscribers.\n'
1567 usage
+= s
* 2 + light_green('list add') + \
1568 ' will add specific person to a list owned by you.' + \
1569 ' You will be asked for list\'s name and person\'s name.\n'
1570 usage
+= s
* 2 + light_green('list rm') + \
1571 ' will remove specific person from a list owned by you.' + \
1572 ' You will be asked for list\'s name and person\'s name.\n'
1573 usage
+= s
* 2 + light_green('list sub') + \
1574 ' will subscribe you to a specific list.\n'
1575 usage
+= s
* 2 + light_green('list unsub') + \
1576 ' will unsubscribe you from a specific list.\n'
1577 usage
+= s
* 2 + light_green('list own') + \
1578 ' will show all list owned by you.\n'
1579 usage
+= s
* 2 + light_green('list new') + \
1580 ' will create a new list.\n'
1581 usage
+= s
* 2 + light_green('list update') + \
1582 ' will update a list owned by you.\n'
1583 usage
+= s
* 2 + light_green('list del') + \
1584 ' will delete a list owned by you.\n'
1595 usage
+= s
+ grey(u
'\u266A' + ' Switching streams \n')
1596 usage
+= s
* 2 + light_green('switch public #AKB') + \
1597 ' will switch to public stream and follow "' + \
1598 light_yellow('AKB') + '" keyword.\n'
1599 usage
+= s
* 2 + light_green('switch mine') + \
1600 ' will switch to your personal stream.\n'
1601 usage
+= s
* 2 + light_green('switch mine -f ') + \
1602 ' will prompt to enter the filter.\n'
1603 usage
+= s
* 3 + light_yellow('Only nicks') + \
1604 ' filter will decide nicks will be INCLUDE ONLY.\n'
1605 usage
+= s
* 3 + light_yellow('Ignore nicks') + \
1606 ' filter will decide nicks will be EXCLUDE.\n'
1607 usage
+= s
* 2 + light_green('switch list') + \
1608 ' will switch to a Twitter list\'s stream. You will be asked for list name\n'
1617 h
, w
= os
.popen('stty size', 'r').read().split()
1620 usage
+= s
+ 'Hi boss! I\'m ready to serve you right now!\n'
1621 usage
+= s
+ '-' * (int(w
) - 4) + '\n'
1622 usage
+= s
+ 'You are ' + \
1623 light_yellow('already') + ' on your personal stream.\n'
1624 usage
+= s
+ 'Any update from Twitter will show up ' + \
1625 light_yellow('immediately') + '.\n'
1626 usage
+= s
+ 'In addition, following commands are available right now:\n'
1627 # Twitter help section
1629 usage
+= s
+ grey(u
'\u266A' + ' Twitter help\n')
1630 usage
+= s
* 2 + light_green('h discover') + \
1631 ' will show help for discover commands.\n'
1632 usage
+= s
* 2 + light_green('h tweets') + \
1633 ' will show help for tweets commands.\n'
1634 usage
+= s
* 2 + light_green('h messages') + \
1635 ' will show help for messages commands.\n'
1636 usage
+= s
* 2 + light_green('h friends_and_followers') + \
1637 ' will show help for friends and followers commands.\n'
1638 usage
+= s
* 2 + light_green('h list') + \
1639 ' will show help for list commands.\n'
1640 usage
+= s
* 2 + light_green('h stream') + \
1641 ' will show help for stream commands.\n'
1644 usage
+= s
+ grey(u
'\u266A' + ' Smart shell\n')
1645 usage
+= s
* 2 + light_green('111111 * 9 / 7') + ' or any math expression ' + \
1646 'will be evaluate by Python interpreter.\n'
1647 usage
+= s
* 2 + 'Even ' + light_green('cal') + ' will show the calendar' + \
1648 ' for current month.\n'
1651 usage
+= s
+ grey(u
'\u266A' + ' Config \n')
1652 usage
+= s
* 2 + light_green('theme') + ' will list available theme. ' + \
1653 light_green('theme monokai') + ' will apply ' + light_yellow('monokai') + \
1654 ' theme immediately.\n'
1655 usage
+= s
* 2 + light_green('config') + ' will list all config.\n'
1657 light_green('config ASCII_ART') + ' will output current value of ' +\
1658 light_yellow('ASCII_ART') + ' config key.\n'
1660 light_green('config TREND_MAX default') + ' will output default value of ' + \
1661 light_yellow('TREND_MAX') + ' config key.\n'
1663 light_green('config CUSTOM_CONFIG drop') + ' will drop ' + \
1664 light_yellow('CUSTOM_CONFIG') + ' config key.\n'
1666 light_green('config IMAGE_ON_TERM = true') + ' will set value of ' + \
1667 light_yellow('IMAGE_ON_TERM') + ' config key to ' + \
1668 light_yellow('True') + '.\n'
1671 usage
+= s
+ grey(u
'\u266A' + ' Screening \n')
1672 usage
+= s
* 2 + light_green('h') + ' will show this help again.\n'
1673 usage
+= s
* 2 + light_green('p') + ' will pause the stream.\n'
1674 usage
+= s
* 2 + light_green('r') + ' will unpause the stream.\n'
1675 usage
+= s
* 2 + light_green('c') + ' will clear the screen.\n'
1676 usage
+= s
* 2 + light_green('v') + ' will show version info.\n'
1677 usage
+= s
* 2 + light_green('q') + ' will quit.\n'
1680 usage
+= s
+ '-' * (int(w
) - 4) + '\n'
1681 usage
+= s
+ 'Have fun and hang tight! \n'
1684 'discover': help_discover
,
1685 'tweets': help_tweets
,
1686 'messages': help_messages
,
1687 'friends_and_followers': help_friends_and_followers
,
1689 'stream': help_stream
,
1694 lambda: printNicely(red('No such command.'))
1702 Pause stream display
1705 printNicely(green('Stream is paused'))
1713 printNicely(green('Stream is running back now'))
1729 printNicely(green('See you next time :)'))
1737 Reset prefix of line
1740 if c
.get('USER_JSON_ERROR'):
1741 printNicely(red('Your ~/.rainbow_config.json is messed up:'))
1742 printNicely(red('>>> ' + c
['USER_JSON_ERROR']))
1744 printNicely(magenta('Need tips ? Type "h" and hit Enter key!'))
1747 printNicely(str(eval(g
['cmd'])))
1800 # Handle function set
1853 return dict(zip(cmdset
, funcset
)).get(cmd
, reset
)
1858 Listen to user's input
1863 ['public', 'mine', 'list'], # switch
1882 ['image'], # show image
1884 ['fl', 'fr'], # list
1886 [i
for i
in g
['message_threads']], # sent
1911 [key
for key
in dict(get_all_config())], # config
1912 g
['themes'], # theme
1917 'friends_and_followers',
1928 init_interactive_shell(d
)
1935 # Only use PREFIX as a string with raw_input
1936 line
= raw_input(g
['decorated_name'](g
['PREFIX']))
1939 # Save cmd to compare with readline buffer
1940 g
['cmd'] = line
.strip()
1941 # Get short cmd to pass to handle function
1943 cmd
= line
.split()[0]
1946 # Lock the semaphore
1948 # Save cmd to global variable and call process
1949 g
['stuff'] = ' '.join(line
.split()[1:])
1950 # Process the command
1953 if cmd
in ['switch', 't', 'rt', 'rep']:
1957 # Release the semaphore lock
1963 printNicely(red('OMG something is wrong with Twitter right now.'))
1966 def reconn_notice():
1968 Notice when Hangup or Timeout
1970 guide
= light_magenta('You can use ') + \
1971 light_green('switch') + \
1972 light_magenta(' command to return to your stream.\n')
1973 guide
+= light_magenta('Type ') + \
1974 light_green('h stream') + \
1975 light_magenta(' for more details.')
1977 sys
.stdout
.write(g
['decorated_name'](g
['PREFIX']))
1981 def stream(domain
, args
, name
='Rainbow Stream'):
1987 c
['USER_DOMAIN']: name
,
1988 c
['PUBLIC_DOMAIN']: args
.track_keywords
or 'Global',
1989 c
['SITE_DOMAIN']: name
,
1992 ascii_art(art_dict
.get(domain
, name
))
1993 # These arguments are optional:
1995 timeout
=0.5, # To check g['stream_stop'] after each 0.5 s
1997 heartbeat_timeout
=c
['HEARTBEAT_TIMEOUT'] * 60)
2000 if args
.track_keywords
:
2001 query_args
['track'] = args
.track_keywords
2003 stream
= TwitterStream(
2008 if domain
== c
['USER_DOMAIN']:
2009 tweet_iter
= stream
.user(**query_args
)
2010 elif domain
== c
['SITE_DOMAIN']:
2011 tweet_iter
= stream
.site(**query_args
)
2013 if args
.track_keywords
:
2014 tweet_iter
= stream
.statuses
.filter(**query_args
)
2016 tweet_iter
= stream
.statuses
.sample()
2017 # Block new stream until other one exits
2018 StreamLock
.acquire()
2019 g
['stream_stop'] = False
2020 last_tweet_time
= time
.time()
2021 for tweet
in tweet_iter
:
2023 printNicely('-- None --')
2024 elif tweet
is Timeout
:
2025 # Because the stream check for each 0.3s
2026 # so we shouldn't output anything here
2027 if(g
['stream_stop']):
2028 StreamLock
.release()
2030 elif tweet
is HeartbeatTimeout
:
2031 printNicely('-- Heartbeat Timeout --')
2033 StreamLock
.release()
2035 elif tweet
is Hangup
:
2036 printNicely('-- Hangup --')
2038 StreamLock
.release()
2040 elif tweet
.get('text'):
2041 # Slow down the stream by STREAM_DELAY config key
2042 if time
.time() - last_tweet_time
< c
['STREAM_DELAY']:
2044 last_tweet_time
= time
.time()
2045 # Check the semaphore pause and lock (stream process only)
2053 keyword
=args
.track_keywords
,
2058 # Current readline buffer
2059 current_buffer
= readline
.get_line_buffer().strip()
2060 # There is an unexpected behaviour in MacOSX readline + Python 2:
2061 # after completely delete a word after typing it,
2062 # somehow readline buffer still contains
2063 # the 1st character of that word
2064 if current_buffer
and g
['cmd'] != current_buffer
:
2066 g
['decorated_name'](g
['PREFIX']) + current_buffer
)
2068 elif not c
['HIDE_PROMPT']:
2069 sys
.stdout
.write(g
['decorated_name'](g
['PREFIX']))
2071 elif tweet
.get('direct_message'):
2072 # Check the semaphore pause and lock (stream process only)
2077 print_message(tweet
['direct_message'])
2078 elif tweet
.get('event'):
2079 c
['events'].append(tweet
)
2081 except TwitterHTTPError
as e
:
2084 magenta('We have connection problem with twitter stream API right now :('))
2085 detail_twitter_error(e
)
2086 sys
.stdout
.write(g
['decorated_name'](g
['PREFIX']))
2090 magenta('There seems to be a connection problem.'))
2095 def spawn_public_stream(args
, keyword
=None):
2097 Spawn a new public stream
2099 # Only set keyword if specified
2101 if keyword
[0] == '#':
2102 keyword
= keyword
[1:]
2103 args
.track_keywords
= keyword
2104 g
['keyword'] = keyword
2106 g
['keyword'] = 'Global'
2107 g
['PREFIX'] = u2str(emojize(format_prefix(keyword
=g
['keyword'])))
2110 th
= threading
.Thread(
2119 def spawn_list_stream(args
, stuff
=None):
2121 Spawn a new list stream
2124 owner
, slug
= check_slug(stuff
)
2126 owner
, slug
= get_slug()
2128 # Force python 2 not redraw readline buffer
2129 listname
= '/'.join([owner
, slug
])
2130 # Set the listname variable
2131 # and reset tracked keyword
2132 g
['listname'] = listname
2134 g
['PREFIX'] = g
['cmd'] = u2str(emojize(format_prefix(
2135 listname
=g
['listname']
2137 printNicely(light_yellow('getting list members ...'))
2139 t
= Twitter(auth
=authen())
2142 while next_cursor
!= 0:
2143 m
= t
.lists
.members(
2145 owner_screen_name
=owner
,
2147 include_entities
=False)
2148 for u
in m
['users']:
2149 members
.append('@' + u
['screen_name'])
2150 next_cursor
= m
['next_cursor']
2151 printNicely(light_yellow('... done.'))
2152 # Build thread filter array
2153 args
.filter = members
2155 th
= threading
.Thread(
2165 printNicely(cyan('Include: ' + str(len(args
.filter)) + ' people.'))
2167 printNicely(red('Ignore: ' + str(len(args
.ignore
)) + ' people.'))
2171 def spawn_personal_stream(args
, stuff
=None):
2173 Spawn a new personal stream
2175 # Reset the tracked keyword and listname
2176 g
['keyword'] = g
['listname'] = ''
2178 g
['PREFIX'] = u2str(emojize(format_prefix()))
2180 th
= threading
.Thread(
2185 g
['original_name']))
2195 args
= parse_arguments()
2199 # Twitter API connection problem
2200 except TwitterHTTPError
as e
:
2203 magenta('We have connection problem with twitter REST API right now :('))
2204 detail_twitter_error(e
)
2207 # Proxy connection problem
2208 except (socks
.ProxyConnectionError
, URLError
):
2210 magenta('There seems to be a connection problem.'))
2212 magenta('You might want to check your proxy settings (host, port and type)!'))
2216 # Spawn stream thread
2217 target
= args
.stream
.split()[0]
2218 if target
== 'mine' :
2219 spawn_personal_stream(args
)
2222 stuff
= args
.stream
.split()[1]
2226 'public': spawn_public_stream
,
2227 'list': spawn_list_stream
,
2229 spawn_dict
.get(target
)(args
, stuff
)
2231 # Start listen process