]> jfr.im git - z_archive/twitter.git/commitdiff
made it repeat the @nicks at the beginning of the post
authorTomas Neme <redacted>
Wed, 5 Oct 2011 06:15:41 +0000 (03:15 -0300)
committerTomas Neme <redacted>
Wed, 5 Oct 2011 06:15:41 +0000 (03:15 -0300)
twitter/cmdline.py

index 421017016b69864c40a29dbcb432c23dd3dfc38c..8353df3473eff11d79af3e76c624cb8bb76d04a8 100644 (file)
@@ -464,13 +464,29 @@ class SetStatusAction(Action):
         statusTxt = (" ".join(options['extra_args'])
                      if options['extra_args']
                      else str(input("message: ")))
+        replies = []
+        ptr = re.compile("@[\w_]+")
+        while statusTxt:
+            s = ptr.match(statusTxt)
+            if s and s.start() == 0:
+                replies.append(statusTxt[s.start():s.end()])
+                statusTxt = statusTxt[s.end()+1:]
+            else:
+                break
+        replies = " ".join(replies)
+        if len(replies) >= 140:
+            # just go back
+            statusTxt = replies
+            replies = ""
+
         splitted = []
         while statusTxt:
-            if len(statusTxt) > 140:
-                end = string.rfind(statusTxt, ' ', 0, 140)
+            limit = 140 - len(replies)
+            if len(statusTxt) > limit:
+                end = string.rfind(statusTxt, ' ', 0, limit)
             else:
-                end = 140
-            splitted.append(statusTxt[:end])
+                end = limit
+            splitted.append(" ".join((replies,statusTxt[:end])))
             statusTxt = statusTxt[end:]
 
         for status in splitted: