From: Orakaro Date: Tue, 11 Nov 2014 14:21:56 +0000 (+0900) Subject: add repall command X-Git-Url: https://vcs.fsf.org/?p=rainbowstream.git;a=commitdiff_plain;h=ba6c09d1585318207fa3ddf47b374b5ebcc3a22c;ds=sidebyside add repall command --- diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..d97965c Binary files /dev/null and b/.DS_Store differ diff --git a/docs/conf.py b/docs/conf.py index 303e3f4..e2bf812 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -48,9 +48,9 @@ copyright = u'2014, Vu Nhat Minh' # built documents. # # The short X.Y version. -version = '1.2.2' +version = '1.2.3' # The full version, including alpha/beta/rc tags. -release = '1.2.2' +release = '1.2.3' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/index.rst b/docs/index.rst index 5ba2701..5152f4f 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -154,7 +154,9 @@ Here is full list of supported command: - ``conversation 12`` will show the chain of replies prior to the tweet with *[id=12]*. -- ``rep 12 Really`` will reply *‘Really’* to the tweet with *[id=12]*. +- ``rep 12 Really`` will reply *‘Really’* to the owner of the tweet with *[id=12]*. + +- ``repall 12 Really`` will reply *‘Really’* to all people in the tweet with *[id=12]*. - ``fav 12`` will favorite the tweet with *[id=12]*. diff --git a/rainbowstream/rainbow.py b/rainbowstream/rainbow.py index b859bab..a5824a6 100644 --- a/rainbowstream/rainbow.py +++ b/rainbowstream/rainbow.py @@ -501,6 +501,27 @@ def reply(): t.statuses.update(status=status, in_reply_to_status_id=tid) +def reply_all(): + """ + Reply to all + """ + t = Twitter(auth=authen()) + try: + id = int(g['stuff'].split()[0]) + except: + printNicely(red('Sorry I can\'t understand.')) + return + tid = c['tweet_dict'][id] + original_tweet = t.statuses.show(id=tid) + text = original_tweet['text'] + owner = '@' + original_tweet['user']['screen_name'] + nick_ary = ['@' + re.sub('[\W_]', '', w) + for w in text.split() if w.startswith('@')] + [owner] + status = ' '.join(g['stuff'].split()[1:]) + status = ' '.join(nick_ary) + ' ' + str2u(status) + t.statuses.update(status=status, in_reply_to_status_id=tid) + + def favorite(): """ Favorite @@ -1483,7 +1504,10 @@ def help_tweets(): usage += s * 2 + light_green('conversation 12') + ' will show the chain of ' + \ 'replies prior to the tweet with ' + light_yellow('[id=12]') + '.\n' usage += s * 2 + light_green('rep 12 oops') + ' will reply "' + \ - light_yellow('oops') + '" to tweet with ' + \ + light_yellow('oops') + '" to the owner of the tweet with ' + \ + light_yellow('[id=12]') + '.\n' + usage += s * 2 + light_green('repall 12 oops') + ' will reply "' + \ + light_yellow('oops') + '" to all people in the tweet with ' + \ light_yellow('[id=12]') + '.\n' usage += s * 2 + \ light_green('fav 12 ') + ' will favorite the tweet with ' + \ @@ -1771,6 +1795,7 @@ cmdset = [ 'conversation', 'fav', 'rep', + 'repall', 'del', 'ufav', 'share', @@ -1818,6 +1843,7 @@ funcset = [ conversation, favorite, reply, + reply_all, delete, unfavorite, share, @@ -1878,6 +1904,7 @@ def listen(): [], # conversation [], # favorite [], # reply + [], # reply_all [], # delete [], # unfavorite [], # url @@ -2089,6 +2116,11 @@ def stream(domain, args, name='Rainbow Stream'): detail_twitter_error(e) sys.stdout.write(g['decorated_name'](g['PREFIX'])) sys.stdout.flush() + except (URLError, ConnectionResetError): + printNicely( + magenta('There seems to be a connection problem.')) + save_history() + sys.exit() def fly(): diff --git a/setup.py b/setup.py index f58a816..fc7a1af 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import os import os.path # Bumped version -version = '1.2.2' +version = '1.2.3' # Require install_requires = [