mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Apr 2014
Posts: 15
G
Pikka bird
OP Offline
Pikka bird
G
Joined: Apr 2014
Posts: 15
Here is my commands:

Quote:
on *:text:!setColor *:#:{
set %color. $+ $nick $2
msg $chan $nick Your favorite color $qt($2) was saved!
}
on *:text:!favColor *:#:{
var %color = %color. [ $+ [ $2 ] ]
if (%color != $null) {
msg $chan $nick $2's favorite color is %color $+ .
}
else {
msg $chan $nick $2 does't have a favorite color set yet.
}
}


The code works perfectly fine, except for one thing. You have to type !favcolor (then the username). I want to remove the requirement of putting a username in the command. Is it possible to make a command that pulls variables using the $nick that said the command instead of the person mentioned in the command?

Joined: Apr 2014
Posts: 191
B
Vogon poet
Offline
Vogon poet
B
Joined: Apr 2014
Posts: 191
try change:

Code:
var %color = %color. [ $+ [ $2 ] ]

with:

Code:
var %color = %color. [ $+ [ $nick ] ]

Joined: Apr 2014
Posts: 15
G
Pikka bird
OP Offline
Pikka bird
G
Joined: Apr 2014
Posts: 15
I've tried that already, just tried it again. Didn't work

EDIT: That just changes the part of the variable it grabs from
Quote:
%color.username green

so no matter the username you type after !favcolor, it will always show your username's color. The name is still required to be entered.

Last edited by gavintrujillo; 10/04/14 10:21 PM.
Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
Code:
on *:text:!setcolor*:#:{
  set %color. [ $+ [ $nick ] ] $2
  msg # $nick $+ 's favorite color is now $2 $+ .
}

on *:text:!favcolor*:#:{
  if ($2 == $null) {
    if (%color. [ $+ [ $nick ] ] == $null) { msg # $nick doesn't have a favorite color set yet. | return }
    msg # $nick $+ 's favorite color is %color. [ $+ [ $nick ] ]
  }
  else { 
    if (%color. [ $+ [ $2 ] ] == $null) { msg # $2 doesn't have a favorite color set yet. | return }
    msg # $2 $+ 's favorite color is %color. [ $+ [ $2 ] ]
  }
}


I kind of combined it. Here's how you do it
!setcolor Green
Color is now Green
!favcolor
Your fav color is Green
!favcolor User
User's fav color is ...


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Apr 2014
Posts: 15
G
Pikka bird
OP Offline
Pikka bird
G
Joined: Apr 2014
Posts: 15
Thanks the code worked. I didn't really want help with that exact code, but I used your advice to finish my welcome bot:

Quote:
on *:text:!name*:#:{
if ((%floodname) || ($($+(%,floodname.,$nick),2))) { return }
set %floodname. $+ $nick On
set %name. [ $+ [ $nick ] ] $2
msg $chan $nick set their nickname to $2
}
on !*:join:#redhunterp:{
if ((%floodwelcome) || ($($+(%,floodwelcome.,$nick),2))) { return }
set -u21600 %floodwelcome. $+ $nick On
if ($2 == $null) {
if (%name. [ $+ [ $nick ] ] == $null) {
var %welcome = $rand(1,6)
if (%welcome == 1) msg $chan $nick $+ , Welcome to the stream! Be welcome!
if (%welcome == 2) msg $chan Welcome to the stream $nick $+ ! Be welcome!
if (%welcome == 3) msg $chan $nick Welcome! Be welcome!
if (%welcome == 4) msg $chan Welcome $nick $+ ! Be welcome!
if (%welcome == 5) msg $chan Good to see you $nick $+ , Welcome to the stream!
if (%welcome == 6) msg $chan $nick $+ , good to see you! Welcome to the stream!
}
else {
var %welcome = $rand(1,6)
if (%welcome == 1) msg $chan %name. [ $+ [ $nick ] ] $+ , Welcome to the stream! Be welcome!
if (%welcome == 2) msg $chan Welcome to the stream %name. [ $+ [ $nick ] ] $+ ! Be welcome!
if (%welcome == 3) msg $chan %name. [ $+ [ $nick ] ] Welcome! Be welcome!
if (%welcome == 4) msg $chan Welcome %name. [ $+ [ $nick ] ] $+ ! Be welcome!
if (%welcome == 5) msg $chan Good to see you %name. [ $+ [ $nick ] ] $+ , Welcome to the stream!
if (%welcome == 6) msg $chan %name. [ $+ [ $nick ] ] $+ , good to see you! Welcome to the stream!
}
}
}


Thanks for the help grin

Joined: Apr 2014
Posts: 191
B
Vogon poet
Offline
Vogon poet
B
Joined: Apr 2014
Posts: 191
My bad. I thought you just want to say !favcolor without username.
If you also want able to say !favcolor with username then it would be like this:

Code:
var %z = $iif($2,$2,$nick)
var %color = %color. [ $+ [ %z ] ]


Originally Posted By: gavintrujillo
I've tried that already, just tried it again. Didn't work

EDIT: That just changes the part of the variable it grabs from
Quote:
%color.username green

so no matter the username you type after !favcolor, it will always show your username's color. The name is still required to be entered.

Joined: Apr 2014
Posts: 191
B
Vogon poet
Offline
Vogon poet
B
Joined: Apr 2014
Posts: 191
I dont think your code will work "perfectly".
Why did you think that join event has $2 in it?
$2 is always $null. CMIIW.

Another thing, if you join with newnick, how could you identify that is "you" with your old nick?
You have to identify it by checking their ip address.

Tips:
To make it more visible to you, dont use same welcome message. First you can use "Be Welcome", but for second part try use "Welcome Back" or else and see what happen.


Originally Posted By: gavintrujillo
Thanks the code worked. I didn't really want help with that exact code, but I used your advice to finish my welcome bot:

Quote:
on *:text:!name*:#:{
if ((%floodname) || ($($+(%,floodname.,$nick),2))) { return }
set %floodname. $+ $nick On
set %name. [ $+ [ $nick ] ] $2
msg $chan $nick set their nickname to $2
}
on !*:join:#redhunterp:{
if ((%floodwelcome) || ($($+(%,floodwelcome.,$nick),2))) { return }
set -u21600 %floodwelcome. $+ $nick On
if ($2 == $null) {
if (%name. [ $+ [ $nick ] ] == $null) {
var %welcome = $rand(1,6)
if (%welcome == 1) msg $chan $nick $+ , Welcome to the stream! Be welcome!
if (%welcome == 2) msg $chan Welcome to the stream $nick $+ ! Be welcome!
if (%welcome == 3) msg $chan $nick Welcome! Be welcome!
if (%welcome == 4) msg $chan Welcome $nick $+ ! Be welcome!
if (%welcome == 5) msg $chan Good to see you $nick $+ , Welcome to the stream!
if (%welcome == 6) msg $chan $nick $+ , good to see you! Welcome to the stream!
}
else {
var %welcome = $rand(1,6)
if (%welcome == 1) msg $chan %name. [ $+ [ $nick ] ] $+ , Welcome to the stream! Be welcome!
if (%welcome == 2) msg $chan Welcome to the stream %name. [ $+ [ $nick ] ] $+ ! Be welcome!
if (%welcome == 3) msg $chan %name. [ $+ [ $nick ] ] Welcome! Be welcome!
if (%welcome == 4) msg $chan Welcome %name. [ $+ [ $nick ] ] $+ ! Be welcome!
if (%welcome == 5) msg $chan Good to see you %name. [ $+ [ $nick ] ] $+ , Welcome to the stream!
if (%welcome == 6) msg $chan %name. [ $+ [ $nick ] ] $+ , good to see you! Welcome to the stream!
}
}
}


Thanks for the help grin

Last edited by blessing; 11/04/14 03:23 AM.
Joined: Apr 2014
Posts: 15
G
Pikka bird
OP Offline
Pikka bird
G
Joined: Apr 2014
Posts: 15
Thanks for pointing that out, I'm gonna make a distinct way of finding their username. Plus I check to see if their nickname is close to their user, so it's more secure. Other than that, the code has been working perfectly

EDIT: Sorry, I don't really understand what you are saying about the $2. Those $numbers are still extremely new to me because im very new to this, but the code still worked perfectly fine :p

Last edited by gavintrujillo; 11/04/14 04:34 AM.
Joined: Apr 2014
Posts: 191
B
Vogon poet
Offline
Vogon poet
B
Joined: Apr 2014
Posts: 191
Try this:

- join with your nick "gavintrujillo"
- text !name gavin
- part from channel
- join back. bot will welcome you as gavin. Ok. thats cool.
- part from channel
- now CHANGE your nick to something else ex: newgavincool
- join back
- if it works perfectly, your bot should welcome you as gavin. not newgavincool.



Joined: Apr 2014
Posts: 15
G
Pikka bird
OP Offline
Pikka bird
G
Joined: Apr 2014
Posts: 15
Yea, it completely works. If I try to change my already set nickname, it doesn't reply, and it doesn't change it. This works exactly how I want it to, because I will be able to permanently change anyone that changes their names to something inappropriate. This has been working for the past 4 hours perfectly with a constant 12 people in the channel. Thanks for the help smile

Joined: Apr 2014
Posts: 191
B
Vogon poet
Offline
Vogon poet
B
Joined: Apr 2014
Posts: 191
It seems you are on irc.twitch.tv which is using registered username/nickname. Unregisterd username/nickname is not allowed. So that's okay.

About $2, you can just remove it from you code, because $2 is always $null on join event.

Code:
on !*:join:*:{
  if ((%floodwelcome) || ($($+(%,floodwelcome.,$nick),2))) { return }
  set -u21600 %floodwelcome. $+ $nick On
  if (%name. [ $+ [ $nick ] ] == $null) {
    var %welcome = $rand(1,6)
    if (%welcome == 1) msg $chan $nick $+ , Welcome to the stream! Be welcome!
    if (%welcome == 2) msg $chan Welcome to the stream $nick $+ ! Be welcome!
    if (%welcome == 3) msg $chan $nick Welcome! Be welcome!
    if (%welcome == 4) msg $chan Welcome $nick $+ ! Be welcome!
    if (%welcome == 5) msg $chan Good to see you $nick $+ , Welcome to the stream!
    if (%welcome == 6) msg $chan $nick $+ , good to see you! Welcome to the stream!
  }
  else {
    var %welcome = $rand(1,6)
    if (%welcome == 1) msg $chan %name. [ $+ [ $nick ] ] $+ , Welcome to the stream! Be welcome!
    if (%welcome == 2) msg $chan Welcome to the stream %name. [ $+ [ $nick ] ] $+ ! Be welcome!
    if (%welcome == 3) msg $chan %name. [ $+ [ $nick ] ] Welcome! Be welcome!
    if (%welcome == 4) msg $chan Welcome %name. [ $+ [ $nick ] ] $+ ! Be welcome!
    if (%welcome == 5) msg $chan Good to see you %name. [ $+ [ $nick ] ] $+ , Welcome to the stream!
    if (%welcome == 6) msg $chan %name. [ $+ [ $nick ] ] $+ , good to see you! Welcome to the stream!
  }
}


Link Copied to Clipboard