Imgur Image Rehoster

By ES
Platform:  mIRC
Published  Oct 15, 2011
Updated  Oct 16, 2011
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 <link>
When loaded in your client: /imgur <link>
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* }
}

Comments

Sign in to comment.
cptpan   -  Jul 13, 2012
This works fine, awesome!
 Respond  
alabama   -  Oct 17, 2011
ty
 Respond  
Jethro   -  Oct 17, 2011
alabama, you should read up on imgu's API here at: http://api.imgur.com/
 Respond  
alabama   -  Oct 17, 2011
could this be used in a php or html script? (if so, i might make)
instead of going 2 imgur u just put a link and badaboombadabing ! uploaded pic ?
 Respond  
Jethro   -  Oct 16, 2011
imgur has their own API at your disposal. You should check it out. It makes writing a socket a lot easier. An API key may need to be requested if there isn't one posted at their API description page.
 Respond  
Firstmate   -  Oct 16, 2011
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
 Respond  
ES   -  Oct 16, 2011
@Jethro, you're right on both accounts, idk why i've always used the -n switch with sockopen, and the sockclose incident was just a typo

@ alabama It currently doesn't support that, i'll look into it tho
 Respond  
alabama   -  Oct 16, 2011
How to upload with a filename?
 Respond  
Jethro   -  Oct 16, 2011
There is no such identifier as: $sockclose()

It's supposed to be:

Code

 
I'm not aware of the -n switch for the sockopen command. I don't believe there is one but the -d and -e switch.
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.