mIRC event programming

Raw code debugging.

The following two lines are at the top of my events section, but commented out. Basically, they are so useful I just keep them around in case I need them. The first is ripped straight out of Jeepster's numeric reference.

All scripts on here are available for download as an ini file here: dmscript.ini.

; Uncomment for raw code investigating.
; raw *:*:/echo 12 -a $numeric 1-
; raw *:*:/echo 12 -a $numeric 1= $+ $1 $+ , 2= $+ $2 $+ , 3= $+ $3 $+ , 4= $+ $4 $+ , 5= $+ $5 $+ , 6= $+ $6 $+ , 7= $+ $7 $+ , 8= $+ $8 $+ , 9 onwards= $+ $9- $+ .

Nick recognition

Somedays, I feel that the bane of my life in IRC is that other people have access to the /nick command. This was my solution: it tracks users by their netmask and their UID. Of course, there is nothing to stop people from changing their UID, in which case you're stuck. Though you could easily change this to keep two files, one of "definite" aliases and one of "probable" aliases, or something. But I decided that would be overkill - I just want to recognise my friends under different nicks.

This no longer uses the ial info, since it was too slow and not reliable enough. It now works from the /who information. As a plus, this means it adds anyone listed in /who to the list, as well as everyone who joins a channel you are in, or who is in a channel you join. In the latter I have limited it to "small" channels of 50 people or less purely because you don't want to get kicked off for flooding by doing a /who of several large channels simultaneously.

; Trigger when people join your channel, or when you join an existing channel.
; The timer value is needed because $nick($1,0) returns one when you've just joined.
on 1:join:*:{
  %mdchan = $chan
  if ( $nick == $me ) timermdjoin 1 5 listsmall #
  else who $nick
}
on 1:nick:who $newnick

; List users only in the smaller channels you join. 
alias listsmall {
  if ( $nick($1,0) < 50 ) {
    %mdchanlist = 1
    who $1
  }
  else echo $1 Cannot list - too many users ( $nick($1,0) )
}

; The "ENDWHO" raw signal. 
; Stops who from being treated as if we just joined a channel - fails in many cases, but a lot better than nothing.
; Fails, for instance if you join several channels at once. A 5 sec delay would resolve this a bit.
raw 315:*:if ( %mdchanlist != $null ) unset %mdchanlist

; Intercepting the return from /who raw details to store nick info on people.
raw 352:*:{
  %md_domain = *! $+ $3 $+ @ $+ $4
  %md_domain = $mask(%md_domain,3)
  if ( %md_domain == $null ) goto md_end2
  if ( %mdchan == $null ) %md_chan = -a
  if ( %mdchanlist == $null ) {
    if (( JAVGUEST isin %md_domain ) || ( JAVAGUEST isin %md_domain )) {
      echo  %mdchan 3 $+ *** $6 no aliases: using a java client. 
      goto md_end2
    }
  }
  %md_numhits = $readini -n recognise.ini %md_domain QUANTITY
  %md_counter = %md_numhits
  %md_nickmatch = 0
  while ( %md_counter > 0 ) {
    %md_onenick = $readini -n recognise.ini %md_domain %md_counter
    if ( $6 == %md_onenick ) {
      inc %md_nickmatch
    }
    else {
      %md_nicks = %md_nicks %md_onenick
    }
    dec %md_counter
  }
  if ( %md_numhits == $null ) %md_numhits = 0
  if ( %md_nicks != $null ) echo %mdchan 3 $+ *** $6 %md_numhits aliases: %md_nicks 
  if ( %md_nickmatch < 1 ) {
    writeini -n recognise.ini %md_domain QUANTITY $calc( %md_numhits + 1 )
    writeini -n recognise.ini %md_domain $calc( %md_numhits + 1 ) $6
  }
  :md_end2
  unset %md_*
  if ( %mdchanlist != $null ) halt
}

Frivolous visual chic

Just being frivolous here - making stuff look nicer. Well, a bit. The only useful bit is that it displays the op status of the people who are talking. The changing of what you yourself are saying took me about six hours to find out - thanks eventually to the staff of #mirc on Dalnet. Many more people on #mirc and #scripting of several networks had told me that overriding your own text was just impossible. Personally, I have my own nick appear in bold as well, but I removed the extended characters for that.

BUG: This prevents keyword hilighting from working. Anyone thick of a bugfix?

Note that initially I did on ^1:text:*:*:, which driggered in DCC chats as well. This broke DCC chats quite horribly. Don't do it.

; The first two change the appearance of nicks for queries. 
on 1:input:?: if (/* !iswm $1) { .raw privmsg $active : $+ $1- | echo < @ $+ $me $+ > $1- | halt }
on ^1:text:*:?: echo $nick < $+ $nick $+ > $1- | haltdef
; The next two do it for channels, adding in @ or + characters.
on 1:input:#: {
  if (/* !iswm $1) {
    if ($me isop # ) { .raw privmsg $active : $+ $1- | echo <@ $+ $me $+ > $1- | halt }
    if ($me isvo # ) { .raw privmsg $active : $+ $1- | echo <+ $+ $me $+ > $1- | halt }
    .raw privmsg $active : $+ $1- | echo < $+ $me $+ > $1- | halt
  }
}
on ^1:text:*:#: { 
  if ($nick isop # ) { echo # < $+ @  $+ $nick $+ > $1- | halt | haltdef }
  if ($nick isvo # ) { echo # < $+  + $+ $nick $+ > $1- | halt | haltdef }
  echo # <  $+ $nick $+ > $1- | halt | haltdef
}

Channelwatcher

This is a testament to overengineering. Or possibly to the vast amount of coding that goes into user interfaces. Basically, I found that being in a quiet channel with few or no people in and nobody talking was boring but sometimes necessary. But you have to keep the window open all the time so you can spot people coming in! This was my answer: you can minimise windows you are opped in, and if people join then the alarm goes off.

; Bring important channels to the front if people join them.
on 1:JOIN:@:{ window -r $chan | mdi -t }

That was it before I started making it friendly. The problem with that one is sometimes I want to watch channels I am not opped in, and sometimes I don't want to watch chans I am opped in. The easy way round is just to create a new line, replacing the @ with the channel name. But I am not so lazy. Instead, the following lets you type ""/channelwatch" (or "/cw") to start watching a channel, and "/cwoff" (or "/cwstop") to stop listening to any. It's left as an exercise for the user to put snazzy stuff like selectively removing channels and such. there's such a thing as ridiculously overcoding something, after all.

alias cw channelwatch $1-
alias channelwatch {
  ; Parse parameters
  if ( $1 == $null ) { %cw_chan = $chan }
  else { 
    if ( $chan == $null ) { echo -a Error: channelwatch needs a parameter if used outside a channel. | halt }
    else { %cw_chan = $1 }
  }
  ; Add params to the list.
  if ( %cw_count == $null ) {
    %cw_count = 0
  }
  set %cw_ [ $+ [ %cw_count ] ] %cw_chan
  set %cw_count %cw_count + 1
  .enable #channelwatch
  echo -a Now watching %cw_chan for text and joins.
}
; Turn off all channel watches.
alias cwoff cwstop $1-
alias cwstop {
  unset %cw_* 
  .disable #channelwatch
  echo -a All watched channels removed.
  halt
}

; Watch important channels that are possibly minimised for talk/joins.
#channelwatch on
on 1:JOIN:#:{ 
  if ( %cw_count != $null ) {
    %cw_loop = %cw_count
    while ( %cw_loop > 0 ) {
      if ( %cw_ [ $+ [ $calc(%cw_loop - 1) ] ] == $chan ) {
        echo -a JOIN detected on channel $chan
        window -r $chan | mdi -t | beep 
      }
      dec %cw_loop
    }
    set %cw_count 0
  }
}
on 1:TEXT:*:#:{
  if ( %cw_count != $null ) {
    %cw_loop = %cw_count
    while ( %cw_loop > 0 ) {
      if ( %cw_ [ $+ [ $calc(%cw_loop - 1) ] ] == $chan ) {
        echo -a TEXT detected on channel $chan
        window -r $chan | mdi -t | beep 
      }
      dec %cw_loop
    }
    set %cw_count 0
  }
}
#channelwatch end

What channel are they on?

I am a member of several channels which require that people joining them no be also in certain other channels. This could apply to teen channels which would disallow people in the "#21+" group, or vice versa, or channels which disallow people in sex, hacking or warez channels. This was a little script to make spotting the bad people easier. It is also trivial to have it autokick for known-bad channels.

; Show what channel people are on when they join.
on 1:join:*:{
  if (( $nick != $me ) && ( %nowhois != 1 ))  {
    .raw whois $nick
    set -u5 %enterchan $chan
  }
}

alias whois {
  .disable #joinwhois
  .raw whois $1-
  .timerjoinwhois 1 10 /.enable #joinwhois
  set -u10 %nowhois 1
}

; Modification for Whois, to show channel joins. Must be before other whois mods, so that it can halt before they run.
#joinwhois on
; Ignores newsflash
; raw 343:*:halt
raw 301:*:halt
raw 307:*:halt
raw 308:*:echo %enterchan $2- | halt
raw 309:*:echo %enterchan $2- | halt
raw 310:*:echo %enterchan $2- | halt
raw 325:*:echo %enterchan $2- | halt
raw 311:*:halt
raw 312:*:halt
raw 313:*:halt
raw 317:*:halt
raw 318:*:halt
raw 319:*:{
  echo %enterchan *** $2 on $3-
  halt
}
#joinwhois end

Where in the world...

This just adds a bit of geographical info to the whois info on someone. I forget where I stole it from.

; Modification for Whois, it includes geographical information.
raw 311:*:{
  var %domain
  %domain = $readini domain.lst domains $gettok($4,-1,46)
  if (%domain != $null) {
    echo -a Whois: $2 ( $+ $3 $+ @ $+ $4 $+ ) ( $+ $gettok(%domain,1,32) $+ / $+ $gettok(%domain,2-10,32) $+ ) $right($5-,-2))
  } 
  else {
    echo -a Whois: $2 ( $+ $3 $+ @ $+ $4 $+ ) (unknown/unknown) $right($5-,-2))
  }
  halt
}

; Copy error messages in the server window into the current window as well.
raw *:*:{
  if ( $numeric > 400 ) && ( $numeric < 522 ) {
    echo 4 -a $2-
  }
}