Spell Checker

Platform:  mIRC
Published  Feb 06, 2010
Updated  Feb 07, 2010
Spell checker. Thanks to napa182 for some corrections + FordLawnmower for many great suggestions. on $*:text:/^[!.@]s(pell|pelling)? \w+$/Si:#: {
if (!$sock(spell)) {
msg # Looking up results for $+([,$chr(3),12,$2,$chr(15),],:)
sockopen spell www.spellcheck.net 80
sockmark spell $chan $2
}
}
on *:sockopen:spell: {
sockwrite -n $sockname GET /cgi-bin/spell.exe?action=CHECKWORD&string= $+ $gettok($sock(spell).mark,2,32) HTTP/1.1
sockwrite -n $sockname Host: www.spellcheck.net
sockwrite -n $sockname Connection: Close
sockwrite -n $sockname $crlf
}
on *:sockread:spell: {
var %sresults | sockread %sresults
var %sword $gettok($sock(spell).mark,2,32)
var %schan $gettok($sock(spell).mark,1,32)
if ($regex(%sresults,/is misspelled/Sig)) { msg %schan $+([,$chr(3),12,%sword,$chr(15),],:) 4Misspelled. | set %spellyesorno yes }
if ($regex(%sresults,/is spelled correctly/Sig)) { msg %schan $+([,$chr(3),12,%sword,$chr(15),],:) 3Spelled correctly. | sockclose spell }
if ($regex(%sresults,/^(\w+)<BR>$/Sig)) { sockmark spell $addtok($sock(spell).mark,$nohtml($regml(1)),32) }
}
on *:sockclose:spell: {
var %sword $gettok($sock(spell).mark,2,32)
var %schan $gettok($sock(spell).mark,1,32)
if (%spellyesorno) { msg %schan Suggestions for $+([,$chr(3),12,%sword,$chr(15),],:) $chr(3) $+ 7 $+ $gettok($sock(spell).mark,3-,32) }
unset %spellyesorno
}
alias nohtml {
var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;)
return %x
}

Comments

Sign in to comment.
RIcko   -  Jul 26, 2012
Someone bring the dialog to life, it's not giving results after clicking "check"
 Respond  
Jethro   -  Aug 07, 2010
'cause you're speechless?
 Respond  
RevJohn Straub   -  Aug 07, 2010
hmmmmmmmmmmmmm no commands though what up with that
 Respond  
Battlemonkey   -  Feb 09, 2010
Wow, thanks!
 Respond  
napa182   -  Feb 09, 2010
on ur dialog like ur bot script: again no need to set global vars and ur dialog don't work.

if you want to turn it into a dialog
you could do something like this

Code

 
 Respond  
Battlemonkey   -  Feb 07, 2010
ok, I never thought timers would work like that lol.

EDIT: I can't get it to work with timers. You might just have to use the dialog.
 Respond  
Jethro   -  Feb 07, 2010

Quote

I mean he $input part, mIRC doesn't let you use it in an event.
you need use a /timer to initiate an input request after the script ends.
 Respond  
slub77   -  Feb 07, 2010
cool:
for the in put you could set each word they say as a variable then get it to check each word against the socket, and if it returns wrong,a dialog coming up with suggested words
 Respond  
Battlemonkey   -  Feb 07, 2010
I mean he $input part, mIRC doesn't let you use it in an event. I did, however, get a dialog made to do this. Code:

Code

 
 Respond  
Jethro   -  Feb 07, 2010
Slub77, are you wishing to get a place in the dialog hall of fame or what? lol I don't believe every one loves the idea of dialogs...which in turn, we should put that into consideration when making a script. You can, however, do that by yourself taking the existing script and "dialogizing" it if you feel warrented, then post it as a snippet with credit to battlemonkey.
 Respond  
slub77   -  Feb 07, 2010
on *:INPUT:*:{


^^ that's how
 Respond  
Battlemonkey   -  Feb 07, 2010
That might be annoying for some people and I'm not sure how to add it every time you say something. I could, however, make a menu item which you can click to spell check what you're about to say.
 Respond  
slub77   -  Feb 07, 2010
why not be still, and choose your scripts now, maybe an input a pop up when said, to check each word before it is spoken, is better then to guess
 Respond  
Battlemonkey   -  Feb 07, 2010
A dialog? Ok, I'll try to make one, will take a while.

@Jethro_ Thanks :D
 Respond  
slub77   -  Feb 07, 2010
i feel special cus my name was said, not everyday is a word that is said, have a meaning to me, normally a sentence, but never a word, it's a very nice script i applaud thee, but i see no reason why and dialog can't be seen?
 Respond  
Jethro   -  Feb 07, 2010
You all should feel special that napa gives a damn about you guys...lol Oh no worries, battlemonkey...you will get better and better as time goes by. Don't stop learning. :-)
 Respond  
Battlemonkey   -  Feb 07, 2010
Ok, I'll be looking into all of that.

@napa I'll take you off the credits and I'll add the $sock().mark.

@Jethro_ Sorry, trying to learn regex, I can't be good at everything.
 Respond  
slub77   -  Feb 07, 2010
lol napa i do type fast, i am normally afk lol, and i know he's human, lol, it was joke :P
aka: napa always corrects me with scripts, so the one time i get to do it to him, is when he makes a typo lol.
 Respond  
napa182   -  Feb 07, 2010
hmm now it seems to work, but Battlemonkey you should really take what i showed you an learn from it not just copy/paste bit's and pieces.
the reason i used $regex in the sockread was to get away from using an alias to strip the html among other things, but yet you still added an alias to strip the html to this. =/ why?

As well from the help file

Quote


/sockmark <name> [text]

The /sockmark command fills the .mark attribute of a socket with the specified info for later reference via the $sock().mark property. If you do not specify any text, the mark is cleared. The mark can hold up to 512 bytes.


whats not to understand from that? I mean if you understand sockwrite then you should understand sockmark

lets say we have a socket named test and using the " sockmark <name> [text] " Ex:
ok so now we are going to fill the sockmark with the info we want. Lest's say we want to fill it with a channel name lets call the channel #test and also add the $1 said in the on text event. so it would look like this:

sockmark test #test $1

now to pull the info we use $sock(test).mark that by it's self will say everything we added into the sockmark, but what if we just want to pull the channel we could do
$gettok($sock(test).mark,1,32)
i know you know how to use $gettok and $addtok so you should understand that.

do you get it now? no need to set all them global vars...


oh and if you are still going to use global vars you can change this

Code

 


into this

Code

 

then you can use

Code

 


or change the name of the vars into somthing like this

Code

 


then use

Code

 

unless you have other global vars that use the name %spell.whatever
 Respond  
napa182   -  Feb 07, 2010
slub77 it's called typing fast. Maybe you should try it sometime.
 Respond  
Jethro   -  Feb 07, 2010
napa is a human being, and all humans do make mistakes.
 Respond  
slub77   -  Feb 07, 2010
napa fail on trying to make ur text bold lol@
{b]Introduction[/b]

lol you put a { on the first one :P

lol

Lol the one thing i can correct napa on....
 Respond  
napa182   -  Feb 07, 2010
Introduction

Quote

Spell checker. Thanks to napa182 for the regexes


@ Battlemonkey Please don't credit me for the regexs cause you changed the ones i made. You shouldn't use them if you don't understand them.

Also ur script don't seem to work for me all i get is

Quote


<~napa182> @spell cow
<&Sick0> Looking up results for [cow]:
 Respond  
Jethro   -  Feb 07, 2010
Battlemonkey, you are supposed to understand the purposes of those three flags, not for the sake of "you're used to." The only exception of those flags is /S , which is available for mirc to strip control codes only.

The /i flag, as you should already know, is to make the regex case insensitive.

the /g flag is to make regex greedy and global and search more than one match. Without the g flag, the regex will only return the first match it finds.

It all depends on what you do with regex, not all of them should be inserted with g flag. Again, not because you want to or you think they look "pretty" in the regex..but because in certain cases the /g is needed to perform required regex functions.
 Respond  
napa182   -  Feb 06, 2010
well on them lines there is no need for the /Sig
 Respond  
Battlemonkey   -  Feb 06, 2010
oh... Quite a few things, eh? /Sig is just what I'm used to, will change that now. $sock().mark is still unfamiliar to me so I'll stay away from that for now. I'll get $nohtml in. I'll fix the unset %s* too. Thank you!
 Respond  
napa182   -  Feb 06, 2010
um in ur regex's

Code

 

may i ask why are you using /Sig ?

also if you are going to use regex's you should know how to use them the right way.
i showed you a way that got you away from setting global vars yet in the update you posted you are setting global vars again. =/

and then you are using an alias $nohtml that you did not include.
 Respond  
FordLawnmower   -  Feb 06, 2010
I noticed a couple of things that you should change with this Battlemonkey.
When you sockread to a variable without setting it first it becomes global which is not necessary. So the sockread line

Code

 
Should be changed to

Code

 

This way %sresults can only be seen inside the script and it will unset it's self at the end.

Which leads me to this

Code

 

The first problem here is unsetting every variable that starts with S.
Suppose someone had a stats script with lots of variables like %statsjoins %statsparts %statslines. Or even more complicated like %stats#chanNICKLines.
This script could wipe out years of someones stats collection and there would be no way to get them back. You need to be way more specific with your variable naming conventions if you are going to use wildcards to unset them.

Luckily, The script will only reach the unset line if there is some sort of error. When you close a socket using sockclose, it does NOT trigger the On Sockclose event. This event is only closed if the Host closes the socket.
If you look in the variable section of your scripts editor, you will see that %schan,%sword and %sresults all remain set.
One way to fix this is to make an alias called SpellCleanUp that unsets all variables and closes the socket. Then just put SpellCleanup where you have Sockclose Spell.

Other than that your script looks fine Battlemonkey. I don't see anything wrong with using variables as long as they are very descriptive and they get unset at the end.

Obviously adding suggestions as napa182 has done will make the script 100% better but yours works fine :)
 Respond  
Battlemonkey   -  Feb 06, 2010
lol I know. That's my way of saying you got it down. btw I figured out how to get it on my script using your regex :P.
 Respond  
napa182   -  Feb 06, 2010
it's not about winning im just showing you one way of dong it thats all. others will show you another way. Thats how it works here..
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.