mIRC Home    About    Download    Register    News    Help

Print Thread
#242004 09/06/13 05:09 PM
Joined: Jun 2013
Posts: 6
H
helen2 Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
H
Joined: Jun 2013
Posts: 6
I need to know how to write a script that replies to a private message. For example, if somebody sends me the private message: "Hello Helen, can you give me 20 dollars?" the script should reply "Sorry I don't have any money". If the same nick sends me the message "Hello Helen, how are you?", the script should reply "Very well thank you". How would I do that? Thanks.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
/help on text

These may also potentially help depending on what you're doing.

/help if then else
/help /set
/help /var

Example:
Code:
on *:text:*do you have*dollars*:?: {
  msg $nick I don't have any money.
}


You'll of course have to adjust it to work in whatever way you want. You may need/want to include IF statements to adjust how it responds and play around with the trigger format to get it to do what you want.


Invision Support
#Invision on irc.irchighway.net
Joined: Jun 2013
Posts: 6
H
helen2 Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
H
Joined: Jun 2013
Posts: 6
Originally Posted By: Riamus2

on *:text:*do you have*dollars*:?: {
msg $nick I don't have any money.
}

You'll of course have to adjust it to work in whatever way you want. You may need/want to include IF statements to adjust how it responds and play around with the trigger format to get it to do what you want.

Thanks, I will. Will that example work on private messages? I tried to copy and adjust it:

on *:text:*do you have*dollars*:?: {
msg $nick I don't have any money.
}
on *:text:*hello helen*:?: {
msg $nick hello my dear.
}

Is that correct? Are the * stars necessary or can I remove them to keep the script/words more specific? Thanks.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
? in the location means private message.

The first * right after on is necessary, though you could optionally make it a 1. It refers to the level of user who can trigger the event. In most cases, you want it to be triggered by anyone. If you wanted to limit who can trigger it, you can add users to the Users tab with different levels and you could put a level there instead of * or 1 and only those with that level (or higher if it's a numeric level) will trigger it. For what you're doing, just use * or 1.

The other *'s are wildcards. It means that anything can be in that location and it will work. For example, *do you have any*dollars* would trigger on any of the following (some aren't grammatically correct, but are just used for examples):

Helen, do you have 5 dollars?
Do you have 435 dollars?
Do you have any dollars?
Do you have some dollars? Can I have some?

If you want it to trigger only on a specific phrase, you can remove them. For example, do you have 5 dollars? will only trigger on:

Do you have 5 dollars?

It will not trigger on anything else, including if someone just put 2 question marks instead of one.

Note that it's case insensitive, meaning it doesn't matter if it's capital or lowercase.

You'll need to determine what kind of wildcards you need or don't need based on what you want to match. There are many tutorials on wildcard use for matchtext on the internet and any of them will help even if they aren't specifically for mIRC. Just note that * means anything from 0 to infinite number of characters at that location. Also note that without a * in front, if someone types it in color, it won't match because the control codes for colors count as part of the matchtext. The * allows someone to type it in color and still trigger the event. That being said, if someone did each letter a different color, it would not match. If you think you need to match something like that, you'd want to look into using $strip() and placing the matchtext into an IF statement and just putting * in the event's matchtext spot. You probably don't have to worry about that, though.

There are a variety of things you can do, including using regex, but this is a good place to start.


Invision Support
#Invision on irc.irchighway.net
Joined: Jun 2013
Posts: 6
H
helen2 Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
H
Joined: Jun 2013
Posts: 6
ok i did it!!!Wow works 100% !!! Now i neade just this.Ok the script will answer hallo to you my dear friend if they will write in pvt Hello helen but...do u know what i must add on the script so that if they write in pvt whatevar exept "Hello helen" so that the script will send to the nick the word "bad sentence" i meane they can write just hello or hey baby or whatevar and the script will allways answer them "bad sentence" only if the write "Hello helen" then will answer back "hallo to you my dear friend" (and taht now works well tahnk's to your help smile
Thank's
Helen

Last edited by helen2; 14/06/13 04:41 PM.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Just put another on TEXT event after your first one in the same script file, but use * as the matchtext. For example:

Code:
on *:text:*hello*:?: { do this }

on *:text:*:?: { do this }


Only the first matching event will trigger from a single script file. So if someone were to say hello in this example, the first event would trigger. But if they said anything that didn't include the work "hello", then it would trigger the second event as long as they are in the same script file.

Or, you can put everything into a single on TEXT event using * as the matchtext, but then use IF/ELSEIF/ELSE inside it. Example:

Code:
on *:text:*:?: {
  if (*hello* iswm $1-) { do this }
  else { do this }
}


Invision Support
#Invision on irc.irchighway.net
Joined: Jun 2013
Posts: 6
H
helen2 Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
H
Joined: Jun 2013
Posts: 6
WOW!Can i adopt u? smile Everything is ok 100% I will open another topic for a more difficult script but alter now is "sun time!"
Thank's again for help
Take care!
Helen


Link Copied to Clipboard