mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Mar 2014
Posts: 2
C
Chevy Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
C
Joined: Mar 2014
Posts: 2
Okay so, I have a lot of scripts wrote out and I'm getting the hang of mIRC, but.. I'm trying to figure out a way in which my bot can respond to various forms of "Hello" like Hi, Hey, Hi, hey or hello "insert name here". I already have a script that allows the bot to reply to the word "hello" but if someone was to put an exclamation mark, a full stop or any words after that hello the bot won't send the message. I'm not sure if you know what I'm getting at but hopefully you or someone does cos I'd really like help on this one. Like if someone was to say hello how are you? Or something along those lines, seeing as hello is in the message shouldn't the bot pick that up and respond to that message instead of only responding to a message that solely consists of the word hello? Thanks for any help, I've been looking all over the net for some insight on this particular topic, no luck yet. Also, could I program the bot to respond to a user that uses all caps so I could give the bot a warning message to send to people who do so. If so, a how would be appreciated! Thanks!

Joined: Jul 2006
Posts: 3,960
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,960
There are two main tools to parse/match text with mIRC, wildcard expressin or regular expression (regex)

A wildcard expression is just a string where the '?' matches one character, '*' match zero or more characters and '&' will match a whole word (in fact, a space seperated token).
Regex allows you to handle very complex situation very easily and that's what you're going to use.

A regular expression is just a string where some characters/sequences has some meaning (it's a bit like a new language so I'm not going to explain in depth).
Unlike wildcard expressions where we only talk about matching characters, regex allow you to match positions as well.
For example \b is an anchor and matches a position at word boundaries, there are three different positions that qualify as word boundaries:
-before the first character in the string, if the first character is a word character.
-after the last character in the string, if the last character is a word character.
-between two characters in the string, where one is a word character and the other is not a word character.

So \bword\b would match any word that is "word", even if "word" is touching punctuation for example.

If you have on *:text:hello:#: -- "hello" is a wildcard expression here, matching on the exact string "hello"
If you have on *:text:*hello*:#: it's still a wildcard expression, and it matches the same as if (hello isin $1-), meaning that it matches if "hello" appears anywhere in the string
If you have on *:text: hello :#: it's still a wildcard expression but this time you're requiring a space to be there before and after the string hello (would fail on a simple string like "hello there")

Now you have on $*:text:/\bhello\b/:#:
The $ is the regular expression event prefix, meaning we want to use that tool, and the / around the expression are delimiters (which is usually /)
And as I said, this will match a real "hello" word, it won't fail on "hello there" or on "hello's the thing to say when you join" for example.

read more about regular expression: http://www.regular-expressions.info/tutorial.html

As for warning CAPS, people usually check how many percent of CAPS there are in the sentence. There are different ways to do it according to how you want to represent the % of CAPS, a basic way is to compare the length of the string ( $len() ) and compare it to the total number of uppercase letters

Two example with the string "FlOOdIng WITH Caps"
$len() = 18
# of CAPS = 9
9*100/18 = 50% so with this method, half the sentence is using uppercase letter.

Now what if the string is "WLDKFLSDZEDZEF!!!!!!!!!!!!!!!!!!!!!!!!!!"
$len() = 40
# of CAPS = 14
14*100/40 = 35%, thought you might want to consider that this is almost 100% since the rest is just non-letter.
My point is that you would have to change the way you get the %percent if you want to account for those kind of things.

Last edited by Wims; 16/03/14 12:18 AM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Mar 2014
Posts: 2
C
Chevy Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
C
Joined: Mar 2014
Posts: 2
Very interesting read, thank you for posting such a great answer!! So much detail to take in but I'll get the hang of it! Thanks again smile

Joined: Apr 2014
Posts: 3
X
Self-satisified door
Offline
Self-satisified door
X
Joined: Apr 2014
Posts: 3
Could try something like this smile
Code:
on *:TEXT:*Hello:#: { msg $chan Hello $user }


Link Copied to Clipboard