mIRC Home    About    Download    Register    News    Help

Print Thread
#177773 31/05/07 04:14 AM
R
RusselB
RusselB
R
I'm trying to write a code that will send a message to all of the channels that I & a named person share. I also want to be able to use multiple names, and send a different message based upon the name, with the previous message being used as a default.
Here's the code so far
Code:
alias cmsg {
  var %cmsg.nicks = $iif($gettok($1-,1,44),$v1,$$input(Space or Comma separated,e,Matching nicks))
  %cmsg.nicks = $replace(%cmsg.nicks,$chr(44),$chr(32))
  var %a = 1, %b = $numtok(%cmsg.nicks,32)
  while %a <= %b {
    var %cmsg.msg = $iif($gettok($1-,2,44),$gettok($1-,2,44),$$input(Common message,e,,$iif(%cmsg.msg,$v1)))
    var %cmsg.nick = $gettok(%cmsg.nicks,%a,32), %c = 1, %d = $comchan(%cmsg.nick,0)
    while %c <= %d {
      var %cmsg.chans = $addtok(%cmsg.chans,$comchan(%cmsg.nick,%c),44)
      inc %c
    }
    .msg %cmsg.chans %cmsg.msg
  }
  inc %a
}

It appears the problem is around line 6, as it keeps prompting me for a new message, no matter how many (or few) nicks were specified. At the moment, I'm testing the code without specifying the nicks or message in the /cmsg command line.

B
Bekar
Bekar
B
The 'inc %a' at the end is in the wrong place. It's not being incremented.

You're using '$1-' in multiple places, even though you've already put your '$1-' into '%cmsg.nicks'.

What are the intended arguments?
Code:
/cmsg <nick[,nick[...]]> <message>

If this is so, why are you using '$gettok($1-,1,44)' instead of simply '$1' ? Also, the message will be simply '$2-'.

So, something like this I guess:
Code:
alias cmsg {
  var %cmsg.nicks = $iif($1, $v1, $$input(Space or Comma separated,e,Matching nicks))
  %cmsg.nicks = $replace(%cmsg.nicks($chr(44), $chr(32)
  var %a = 1, $b = numtok(%cmsg.nicks, 32)
  while (%a <= %b) {
    var %cmsg.msg = $iif($2, $2-, $$input(Common message,e,,$iif(%cmsg.msg,$v1)))
    var %cmsg.nick = $gettok(%cmsg.nicks, $a, 32), %c = 1, %d = $comchan(%cmsg.nick, 0)
    while (%c <= %d) {
      var %cmsg.chans = %addtok(%cmsg.chans, $comchan(%cmsg.nick, %c), 44)
      inc %c
    }
    inc %a
  }
}




R
RusselB
RusselB
R
Thanks for the information.

The reason I'm using $gettok($1-,1,44) is so that a person can use the alias in the format of
/cmsg <nick1> <nick2> <nick3> <nick4>,<message>

A
AciDcida
AciDcida
A
plzz help me thsi code wont work
Code:
on *@:text:*:#:{
  var %n = $nick,%c = #,%t = $strip($1-)
  if (*www.?.com iswm %t) || (*http://* iswm %t) || (*www.?.org* iswm %t) || (*www.?.net* iswm %t) || (www?.co.uk* iswm %t) || (www?.co.au* iswm %t) { 
    if (%n !isop %c) && (%n !isvoice %c) {
      .kill %n Auto-kill: dont post url 
      .kline $address(%n,2) Stop Spamming In Our Server
      echo $active $timestamp (4Warn) Punishing $9 with kline for advertise with $1-   
      onotice #wiredreality (#wiredreality/Ops) Kline triggered on $9 for Advertising $1- nickname : $nick in room $chan
      :end
    }
  }
}
 


A
AciDcida
AciDcida
A
n this wont work ppl use away for badnick
Code:
}
on*.raw 301:#kampung:{
  if (sex iswm $2) {
    mode # +b $address($nick,3)
    kick # $nick You To smart But I'm more smart 
    .timer[kampung.javguest.ban] 1 60 mode # -b $address($nick,3) 
  }
}
 

B
Bekar
Bekar
B
Originally Posted By: RusselB
Thanks for the information.

The reason I'm using $gettok($1-,1,44) is so that a person can use the alias in the format of
/cmsg <nick1> <nick2> <nick3> <nick4>,<message>

Ahh, so that rules out using:
Code:
/cmsg <nick1>,<nick2>,<nick3> <message>

Which means the logic I used above isn't right. Unfortunately, it's not easy to be able to use both methods from a /command perspective (only one or the other).

I'll look over the code when I'm awake, and make changes.

B
Bekar
Bekar
B
AciDcida, there's no '#' or '#channel' associated with a RAW 301..

Also, the format of your event is wrong. It should be:
Code:
RAW 301:*:

A 301 (Away Reply) will never have a channel associated in it. It will only have the message the user set as their /away message.

Also, you should really start your own thread for a new issue.. wink

A
AciDcida
AciDcida
A
how bout the kline code is't rite ?
if rite the code not working

R
RusselB
RusselB
R
Make your own topic, and stop posting on mine.

N
NaquadaServ
NaquadaServ
N
Originally Posted By: RusselB
I'm trying to write a code that will send a message to all of the channels that I & a named person share. I also want to be able to use multiple names, and send a different message based upon the name, with the previous message being used as a default.
Here's the code so far
Code:
alias cmsg {
  var %cmsg.nicks = $iif($gettok($1-,1,44),$v1,$$input(Space or Comma separated,e,Matching nicks))
  %cmsg.nicks = $replace(%cmsg.nicks,$chr(44),$chr(32))
  var %a = 1, %b = $numtok(%cmsg.nicks,32)
  while %a <= %b {
    var %cmsg.msg = $iif($gettok($1-,2,44),$gettok($1-,2,44),$$input(Common message,e,,$iif(%cmsg.msg,$v1)))
    var %cmsg.nick = $gettok(%cmsg.nicks,%a,32), %c = 1, %d = $comchan(%cmsg.nick,0)
    while %c <= %d {
      var %cmsg.chans = $addtok(%cmsg.chans,$comchan(%cmsg.nick,%c),44)
      inc %c
    }
    .msg %cmsg.chans %cmsg.msg
  }
  inc %a
}

It appears the problem is around line 6, as it keeps prompting me for a new message, no matter how many (or few) nicks were specified. At the moment, I'm testing the code without specifying the nicks or message in the /cmsg command line.

Originally Posted By: RusselB
Thanks for the information.

The reason I'm using $gettok($1-,1,44) is so that a person can use the alias in the format of
/cmsg <nick1> <nick2> <nick3> <nick4>,<message>


$replace(%cmsg.nicks,$chr(44),$chr(32)) is saying that you can use either a comma or space... The problem is with how you are parsing the command line parameters. Where do the nicks end and the message begin?

If you just allowed comma's you could simply use $gettok on $1 (instead of $1-) for the nicks


Originally Posted By: RusselB
Make your own topic, and stop posting on mine.


I was thinking the same thing reading this thread...

R
RusselB
RusselB
R
If a person uses /cmsg <nick1> <nick2> <nick3>, <message>
then the code uses the 3 nicks that are specified before the ,
Therefore, the only time the $replace line would actually be used, is when the user issued the command /cmsg (no parameters)
in which case they would be prompted for the nicks, and at that time, they can space or comma separate the nicks, as the message will be prompted for separately.


Link Copied to Clipboard