all channels identifier $chans

By independentt on Sep 28, 2009

Join a lot of channels then

Syntax is //echo -a $chans

Will return all your channels you are currently in

alias chans {
  %xx = 1
  while (%xx <= $chan(0)) { set -u1 %chans $chan(%xx) $+ , $+ %chans | inc %xx }
  return %chans
}

Comments

Sign in to comment.
FordLawnmower   -  Sep 29, 2009

I've used it with /didtok sending hashtables to dialogs and it works like a dream.
You can also do some real fancy stuff if you tokenize the result and use $*.

 Respond  
Jethro   -  Sep 29, 2009

I like the fact that you can convert it into listing the 'entire population' of a channel:

//echo -a $regsubex($str(.,$nick(#,0)),/(.)/g,$nick(#,\n) $chr(32))

lol

 Respond  
sunslayer   -  Sep 29, 2009

lol nice ford, wonder where WoldDMT went off to... /me ponders

 Respond  
FordLawnmower   -  Sep 29, 2009

Nice regsubex sunslayer :)
I call that the WorldDMT trick cause that's where I learned it.
If someone doesn't understand how it works, a string of .(dots) is created based on the number of channels. So if there are 7 channels it's like this -->> .......
You use /./g to make it find all matches of the .(dot)
Each time it finds a .(dot) it will do a substitution, so you can use \n inside of $chan() - ie $chan(\n) to return each channel because \n will return the number of the current match or .(dot)
It's a sweet shortcut that can save lots of time and replace a lot of code.

 Respond  
sunslayer   -  Sep 29, 2009

while's are of course easier to learn, but regex is far more powerful than any while loop and is definitely worth learning imo

 Respond  
knoeki   -  Sep 29, 2009

'easy' and 'simple' are relative, and personally I think a while loop is more quickly learned than regex :p

I might be wrong though, it's all relative after all.. ;_)

 Respond  
Jethro   -  Sep 29, 2009

Nice. It sure is a lot simpler with $regsubex.

 Respond  
sunslayer   -  Sep 29, 2009

its easier to use a simple $regsubex to loop through your channels instead of using while and doesn't use any vars and takes much less code in general

alias chans return $regsubex($str(.,$chan(0)),/./g,$chan(\n) $chr(32))
 Respond  
gooshie   -  Sep 29, 2009

For a space deliminated channel list:

alias Chans {
  var %c,%i = 1
  while $chan(%i) {
    %c = %c $v1
    inc %i
  }
  if $isid { return %c }
  else { echo -a %c }
}

For a comma deliminated channel list:

alias Chans {
  var %c,%i = 1
  while $chan(%i) {
    %c = $addtok(%c,$v1,44)
    inc %i
  }
  if $isid { return %c }
  else { echo -a %c }
}
 Respond  
Jethro   -  Sep 29, 2009

@independentt: Your code will only return one channel. It won't return all the channels where you are. You should correct it and make it as such:

alias chans {
  var %xx = 1
  while (%xx <= $chan(0)) {
    var %yy = %yy $chan(%xx)
    inc %xx
  }
  return %yy
}

@blackvenomm666, the trigger is: //echo -a $chans

You can change

return %yy

to

echo # %yy

so that you can just use /chans to trigger the script and have all your channels echoed to you where you submit the alias.

 Respond  
blackvenomm666   -  Sep 28, 2009

maybe its just me but i couldnt get it to work

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.