mIRC Home    About    Download    Register    News    Help

Print Thread
Specific nicks for script command #245188
13/04/14 01:15 AM
13/04/14 01:15 AM
Joined: Apr 2014
Posts: 7
A
amber Offline OP
Nutrimatic drinks dispenser
amber  Offline OP
Nutrimatic drinks dispenser
A

Joined: Apr 2014
Posts: 7
Hi, Im sure this gets asked but I am really new to scripting. Like just a few days into it. lol I've gotten the hang of it pretty well but I'd like to ask this:

How do I get the bot to recognize a specific username?

For example: Anyone can come in and say !coffee and the bot says gives so and so a cup of coffee.

But if specifically Joe comes in and he says !coffee I'd like for the bot to say something specific about Joe and just recognize him. Like "gets Joe's favorite cup and pours coffee in it".

Does this make sense? And if so, is there a way to do this?

Re: Specific nicks for script command [Re: amber] #245190
13/04/14 03:05 AM
13/04/14 03:05 AM
Joined: Mar 2014
Posts: 52
P
patrickplays Offline
Babel fish
patrickplays  Offline
Babel fish
P

Joined: Mar 2014
Posts: 52
Code:
on *:text:!coffee:#: {
 if ($nick == joe) {
  msg # blub
 } else {
  msg # blab
}

Last edited by patrickplays; 13/04/14 03:20 AM.
Re: Specific nicks for script command [Re: patrickplays] #245225
13/04/14 11:32 PM
13/04/14 11:32 PM
Joined: Mar 2014
Posts: 215
USA
J
judge2020 Offline
Fjord artisan
judge2020  Offline
Fjord artisan
J

Joined: Mar 2014
Posts: 215
USA
Also if you'd like his username to be displayed you would put $nick somewhere in the message. If you want a punctuation right after the name you would

$+ ($nick,!) which will show as joe!


#imAbeginner
i made a chat bot for mark_paintball! http://twitch.tv/mark_paintball
Re: Specific nicks for script command [Re: amber] #245227
14/04/14 01:42 AM
14/04/14 01:42 AM
Joined: Apr 2014
Posts: 7
A
amber Offline OP
Nutrimatic drinks dispenser
amber  Offline OP
Nutrimatic drinks dispenser
A

Joined: Apr 2014
Posts: 7
Well it worked... Kind of. This is exactly what it's doing

*ambiebot gives Joe a cup of coffee in his favorite cup.
*ambiebot gives Joe a cup of coffee.

At the same time. So even though it's working, it's giving the person the customized coffee, and also the general one.

Help? lol

Re: Specific nicks for script command [Re: patrickplays] #245229
14/04/14 02:12 AM
14/04/14 02:12 AM
Joined: Jan 2004
Posts: 1,271
L
Loki12583 Online
Hoopy frood
Loki12583  Online
Hoopy frood
L

Joined: Jan 2004
Posts: 1,271
That's because the else needs to go on its own line

Code:
on *:text:!coffee:#: {
  if ($nick == joe) {
    msg # blub
  }
  else {
    msg # blab
  }
{

Re: Specific nicks for script command [Re: Loki12583] #245231
14/04/14 02:41 AM
14/04/14 02:41 AM
Joined: Apr 2014
Posts: 7
A
amber Offline OP
Nutrimatic drinks dispenser
amber  Offline OP
Nutrimatic drinks dispenser
A

Joined: Apr 2014
Posts: 7
Thank you!! This worked. I appreciate the help!

Re: Specific nicks for script command [Re: amber] #245265
14/04/14 06:51 PM
14/04/14 06:51 PM
Joined: Apr 2014
Posts: 7
A
amber Offline OP
Nutrimatic drinks dispenser
amber  Offline OP
Nutrimatic drinks dispenser
A

Joined: Apr 2014
Posts: 7
needing just a bit more help! blush

So I got the script to work, now I'd like to do a randomization on what the general response will be. I know it's this:
Code:
var %hi = $rand(1,3)
if (%hi == 1) { msg # Hello $nick }
elseif (%hi == 2) { msg # what's up $nick }
elseif (%hi == 3) { msg # Welcome $nick }


But where do I put it? Under the coffee command, I have other commands. Do I put it directly on the next line after the coffee command, or can I put it on the bottom line under all the commands I've made thus far?

I'll explain better if this doesnt make sense. lol Basically what Im asking is where does it go?

Re: Specific nicks for script command [Re: amber] #245266
14/04/14 07:06 PM
14/04/14 07:06 PM
Joined: Mar 2014
Posts: 215
USA
J
judge2020 Offline
Fjord artisan
judge2020  Offline
Fjord artisan
J

Joined: Mar 2014
Posts: 215
USA
under your if command
Code:
on *:TEXT:!command:#: {
THE CODE YOU SAID
}


#imAbeginner
i made a chat bot for mark_paintball! http://twitch.tv/mark_paintball
Re: Specific nicks for script command [Re: judge2020] #245275
15/04/14 03:01 AM
15/04/14 03:01 AM
Joined: Apr 2014
Posts: 191
B
blessing Offline
Vogon poet
blessing  Offline
Vogon poet
B

Joined: Apr 2014
Posts: 191
You can improve the code like this.
Code:
on *:text:!coffee:#:{
  ; store your vip user into %vip.user variable
  var %vip.user joe dad mom sister brother

  ; check if $nick is vip.user
  if $istok(%vip.user,$nick,32) {

    ; so $nick is vip.user.. give $nick special random msg.
    var %r $rand(1,3)
    if %r == 1 { msg # blah }
    if %r == 2 { msg # bleh }
    if %r == 3 { msg # bluh }
  }
  else {
    ; not vip.user.. give $nick another random msg.

    var %r $rand(1,2)
    if %r == 1 { msg # hah }
    if %r == 2 { msg # heh }
  }
}

Re: Specific nicks for script command [Re: amber] #245287
15/04/14 01:04 PM
15/04/14 01:04 PM
Joined: Apr 2014
Posts: 7
A
amber Offline OP
Nutrimatic drinks dispenser
amber  Offline OP
Nutrimatic drinks dispenser
A

Joined: Apr 2014
Posts: 7
Thank you! I got that working.

Now... last thing and I'll stop pestering you, maybe! :P

Say I wanted a dark blend coffee. how would I get

!coffee dark blend

into

*ambiebot gives amber a fresh cup of dark blend coffee.

Does this make sense and if so, how do I get it to do that?

Re: Specific nicks for script command [Re: amber] #245288
15/04/14 01:09 PM
15/04/14 01:09 PM
Joined: Dec 2013
Posts: 779
Sweden
N
Nillen Offline
Hoopy frood
Nillen  Offline
Hoopy frood
N

Joined: Dec 2013
Posts: 779
Sweden
If your message is "!coffee dark blend", !coffee would then be $1, dark would be $2 and blend would be $3. If you want to use $2 and everything that is after in a sentence, you would put $2- in your script.
Example:
Code:
on *:text:!test*:#: {
msg # $2- 
}
User: !test to show you
Bot: to show you

So for instance,
Code:
on *:text:!coffee*:#: {
msg # /me gives $nick a fresh cup of $2- coffee.
}

Would give you the results you want.


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Re: Specific nicks for script command [Re: Nillen] #245302
15/04/14 09:24 PM
15/04/14 09:24 PM
Joined: Apr 2014
Posts: 7
A
amber Offline OP
Nutrimatic drinks dispenser
amber  Offline OP
Nutrimatic drinks dispenser
A

Joined: Apr 2014
Posts: 7
That doesnt make any sense to me, can you be a bit more descriptive on where that should go, and what it should say? I'm still a newbie at this stuff. lol blush

Re: Specific nicks for script command [Re: amber] #245303
15/04/14 10:46 PM
15/04/14 10:46 PM
Joined: Dec 2013
Posts: 779
Sweden
N
Nillen Offline
Hoopy frood
Nillen  Offline
Hoopy frood
N

Joined: Dec 2013
Posts: 779
Sweden
Code:
on *:text:!coffee*:#:{
  ; Store your vip user into %vip.user variable
  var %vip.user username username2 username3 etc
  ; Make sure there's no message after !coffee
  if ($2 == $null) {
    ; Make sure that the user is a VIP
    if $istok(%vip.user,$nick,32) {
      ; Random between 1 and 3.
      var %r $rand(1,3)
      if (%r == 1) { msg # /me gives $nick a cup of coffee in his favorite cup. | return }
      if (%r == 2) { msg # bleh | return }
      if (%r == 3) { msg # bluh | return }
    }
    ; If user isn't a VIP
    else {
    ; Random between 1 and 2.
      var %r $rand(1,2)
      if (%r == 1) { msg # /me throws a cup of coffee to $nick $+ . | return }
      if (%r == 2) { msg # heh | return }
    }
  }
  ;If another message is posted after, the above code won't go, so this goes.
  ; Make sure that the user is a VIP
  if $istok(%vip.user,$nick,32) {
    ; Random between 1 and 3.
    var %r $rand(1,3)
    if (%r == 1)  { msg # /me gives $nick a cup of $2- coffee in his favorite cup. | return }
    if (%r == 2)  { msg # bleh $2- | return }
    if (%r == 3)  { msg # bluh $2- | return }
  }
  ; If user isn't a VIP
  else {
    ; Random between 1 and 2.
    var %r $rand(1,2)
    if (%r == 1) { msg # /me throws a cup of $2- coffee to $nick $+ . | return }
    if (%r == 2) { msg # heh | return }
  }
}


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Re: Specific nicks for script command [Re: Nillen] #245328
16/04/14 12:40 PM
16/04/14 12:40 PM
Joined: Apr 2014
Posts: 191
B
blessing Offline
Vogon poet
blessing  Offline
Vogon poet
B

Joined: Apr 2014
Posts: 191
The code can be shortened using $iif().
$iif() is same as if {..} | else {..}.

//echo $iif(%a,yes,no) is same as //if %a { echo yes } | else { echo no }
If %a has value it will echoes yes, otherwise no.

So, we simply put $iif() into the message.
msg # /me gives $nick a cup of $iif($2,$2-,$null) coffee in his favorite cup.

If $2 has value, $2- will be added to msg, otherwise nothing will be added.

Code:
on *:text:!coffee*:#:{
  ; Store your vip user into %vip.user variable
  var %vip.user username username2 username3 etc
  ; Make sure that the user is a VIP
  if $istok(%vip.user,$nick,32) {
    ; Random between 1 and 3.
    var %r $rand(1,3)
    if (%r == 1)  { msg # /me gives $nick a cup of $iif($2,$2-,$null) coffee in his favorite cup. | return }
    if (%r == 2)  { msg # bleh $2- | return }
    if (%r == 3)  { msg # bluh $2- | return }
  }
  ; If user isn't a VIP
  else {
    ; Random between 1 and 2.
    var %r $rand(1,2)
    if (%r == 1) { msg # /me throws a cup of $iif($2,$2-,$null) coffee to $nick $+ . | return }
    if (%r == 2) { msg # heh | return }
  }
}

Re: Specific nicks for script command [Re: blessing] #245329
16/04/14 02:13 PM
16/04/14 02:13 PM
Joined: Dec 2013
Posts: 779
Sweden
N
Nillen Offline
Hoopy frood
Nillen  Offline
Hoopy frood
N

Joined: Dec 2013
Posts: 779
Sweden
Oh nice! I did not actually know this. I had seen the statement before but never taken the time to read up on it properly. Thanks for the info sir smile


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net