Advertisement
Guest User

nth tweet code in clojure

a guest
Mar 18th, 2010
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.94 KB | None | 0 0
  1. ;;; tweet.clj
  2. ;;;
  3. ;;; Run this when you want to tweet
  4. ;;;
  5. ;;; -h for usage
  6. ;;;
  7. ;;; Written and maintained by Stephen Ramsay
  8. ;;;
  9. ;;; Last Modified: Wed Mar 17 23:44:42 CDT 2010
  10.  
  11. (ns gropius.sramsay.nth
  12.      (:use clojure.contrib.command-line))
  13.  
  14. (load-file "auth.clj")
  15.  
  16. ;;
  17. ;; Parse the command line and go
  18. ;;
  19. (with-command-line
  20.   *command-line-args*
  21.     "Usage: tweet [-D username] message."
  22.     [[direct? D? "Direct message" false]]
  23.     (let [tweet (apply str (interpose " " *command-line-args*)) ; Awkward
  24.           length (.length tweet)] ; check length                ; way to get a
  25.       (if (<= length 140)                                       ; string.
  26.         (do
  27.           (.updateStatus (get-auth) tweet)) ; Tweet!
  28.         (do
  29.           (println length)
  30.           (printf "\nSorry, you lost me at:\n\n%s\n" (apply str (take 140 tweet)))
  31.           (printf "\nYou need to get rid of %d characters.\n" (- length 140))))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement