Imgur Image Rehoster

By ES on Oct 15, 2011

Simple script that allows you to rehost images to imgur (a popular image service)
Useful for places that don't allow hotlinking


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 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:
  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* }


Sign in to comment.
cptpan   -  Jul 13, 2012

This works fine, awesome!

alabama   -  Oct 17, 2011


Jethro   -  Oct 17, 2011

alabama, you should read up on imgu's API here at:

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 ?

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.

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: looks like a good one

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

alabama   -  Oct 16, 2011

How to upload with a filename?

Jethro   -  Oct 16, 2011

There is no such identifier as: $sockclose()

It's supposed to be:

if $sock(imgur) { sockclose $v1 }

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.

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.