|
Joined: Nov 2003
Posts: 102
Vogon poet
|
OP
Vogon poet
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,
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
|
|
|
|
Joined: Dec 2002
Posts: 2,033
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 2,033 |
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.
}
|
|
|
|
Joined: Nov 2003
Posts: 102
Vogon poet
|
OP
Vogon poet
Joined: Nov 2003
Posts: 102 |
that as is should work ? I get nothing from it at all that i can see
|
|
|
|
Joined: Nov 2003
Posts: 102
Vogon poet
|
OP
Vogon poet
Joined: Nov 2003
Posts: 102 |
wait let me check the edited one
|
|
|
|
Joined: Nov 2003
Posts: 102
Vogon poet
|
OP
Vogon poet
Joined: Nov 2003
Posts: 102 |
Yeah i still get nothing Do i need to change anything first?
|
|
|
|
Joined: Dec 2002
Posts: 2,033
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 2,033 |
Sorry, this works.
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.
|
|
|
|
Joined: Nov 2006
Posts: 1,559
Hoopy frood
|
Hoopy frood
Joined: Nov 2006
Posts: 1,559 |
You cannot use the space in the matchtext definition for a match of "beer" only... 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
|
|
|
|
Joined: Dec 2002
Posts: 2,033
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 2,033 |
I found that. I didn't realize I had put a space there, but thanks.
|
|
|
|
Joined: Nov 2003
Posts: 102
Vogon poet
|
OP
Vogon poet
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 ?
|
|
|
|
Joined: Nov 2006
Posts: 1,559
Hoopy frood
|
Hoopy frood
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"
Last edited by Horstl; 27/10/08 10:54 PM.
|
|
|
|
Joined: Jul 2007
Posts: 1,129
Hoopy frood
|
Hoopy frood
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. 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.
|
|
|
|
Joined: Nov 2003
Posts: 102
Vogon poet
|
OP
Vogon poet
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... 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
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
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 <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.
|
|
|
|
Joined: Nov 2003
Posts: 102
Vogon poet
|
OP
Vogon poet
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.
on *:TEXT:hello ToRmEnTeD*:#: {
if ($2 == $null) describe # Hello $nick Hows it going ? :)
}
Thats how it is on my script
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
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
Hoopy frood
|
Hoopy frood
Joined: Jul 2007
Posts: 1,129 |
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
Hoopy frood
|
Hoopy frood
Joined: Jul 2007
Posts: 1,129 |
You can also do it this way: on $*:TEXT:/^(hey|hello|hi)\s(ToRmEnTeD)$/Si:#: { describe # Hello $nick $+ , hows it going ? :) }
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
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.
|
|
|
|
Joined: Nov 2003
Posts: 102
Vogon poet
|
OP
Vogon poet
Joined: Nov 2003
Posts: 102 |
You can also do it this way:
on $*:TEXT:/^(hey|hello|hi)\s(ToRmEnTeD)$/Si:#: { describe # Hello $nick $+ , hows it going ? :) }
hey ...IT WORKS! Thanks man!
Last edited by ToRmEnTeD; 29/10/08 09:09 AM.
|
|
|
|
Joined: Jul 2007
Posts: 1,129
Hoopy frood
|
Hoopy frood
Joined: Jul 2007
Posts: 1,129 |
RusselB, can you please give an example of what you've wondered about in your question?
|
|
|
|
|