-
-
Save jaytaph/4335232 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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