All pastes #2011007 Raw Edit

ChannelWatcher By: Kool-aid_Man

public text v1 · immutable
#2011007 ·published 2010-12-05 09:13 UTC
rendered paste body
/*
Things to get done:
*Lots more...
--Menus need work
--Customization dialog?
--Tabs? Channel filtering (need log)

/aline [c] <@name> <text>     add line to list
/cline [c] <@name> <N>        changes the color of the Nth line to color C
/dline [c] <@name> <N[-N2]>   delete Nth line through N2th line
/iline [c] <@name> <N> <text> insert line at Nth line
/rline [c] <@name> <N> <text> replace Nth line
/sline [c] <@name> <N>        select Nth line

-l for listbox
*/
;also a comment

on *:LOAD: {
  set %ChannelWatch.chans
  set %ChannelWatch.colors 3,4,5,6,7,8,9,10,11,12,13,14,15
  set %ChannelWatch.colors.On-Off $true
  set %ChannelWatch.i 1
  set %ChannelWatch.msg
  set %ChannelWatch.nc ),)-,},}-,],]-,;,:,\,\-,/,/-,>,>-,»
  set %ChannelWatch.tmp
  .disable #ChannelWatch.T/A/N/I
  echo -se ChannelWatch Load Sucessfull! ( $+ $script $+ )
  echo -s To use ChannelWatch right-click in the Status Window or any Channel and select ChannelWatch>Run from the popup window
  echo -s All channels currently open will be added to the list of channels being Watched.
  echo -s Joining a channel will automatically cause it to be Watched.
  echo -s Parting (leaving) a channel will automatically cause it to be removed from the list of channels currently being Watched.
  echo -s You can Add/Remove a channel by right clicking...
  echo -s -*In a channel: Select ChannelWatch>Add/Remove This Channel
  echo -s -*In the @ChannelWatch window:
  echo -s ---*To Add: right-click anywhere and select: Add a Channel
  echo -s ---*To Remove: Select a channel in the list to the right, right-click anywhere and select: Remove #CHANNELname
  echo -s Here is the format for the messages that will appear in the @ChannelWatch window:
  echo -s For normal messages: [HH:nn:ss] #CHANNEL <nick> message
  echo -s -ex: 1,3[02:01:50] #hackthissite <JonDoe> How's it going?
  echo -s For normal messages YOU send: [HH:nn:ss] #CHANNEL <YourNick> message
  echo -s -ex: 3[02:03:27] #hackthissite <You> Just fine!
  echo -s For emotes/actions: [HH:nn:ss] #CHANNEL *nick message
  echo -s -ex: 3,1[02:03:48] #hackthissite6 *JonDoe waves to everyone
  echo -s For emotes/actions YOU send: [HH:nn:ss] #CHANNEL *YourNick message
  echo -s -ex: 3[02:04:00] #hackthissite6 *You wave back
  echo -s For ALL notices: [HH:nn:ss] - CHANNEL/NICK - message
  echo -s -ex 5[02:04:12] - JonDoe - You're my friend!
  echo -s -*ChanServ, NickServ, and MemoServ notices will not appear in the @ChannelWatch window
  echo -s At the moment @ChannelWatch is not ment to be used with multiple server connections, however as long as there are no mulitple
  echo -s instances of the same channel being watched I forsee no problems ariseing from this lack.
}
;The command that begins it all and the startup functions necessary to it's performance.
alias ChannelWatch {
  ;Initialize variables
  set %ChannelWatch.chans
  set %ChannelWatch.colors 3,4,5,6,7,8,9,10,11,12,13,14,15
  set %ChannelWatch.colors.On-Off $true
  set %ChannelWatch.i 1
  set %ChannelWatch.msg
  set %ChannelWatch.nc ),)-,},}-,],]-,;,:,\,\-,/,/-,>,>-,»
  set %ChannelWatch.tmp
  ;Create custom window @ChannelWatch
  window -dek0l12mRSv @ChannelWatch -1 -1 700 500
  ;Enables the on:TEXT/ACTION/NOTICE/INPUT events
  .enable #ChannelWatch.T/A/N/I
  ;Adds all channels to the listbox, and to %ChannelWatch.chans
  set %ChannelWatch.i 1
  while (%ChannelWatch.i <= $chan(0)) {
    ChannelWatch.AddChan $chan(%ChannelWatch.i)
    inc %ChannelWatch.i
  }
}
;$chr(35) == #
alias ChannelWatch.AddChan {
  ;Checks that channel name is prepended with '#' and that
  ;'#' does not appear more than once (to eliminate adding multiple channels)
  if (($left($$1,1) == $chr(35)) && ($chr(35) !isin $right($$1,-1))) {
    ;Add channel to the listbox
    aline -l @ChannelWatch $$1
    ;Colors channel name if there is still a color available for it [range: 3-15 (starts with 3, then 4,...)]
    cline -ml $ChannelWatch.Color(AddChan) @ChannelWatch $fline(@ChannelWatch,$$1,1,1)
    ;Stores the channels for later reference
    set %ChannelWatch.chans $addtok(%ChannelWatch.chans,$$1,44)
  }
  else {
    if ($left($$1,1) != $chr(35)) { echo 4 @ChannelWatch ***ERROR: Channel you attempted to add was not prepended with '#'. }
    elseif ($chr(35) isin $right($$1,-1)) { echo 4 @ChannelWatch ***ERROR: You attempted to add more than one channel at a time ('#' was in the channel name other than the first character). }
  }
}
alias ChannelWatch.RemChan {
  ;Checks that channel name is prepended with '#' and that
  ;'#' does not appear more than once (to eliminate adding multiple channels)
  if (($left($$1,1) == $chr(35)) && ($chr(35) !isin $right($$1,-1))) {
    ;Adds the channel's colour back into the Available colours list
    $ChannelWatch.color(RemChan,$line(@ChannelWatch,$fline(@ChannelWatch,$$1,1,1),1).color)
    ;Removes a channel from the listbox
    dline -l @ChannelWatch $fline(@ChannelWatch,$$1,1,1)
    ;Removes the channel from %ChannelWatch.chans
    set %ChannelWatch.chans $remtok(%ChannelWatch.chans,$$1,1,44)
  }
  else {
    if ($left($$1,1) != $chr(35)) { echo 4 -e @ChannelWatch ***ERROR: Channel you attempted to remove was not prepended with '#'. }
    elseif ($chr(35) isin $right($$1,-1)) { echo 4 -e @ChannelWatch ***ERROR: You attempted to remove more than one channel at a time (An instance of '#' occured other than the as first character). }
  }
}
alias ChannelWatch.Color {
  if ($$1 == AddChan) {
    if (%ChannelWatch.colors != $null) {
      set %ChannelWatch.tmp $gettok(%ChannelWatch.colors,1,44)
      set %ChannelWatch.colors $deltok(%ChannelWatch.colors,1,44)
      return %ChannelWatch.tmp
    }
    else { return 1 }
  }
  elseif ($$1 == RemChan) {
    if ($$2 isnum 3-15) {
      set %ChannelWatch.colors $sorttok($addtok(%ChannelWatch.colors,$$2,44),44,n)
    }
    else { return }
  }
}

menu @ChannelWatch {
  Add a Channal:{
    var %ChannelWatch.tmp $?="Enter ONE channel you want to add. $crlf $+ Make sure to prefix the channel with '#'."
    ChannelWatch.AddChan %ChannelWatch.tmp
  }
  $iif($sline(@ChannelWatch,1) == $null,Select The Channel To Remove,Remove $sline(@ChannelWatch,1)): {
    if ($sline(@ChannelWatch,1) == $Null) { echo 4 -e @ChannelWatch ***ERROR: To remove a channel please select it in the listbox first. }
    elseif ($?!="This will remove $sline(@ChannelWatch,1) from the Watch list. $ctrl $+ Continue?" == $true) {
      ChannelWatch.RemChan $sline(@ChannelWatch,1)
    }
  }
  ;enable/disable colours, %ChannelWatch.colors.On-Off == $true or $false, $true = currently enabled
  Turn Colors $iif(%ChannelWatch.colors.On-Off,OFF,ON) {
    $iif(%ChannelWatch.colors.On-Off,set %ChannelWatch.colors.On-Off $false,set %ChannelWatch.colors.On-Off $true)
  }
}
;Which Run/Stop is better? the Status version or the Channel version?
menu Status {
  ChannelWatch
  .$iif($window(@ChannelWatch) == $null,Run,Stop):{
    if ($window(@ChannelWatch) != $null) {
      .disable #ChannelWatch.T/A/N/I
      window -c @ChannelWatch
    }
    elseif ($window(@ChannelWatch) == $null) { ChannelWatch }
  }
}
menu Channel {
  ChannelWatch
  .$iif($window(@ChannelWatch) == $null,Run):/ChannelWatch
  .$iif($window(@ChannelWatch) == @ChannelWatch,Stop):{
    .disable #ChannelWatch.T/A/N/I
    window -c @ChannelWatch
  }
  ;To add/remove the $active channel based on:
  ;--IF @ChannelWatch exists
  ;--To add: $active channel is NOT in %ChannelWatch.chans
  ;--To remove: $active channel IS in %ChannelWatch.chans
  .$iif(($window(@ChannelWatch) == @ChannelWatch) && ($active !isin %ChannelWatch.chans),Add This Channel):ChannelWatch.AddChan $active
  .$iif(($window(@ChannelWatch) == @ChannelWatch) && ($active isin %ChannelWatch.chans),Remove This Channel):ChannelWatch.RemChan $active
}

;Disables the on:TEXT/ACTION/NOTICE/INPUT events when @ChannelWatch is closed
on *:CLOSE:@ChannelWatch:{ .disable #ChannelWatch.T/A/N/I }

;All events that control the manipulation of text for display within @ChannelWatch
#ChannelWatch.T/A/N/I on
/*For all input when entered into @ChannelWatch:
-Leaves all input to mIRC's processes if first character is == / (is a command)
-Sends everything else (standard text) to the channel selected in the listbox via /msg
echoes that text into @ChannelWatch
Prepends echoed text with the time, selected channel, and nick (user's)
If colours are enabled it colours the time and channel to match their colour in the listbox
--The colour is applied to the foreground, the background is blank
--Doesn't colour anything if the colour is less than 3 (for contrast purposes)
Includes a Nick Completer (NC) that works when the first "word" is apended with "$"
*/
on *:INPUT:@ChannelWatch:{
  ;/me support through the use of /describe <#CHANNEL> <msg>. Supports multiple send
  if ($$1 == /me) {
    set %ChannelWatch.i 1
    set %ChannelWatch.msg $$2-
    while (%ChannelWatch.i <= $sline(@ChannelWatch,0)) {
      describe $sline(@ChannelWatch,%ChannelWatch.i) $$2-
      ;Echo the msg coloured if the colour > 2 into @ChannelWatch
      if (($line(@ChannelWatch,$sline(@ChannelWatch,%ChannelWatch.i).ln,1).color isnum 3-15) && (%ChannelWatch.colors.On-Off)) {
        echo $line(@ChannelWatch,$sline(@ChannelWatch,%ChannelWatch.i).ln,1).color @ChannelWatch $time([HH:nn:ss]) $sline(@ChannelWatch,%ChannelWatch.i) 6 $+ * $+ $me %ChannelWatch.msg
      }
      ;Echo the message into @ChannelWatch if previous statement fails (colour <= 2)
      else { echo @ChannelWatch $time([HH:nn:ss]) $sline(@ChannelWatch,%ChannelWatch.i) 6 $+ * $+ $me %ChannelWatch.msg }
      inc %ChannelWatch.i
    }
    halt
  }
  ;Filter out commands (that arent /me)
  elseif ($left($1,1) != /) {
    ;No channel selected error
    if ($sline(@ChannelWatch,1) == $null) { echo 4 @ChannelWatch ***ERROR: You must select a channel the from listbox before sending a message. }
    else {
      set %ChannelWatch.msg $1-
      set %ChannelWatch.i 1
      ;NickCompleter using $
      if ($right($1,1) == $) {
        set %ChannelWatch.msg $ialchan($left($$1,-1) $+ *,$sline(@ChannelWatch,1),1).nick $+ $gettok(%ChannelWatch.nc,$rand(1,$numtok(%ChannelWatch.nc,44)),44) $2-
      }
      if ($sline(@ChannelWatch,0) == 1) {
        ;Send the message to the selected channel
        msg $sline(@ChannelWatch,1) %ChannelWatch.msg
        ;Echo the msg coloured if the colour > 2 into @ChannelWatch
        if (($line(@ChannelWatch,$sline(@ChannelWatch,1).ln,1).color > 2) && (%ChannelWatch.colors.On-Off)) {
          echo @ChannelWatch  $+ $line(@ChannelWatch,$sline(@ChannelWatch,1).ln,1).color $+ $time([HH:nn:ss]) $sline(@ChannelWatch,1) $+  < $+ $nick $+ > %ChannelWatch.msg
        }
        ;Echo the message into @ChannelWatch if previous statement fails (colour <= 2)
        else { echo @ChannelWatch $time([HH:nn:ss]) $sline(@ChannelWatch,1) < $+ $me $+ > %ChannelWatch.msg }
      }
      elseif ($sline(@ChannelWatch,0) > 1) {
        while (%ChannelWatch.i <= $sline(@ChannelWatch,0)) {
          ;Send the message to the selected channel
          msg $sline(@ChannelWatch,%ChannelWatch.i) %ChannelWatch.msg
          ;Echo the msg coloured if the colour > 2 into @ChannelWatch
          if (($line(@ChannelWatch,$sline(@ChannelWatch,%ChannelWatch.i).ln,1).color > 2) && (%ChannelWatch.colors.On-Off)) {
            echo @ChannelWatch  $+ $line(@ChannelWatch,$sline(@ChannelWatch,%ChannelWatch.i).ln,1).color $+ $time([HH:nn:ss]) $sline(@ChannelWatch,%ChannelWatch.i) $+  < $+ $nick $+ > %ChannelWatch.msg
          }
          ;Echo the message into @ChannelWatch if previous statement fails (colour <= 2)
          else { echo @ChannelWatch $time([HH:nn:ss]) $sline(@ChannelWatch,%ChannelWatch.i) < $+ $me $+ > %ChannelWatch.msg }
          inc %ChannelWatch.i
        }
      }
    }
  }
}
/*Echoes all standard conversation text originating from
- - a Watched channel (%ChannelWatch.chans) to @ChannelWatch.
Prepends that text with the originating time, channel, and nick.
If colours are enabled it colours the time and channel to match their colour in the listbox
--the colour is applied to the background, not the foreground
--doesn't colour anything if the colour is less than 3 (for contrast purposes)
*/
on *:TEXT:*:%ChannelWatch.chans:{
  if ($window(@ChannelWatch) == @ChannelWatch) {
    /*The following IF and ELSE statements could be replaced with this:
    echo @ChannelWatch $iif(($line(@ChannelWatch,$fline(@ChannelWatch,$chan,1,1),1).color > 2) && (%ChannelWatch.colors.On-Off),echo @ChannelWatch 1 $+ $chr(44) $+ $line(@ChannelWatch,$fline(@ChannelWatch,$chan,1,1),1).color $+ $time([HH:nn:ss]) $chan $+ ,$time([HH:nn:ss]) $chan) < $+ $nick $+ > $1-
    */
    if (($line(@ChannelWatch,$fline(@ChannelWatch,$chan,1,1),1).color > 2) && (%ChannelWatch.colors.On-Off)) {
      echo @ChannelWatch 1, $+ $line(@ChannelWatch,$fline(@ChannelWatch,$chan,1,1),1).color $+ $time([HH:nn:ss]) $chan $+  < $+ $nick $+ > $1-
    }
    else {
      echo @ChannelWatch $time([HH:nn:ss]) $chan < $+ $nick $+ > $1-
    }
  }
}
on *:JOIN:#:{
  if (($window(@ChannelWatch) == @ChannelWatch) && ($nick == $me) && ($chan !isin %ChannelWatch.chans)) {
    ChannelWatch.AddChan $chan
  }
  if (($window(@ChannelWatch) == @ChannelWatch) && ($chan isin %ChannelWatch.chans) && ($nick != $me)) {
    echo 3 @ChannelWatch 1, $+ $line(@ChannelWatch,$fline(@ChannelWatch,$chan,1,1),1).color $+ $time([HH:nn:ss]) $chan $+  * Joins: $nick $chr(40) $+ $right($ial($nick $+ *), $calc((1 + $len($nick))*-1)) $+ $chr(41)
  } 
}
on *:PART:#:{
  if (($window(@ChannelWatch) == @ChannelWatch) && ($nick == $me) && ($chan isin %ChannelWatch.chans)) {
    ChannelWatch.RemChan $chan
  }
  if (($window(@ChannelWatch) == @ChannelWatch) && ($chan isin %ChannelWatch.chans) && ($nick != $me)) {
    echo 3 @ChannelWatch 1, $+ $line(@ChannelWatch,$fline(@ChannelWatch,$chan,1,1),1).color $+ $time([HH:nn:ss]) $chan $+  * Parts: $nick $chr(40) $+ $right($ial($nick $+ *), $calc((1 + $len($nick))*-1)) $+ $chr(41)
  } 
}

on *:BAN:#:{
  echo @ChannelWatch BNICK: $bnick  NICK: $nick  CHAN: $chan  ADDRESS: $address  ONE-: $1- BANMASK: $banmask
  if (($Window(@ChannelWatch) == @ChannelWatch) && ($chan isin %ChannelWatch.chans)) {
    if ($bnick == $me) {
      echo 4 @ChannelWatch 1, $+ $line(@ChannelWatch,$fline(@ChannelWatch,$chan,1,1),1).color $+ $time([HH:nn:ss]) $chan $+  * You have been banned by $nick - $chr(40) $+ $banmask $+ $chr(41) 
    }
    elseif ($bnick != $me) {
      echo 3 @ChannelWatch 1, $+ $line(@ChannelWatch,$fline(@ChannelWatch,$chan,1,1),1).color $+ $time([HH:nn:ss]) $chan $+  * BAN: $banmask by $nick
    }
  }
}
on *:KICK:#:{
  if (($Window(@ChannelWatch) == @ChannelWatch) && ($chan isin %ChannelWatch.chans)) {
    if ($knick == $me) {
      echo 4 @ChannelWatch 1, $+ $line(@ChannelWatch,$fline(@ChannelWatch,$chan,1,1),1).color $+ $time([HH:nn:ss]) $chan $+  * You were kicked from $chan by $nick
    }
    elseif ($knick != $me) {
      echo 3 @ChannelWatch 1, $+ $line(@ChannelWatch,$fline(@ChannelWatch,$chan,1,1),1).color $+ $time([HH:nn:ss]) $chan $+  * KICK: $knick by $nick
    }
  }
}
;VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
on *:UNBAN:#:{
  if (($Window(@ChannelWatch) == @ChannelWatch) && ($chan isin %ChannelWatch.chans)) {

  }
}
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
on *:QUIT:{
  ;on 1:QUIT:/notice $me $nick just quit IRC with the message $1-
  ;[05:59:49] * dainty (pulkaN@HTS-5CFA6B4B.telia.com) Quit (Broken pipe)
  if ($window(@ChannelWatch) == @ChannelWatch) {
    echo 2 @ChannelWatch $time([HH:nn:ss]) * $nick $chr(40) $+ $right($ial($nick $+ *), $calc((1 + $len($nick))*-1)) $+ $chr(41) Quit $chr(40) $+ $1- $+ $chr(41)
  }
}
/*Echoes user's input to @ChannelWatch when entered into a Watched channel (%ChannelWatch.chans)
--If /me: echoes the action properly formatted into @ChannelWatch
----Format is: Time Channel *Me does something
----Time & Channel coloured to match channel's colour in nicklist (foreground, bkg is blank)
----*Me does something <<standard purple
--Leaves all input to mIRC's processes if first character is == / (is a command) and isn't /me
Everything else (standard text for chatting) is echoed to @ChannelWatch
Prepends echoed text with the originating time, channel, and nick (user's)
If colours are enabled it colours the time and channel to match their colour in the listbox
--The colour is applied to the foreground, the background is blank
--Doesn't colour anything if the colour is less than 3 (for contrast purposes)
*/
on *:INPUT:%ChannelWatch.chans:{
  if ($1 == /me) { echo 6 @ChannelWatch $time([HH:nn:ss]) $chan * $+ $nick $2- }
  elseif (($left($1,1) != /) && ($window(@ChannelWatch) == @ChannelWatch)) {
    if (($line(@ChannelWatch,$sline(@ChannelWatch,1).ln,1).color > 2) && (%ChannelWatch.colors.On-Off)) {
      echo @ChannelWatch  $+ $line(@ChannelWatch,$fline(@ChannelWatch,$chan,1,1),1).color $+ $time([HH:nn:ss]) $chan $+  < $+ $nick $+ > $1-
    }
    else { echo @ChannelWatch $time([HH:nn:ss]) $chan < $+ $nick $+ > $1- }
  }
}
/*Echoes all ACTIONs (/me) originating from a Watched channel (%ChannelWatch.chans) to @ChannelWatch.
Prepends that text with the originating time, channel, and nick.
If colours are enabled it colours the time and channel to match their colour in the listbox
--the colour is applied to the foreground, the background is black
--doesn't colour anything if the colour is less than 3 (for contrast purposes)
Formats the nick and message into the standard purple *Joe does this
*/
on *:ACTION:*:%ChannelWatch.chans:{
  if ($window(@ChannelWatch) == @ChannelWatch) {
    if (($line(@ChannelWatch,$sline(@ChannelWatch,1).ln,1).color > 2) && (%ChannelWatch.colors.On-Off)) {
      echo 6 @ChannelWatch  $+ $line(@ChannelWatch,$fline(@ChannelWatch,$chan,1,1),1).color $+ ,1 $+ $time([HH:nn:ss]) $chan $+  * $+ $nick $1-
    }
    else { echo 6 @ChannelWatch $time([HH:nn:ss]) $chan * $+ $nick $1- }
  }
}
/*Echoes notices to @ChannelWatch when they meet the following conditions:
--@ChannelWatch is mIRC's active window
--The notice is NOT from: ChanServ, NickServ, or MemoServ
Prepends the echoed text with the originating time and channel/nick.
Formats the message into the standard maroon and style:
--[HH:nn:ss] - CHAN/NICK - Message
*/
on *:NOTICE:*:*:{
  if (($window(@ChannelWatch) == @ChannelWatch) && ($active == @ChannelWatch)) {
    if (($nick != nickserv) && ($nick != chanserv) && ($nick != memoserv)) {
      echo 5 @ChannelWatch $time([HH:nn:ss]) - $chan $+ $nick - $1-
    }
  }
}
#ChannelWatch.T/A/N/I end