Make use of modern-style quotes
authorLertsenem <lertsenem@lertsenem.com>
Sun, 9 Oct 2016 00:34:06 +0000 (02:34 +0200)
committerLertsenem <lertsenem@lertsenem.com>
Sun, 9 Oct 2016 00:34:06 +0000 (02:34 +0200)
(See issue https://github.com/DTVD/rainbowstream/issues/134)

Twitter introduced a new way of quoting, by simply putting the tweet url
as a quote. The web interface (and most clients) will then display a
preview of the quoted tweet, leaving more characters available for your
quote.

This patch change the default quote format from the old mode ("#comment
RT #owner #text") to the new one, introducing a new #tid keyword holding
the tweet id (needed to find the tweet URL). It's still possible to go
back to the old mode, by changing the QUOTE_FORMAT config parameter
back to "#comment RT @#owner #text".

docs/index.rst
rainbowstream/colorset/config
rainbowstream/draw.py

index 44cc06852dd3f5875b0ec643e1acc786c79dd928..0fa1319566f10ce6e146e4232930dbdb5af32f54 100644 (file)
@@ -351,8 +351,9 @@ You also can view or set a new value of every config key by ``config`` command (
 -  ``QUOTE_FORMAT``: format when quote a tweet
 
     + ``#comment``: Your own comment about the tweet
-    + ``#owner``: owner's username with '@'
+    + ``#owner``: owner's username *without* '@'
     + ``#tweet``: original tweet
+    + ``#tid``: the tweet id on Twitter
 
 -  ``THREAD_META_LEFT``: format for meta information of messages from partner which is display in the left of screen.
 
index a9ee3fd8a7f47e6eac6783424f15303f067be7b0..6bfd43e6358488a8f50dc792149fd3008a3b725b 100644 (file)
@@ -24,7 +24,7 @@
     // 'conversation': max tweet in a thread
     "CONVERSATION_MAX" : 30,
     // 'quote' format
-    "QUOTE_FORMAT" : "#comment RT #owner: #tweet",
+    "QUOTE_FORMAT" : "#comment https:\/\/twitter.com\/#owner\/status\/#tid",
     // 'thread' meta format
     "THREAD_META_LEFT" : "(#id) #clock",
     "THREAD_META_RIGHT" : "#clock (#id)",
index ab202763c2bb6506d6d6655f78618be3330741ce..4423c265fb4b7fd309d1ebd0575c31601b056335 100644 (file)
@@ -1066,8 +1066,10 @@ def format_quote(tweet):
     Quoting format
     """
     # Retrieve info
-    screen_name = '@' + tweet['user']['screen_name']
-    text = tweet['text']
+    screen_name = str( tweet['user']['screen_name'] )
+    text        = str( tweet['text'] )
+    tid         = str( tweet['id'] )
+
     # Validate quote format
     if '#owner' not in c['QUOTE_FORMAT']:
         printNicely(light_magenta('Quote should contains #owner'))
@@ -1075,12 +1077,16 @@ def format_quote(tweet):
     if '#comment' not in c['QUOTE_FORMAT']:
         printNicely(light_magenta('Quote format should have #comment'))
         return False
+
     # Build formater
     formater = ''
     try:
         formater = c['QUOTE_FORMAT']
-        formater = screen_name.join(formater.split('#owner'))
-        formater = text.join(formater.split('#tweet'))
+
+        formater = formater.replace('#owner', screen_name)
+        formater = formater.replace('#tweet', text)
+        formater = formater.replace('#tid',   tid)
+
         formater = emojize(formater)
     except:
         pass