Difference between revisions of "$chan (window)"

From Scriptwiki
Jump to: navigation, search
m
m ("See Also")
 
(9 intermediate revisions by 6 users not shown)
Line 6: Line 6:
  
 
When used without any parameters, $chan returns the channel where the current event (e.g. an [[on_text|on TEXT]] or [[on_join|on JOIN]] event) occured.
 
When used without any parameters, $chan returns the channel where the current event (e.g. an [[on_text|on TEXT]] or [[on_join|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:
 
The following properties are available for $chan:
  
<table border="1">
+
{| style="width:100%;"
<tr><td>Property</td><td>Description</td></tr>
+
|-
<tr><td>topic</td><td>the channel's topic</td></tr>
+
| style="width:10%;" | '''''Property'''''  || style="width:90%;" | '''''Description'''''
<tr><td>mode</td><td>the channel modes</td></tr>
+
|-
<tr><td>key</td><td>the channel key (if channel mode +k is set)</td></tr>
+
| topic   || the channel topic
<tr><td>limit</td><td>the channel limit (if channel mode +l is set)</td></tr>
+
|-
<tr><td>ial</td><td>$true when mIRC knows the addresses of all users on that channel, $inwho if mIRC is updating its address list, $false otherwise</td></tr>
+
| mode   || the channel modes
<tr><td>logfile</td><td>the logfile's path and filename for this channel</td></tr>
+
|-
<tr><td>stamp</td><td>$true when timestamps are enabled, $false if not</td></tr>
+
| key     || the channel key (if channel mode +k is set)
<tr><td>ibl</td><td>$true if mIRC knows the banlist for this channel, $inmode if it's currently updating its banlist, $false if it doesn't</td></tr>
+
|-
<tr><td>status</td><td>your status on that channel (e.g. ''joined'' or ''kicked'')</td></tr>
+
| limit   || the channel limit (if channel mode +l is set)
<tr><td>inwho</td><td>$true when mIRC is currently processing a /who request for that channel</td></tr>
+
|-
<tr><td>wid</td><td>the window ID for this channel<td></tr>
+
| ial     || $true when mIRC knows the addresses of all users on that channel, $inwho if mIRC is updating its address list, $false otherwise
<tr><td>hwnd</td><td>the window handle for this channel, can be used in DLLs</td></tr>
+
|-
</table>
+
| logfile || the logfile's path and filename for the channel
<br>
+
|-
 +
| 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
 +
|-
 +
| idle    || shos how long it has been from the last message in the channel (in seconds)
 +
|}
 +
 
 +
== 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#Example|$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
 +
 
 +
== See Also ==
 +
* [[$comchan]] Find common channels between you and another user. (And yourself)
  
$chan(#help.script) returns ''#help.script'' if you're on that channel, ''$null'' otherwise<br>
 
$chan(#help.script).topic returns the topic, which is currently set for #help.script
 
 
[[Category:Window Identifiers]]
 
[[Category:Window Identifiers]]

Latest revision as of 09:25, 25 July 2009

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
idle shos how long it has been from the last message in the channel (in seconds)

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

See Also

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