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, )
return %x
}
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
dialog spc {
title "Spell"
size -1 -1 79 69
option dbu
box "Enter 1 Word To Check:", 1, 2 2 76 20
edit "", 2, 4 10 48 9, autohs left
button "Check", 3, 54 10 22 9, flat
box "Outcome", 4, 2 23 76 45
list 5, 4 32 48 34, size vsbar
button "Clear", 6, 54 32 22 9, flat
button "Copy", 7, 54 44 22 9, flat
button "Exit", 8, 54 56 22 9, flat ok
}
on *:load: {
echo 12 -a You Have Just Loaded Napa182's SpellChecker Dialog
echo 12 -a A Script0rs Inc. Production
echo -a 14,1(14,1¯15,1¯0,1¯0,1º $+($chr(171),$chr(164),$chr(88),$chr(167),$chr(199), $&
$chr(174),$chr(238),$chr(254),$chr(116),$chr(48),$chr(174),$chr(167),$chr(88),$chr(164),$chr(187)) º0,1¯15,1¯14,1¯) $+ $chr(153)
}
menu menubar,channel {
.Spell Checker:{ dialog $iif($dialog(spc),-v,-md) spc spc }
}
on *:dialog:spc:init:0:{ did -b spc 3,6-7 }
on *:dialog:spc:edit:2:{
did -e spc 3,6-7
if ($chr(32) isin $did(2).text || $did(2).text !isalpha) { did -r spc 2 | noop $input(Please Enter Only One Word No Space's And No Numbers,uhdo,ERROR!) }
}
on *:dialog:spc:sclick:*: {
if ($did == 3) {
did -r spc 5
if ($sock(spell)) sockclose spell
sockopen spell www.spellcheck.net 80
sockmark spell $did(2).text didtok spc 5 32
}
if ($did == 6) { did -r spc 2,5 | did -b spc 3,6-7 }
if ($did == 7) { clipboard $did(5).seltext }
}
on *:sockopen:spell: {
sockwrite -nt $sockname GET $+(/cgi-bin/spell.exe?action=CHECKWORD&string=,$gettok($sock(spell).mark,1,32)) HTTP/1.1
sockwrite -nt $sockname Host: $+(www.spellcheck.net,$str($crlf,2))
}
on *:sockclose:spell: { $gettok($sock(spell).mark,2-,32) }
on *:sockread:spell: {
var %spell | sockread %spell
if ($regex(%spell,/<BR><BR><.+<B>(.+correctly.)<\/B><\/font><P><BR>/)) { $gettok($sock(spell).mark,2-,32) $regml(1) | sockclose spell }
if ($regex(%spell,/^(\w+)<BR>$/)) { sockmark spell $addtok($sock(spell).mark,$regml(1),32) }
}
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:
menu * {
Spell Check: {
var %i $input(Please enter one word to spell,aoe,Spell Check)
if (%i) { sockopen spelld www.spellcheck.net 80 | sockmark spelld %i }
}
}
on *:sockopen:spelld: {
sockwrite -n $sockname GET /cgi-bin/spell.exe?action=CHECKWORD&string= $+ $gettok($sock(spelld).mark,1,32) HTTP/1.1
sockwrite -n $sockname Host: www.spellcheck.net
sockwrite -n $sockname Connection: Close
sockwrite -n $sockname $crlf
}
on *:sockread:spelld: {
var %sresults | sockread %sresults
var %sword $gettok($sock(spelld).mark,1,32)
if ($regex(%sresults,/is misspelled/Sig)) { set %spelledcorrectly no }
if ($regex(%sresults,/is spelled correctly/Sig)) { set %spelledcorrectly yes }
}
on *:sockclose:spelld: { dialog -m spch spch }
dialog spch {
Title "Spell Check"
Size -1 -1 75 30
option dbu
button "$iif(%spelledcorrectly == yes,Spelled Correctly,Misspelled)", 1, 10 10 50 12,ok
}
on *:dialog:spch:init:*: {
unset %spelledcorrectly
}
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.
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
/sockmark [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 [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
alias spellclear {
unset %spellyesorno
unset %schan
unset %ssug
unset %sword
}
into this
alias -l spellclear { unset %spellyesorno %schan %ssug %sword }
then you can use
$spellclear
or change the name of the vars into somthing like this
%spell.yesorno %spell.chan %spell.sug %spell.word
then use
unset %spell.*
unless you have other global vars that use the name %spell.whatever
Introduction
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
<~napa182> @spell cow
<&Sick0> Looking up results for [cow]:
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.
um in ur regex's
if ($regex(%sresults,/is misspelled/Sig)) {
if ($regex(%sresults,/is spelled correctly/Sig)) {
if ($regex(%sresults,/^(\w+)<BR>$/Sig)) {
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.
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
sockread %sresults
Should be changed to
var %sresults | sockread %sresults
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
on *:sockclose:spell: {
unset %s*
}
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 :)