I see some of the slang checker scripts are not fully functional or unworkable, so I figure I'd give it a shot.
!define dani A person with lots of layers of goodness, like an onion without the crying and the smell. @define Hawkee Hawkee is undefined! !define smart alec A nicer way to say smart ass. You can use this in an office or when kids are around instead of saying smart ass or if you are a stick in the mud and don't cuss. The command is self-explanatory and can be prefixed with !, @, or . to trigger. PM and channel supported.
- Fixed the line break characters being outputted.
6/15/12 - Updated using urbandictionary.com's API link.
10/20/12 - Updated a bit to remove \ character
on *:sockopen:ud*:{
tokenize 32 $sock($sockname).mark
if ($sockerr) {
$5-6 Socket Error!
halt
}
$2-4 GET $+(/v0/define?term=,$1) HTTP/1.0
$2-4 Host: $+($sock($sockname).addr,$str($crlf,2))
$2-4 Connection: close
}
on $*:text:/^[!@.]define( |$)/iS:*:{
if (!$($+(%,-,$site,.,$cid,.,$nick),2)) {
inc -u3 $+(%,-,$site,.,$cid,.,$nick)
var %ud = $+(ud,$str($ticks,3))
$+(sock,$iif($sock(%ud),close,open) %ud api.urbandictionary.com 80)
sockmark %ud $replace($strip($2-),$chr(32),+) $&
sockwrite -nt %ud .msg $iif(#,#,$nick)
}
}
on *:sockread:ud*:{
sockread &ud
tokenize 32 $sock($sockname).mark
if ($sockerr) {
$5-6 Socket Error!
}
elseif (no_results isin $bvar(&ud,1-).text) {
$5-6 $qt($1) is undefined!
}
elseif ($regex($bvar(&ud,1-).text,/"definition":"(.*)/)) {
tokenize 34 $regml(1)
$gettok($sock($sockname).mark,5-6,32) $remove($regsubex($1,/\x5C(r|n{1,2})/gi,$chr(32)),\)
}
}
turbuiance, the latest mIRC version automatically splits a long line of text into many chunk of sentences for you if it becomes too long. You can disable the function via mIRC options under IRC Messages at "Split long channel/query message" and then deselect it, BUT you many start to see it cut off (you won't be able to see the entire message) because a text line is too long that exceeds your chat server's message length. I'll suggest that you live with the message output to preserve the integrity of it.
Here you go, Rick:
on $*:text:/^!define o(n|ff)$/iS:#:{
if ($nick isop #) {
if ($regml(1) == n) {
if (!$istok(%chan,#,44)) {
set %chan $addtok(%chan,#,44)
.notice $nick # has been added!
}
else .notice $nick the channel $qt(#) has already been added!
}
else {
if ($istok(%chan,#,44)) {
set %chan $remtok(%chan,#,1,44)
.notice $nick # has been removed.
}
else .notice $nick the channel $qt(#) has already been removed.
}
}
else .notice $nick Access Denied. This command is reserved for OP only.
}
on *:sockopen:ud*:{
tokenize 32 $sock($sockname).mark
if ($sockerr) {
$5-6 Socket Error!
halt
}
$2-4 GET $+(/v0/define?term=,$1) HTTP/1.0
$2-4 Host: $+($sock($sockname).addr,$str($crlf,2))
$2-4 Connection: close
}
on $*:text:/^[!@.]define( |$)/iS:%chan,?:{
if (!$($+(%,-,$site,.,$cid,.,$nick),2)) {
inc -u3 $+(%,-,$site,.,$cid,.,$nick)
var %ud = $+(ud,$str($ticks,3))
$+(sock,$iif($sock(%ud),close,open) %ud api.urbandictionary.com 80)
sockmark %ud $replace($strip($2-),$chr(32),+) $&
sockwrite -nt %ud .msg $iif(#,#,$nick)
}
}
on *:sockread:ud*:{
sockread &ud
tokenize 32 $sock($sockname).mark
if ($sockerr) {
$5-6 Socket Error!
}
elseif (no_results isin $bvar(&ud,1-).text) {
$5-6 $qt($1) is undefined!
}
elseif ($regex($bvar(&ud,1-).text,/"definition":"(.*)/)) {
tokenize 34 $regml(1)
$gettok($sock($sockname).mark,5-6,32) $regsubex($1,/\Q\r\n\E/g,$chr(32))
}
}
Am guessing your talking about the same thing as @incognitus
Removed since script has been updated
That's the same version as I PM'eD him... hope this helps @Kilim
Simply add a @ to the on $:TEXT: event so it looks like this -> @$:TEXT:
on @$*:TEXT:/^[!@.]define( |$)/iS:*:{
if (!$($+(%,-,$site,.,$cid,.,$nick),2)) && ($regex($nick($chan,$nick).pnick,/(!|~|&|@)/)) { inc -u3 $+(%,-,$site,.,$cid,.,$nick) | var %ud = $+(ud,$str($ticks,3))
$+(sock,$iif($sock(%ud),close,open) %ud api.urbandictionary.com 80) | sockmark %ud $replace($strip($2-),$chr(32),+) sockwrite -nt %ud .msg $iif(#,#,$nick) }
}
Above will only work if the user is OP'eD (@)
NOTE: Have "only" added the text event here... you'll need the rest of the script for it to work.
EDiT
I might have misunderstood you... the above will only work if the bot / host ( client running the script ) is OP'eD (@) and come to think of it that wasn't what you asked for I'm guessing ?
on *:sockopen:ud*:{ tokenize 32 $sock($sockname).mark
if ($sockerr) { $5-6 Socket Error! | halt }
$2-4 GET $+(/v0/define?term=,$1) HTTP/1.0
$2-4 Host: $+($sock($sockname).addr,$str($crlf,2))
$2-4 Connection: close
}
on $*:TEXT:/^[!@.]define( |$)/iS:*:{
if (!$($+(%,-,$site,.,$cid,.,$nick),2)) && ($regex($nick($chan,$nick).pnick,/(!|~|&|@)/)) { inc -u3 $+(%,-,$site,.,$cid,.,$nick) | var %ud = $+(ud,$str($ticks,3))
$+(sock,$iif($sock(%ud),close,open) %ud api.urbandictionary.com 80) | sockmark %ud $replace($strip($2-),$chr(32),+) sockwrite -nt %ud .msg $iif(#,#,$nick) }
}
on *:sockread:ud*:{ sockread &ud
tokenize 32 $sock($sockname).mark
if ($sockerr) { $5-6 Socket Error! }
elseif (no_results isin $bvar(&ud,1-).text) { $5-6 $qt($1) is undefined! }
elseif ($regex($bvar(&ud,1-).text,/"definition":"(.*)/)) { tokenize 34 $regml(1) | $gettok($sock($sockname).mark,5-6,32) $regsubex($1,/\Q\r\n\E/g,$chr(32)) }
;*** Use the one below and comment the one above out if you only want 1 line ( sockclose added to the one below )
elseif ($regex($bvar(&ud,1-).text,/"definition":"(.*)/)) { tokenize 34 $regml(1) | $gettok($sock($sockname).mark,5-6,32) $regsubex($1,/\Q\r\n\E/g,$chr(32)) | sockclose $sockname }
}
The above will "only" work if the user is OP'eD (@) or above
And have added a extra line with sockclose in case people only want the first definition.
Ricko,
I modified the code as shown so i could simply /define [WORD]
and it works so I'm suspecting you have other issues or are trying to
trigger your own 'on text' event which is impossible.
on *:sockopen:ud*:{
tokenize 32 $sock($sockname).mark
if ($sockerr) { $5-6 Socket error! | return }
$2-4 GET $+(/iphone/search/define?term=,$1) HTTP/1.1
$2-4 Host: $+($sock($sockname).addr,$str($crlf,2))
$2-4 Connection: close
}
on *:sockread:ud*:{
tokenize 32 $sock($sockname).mark
if ($sockerr) { $5-6 Socket error! | return } | var %ud | sockread %ud
if (undefined isin %ud) { $5-6 $qt($replace($1,+,$chr(32))) is $+($v1,!) }
elseif ($regex(%ud,/"definition":"(.*)/)) { $5-6 $remde($gettok($regml(1),1,34)) }
}
alias define {
set -l %ud $+(ud,$str($ticks,3))
$+(sock,$iif($sock(%ud),close,open) %ud www.urbandictionary.com 80)
sockmark %ud $replace($strip($1-),$chr(32),+) sockwrite -nt %ud .echo -a
}
alias remde var %. | noop $regsub($1,/\134r\134n/g,$chr(32),%.) | return %.
They English people have their own slang terms, which, to some extent, are different from Americans'
gooshie, the whole vernacular thing is a deep sought-after anthropological subject to read up upon or study of.
I think it's never easy enough to fake an English or American accent. It all comes down naturally when you were born to expose yourself to that particular culture to begin with.
Thanks for the script, Jethro!
Can you edit this to work with mods only?
Thanks in advance.