Skip to content

Instantly share code, notes, and snippets.

@Ikke
Forked from jaytaph/twitter.tcl
Created May 11, 2013 17:17
Show Gist options
  • Save Ikke/5560667 to your computer and use it in GitHub Desktop.
Save Ikke/5560667 to your computer and use it in GitHub Desktop.
package require http
namespace eval twitter {
variable status_url "http://api.twitter.com/1/statuses/user_timeline/"
bind pub -|- "!twitter" twitter::tweet
}
proc twitter::tweet {nick uhost hand chan argv} {
if {[string length $argv] < 1} {
$twitter::putserv "PRIVMSG $chan :Usage: !twitter <user>"
return
}
set url "${twitter::status_url}$argv.xml?count=1&include_rts=true"
set result [::http::geturl $url]
upvar #0 $result state
set text ""
set id ""
regexp {<id>(.*?)</id>.*?<text>(.*?)</text>} $state(body) - id text
putserv "PRIVMSG $chan :$text (http://twitter.com/$argv/statuses/$id)"
}
putlog "twitter.tcl jaytaph"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment