Simple script that allows you to rehost images to imgur (a popular image service)
Useful for places that don't allow hotlinking
Usage:
When loaded in a bot: !imgur
When loaded in your client: /imgur
on *:TEXT:!imgur*:#: { $imgur($2,#) }
alias imgur {
set %imgurpic $1
if $sock(imgur) { sockclose(imgur) }
sockopen imgur imgur.com 80
sockmark imgur $iif($2,/msg $2,/echo -a)
}
on *:SOCKOPEN:imgur: {
sockwrite -n $sockname GET /upload?url= $+ %imgurpic HTTP/1.1
sockwrite -n $sockname Host: imgur.com
sockwrite -n $sockname Connection: close
sockwrite -n $sockname $crlf
}
on *:SOCKREAD:imgur: {
var %imgurtemp | sockread %imgurtemp
if (location isin %imgurtemp) { $sock(imgur).mark $iif(?err isin %imgurtemp, Sorry but that isn't a valid image link. Alternatively $+ $chr(44) you broke it.,Imgur Link: $gettok(%imgurtemp,2-,58) $+ .jpg) | unset %imgur* }
}
You'll have to create a POST socket and, using binvars, send the image bytes. In this manner, the socket will see it as an image. I think there are several examples laying around Hawkee, I'll try to find one and post back before anyone beats me to it :p
Edit: http://www.hawkee.com/snippet/4948/ looks like a good one