Okay, so I just got 'round to changing this snippet too.
Usage: !define (Remove the < >)
All comments/suggestions are welcome. :)
Example: > [2:00pm] <~Stewie> !define Example
[2:00pm] <&thunderbolt> Definition: a thing characteristic of its kind or illustrating a general rule Pronunciation: /ɪgˈzɑːmp(ə)l, ɛg-/
on $*:TEXT:/^!define( |$)/Si:#:{
if ($($+(%,defpro,$remove($chan,$chr(35))),5) == $null) {
define msg $chan $2-
set -u6 $+(%,defpro,$remove($chan,$chr(35))) Flood-Pro
}
else { .notice $nick This command can only be used once every 6 seconds. }
}
alias def define .echo -a $1-
alias define {
if ($sock(define)) sockclose define
sockopen define www.oxforddictionaries.com 80
sockmark define $1-
}
on *:sockopen:define:{
tokenize 32 $sock($sockname).mark
sockwrite -nt $sockname GET $+(/definition/english/,$lower($3)) HTTP/1.1
sockwrite -nt $sockname Host: $+($sock($sockname).addr,$str($crlf,2))
}
on *:sockread:define:{
var %define | sockread %define
if ($regex(%define,/definition">(.+?)</span>/)) hadd -m $sockname def $remove($regml(1),:)
if ($regex(%define,/key-to-pronunciation"> (.+?)</a></div>/)) hadd -m $sockname pro $regml(1)
if ($hget($sockname)) {
var %s = $sockname
$gettok($sock($sockname).mark,1-2,32) 04Definition: $hget(%s,def) 04Pronunciation: $hget(%s,pro)
hfree $sockname
sockclose $sockname
}
if (*Page not found* iswm %define) {
tokenize 32 $sock($sockname).mark
$gettok($sock($sockname).mark,1-2,32) No Results have been found for: $qt($3)
sockclose $sockname
}
}
Did my update/fix help you? I know you just didn't know it wasn't working.. but it seems you adopted some of the minor changes I did to make it functional again.. except your url is english and not american_english.
I'm not an experienced IRC coder,.. but I decided to just take a stab at it and figured perhaps the website format had changed a bit.. and adjusted the URL but it didn't work exactly.. and added the "www" as well, and then it worked perfectly.
The Pronunciation is a neat feature, but I use this in a JTV chatroom, so I try to minimize any unnecessary information due to limited chat space. I also run Urban dictionary, as often the dictionary doesn't pick up the word -- especially if it is in an adverb/adjective format.. so I have it say " No Results have been found, please try !Urban (word)" for example. :)
Great and efficient script. Your coding looks quite good and not bloated (like mine would be). Do you code in anything else?
Thanks for script.
It stopped working over the last month or so..
I managed to correct it by modifying the following:
sockopen define www.oxforddictionaries.com 80
and
sockwrite -nt $sockname GET $+(/us/definition/american_english/,$lower($3)) HTTP/1.1
For any using it, and need to fix it to work with the new website layout of oxford.
Take care.
@Kiddo96 - I have added an alias: /def ... Will echo it to your active window.
I use FireFox... Also seems I am getting the same issue, but when I re-coded this, I had no issue with it.
Edit: I think I have found the issue, the searching seems to be case sensitive.
[7:43pm] <~Stewie> !define smoke
[7:43pm] <&thunderbolt> Definition: a visible suspension of carbon or other particles in air, typically one emitted from a burning substance and > [7:44pm] <~Stewie> !define Smoke
[7:44pm] <&thunderbolt> No Results have been found for: "Smoke" Maybe the reason for the script not working, when you posted your first comment was because of this reason, I will post a fix around this soon.
Okay another post edit: Updated, so now should be fixed for that issue. > [11:04pm] <~Stewie> !define Smoke
[11:04pm] <&thunderbolt> Definition: a visible suspension of carbon or other particles in air, typically one emitted from a burning substance
[11:04pm] <~Stewie> !define smoke
[11:04pm] <&thunderbolt> Definition: a visible suspension of carbon or other particles in air, typically one emitted from a burning substance
Pardon me, jaytea, if I came out too harshly. It's just sometimes you spit out words like "not the same," or a line of sentence with nothing to explain. Perhaps I was being a bit selfish. Did you do that to me mainly? :/ I certainly am living proof that I've come across some of your posts made as such.
leaving people out in the cold? huh?
the question was purely rhetorical. a bit of banter between 2 coders. to spell out exactly what was (already strongly) implied is akin to a comedian explaining a joke for the special few who did not understand it after the audience's laughter has died down. i give Fuzionx more credit than that.
Firstmate has a valid point. Instead of picking on each other, why don't each one of us be sincere and humble to assist one another without behaving like an egocentric person? jaytea, I truly expect that you will share your expertise in MSL field with explanation...not just leaving people out in the cold.
I'll work on it and a few days man.
EDIT: I will probably re-code too.