Skip to content

Instantly share code, notes, and snippets.

@Gargaj
Last active February 28, 2021 00:29
Show Gist options
  • Save Gargaj/32464ccd60294af34d60 to your computer and use it in GitHub Desktop.
Save Gargaj/32464ccd60294af34d60 to your computer and use it in GitHub Desktop.
Webchat-to-GeoIP lookup script for mIRC
; Webchat-to-GeoIP lookup script for mIRC
; by Gargaj
Alias geoip {
var %sn geo_
var %r 1
while (%r <= 10) {
var %sn %sn $+ $rand(a,z)
inc %r 1
}
set %geo.chan. [ $+ [ %sn ] ] $2
set %geo.target. [ $+ [ %sn ] ] $1
;sockopen -e %sn freegeoip.net 443
sockopen %sn freegeoip.net 80
}
Alias hexip {
var %s $base( $mid( $1,1,2 ), 16, 10)
var %s %s $+ . $+ $base( $mid( $1,3,2 ), 16, 10)
var %s %s $+ . $+ $base( $mid( $1,5,2 ), 16, 10)
var %s %s $+ . $+ $base( $mid( $1,7,2 ), 16, 10)
return %s
}
Alias geohexip {
/geoip $hexip( $1 ) $2
}
on *:SockOpen:geo_*: {
if ($sockerr) {
unset %geo.target. [ $+ [ $sockname ] ]
unset %geo.chan. [ $+ [ $sockname ] ]
halt
}
var %target %geo.target. [ $+ [ $sockname ] ]
sockwrite -nt $sockname GET /csv/ $+ %target HTTP/1.0
sockwrite -nt $sockname Host: freegeoip.net
sockwrite -nt $sockname $crlf
}
on *:SockRead:geo_*: {
var %read
sockRead -f %read
var %target %geo.target. [ $+ [ $sockname ] ]
if (%read == $null) halt
if ( $pos( %read, %target,0) <= 0 ) halt
unset %geo.target. [ $+ [ $sockname ] ]
var %chan %geo.chan. [ $+ [ $sockname ] ]
unset %geo.chan. [ $+ [ $sockname ] ]
tokenize 44 %read
var %msg $chr(91) $+ %target $+ $chr(93)
if ( $len( $noqt( $5 ) ) > 0 ) var %msg %msg $+ $chr(32) $+ $noqt( $5 ) $+ $chr(44)
var %msg %msg $+ $chr(32) $+ $noqt( $3 )
/echo 5 -t %chan %msg
/sockclose $sockname
}
on *:JOIN:*:{
if ( $regex( hexipreg, $address, /^~?([0-9a-f]{8})@/ ) > 0 ) {
/geohexip $mid( $regml(hexipreg,1),1,8) $chan
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment