mIRC Home    About    Download    Register    News    Help

Print Thread
Grammar script. #252636 30/04/15 04:21 AM
Joined: May 2010
Posts: 44
M
Mythos Offline OP
Ameglian cow
OP Offline
Ameglian cow
M
Joined: May 2010
Posts: 44
I'm trying to write up a script. I know there's a features and suggestion thread about spell check and grammar, but that's not what I'm after.

I run a bot for a channel, and as a running gag it corrects spelling on a few key words. This means it messages you if you spell something wrong.

Now, currently I have it running on different triggers for each word, but I was curious if there was a better way for it to react to the key words and in sending the corrections to users.

Re: Grammar script. [Re: Mythos] #252669 02/05/15 03:12 PM
Joined: Feb 2015
Posts: 243
O
OrFeAsGr Offline
Fjord artisan
Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
hi .. a quick thought about this is that you can save the mistaken words in a ini file with their value being the correct word which will be sent. I'm pretty sure there are many other ways and smarter but i can't think something better for now

Re: Grammar script. [Re: OrFeAsGr] #252743 08/05/15 02:09 AM
Joined: May 2010
Posts: 44
M
Mythos Offline OP
Ameglian cow
OP Offline
Ameglian cow
M
Joined: May 2010
Posts: 44
I figured that much but I don't have the knowhow on how to do that. I've been looking through help but it's just.. escaping my grasp.

Re: Grammar script. [Re: Mythos] #252748 08/05/15 02:03 PM
Joined: Dec 2008
Posts: 1,512
westor Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,512
Have a look at this add-on: http://hawkee.com/snippet/8748/


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
Re: Grammar script. [Re: westor] #252755 09/05/15 01:07 PM
Joined: May 2010
Posts: 44
M
Mythos Offline OP
Ameglian cow
OP Offline
Ameglian cow
M
Joined: May 2010
Posts: 44
That's nice but not remotely anything like what I'm wanting. I'm essentially just looking for a script that causes a bot to respond to key words. In some cases the bot could reply to multiple key words in one sentence, not just the first key word.

Last edited by Mythos; 09/05/15 01:08 PM.
Re: Grammar script. [Re: Mythos] #252756 09/05/15 01:31 PM
Joined: Jul 2006
Posts: 3,833
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,833
The idea is to use $hfind, with either regex or just wildcard matching, but regex allow you to match in a better way.

If you plan on having a lot of keywords, you should use an hash table where each item is an unique name and where the data is the expression (we can't use the item name for the expression in case you want to use spaces in your expression, see the example below).

So, supposing keyword are actually words in your case, with a regular expression it could be useful to use \b, which match at words boudaries, it doesn't match characters, it makes sure we are 'around' a word, we use () to capture the actual keyword to be able to get it later:

/hmake keywords
/hadd keywords 1 /\b(word1)\b/
/hadd keywords 2 /\b(word2)\b/
/hadd keywords 3 /\b(word3 word4)\b/

And now, inside an on text event, you can do:

Code:
on *:text:*:#mychannel:{
var %t $1-
noop $hfind(keywords,$1-,0,R,noop $regex(%t,$hget(keywords,$1)) [ $(|) ] msg $chan the keyword $qt($regml(1)) was matched).data
}


Calling $hfind that way tell mIRC to try each data in the hash table as the regular expression against the value $1-, which correspond to the message.

Quote:
[15:24:17] <@Aphrodite> word1 word2 word3 word4
[15:24:17] <@Ouims> the keyword "word3 word4" was matched
[15:24:17] <@Ouims> the keyword "word1" was matched
[15:24:17] <@Ouims> the keyword "word2" was matched


If you are not familiar with regular expression, you can use simple wildcard expression but you cannot successfuly match a 'word' with them. To do so you just change the R to W in the $hfind call and you change your expresion to wildcard expression like *word1*.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Grammar script. [Re: Wims] #252783 11/05/15 06:42 AM
Joined: May 2010
Posts: 44
M
Mythos Offline OP
Ameglian cow
OP Offline
Ameglian cow
M
Joined: May 2010
Posts: 44
I think this is beyond me as I don't understand even a little bit of that post. Thanks for trying, though.

All that shows me is that words can be found, but not respond to the individual words in a specific way. I mean.. I don't know how to take what you posted and develop it into what I want. Not in the slightest. I don't even know how hash tables work and I looked at the help file.

Last edited by Mythos; 11/05/15 06:44 AM.
Re: Grammar script. [Re: Mythos] #252784 11/05/15 11:51 AM
Joined: Jul 2006
Posts: 3,833
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,833
Ok. Well, can you give some good example of what you want to do, what do you mean with keywords etc?
Hash table are associative array, you associate something (an item) to something else (a data), if you associate 'potatoes' to 'good', you can retrieve 'good' from just using potatoes. Here I associate nothing though, I just use an hash table because $hfind allow you to do efficient work on the table, I use the hash table as a list.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Grammar script. [Re: Wims] #252788 11/05/15 05:08 PM
Joined: May 2010
Posts: 44
M
Mythos Offline OP
Ameglian cow
OP Offline
Ameglian cow
M
Joined: May 2010
Posts: 44
I want it where if you type one thing, it responds with a nother. Each word would get a different response. Also, in some cases, possibly two words in a certain pattern triggering a response.

Re: Grammar script. [Re: Mythos] #252833 13/05/15 10:07 AM
Joined: Jul 2006
Posts: 3,833
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,833
Right, well then I explained how to do that, what exactly don't you understand in what I said?


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Grammar script. [Re: Wims] #252847 13/05/15 09:21 PM
Joined: May 2010
Posts: 44
M
Mythos Offline OP
Ameglian cow
OP Offline
Ameglian cow
M
Joined: May 2010
Posts: 44
I only see it saying words were matched. That's the thing. I don't see how you match words and have it spit something else back. I also don't know how you'd make it take words with spaces.

Re: Grammar script. [Re: Mythos] #252852 13/05/15 11:11 PM
Joined: Jul 2006
Posts: 3,833
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,833
The hash table acts as a list, a list of expression that will match something (words). I used regular expressions (regex) to match words.
With hash table, you associate a value (data) to an item.
Because of the syntax "/hadd <table> <item> <data>", we can't use spaces for the item's name so I used the data.
For example, the regular expression /\b(word1)\b/ matche a word "word1". To know if it matches, you typcally use the $regex function, $regex(word1,/\b(word1)\b/) is 1 because the expression matches the string, the word "word1" is found.
$hfind is typically used one way: you want to know if something matches an item/data:
If you execute in your editbox:
//hadd -m test item data | echo -a $hfind(test,*te*,1,w) | hfree test
you get "item", because the wildcard expression *te* matches "item", $hfind(test,*at*,1,w).data would match "data" (the .data property makes it look into the data, not the item), note though that $hfind always return the item name so it would actually return 'item' when founding "data".
In the above examples, we pass a wildcard expression to $hfind that is compared against the items (or datas) of the table, in the script I gave, we use the parameter 'R', it indicates that, this time, the items (or datas) are the expressions:
//hadd -m test /\b(item)\b/ /\b(data)\b/ | echo -a $hfind(test,this is a long sentence with the word item in it,1,W) | hfree test
would return "/\bitem\b/" because that item name, representing a regular expression, matches the string provided.
$hfind does all the job basically.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Grammar script. [Re: Wims] #252853 13/05/15 11:29 PM
Joined: May 2010
Posts: 44
M
Mythos Offline OP
Ameglian cow
OP Offline
Ameglian cow
M
Joined: May 2010
Posts: 44
... That is all greek to me. I even tried reading the help file.

Re: Grammar script. [Re: Mythos] #252861 14/05/15 12:08 PM
Joined: Dec 2008
Posts: 1,512
westor Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,512
Originally Posted By: Mythos
... That is all greek to me. I even tried reading the help file.


WOW!! Greeks are not to difficult also mIRC Scripting Language is not. if you read careful the Help File you can understand also @Wims is one of the best on explanations and if you read with attention what he says you can easy understand what is saying..


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
Re: Grammar script. [Re: westor] #252863 14/05/15 12:48 PM
Joined: May 2010
Posts: 44
M
Mythos Offline OP
Ameglian cow
OP Offline
Ameglian cow
M
Joined: May 2010
Posts: 44
Thanks for the input but I'm just gonna let this die for now. I'm not grasping the basics of the hashtable and I've been hacking at it for more than an hour trying to figure it out. It's not meant to be so, thanks for the input but I'll let this concept go.

Re: Grammar script. [Re: Mythos] #255210 30/09/15 04:40 AM
Joined: May 2010
Posts: 44
M
Mythos Offline OP
Ameglian cow
OP Offline
Ameglian cow
M
Joined: May 2010
Posts: 44
I'm going to revisit this since I've spent some time still trying to figure that out, but being unable to get it to do what I actually want.

The Hash Table is just a complication I'm not understanding. I mean, I get how it works in the way explained, but I don't see how it'd help with what I'm wanting.

I guess it's my fault as I've not fully explained what I have been wanting this bot to do.

As it is, the hash table recognizes words being said, but only acknowledges that the words are found. What I want is something I can dynamically change at any time to suit my needs, and it seems if I want to change things instantly, I might need to delete the hash table and remake it.. or reboot mirc after making changes.

I'd really rather just do something based on a text file.

As for what I want the bot to do? It's simple. I want it to pick up words and respond in either a message or in channel a different word, and to do it if there's multiples in the same post. The Hashtable thing seems to pick up multiples of different words, but it just responds with 'found it'.

I want it to go..., let's say the words are Red, Blue and Yellow.

I want it to respond with Green, Purple and Orange.. separately, of course.

"I had a cool blue and red notebook."

I want the bot to go "Purple! Green!" in response. If it can do it in the same response instead of splitting it, that'd be nice.

The reason I'm struggling with the hash table is I'm trying to get it to do all of that.. but so far I'm at 'Red Recognized.' 'Blue Recognized', but not the response I want.

That's why the Hash table thing comes across as 'nonsense' to me. I should also explain that I have a bit of a communication and learning disability. I don't grasp things right away. Sometimes I don't grasp things at all. If it's 'easy' to you, that's cool. smirk

Last edited by Mythos; 30/09/15 04:41 AM.
Re: Grammar script. [Re: Mythos] #255340 10/10/15 03:03 PM
Joined: Feb 2015
Posts: 243
O
OrFeAsGr Offline
Fjord artisan
Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
Hi..
I don't like hashtables either and avoid them all the time. I know they are a lot faster than txt files but they are confusing to me. But i think i know some basics.
1st of all you dont need to restart mIRC in order to clear a hashtable. There is a command that does that. Which i cant remember right now but you can find it at the help files.
2nd of all, how do you save the words on the hashtable? I would save the word as the item and the responses as the value.
3rd of all. If you want to change the values or delete a word/words fast, you can create some aliases to make it easier.

P.S As i said i dont use hashtables either, but i just thought of sharing some practical solutions that might make hashtables more friendly to your goal.
smile

Last edited by OrFeAsGr; 10/10/15 03:04 PM.
Re: Grammar script. [Re: OrFeAsGr] #255341 10/10/15 03:41 PM
Joined: May 2010
Posts: 44
M
Mythos Offline OP
Ameglian cow
OP Offline
Ameglian cow
M
Joined: May 2010
Posts: 44
I actually did find out how to clear a hash table and set it back up. It took me some time to find that part.

The problem is, with how the hash table is, I'm not even sure how to set up a response as a value. The code that was given to me on here just goes 'word found! :D' to everything, not made to respond differently to each one.

I'd much prefer a text file system over hashtables, but I'll use what I need if that's the way it absolutely must be done, but I'm not sure how to make it work with a text file.

I'm a super novice when it comes to mirc scripting. Super extreme novice, and I've been tinkering for years. I've never gotten a hang on regex and things like that.

You should see my IRC connection script I have written up. It likely needs serious editing to be more efficient.

Last edited by Mythos; 10/10/15 03:44 PM.
Re: Grammar script. [Re: Mythos] #255439 23/10/15 04:35 PM
Joined: Oct 2015
Posts: 1
S
Subangelis Offline
Mostly harmless
Offline
Mostly harmless
S
Joined: Oct 2015
Posts: 1
Other than the scripting, I think the biggest problem you're going to face is words can be misspelled in a lot of different ways. Your bot would have to look for each instance of a word.


In the immortal words Socrates once said, "I drank what?!?"