User Control Panel
Advertisements
HELP US, HELP YOU!
Author
Message
Tony_shu God Like Joined: 12 Nov 2003Posts: 624
Posted: Mon Jan 26, 2004 4:56 am Post subject:
I tried to download the dictionary.txt file that was posted on this site. However, I found that it was too limited (no offense to those who compiled them)...and I thought I'd try and make my own. This runs for AIM Code: ######################################<br /># #<br /># ## #<br /># ########### # # #<br /># # # # #<br /># # ### # ### #<br /># # # # # #<br /># # ### # #<br /># # # # # #<br /># # ########## #<br /># # #<br /># ########### #<br /># #<br /># @-Squared Productions #<br /># #<br />######################################<br /><br />use LWP::Simple;<br /><br />sub dictionary {<br /><br /> my ($victim,$msg,$aim) = (shift,shift,shift);<br /> my ($reply,$replya,$define,$definea);<br /> my $sn = $screenname;<br /> my $check = 0;<br /> my (@simp,@meaning);<br /><br /> $msg =~ s/(\!|\.|\/)dictionary //ig;<br /><br /> if ($msg ne "" || $msg ne " ") {<br /> $def = LWP::Simple::get( "http://www.m-w.com/cgi-bin/dictionary?book=Dictionary&va=$msg" );<br /> @simp = split(/\n/,$def);<br /> chomp(@simp);<br /> $define = "Webster's Dictionary defines $msg as:\n";<br /> foreach my $line (@simp) {<br /> if ($line =~ /^(Main Entry\:)/i) {<br /> $define .= "$line\n";<br /> } elsif ($line =~ /^(Pronunciation\:)/i) {<br /> $define .= "$line\n";<br /> } elsif ($line =~ /^(Function\:)/i) {<br /> $define .= "$line\n";<br /> } elsif ($line =~ /^(Inflected Form\(s\)\:)/i) {<br /> $define .= "$line\n";<br /> } elsif ($line =~ /^(Etymology\:)/i) {<br /> $define .= "$line\n";<br /> } elsif ($line =~ /^(\<b\>1 a|\<b\>1)/i) {<br /> $definea .= "$line\n";<br /> }<br /> }<br /> $aim->send_im($victim,$define);<br /> sleep(1);<br /> $definea =~ s/<(.|\n)+?>//gi;<br /> $replya = $definea;<br /> $aim->send_im($victim,$replya);<br /> sleep(1);<br /> $reply = "That is all <a href=\"http://www.m-w.com/cgi-bin/dictionary?book=Dictionary&va=$msg\">Webster's Dictionary</a> has provided me for your word.";<br /> } else {<br /> $reply = "I'm sorry, but you have not given me any word to define.";<br /> }<br /><br /> return $reply;<br /><br />}<br /><br />sub dict {<br /> my ($victim,$msg,$aim) = (shift,shift,shift);<br /> $msg =~ s/dict/dictionary/ig;<br /> dictionary($victim,$msg,$aim)<br />}<br /><br />sub define {<br /> my ($victim,$msg,$aim) = (shift,shift,shift);<br /> $msg =~ s/define/dictionary/ig;<br /> dictionary($victim,$msg,$aim)<br />}<br />1;
This code uses LWP::Simple ... and the get function. It gets the definitions off of Merriam-Webster's Online Dictionary. However, it originally pulled the entire results page...so if you scroll down you'll see that I narrowed down the page, and cut out the "crap". However, this is still rather rudimentary...and I'm open to any adjustments that can help make it more efficient. When you define a word on www.m-w.com, the page has Bold and Italics within the definition to help emphasize certain things. However, if I kept the html tags in the code, it would have been too long to have the bot return the message. Well...I don't believe I've seen this anywhere...so I will toot my own horn here and pat myself on the back. _________________ Anthony Arslan
@-Squared Enterprises
MacroHard Corporation
Back to top
Tony_shu God Like Joined: 12 Nov 2003Posts: 624
Posted: Mon Jan 26, 2004 6:23 am Post subject:
I thought I'ld try & start learning perl programming for MSN...so this should work for MSN Code: ######################################<br /># #<br /># ## #<br /># ########### # # #<br /># # # # #<br /># # ### # ### #<br /># # # # # #<br /># # ### # #<br /># # # # # #<br /># # ########## #<br /># # #<br /># ########### #<br /># #<br /># @-Squared Productions #<br /># #<br />######################################<br /><br />use LWP::Simple;<br /><br />sub dictionary {<br /><br /> my ($victim,$msg,$self) = (shift,shift,shift);<br /> my ($reply,$replya,$define,$definea);<br /> my $check = 0;<br /> my (@simp,@meaning);<br /><br /> $msg =~ s/(\!|\.|\/)dictionary //ig;<br /><br /> if ($msg ne "" || $msg ne " ") {<br /> $def = LWP::Simple::get( "http://www.m-w.com/cgi-bin/dictionary?book=Dictionary&va=$msg" );<br /> @simp = split(/\n/,$def);<br /> chomp(@simp);<br /> $define = "Webster's Dictionary defines $msg as:\n";<br /> foreach my $line (@simp) {<br /> if ($line =~ /^(Main Entry\:)/i) {<br /> $define .= "$line\n";<br /> } elsif ($line =~ /^(Pronunciation\:)/i) {<br /> $define .= "$line\n";<br /> } elsif ($line =~ /^(Function\:)/i) {<br /> $define .= "$line\n";<br /> } elsif ($line =~ /^(Inflected Form\(s\)\:)/i) {<br /> $define .= "$line\n";<br /> } elsif ($line =~ /^(Etymology\:)/i) {<br /> $define .= "$line\n";<br /> } elsif ($line =~ /^(\<b\>1 a|\<b\>1)/i) {<br /> $definea .= "$line\n";<br /> }<br /> }<br /> $self->sendmsg($victim,$define);<br /> sleep(1);<br /> $definea =~ s/<(.|\n)+?>//gi;<br /> $replya = $definea;<br /> $self->sendmsg($victim,$replya);<br /> sleep(1);<br /> $reply = "That is all <a href=\"http://www.m-w.com/cgi-bin/dictionary?book=Dictionary&va=$msg\">Webster's Dictionary</a> has provided me for your word.";<br /> } else {<br /> $reply = "I'm sorry, but you have not given me any word to define.";<br /> }<br /><br /> return $reply;<br /><br />}<br /><br />sub dict {<br /> my ($victim,$msg,$self) = (shift,shift,shift);<br /> $msg =~ s/dict/dictionary/ig;<br /> dictionary($victim,$msg,$self)<br />}<br /><br />sub define {<br /> my ($victim,$msg,$self) = (shift,shift,shift);<br /> $msg =~ s/define/dictionary/ig;<br /> dictionary($victim,$msg,$self)<br />}<br />1;
_________________ Anthony Arslan
@-Squared Enterprises
MacroHard Corporation
Back to top
Dazzy Agent Joined: 09 Jan 2004Posts: 1731
Posted: Mon Jan 26, 2004 7:50 am Post subject:
i tried out your msn one and is half works when you !dictionary word it comes up with 2 blank spaces and then a link to the defined word can you help?
Back to top
Tony_shu God Like Joined: 12 Nov 2003Posts: 624
Posted: Mon Jan 26, 2004 8:50 am Post subject:
I'm not really good with MSN...but when I look at the other commands in this forum I think you should try this: take out $victim in all the sendmsg(): For example: This Code: $self->sendmsg($victim,$define);
should become Code: $self->sendmsg($define);
...or even Code: $self->sendmsg("$define");
...if neither of those work...then I can't help anymore...sorry (I'm just starting to try and learn MSN coding....for the fun of it) _________________ Anthony Arslan
@-Squared Enterprises
MacroHard Corporation
Back to top
Keenie Almost An Agent Joined: 31 Oct 2003Posts: 1071
Posted: Mon Jan 26, 2004 1:22 pm Post subject:
heh good work, and you beat me to releasing a dictionary command
Back to top
Tony_shu God Like Joined: 12 Nov 2003Posts: 624
Posted: Mon Jan 26, 2004 2:24 pm Post subject:
Woohoo.... _________________ Anthony Arslan
@-Squared Enterprises
MacroHard Corporation
Back to top