$chan (window)

From Scriptwiki
Revision as of 16:25, 22 April 2008 by Daveoh (talk | contribs)

Jump to: navigation, search

Using the $chan identifier you can get information about the channel(s) you're using.

$chan(N/#chan)

You can use a channel or a number for the first parameter. When you specify a channel, mIRC will return information about that particular channel, otherwise it returns information about the Nth channel. $chan returns the number of channels if N is 0 (zero).

When used without any parameters, $chan returns the channel where the current event (e.g. an on TEXT or on JOIN event) occured.

Note that if you get kicked from a channel and have the option 'leave channels open' enabled in the mIRC option dialog, $chan() will still contain that channel. If you want to get info about channels, you are really in, you'd have to use $comchan($me,0).

The following properties are available for $chan:

Property Description
topic the channel topic
mode the channel modes
key the channel key (if channel mode +k is set)
limit the channel limit (if channel mode +l is set)
ial $true when mIRC knows the addresses of all users on that channel, $inwho if mIRC is updating its address list, $false otherwise
logfile the logfile's path and filename for the channel
stamp $true when timestamps are enabled, $false if not
ibl $true if mIRC knows the banlist for this channel, $inmode if it's currently updating its banlist, $false if it doesn't
banlist same as ibl [undocumented]
status your status on that channel (e.g. joined, 'joining' or kicked)
inwho $true when mIRC is currently processing a /who request for that channel
wid the window ID for this channel
hwnd the window handle for this channel, can be used in DLLs

Examples

$chan(#help.script)  ;returns #help.script if you're on that channel, $null otherwise
$chan(#help.script).topic  ;returns the topic, which is currently set for #help.script

Note

When using $chan(N) to loop through all channels, it is usually advisable to use $comchan($me,n) instead.

The reason for this is if you get disconnected and have the setting 'Keep channels open' enabled, the channel still remains in $chan(n) list, when you reconnect to the server, for a short while before you've actually joined $chan(n).status would be set to 'Joining'.

If for some reason you can't connect, ie: you're banned, user limit reached, invite only, $chan(n).status would now be set to kicked.

For this reason, $chan(n) shouldn't be used to find what channels you're on unless you do extra checks. Example:

;clear %chans varible and set %i to total amount of channel windows open for this connection.
var %chans, %i = $chan(0)
;keep looping while we have aleast one more channel to check.
while (%i) {
  ;If we have joined that channel, add it to the list of chans.
  if ($chan(%i).status == joined) var %chans = $addtok(%chans,$chan(%i),32)
  ;decrease the value of %i
  dec %i
}
;return all the channels we've found we are in.
return %chans

Also See

  • $comchan Find common channels between you and another user. (And yourself)