nth tweet code in clojure
By: a guest | Mar 18th, 2010 | Syntax:
Lisp | Size: 0.94 KB | Hits: 177 | Expires: Never
;;; tweet.clj
;;;
;;; Run this when you want to tweet
;;;
;;; -h for usage
;;;
;;; Written and maintained by Stephen Ramsay
;;;
;;; Last Modified: Wed Mar 17 23:44:42 CDT 2010
(ns gropius.sramsay.nth
(:use clojure.contrib.command-line))
(load-file "auth.clj")
;;
;; Parse the command line and go
;;
(with-command-line
*command-line-args*
"Usage: tweet [-D username] message."
[[direct? D? "Direct message" false]]
(let [tweet (apply str (interpose " " *command-line-args*)) ; Awkward
length (.length tweet)] ; check length ; way to get a
(if (<= length 140) ; string.
(do
(.updateStatus (get-auth) tweet)) ; Tweet!
(do
(println length)
(printf "\nSorry, you lost me at:\n\n%s\n" (apply str (take 140 tweet)))
(printf "\nYou need to get rid of %d characters.\n" (- length 140))))))