mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
#205650 27/10/08 09:40 PM
Joined: Nov 2003
Posts: 102
T
Vogon poet
OP Offline
Vogon poet
T
Joined: Nov 2003
Posts: 102
Hey i am not good at this scripting stuff but i am trying to get a command to work so that when a users says a "keyword" it would trigger a response from the bot.
Seen them in some channels before that do what i want.

Heres what i been trying to play around with. I figured i could just make alot of them and it would work,

Code:

on 1:text:beer:#:describe $chan hands $$1 a Ice Cold Budweiser

 


and it displays results as

[5:40pm] * @ToRmEnTeD hands beer a Ice Cold Budweiser

well this does kinda work but it wont say the users name and it just seems a bit odd working....I need this to stay simple because i am well...very new at this.

If i could get someone to make me a example line that works likle that i would greatly apprecate it. Im just wanting to make a big list of them to add to my PNP script.
Thanks to anyone who helps


Rock and Metal Music videos ON DEMAND!
<<<<<< http://www.tormented.tv >>>>>>
Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031

Code:

on *:TEXT:beer *:#: {
  if ($1 == $null) describe # hands $nick an Ice Cold Budweiser.
  elseif ($1 !ison #) describe # hands an Ice Cold Budweiser to the non-existent $1 and it falls to the floor.
  else describe # hands $nick(#,$nick(#,$1)) an Ice Cold Budweiser.
}


RoCk #205652 27/10/08 09:50 PM
Joined: Nov 2003
Posts: 102
T
Vogon poet
OP Offline
Vogon poet
T
Joined: Nov 2003
Posts: 102
that as is should work ? I get nothing from it at all that i can see


Rock and Metal Music videos ON DEMAND!
<<<<<< http://www.tormented.tv >>>>>>
Joined: Nov 2003
Posts: 102
T
Vogon poet
OP Offline
Vogon poet
T
Joined: Nov 2003
Posts: 102
wait let me check the edited one


Rock and Metal Music videos ON DEMAND!
<<<<<< http://www.tormented.tv >>>>>>
Joined: Nov 2003
Posts: 102
T
Vogon poet
OP Offline
Vogon poet
T
Joined: Nov 2003
Posts: 102
Yeah i still get nothing frown
Do i need to change anything first?


Rock and Metal Music videos ON DEMAND!
<<<<<< http://www.tormented.tv >>>>>>
Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031

Sorry, this works.

Code:

on *:TEXT:beer*:#: {
  if ($2 == $null) describe # hands $nick an Ice Cold Budweiser.
  elseif ($2 == $me) {
    msg # Thank you sir, don't mind if I do. :-)
    describe # opens himself an Ice Cold Budweiser.
  }
  elseif ($2 !ison #) describe # hands an Ice Cold Budweiser to the non-existent $2 and it falls to the floor.
  else describe # hands $nick(#,$nick(#,$2)) an Ice Cold Budweiser.
}


Last edited by RoCk; 27/10/08 10:00 PM.
RoCk #205656 27/10/08 10:03 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
You cannot use the space in the matchtext definition for a match of "beer" only...

Code:
on *:text:*:#: {

  ; first word is beer
  if ($1 == beer) {
    ; second paramater is a nick on this channel. give the beer to him, thanks to $nick
    if ($2 ison $chan) { describe $chan hands $2 a beer - salute to $nick $+ ! }

    ; second parameter is no nick on this channel, but there's a second parameter. spoil the beer.
    elseif ($2) { describe $chan hands a beer to the non-existant $2 and it falls to the floor. }

    ; no second parameter. plain beer.
    else { describe $chan hands $nick a beer. }
  }

  ; first word is peanuts
  elseif ($1 == peanuts) {
    ; something with another first word: peanuts
  }
}


EDIT: nevermind, you fixed it wink

Horstl #205657 27/10/08 10:04 PM
Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031

I found that. I didn't realize I had put a space there, but thanks.

RoCk #205659 27/10/08 10:30 PM
Joined: Nov 2003
Posts: 102
T
Vogon poet
OP Offline
Vogon poet
T
Joined: Nov 2003
Posts: 102
yup that worked perfect. very nice work thanks to the both of you. Only leaves me with one question. Do i need to add anything if i wana drop down and add another one below it? or do i just keep stacking them as is ?


Rock and Metal Music videos ON DEMAND!
<<<<<< http://www.tormented.tv >>>>>>
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
You can add more than one "on text" event in the same scriptfile.

on *:TEXT:beer*:#: { some code }
on *:TEXT:wine*:#: { some other code }
... this would work.

Now, if you decide to use my approach instead (and merge different things in one on-text-event):
You just cannot have an identical on text event in the same scriptfile (not a second on *:TEXT:*:#: { codes for if ($1 == beer) etc } ).
With "identical event" I mean identical in all three of <level>:TEXT:<matchtext>:<target>:<commands>
Separate scriptfiles with identical event definitions would work, but the idea was to use one event for all your "bar activities" smile

Last edited by Horstl; 27/10/08 10:54 PM.
Horstl #205662 27/10/08 11:00 PM
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Yes, you can add as many words as you like to be triggered as shown below in red, based on Horstl's code. smile

Quote:

on *:TEXT:*:#: {
if ($1 == beer) || ($1 == soda) || ($1 == wine) {
if ($2 ison $chan) { describe $chan hands $2 a $1 - salute to $nick $+ ! }
elseif ($2) { describe $chan hands a $1 to the non-existant $2- and it falls to the floor. }
else { describe $chan hands $nick a $1 $+ . }
}
}


- a little bug. Edited.

Tomao #205697 28/10/08 09:59 PM
Joined: Nov 2003
Posts: 102
T
Vogon poet
OP Offline
Vogon poet
T
Joined: Nov 2003
Posts: 102
Ok so i ran into an issue pretty quick here. The code works exactly how i asked...however me being a newb bit me in my ass. I made one that says Hello to a user when a user types Hello....
During my test this worked fine..However once it was running in the room is soon realised that is was a problem.
Someone says Hello. the bot says Hello back...but then..lol
the people in the channel say hello to the user and guess what?
lol the script says hello to everyone that says hello back...
frown I never ever thought of that...
I have seen channels that have bots that do this kinda thing and done seem to have these issues so what would be the best way to fix these types of issues?
However


Rock and Metal Music videos ON DEMAND!
<<<<<< http://www.tormented.tv >>>>>>
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
One option is to only reply if the name of the bot is included.
Eg. converstaion where Tormented is the bot
Quote:
<RusselB> Hello Tormented
<Tormented> Hello RusselB
<Frank> Hey there RusselB
<RusselB> ^5's Frank


Another option, is to set a variable, so that the bot only responds to the same command if issued more than a minute apart.

There are probably other options, but those are the first two that occur to me.

RusselB #205700 28/10/08 11:12 PM
Joined: Nov 2003
Posts: 102
T
Vogon poet
OP Offline
Vogon poet
T
Joined: Nov 2003
Posts: 102
hmm I tried to do it with my nick and i cant seem to get it to trigger....but i have not been able to get any thing thats more than 1 word to trigger.

Code:

on *:TEXT:hello ToRmEnTeD*:#: {
  if ($2 == $null) describe # Hello $nick Hows it going ? :)

}



 


Thats how it is on my script


Rock and Metal Music videos ON DEMAND!
<<<<<< http://www.tormented.tv >>>>>>
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Change $2 to $3 as your matchtext section of the ON TEXT event will recognize hello as $1 and ToRmEnTeD as $2

Also, just in case you weren't aware of this, it's impossible for you to trigger your own ON TEXT events, so if you are running the code, someone else will have to send the message "hello Tormented" (without the quotes) for the script to trigger..

Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Code:
on *:TEXT:*:#: {
  var %x = /^(hello|hey|hi)\s $+ $me $+ /Si
  if ($regex($1-,%x)) { describe # Hello $nick $+ , hows it going ? :) }
}


You can use $regex to achieve this. You can add more greeting words to it as shown above.

This script will only be triggered when your name is being greeted, as in:

Hello ToRmEnTeD, Hey Tormented or hi tormented

Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
You can also do it this way:

Code:
on $*:TEXT:/^(hey|hello|hi)\s(ToRmEnTeD)$/Si:#: { describe # Hello $nick $+ , hows it going ? :) }

Tomao #205707 29/10/08 06:05 AM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
I admit I'm still learning about regex, but wondered if something similar could be done so that it responds with one message if my nick had -afk attached to it, but a different message if it didn't.

To the OP, sorry to horn in on your topic, but this got me wondering.

Tomao #205709 29/10/08 09:09 AM
Joined: Nov 2003
Posts: 102
T
Vogon poet
OP Offline
Vogon poet
T
Joined: Nov 2003
Posts: 102
Originally Posted By: Tomao
You can also do it this way:

Code:


on $*:TEXT:/^(hey|hello|hi)\s(ToRmEnTeD)$/Si:#: { describe # Hello $nick $+ , hows it going ? :) }






hey ...IT WORKS! smile Thanks man!

Last edited by ToRmEnTeD; 29/10/08 09:09 AM.

Rock and Metal Music videos ON DEMAND!
<<<<<< http://www.tormented.tv >>>>>>
RusselB #205726 29/10/08 11:07 PM
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
RusselB, can you please give an example of what you've wondered about in your question?

Page 1 of 2 1 2

Link Copied to Clipboard