DasSaffe
DasSaffe

Reputation: 2198

how to join channels with a variable username (mirc)

simple question, i guess, but I'm fairly new to this, so maybe you can help me. I made a bot for a chat, which i want to share with people. So, my first thought was: i'll add a command (!join), which then will let the bot join the specific channel. For some reason (i guess its due the operators), my join won't work.

Here is the snippet:

on *:TEXT:!join:#: {
  var %name = $nick
  ;/msg $chan joining channel %name 
  /join #%nick
}

But it just won't connect. Any ideas?

If i just use /kick $nick (or %name), it works, so i guess this # is messing things up.

Thanks in advance

Upvotes: 0

Views: 339

Answers (2)

Eder
Eder

Reputation: 1884

Use mIRC's $eval function, eg: $($+(#, %nick))

Upvotes: 0

Patrickdev
Patrickdev

Reputation: 2381

Try the following:

/join $chr(35) $+ %nick

Explanation: A variable name must be a word on its own in your line of code for it to be recognised as a variable name. Therefore, #%nick will be interpreted as the string #%nick, whereas %nick will be interpreted as the name of the user issuing the command.

To append the value of a variable or identifier, you can use the identifier $+ which appends strings together. For instance, a $+ b will return ab.

Another issue arises when you use # $+ %nick, because # is an alias for the identifier $chan. This means that if I were to type !join in #test, it would try to join #testPatrickdev. Instead of using #, I use $chr(35) (which will in turn return the character #). It appends that to the value of the variable %nick.

Upvotes: 1

Related Questions