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))
}
}
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-
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
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...)
A few things/questions/suggestions...
"if ($nick == $me) { halt }" is useless, because the bot wouldn't be able to activate the event itself anyways.
You can just set %lol as a local variable, so that you don't have to unset it every time the script is run.*
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.*
*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 )
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