X-Git-Url: https://vcs.fsf.org/?p=rainbowstream.git;a=blobdiff_plain;f=rainbowstream%2Frainbow.py;h=de908e6ae94dfc997b8b1ef73c93b23a47106bf2;hp=8d930847c8887e5ab7ebc2f54eaea0fb4ade1676;hb=954b31016c5bf5c633e9a8793a2659e1a74024b3;hpb=03c0d30be5c9eff80893cce9320a01ef3ce918a5 diff --git a/rainbowstream/rainbow.py b/rainbowstream/rainbow.py index 8d93084..de908e6 100644 --- a/rainbowstream/rainbow.py +++ b/rainbowstream/rainbow.py @@ -122,7 +122,7 @@ def init(args): name = credential['name'] if not get_config('PREFIX'): set_config('PREFIX', screen_name) - g['original_name'] = screen_name[1:] + c['original_name'] = g['original_name'] = screen_name[1:] g['full_name'] = name g['decorated_name'] = lambda x: color_func( c['DECORATED_NAME'])('[' + x + ']: ') @@ -249,13 +249,24 @@ def search(): Search """ t = Twitter(auth=authen()) - g['stuff'] = g['stuff'].strip() - rel = t.search.tweets(q=g['stuff'])['statuses'] + # Setup query + query = g['stuff'].strip() + type = c['SEARCH_TYPE'] + if type not in ['mixed', 'recent', 'popular']: + type = 'mixed' + max_record = c['SEARCH_MAX_RECORD'] + count = min(max_record, 100) + # Perform search + rel = t.search.tweets( + q=query, + type=type, + count=count + )['statuses'] + # Return results if rel: printNicely('Newest tweets:') - for i in reversed(xrange(c['SEARCH_MAX_RECORD'])): - draw(t=rel[i], - keyword=g['stuff']) + for i in reversed(xrange(count)): + draw(t=rel[i], keyword=query) printNicely('') else: printNicely(magenta('I\'m afraid there is no result')) @@ -461,8 +472,9 @@ def urlopen(): return tid = c['tweet_dict'][int(g['stuff'])] tweet = t.statuses.show(id=tid) - link_ary = [ - u for u in tweet['text'].split() if u.startswith('http://')] + link_prefix = ('http://', 'https://') + link_ary = [u for u in tweet['text'].split() + if u.startswith(link_prefix)] if not link_ary: printNicely(light_magenta('No url here @.@!')) return