[color:#004400]
; If we are joining the channel rather than if someone else is...
[/color]
on me:^*:JOIN:#:{
[color:#004400]
; Create a variable called %Me.JOIN.1.#mIRC (if the $cid happens to be 1). This will allow us to
; check in the following raw events to see if we are currently in the process of joining a channel.
; That way, we won't block ourselves from using commands that would generate the same raw numerics
; again.
[/color]
set -u600 $+(%,Me.JOIN.,$cid,.,$chan) 0 0
[color:#004400]
; Issue the two commands that will fill up the Internal Address List (IAL) and Internal Ban List
; (IBL). /who #channel will fill the IAL, /mode #channel +b will fill the ban list.
[/color]
.raw $+(WHO $chan,$crlf,MODE $chan +b)
[color:#004400]
; And halt the default * Now talking in #channel.
[/color]
haltdef
}
[color:#004400]
; /ChanStats [#channel]
;
; This command allows us to recreate the join stats, just as if we rejoined the channel. It does this
; by basically issuing the same commands that the server would have sent us when we joined the channel,
; in the same order as they were initially sent. Also, this command can be used on a channel we're not
; on to give partial stats for it. If the channel is +s, then a lot of the information will be missing.
; If any of the nicks on the channel are +i, they will be missing as well. Thus the stats will only be
; partial if we're not on the channel.
[/color]
alias ChanStats {
[color:#004400]
; Allow /ChanStats works on the active channel; if $active is not a channel, it does nothing
; /ChanStats mIRC gets #mIRC's stats (adds the # itself)
; /ChanStats #mIRC
[/color]
if ($1) set %chan #$1
elseif (#* iswm $active) set %chan $active
[color:#004400]
; Make sure we have a target channel to work with, however we got it.
[/color]
if (%chan) {
[color:#004400]
; Recreate the %Me.JOIN.1.#mIRC, just as if we were joining the channel initially. The two zeros
; are going to be used to hold the number of opers and the number of away nicks.
[/color]
set -u600 $+(%,Me.JOIN.,$cid,.,%chan) 0 0
[color:#004400]
; Fake the join by getting all the same command raw numerics resent in the same order they would
; arrive in a normal join. Send them all in one data packet to ensure they arrive in the correct
; order.
;
; /topic #mIRC get the channel topic
; /names #mIRC get the nicklist
; /mode #mIRC get the channel modes (+smtni)
; /who #mIRC fill the IAL and count the opered/away nicks
; /mode #mIRC b fill the IBL
[/color]
.raw $+(TOPIC %chan,$crlf,NAMES %chan,$crlf,MODE %chan,$crlf,WHO %chan,$crlf,MODE %chan +b)
}
}
[color:#004400]
; Halt the joining numerics on me:*:JOIN:
;
; Most of these just check to see if this is a channel we're joining or using /ChanStats on and then
; halt the default text so we can still use the commands normally when we're not joining and can see
; their default output.
;
; 332 - Topic line
[/color]
raw 332:*: if ($eval($+(%,Me.JOIN.,$cid,.,$2),2) != $null) halt
[color:#004400]
; 333 - Topic set by and time it was sent
;
; All we need to do is save who set the topic and when. We'll parse it all out later on in the process.
[/color]
raw 333:*:{
if ($eval($+(%,Me.JOIN.,$cid,.,$2),2) != $null) {
set $+(%,Me.JOIN.,$cid,.,$2) $eval($+(%,Me.JOIN.,$cid,.,$2),2) $3-
halt
}
}
[color:#004400]
; 353 - /names #channel (the nicklist)
[/color]
raw 353:*: if ($eval($+(%,Me.JOIN.,$cid,.,$3),2) != $null) halt
[color:#004400]
; 366 - End of /NAMES list.
[/color]
raw 366:*: if ($eval($+(%,Me.JOIN.,$cid,.,$2),2) != $null) halt
[color:#004400]
; 324 - /mode #channel reply
[/color]
raw 324:*: if ($eval($+(%,Me.JOIN.,$cid,.,$2),2) != $null) halt
[color:#004400]
; 329 - Channel creation time
;
; Save this to be parsed out later as well.
[/color]
raw 329:*:{
if ($eval($+(%,Me.JOIN.,$cid,.,$2),2) != $null) {
set $+(%,Me.JOIN.,$cid,.,$2) $eval($+(%,Me.JOIN.,$cid,.,$2),2) $3
halt
}
}
[color:#004400]
; 352 - /who reply - IAL Filler
;
; This is really the workhorse portion of the script. It updates the Oper countand the Away count by
; checking $7 for * and G, respectively. Then it re-stores the information in %Me.JOIN.1.#mIRC.
[/color]
raw 352:*:{
[color:#004400]
; If we're joining or using /ChanStats
[/color]
if $eval($+(%,Me.JOIN.,$cid,.,$2), 2) != $null {
[color:#004400]
; Parse out the variable into 3 portions:
;
; Oper count is the first "word" which wil be a number.
;
; Away count is the second "word", also a number.
;
; Other is the rest of the data we're storing for later, so we still want to save it for
; later and don't want to lose it.
[/color]
var %Oper.Count = $gettok($ifmatch, 1, 32)
var %Away.Count = $gettok($ifmatch, 2, 32)
var %Other = $gettok($ifmatch, 3-, 32)
[color:#004400]
; Check to see if this person is an oper.
[/color]
if (* isin $7) inc %Oper.Count
[color:#004400]
; Check to see if they are set /away.
[/color]
if (G isin $7) inc %Away.Count
[color:#004400]
; Now that we have updated our oper and away counts, re-set the %Me.JOIN.1.#mIRC variable to hold
; all the values.
[/color]
set $+(%,Me.JOIN.,$cid,.,$2) %Oper.Count %Away.Count %Other
[color:#004400]
; Since we're joining or using /ChanStats, we don't want to see the default output (or your
; scripted output, done elsewhere). Halt it.
[/color]
halt
}
}
[color:#004400]
; 315 - End of /WHO list.
[/color]
raw 315:*: if ($eval($+(%,Me.JOIN.,$cid,.,$2), 2) != $null) halt
[color:#004400]
; 367 - /mode #mIRC +b - IBL filler
[/color]
raw 367:*: if ($eval($+(%,Me.JOIN.,$cid,.,$2), 2) != $null) halt
[color:#004400]
; 368 - End of Channel Ban List
;
; This is the end of the road for this script, the last raw numeric event we we are going to see. From
; here, we only need to check to see if we need to escape the event if we are NOT joining or using
; /ChanStats. If we are then we will call /ChanStatsReport #mIRC to generate the full report listing
; that we've come to love and respect. Once control returns here, we will halt the default text.
[/color]
raw 368:*:{
if ($eval($+(%,Me.JOIN.,$cid,.,$2), 2) == $null) return
ChanStatsReport $2
halt
}
[color:#004400]
; /ChanStatsReport <#channel>
;
; This is the section that produces the output. If you want to modify what the output of the script
; looks like, you need only modify the echo commands and possibly leave out the /linesep commands if
; you don't like those.
;
; This command is where we will parse the %Me.JOIN.1.#mIRC variable we've been creating and building
; throughout this process.
[/color]
alias ChanStatsReport {
[color:#004400]
; If we have not used /ChanStats or joined the channel, halt the alias due to lack of data to work
; with.
[/color]
if ($eval($+(%,Me.JOIN.,$cid,.,$1), 2) != $null) {
[color:#004400]
; Now, parse out each segment "word" of %Me.JOIN.1.#mIRC into its parts. In this case, we'll use
; descriptive variable names to hold the data. This is only done for readability. The data could
; just as easily have been used directly within each of of the echo commands responsible for
; outputting the formatted data.
;
; Token Value
; 1 integer count of opers
; 2 integer count of nicks marked /away
; 3 string containing who set the topic
; 4 ctime of when the topic was set
; 5 ctime of when the channel was created
[/color]
var %Oper.Count = $gettok($ifmatch, 1, 32)
var %Away.Count = $gettok($ifmatch, 2, 32)
var %Topic.Set.By = $gettok($ifmatch, 3, 32)
var %Topic.Set.Time = $asctime($gettok($ifmatch, 4, 32), yyyy/mm/dd HH:nn:ss)
var %Channel.Created = $asctime($gettok($ifmatch, 5, 32), yyyy/mm/dd HH:nn:ss)
[color:#004400]
; Again, for readability, $1 (which holds the channel name) is renamed to %chan simply because
; most scripters are used to seeing $chan; that's only one character different than %chan so the
; meaning of the commands/$identifiers used is more immediately obvious.
[/color]
var %chan = $1
[color:#004400]
; If you want to modify the look and feel of the script, here is where you will start and finish.
; The following lines try to imitate mIRC itself fairly closely. They are delayed, of course, from
; when you would normally see them since we have reordered their display order; for instance,
; channel creation time is not displayed at all by default, but this script puts it right after
; the "default looking" * Now talking in #mIRC" line.
;
; Each of the following lines is a fairly straightforward echo. The only one that is not is the
; long nick totals line.
;
; The entire stats block is surrounded by line separators to set it off from the rest of the text
; in the channel.
;
; .-=[ START SCRIPT MODIFICATION HERE ]=-.
[/color]
linesep %chan
echo $color(join) -bfirt %chan * Now talking in %chan $+([,$asctime($ctime, yyyy/mm/dd HH:nn:ss),])
echo $color(join) -bfirt %chan * Created: %Channel.Created
echo $color(topic) -bflirt %chan * Topic is: $chan(%chan).topic
echo $color(topic) -bfirt %chan * Set by %Topic.Set.By $+([,%Topic.Set.Time,])
[color:#004400]
; The next line is really only a little bit complex looking because it is checking the values of
; each item it is describing. If the value is a 1, we don't want to have it say 1 nicks. Proper
; grammer dictates that we use 0 nicks, 1 nick and 2 or more nicks. This pattern is followed all
; the way through for each value reported on.
;
; Since the line is so long, liberal use has been made of the line continuation character, both to
; format it for display in a forum and to make looking at each section a little easier even in the
; mIRC editor.
[/color]
echo $color(join) -bfirt %chan * $+([, $&
$nick(%chan, 0) Nick,$iif($nick(%chan, 0) != 1,s),][, $&
$nick(%chan, 0, o) Op,$iif($nick(%chan, 0, o) != 1,s),][, $&
$nick(%chan, 0, v) Voice,$iif($nick(%chan, 0, v) != 1,s),][, $&
$nick(%chan, 0, r) Regular][, $&
%Oper.Count Oper, $iif(%Oper.Count != 1,s),][, $&
%Away.Count Away][, $&
$ibl(%chan, 0) Ban,$iif($ibl(%chan, 0) != 1,s),])
linesep %chan
[color:#004400]
; .-=[ STOP SCRIPT MODIFICATION HERE ]=-.
;
; Clean up by unsetting the variable we've been using so you can use the commands whose outputs we
; have captured for our own purposes.
[/color]
unset $+(%,Me.JOIN.,$cid,.,$1)
}
}