support quote format
authorOrakaro <nhatminh_179@hotmail.com>
Sun, 17 Aug 2014 08:10:19 +0000 (17:10 +0900)
committerOrakaro <nhatminh_179@hotmail.com>
Sun, 17 Aug 2014 08:10:19 +0000 (17:10 +0900)
docs/conf.py
docs/index.rst
rainbowstream/colorset/config
rainbowstream/draw.py
rainbowstream/py3patch.py
rainbowstream/rainbow.py
setup.py

index a6b2510e6ff9c24b27a9aacb638c5e2a7d2cbe9f..5928a34c4d0186f317d2f4d1712d4509b3c1e189 100644 (file)
@@ -48,9 +48,9 @@ copyright = u'2014, Vu Nhat Minh'
 # built documents.
 #
 # The short X.Y version.
 # built documents.
 #
 # The short X.Y version.
-version = '0.7.5'
+version = '0.7.6'
 # The full version, including alpha/beta/rc tags.
 # The full version, including alpha/beta/rc tags.
-release = '0.7.5'
+release = '0.7.6'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
index adf6578c61f447a2c618f5207bdefd3ca105426a..a3a8420d520c6f3ba45de38dd786ea2cadb77444 100644 (file)
@@ -311,6 +311,12 @@ You can view or set a new value of every config key by ``config`` command (See *
 \r
 -  ``RETWEETS_SHOW_NUM``: default tweets to display on 'allrt' command.\r
 \r
 \r
 -  ``RETWEETS_SHOW_NUM``: default tweets to display on 'allrt' command.\r
 \r
+-  ``QUOTE_FORMAT``: format when quote a tweet\r
+\r
+    + ``#comment``: Your own comment about the tweet\r
+    + ``#owner``: owner's username with '@'\r
+    + ``#tweet``: original tweet\r
+\r
 -  ``MESSAGES_DISPLAY``: default messages to display on 'inbox' or 'sent' command.\r
 \r
 -  ``TREND_MAX``: default trends to display on 'trend' command.\r
 -  ``MESSAGES_DISPLAY``: default messages to display on 'inbox' or 'sent' command.\r
 \r
 -  ``TREND_MAX``: default trends to display on 'trend' command.\r
index da155839b0ae1fb033fae6fd138cd89c6862b703..9859d902021e02fe79f046347b19fdc1365edb58 100644 (file)
@@ -17,6 +17,8 @@
     "HOME_TWEET_NUM" : 5,
     // 'allrt': default number of retweets
     "RETWEETS_SHOW_NUM" : 5,
     "HOME_TWEET_NUM" : 5,
     // 'allrt': default number of retweets
     "RETWEETS_SHOW_NUM" : 5,
+    // 'quote' format
+    "QUOTE_FORMAT" : "#comment RT #owner: #tweet",
     // 'inbox','sent': default number of direct message
     "MESSAGES_DISPLAY" : 5,
     // 'trend': max trending topics
     // 'inbox','sent': default number of direct message
     "MESSAGES_DISPLAY" : 5,
     // 'trend': max trending topics
index b4f5883959a969891148c900dcc570f31dadb53c..248d1a92f2b9112ca09bc3df8cc9504202c39fbd 100644 (file)
@@ -275,10 +275,10 @@ def draw(t, keyword=None, check_semaphore=False, fil=[], ig=[]):
     formater = ''
     try:
         formater = c['FORMAT']['TWEET']['DISPLAY']
     formater = ''
     try:
         formater = c['FORMAT']['TWEET']['DISPLAY']
-        formater = name.join(formater.split("#name"))
-        formater = nick.join(formater.split("#nick"))
-        formater = fav.join(formater.split("#fav"))
-        formater = tweet.join(formater.split("#tweet"))
+        formater = name.join(formater.split('#name'))
+        formater = nick.join(formater.split('#nick'))
+        formater = fav.join(formater.split('#fav'))
+        formater = tweet.join(formater.split('#tweet'))
         # Change clock word
         word = [w for w in formater.split() if '#clock' in w][0]
         delimiter = color_func(c['TWEET']['clock'])(
         # Change clock word
         word = [w for w in formater.split() if '#clock' in w][0]
         delimiter = color_func(c['TWEET']['clock'])(
index 660bd0bd29653784b6b49cd4bb31202b18e60e71..b19bdca01fe4cdbf40b8c18ba3bb5918e2e04736 100644 (file)
@@ -23,9 +23,10 @@ unescape = HTMLParser().unescape
 # raw_input and map function behaviour
 if sys.version[0] == "2":
     lmap = lambda f, a: map(f, a)
 # raw_input and map function behaviour
 if sys.version[0] == "2":
     lmap = lambda f, a: map(f, a)
-    unc = lambda x: x.decode('utf-8')
+    str2u = lambda x: x.decode('utf-8')
+    u2str = lambda x: x.encode('utf-8')
 else:
     xrange = range
     raw_input = input
     lmap = lambda f, a: list(map(f, a))
 else:
     xrange = range
     raw_input = input
     lmap = lambda f, a: list(map(f, a))
-    unc = lambda x: x
+    str2u = u2str = lambda x: x
index f1504ac1211b40c616c61e9d606226d7496473d7..5d9e89a44ab24e3120304ec572fcd8636c07626b 100644 (file)
@@ -312,6 +312,7 @@ def quote():
     """
     Quote a tweet
     """
     """
     Quote a tweet
     """
+    # Retrieve info
     t = Twitter(auth=authen())
     try:
         id = int(g['stuff'].split()[0])
     t = Twitter(auth=authen())
     try:
         id = int(g['stuff'].split()[0])
@@ -320,17 +321,34 @@ def quote():
         return
     tid = c['tweet_dict'][id]
     tweet = t.statuses.show(id=tid)
         return
     tid = c['tweet_dict'][id]
     tweet = t.statuses.show(id=tid)
-    screen_name = tweet['user']['screen_name']
+    screen_name = '@' + tweet['user']['screen_name']
     text = tweet['text']
     text = tweet['text']
-    quote = '\"@' + screen_name + ': ' + text + '\"'
-    quote = quote.encode('utf8')
-    notice = light_magenta('Compose mode ')
-    notice += light_yellow('(Enter nothing will cancel the quote)')
-    notice += light_magenta(':')
+    # Validate quote format
+    if '#owner' not in c['QUOTE_FORMAT']:
+        printNicely(light_magenta('Quote should contains #owner'))
+        return
+    if '#comment' not in c['QUOTE_FORMAT']:
+        printNicely(light_magenta('Quote format should have #comment'))
+        return
+    # Notice
+    notice = light_magenta('Current quote format is: ')
+    notice += light_green(c['QUOTE_FORMAT'])
     printNicely(notice)
     printNicely(notice)
-    extra = raw_input(quote)
-    if extra:
-        t.statuses.update(status=quote + extra)
+    # Build formater
+    formater = ''
+    try:
+        formater = c['QUOTE_FORMAT']
+        formater = screen_name.join(formater.split('#owner'))
+        formater = text.join(formater.split('#tweet'))
+        formater = u2str(formater)
+    except:
+        pass
+    # Get comment
+    prefix = light_magenta('Compose your ') + light_green('#comment: ')
+    comment = raw_input(prefix)
+    if comment:
+        quote = comment.join(formater.split('#comment'))
+        t.statuses.update(status = quote)
     else:
         printNicely(light_magenta('No text added.'))
 
     else:
         printNicely(light_magenta('No text added.'))
 
@@ -392,7 +410,7 @@ def reply():
     tid = c['tweet_dict'][id]
     user = t.statuses.show(id=tid)['user']['screen_name']
     status = ' '.join(g['stuff'].split()[1:])
     tid = c['tweet_dict'][id]
     user = t.statuses.show(id=tid)['user']['screen_name']
     status = ' '.join(g['stuff'].split()[1:])
-    status = '@' + user + ' ' + unc(status)
+    status = '@' + user + ' ' + str2u(status)
     t.statuses.update(status=status, in_reply_to_status_id=tid)
 
 
     t.statuses.update(status=status, in_reply_to_status_id=tid)
 
 
@@ -1742,7 +1760,7 @@ def stream(domain, args, name='Rainbow Stream'):
                 # the 1st character of that word
                 if current_buffer and g['cmd'] != current_buffer:
                     sys.stdout.write(
                 # the 1st character of that word
                 if current_buffer and g['cmd'] != current_buffer:
                     sys.stdout.write(
-                        g['decorated_name'](c['PREFIX']) + unc(current_buffer))
+                        g['decorated_name'](c['PREFIX']) + str2u(current_buffer))
                     sys.stdout.flush()
                 elif not c['HIDE_PROMPT']:
                     sys.stdout.write(g['decorated_name'](c['PREFIX']))
                     sys.stdout.flush()
                 elif not c['HIDE_PROMPT']:
                     sys.stdout.write(g['decorated_name'](c['PREFIX']))
index 90653fd8985833ba42352adc3c9a07ec92a2ba44..043b9c58233d0ea5f47d29746a8188b39f132513 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -3,7 +3,7 @@ import os
 import os.path
 
 # Bumped version
 import os.path
 
 # Bumped version
-version = '0.7.5'
+version = '0.7.6'
 
 # Require
 install_requires = [
 
 # Require
 install_requires = [