ChannelList

By PowerScripters on Jan 21, 2010

If u type: !chanlist the bot will show all the channel's he is in.

Instructions:
Press Alt+R
Tab Remote
File -> New
Paste below
Type !chanlist for the list

on *:TEXT:!chanlist:#: {
  if ($nick == $me) { halt }
  else {
    unset %lol
    var %total = $comchan($nick,0), %x = 1
    while ( %x <= %total ) {
      set %lol %lol $+ , $+ $comchan($nick,%x)
      inc %x
    }
    msg # I'm in: $replace(%lol,$chr(44),$chr(32))
  }
}

Comments

Sign in to comment.
gooshie   -  Jan 22, 2010

Jethro
I like that better than the regex

 Respond  
Jethro   -  Jan 21, 2010

If you're going to use a while loop for listing all the channels horizontally, you might as well do this:

on *:TEXT:!chanlist:#:while ($chan($0)) tokenize 32 $1- $v1 | .msg # I'm in: $2-

And for $comchan:

on *:TEXT:!chanlist:#:while ($comchan($nick,$0)) tokenize 32 $1- $v1 | .msg # $me and $nick are in: $2-
 Respond  
gooshie   -  Jan 21, 2010
on $*:TEXT:/^!chanlist$/iS:#:msg # I'm in: $regsubex($str(.,$chan(0)),/(.)/g,$chan(\n) $chr(32))

no need for $+()

on $*:TEXT:/^!chanlist$/iS:#: {
  var %i 1,%m
  while $chan(%i) { %m = %m $v1 | inc %i }
  msg # I'm in: %m
}
 Respond  
napa182   -  Jan 21, 2010

well if you still want to use a while loop then make it abit better
to show the channels the bot is in

on $*:TEXT:/^!chanlist$/iS:#: {
  var %a = $chan(0)
  while (%a) {
    var %m $addtok(%m,$chan(%a),32)
    dec %a
  }
  msg # I'm in: %m
}

and $comchan so it would show the channels which both you and the bot are on.

on $*:TEXT:/^!chanlist$/iS:#: {
  var %a = $comchan($nick,0)
  while (%a) {
    var %m $addtok(%m,$comchan($nick,%a),32)
    dec %a
  }
  msg # Me and $nick are in these same channels: %m
}

but i would still go the $regsubex way as i stated before

 Respond  
Jethro   -  Jan 21, 2010

Unless the script is constructed as such:

on *:text:!chanlist:#:{
  if ($address($me,2) == $wildsite) {

Let's say you and the client running the code share the same !@host and you want it to trigger by you and no one else.

 Respond  
Meta   -  Jan 21, 2010

GuitarMasterx7, those two would actually be near opposites in a way.

on *:INPUT:#{
  if ($1 == !chanlist) {

Suggests to have the script trigger when the bot or person with the script says !chanlist. while...

on *:TEXT:!chanlist:#: {
  if ($nick == $me) { halt }

Suggests to have the script trigger if anyone other than the bot or person with the script says !chanlist... (although as mentioned a few times, the if statement is useless since the bot or person wouldn't be able to trigger their own on text events anyways...)

 Respond  
Jethro   -  Jan 21, 2010

I think using $regusbex is much better than using a while loop for this sort of operation (there are a few variations I've seen)...but it's a matter of preference, really.

 Respond  
Jethro   -  Jan 21, 2010

GuitarMasterx7, you cannot put the command in the input event as a match text. It has to be done as such:

on *:INPUT:#: {
  if ($1 == !chanlist) {
 Respond  
GuitarMasterx7   -  Jan 21, 2010

idk if im right buuuuut

if its this

on *:TEXT:!chanlist:#: {
  if ($nick == $me) { halt }

shouldnt it just be

on *:INPUT:!chanlist:#: {
 Respond  
Battlemonkey   -  Jan 21, 2010

No need for a "if ($nick == $me) { halt }" because on TEXT events are only triggered by other users.

 Respond  
Meta   -  Jan 21, 2010

A few things/questions/suggestions...

  1. "if ($nick == $me) { halt }" is useless, because the bot wouldn't be able to activate the event itself anyways.

  2. You can just set %lol as a local variable, so that you don't have to unset it every time the script is run.*

  3. Why go through the trouble of adding a comma between the channels (without spaces between the channels and the commas), only to replace the comma with a space immediately after? var %lol = %lol $comchan($nick,%x) seems much easier.*

  4. Is this script intentionally made to only list the channels that both the nick triggering the event and the bot is in? (as opposed to actually listing all of the channels the bot is in...) Just wondering...

*These are unless you're actually using the variable %lol in that format for some other event.

For fun, $regsubex method:

on *:TEXT:!chanlist:#: msg # Im in: $regsubex($str(.,$comchan($nick,0)),/./g,$comchan($nick,\n) $chr(32))

( five edits later... o_o )

 Respond  
napa182   -  Jan 21, 2010

this is to show the channels the bot is in.

on $*:TEXT:/^!chanlist$/iS:#: { msg # I'm in: $regsubex($str(-,$chan(0)),/(.)/g,$+($chan(\n),$chr(32))) }

on the code you have posted you used $comchan so it would show the channels which both you and the bot are on.
if thats what you are going for then do

on $*:TEXT:/^!chanlist$/iS:#: { msg # Me and $nick are in these same channels: $regsubex($str(-,$comchan($nick,0)),/(.)/g,$+($comchan($nick,\n),$chr(32))) }

also the

if ($nick == $me) { halt }

is useless hence you cant trigger ur own on text events

 Respond  
Shiny   -  Jan 21, 2010

Lol i Search that script Yesterday

 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.