Skip to content

Instantly share code, notes, and snippets.

Created December 18, 2012 15:03
Show Gist options
  • Save anonymous/4328760 to your computer and use it in GitHub Desktop.
Save anonymous/4328760 to your computer and use it in GitHub Desktop.
Simple eggdrop TCL bot that just tweets the latest status from a user. Since I could not find any that did just this, I've created a simple one myself.. I don't know TCL, so if things are not ok, just update the gist..
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"
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