Skip to content

Instantly share code, notes, and snippets.

@jaytaph
Forked from anonymous/twitter.tcl
Last active December 9, 2015 22:08
Show Gist options
  • Save jaytaph/4335232 to your computer and use it in GitHub Desktop.
Save jaytaph/4335232 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