mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Mar 2018
Posts: 9
S
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Mar 2018
Posts: 9
Okay. I want to do sth like this.

on *:TEXT:*ARG1*ARG2*:#: {
if (ARG1 == sth || ARG1 == sthelse) {
if (ARG2 == adjective1) { msg $chan Such reply }
elseif (ARG2 == adjective2) { msg $chan Different reply } }
elseif (ARG1 == another)

etc etc

So You can see, I want it to be specific arguments 1 and 2, done by if statement, but I want it to let people wrote sth before, between and after it.

It would be like

Hey, do You know argument 1 is very argument 2?
It should recognize argument 1 and 2 between words and reply to it.

I can do if statement if there is just one argument. just type :TEXT:*:#: and then I can set $2 in if. But with what I want, I don't know which argument will it be. Second, third, fifth. So what can I do?

I did such thing:

on *:TEXT:*:#: {
if ($1 == Thing) { msg $chan It works }
}

And this works... but only iw Thing is first argument. And I don't want it to be always first. Also I would like argument1 being a string. So like "Some argument".

How to do it? i tried variables, tryign to put $1-, $1+, $n, everything I know. But nothing works.

Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
You really ought to learn the programming language called Regular Expressions. It is how you manipulate strings of any complexity with relative ease.
You will never completely learn Regular Expressions. Not for at least 10 years of trying.

Code:
On $*:TEXT:/(sth|sthelse).*(adjective\d)/:#: {
  var %arg1 = $regml(1)
  var %arg2 = $regml(2)
  ... whatever you want here.
}


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Joined: Mar 2018
Posts: 9
S
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Mar 2018
Posts: 9
I really don't uderstand what's in Your code.

I mean. How do I make the bot reply to it and set my specific things?

Cause I wanted it to have so many things that will be repliable.

Hmmm... sth like this:

Msg1: those beans are good, aren they?
Bot: Yes, they are!

Msg2: those beans are bad!
Bot: No! They are so damn tasty!

Msg3: Cats are cute :3
Bot: Awwww :3

That's why I want to make the command. Specific things with specific adjectives will get specific answers. Like complimenting sth or disapproving. Also different things will have different sets of adjectives that will fit. Beans can be tasty, but cats rather not. I mean, they can, but generally, You know what I mean, right?

I don't really know what those things, You send do. I see, You did string manipulation, but doesn't know if those words ("sth", "sthelse" are specific things or I can set it later with if statements? Also don't know what \d does and whats $regml(1) and what I do with those variables.

What should or can I wrote in "... whatever I want here." section?

Thanks for the answer, butI still doesn't understand ^^"

Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
If you're working with an especially large dictionary, you should consider building a hashtable of item data pairs and then search the list with each word in the sentence until a match is found. I'll be honest though, it sounds like you're in way over your head.


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Joined: Mar 2018
Posts: 9
S
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Mar 2018
Posts: 9
Not that kind of large.
Maybe 20-50 TOTAl (so things * adjectives) different messages. And I doubt it even get to the 50.

Just wanted few thins, that bot will answer to, if someone is saying good or bad things about it. Naswers will be pretty much very similar.

Also, one thing can have few adjectives. And regarding of type of adjective (like cute/tasty/good/bad), answer will be different. But not regarding to the thing. If someone says sth is cute, it doesn't matter what is cute, but that it is cute and it is one of the things listed.


Bla bla bla SOMETHING bla bla CUTE, bla?
No matter how many bla will be there.

It can't be that hard. This is simple task I want from bot. It's almost the same as setting $2 to specific word. But instead of $2, it will be $n, cause I want unspecific ammount of words between those 2 keywords.

Last edited by Smokofenek; 08/03/18 01:51 PM.
Joined: Mar 2018
Posts: 1
V
Mostly harmless
Offline
Mostly harmless
V
Joined: Mar 2018
Posts: 1
If you don't want to do a hash table and search with each word in the sentence, you can use something like

Code:
; Is $1 a word in $2 (case-insensitive)
;
alias isword {
  return $regex($2,/.*(^|\W) $+ $1 $+ ($|\W).*/i)
}


and then check if ($isword(<word>,$1-))

There are probably better options (I just started messing with this stuff), but that's what I've used to pick out a handful of words to trigger different responses.

isin is also an option, I suppose, although it'll find "good" in "goodbye", which is why I've stopped using it.


Link Copied to Clipboard