Urban Dictionary Script For A Bot
on $*:TEXT:/^[~`!@^&.]u(d|rbandictionary) ./i:*: {
sockclose UrbanDictionary
set %UD# $iif($chan,$chan,$nick)
set %UDURL /define.php?term= $+ $regsubex($2-,/([ `@#$%^&+=\[\]{}\\|;'",<>\/?])/g,% $+ $base($asc(\t),10,16))
sockopen UrbanDictionary www.urbandictionary.com 80
}
on $*:TEXT:/urbandictionary\.com(\/define\.php\?term=\S+)/i:*: {
sockclose UrbanDictionary
set %UD# $iif($chan,$chan,$nick)
set %UDURL $regml(1)
sockopen UrbanDictionary www.urbandictionary.com 80
}
on *:SOCKOPEN:UrbanDictionary: {
sockwrite -n UrbanDictionary GET %UDURL HTTP/1.1
sockwrite -n UrbanDictionary Host: www.urbandictionary.com
sockwrite UrbanDictionary $crlf
}
on *:SOCKREAD:UrbanDictionary: {
sockread %UD
while ($sockbr) {
if (<div class="definition">* iswm %UD) {
var %UD~ = $regsubex($regsubex($remove(%UD,$cr),/(<br\/>)+/g,$chr(32) $+ - $+ $chr(32)),/<div class="definition">(.+?)<\/div>(?:<div class="example">(.+?)<\/div>)?/,\1), %UD~~ = $regml(2)
msg %UD# $regsubex($replace($regsubex(%UD~,/(<.+?>)+/g,),&,&,",",<,<,>,>),/&#(x?\d+);/g,$iif(x !isin \t,$chr(\t),$chr($base($remove(\t,x),16,10))))
$iif(%UD~~,msg %UD# Example - $regsubex($replace($regsubex(%UD~~,/(<.+?>)+/g,),&,&,",",<,<,>,>),/&#(x?\d+);/g,$iif(x !isin \t,$chr(\t),$chr($base($remove(\t,x),16,10)))))
unset %UD*
sockclose UrbanDictionary
return
}
elseif (</i> isn't defined.<br/>Can you define it? isin %UD) {
msg %UD# $regsubex($gettok(%UDURL,-1,61),/%(..)/g,$chr($base(\t,16,10))) is not defined
unset %UD*
sockclose UrbanDictionary
return
}
sockread %UD
}
}
and also. is it possible to add a timer between messages if the text is too long? 'cause I'm using this in a Twitch.tv channel which has like a 2 second auto message filter in every channel.