To create new wiki account, please join us on #znc at Libera.Chat and ask admins to create a wiki account for you. You can say thanks to spambots for this inconvenience.

SVN and Timestamps: Difference between pages

From ZNC
(Difference between pages)
Jump to navigation Jump to search
Created page with "__toc__ === What is SVN? === (from [http://en.wikipedia.org/wiki/Subversion_%28software%29 Wikipedia]) '''Subversion''' is an open source application for revision control. Al..."
 
>Kuja
m remove some commented out echos from the kvirc script
 
Line 1: Line 1:
__toc__
== Usage ==
=== What is SVN? ===
If you want real timestamps you should use these settings for your user:
(from [http://en.wikipedia.org/wiki/Subversion_%28software%29 Wikipedia])


'''Subversion''' is an open source application for revision control. Also commonly referred to as svn or [[SVN]]. It is used to maintain current and historical versions of files such as source code, web pages, and documentation. Its goal is to be a mostly-compatible successor to the widely used Concurrent Versions System (CVS).
TimestampFormat = [%H:%M:%S]
AppendTimestamp = false
PrependTimestamp = true


=== Is the ZNC code in SVN the bleeding edge? How stable is it? ===
It currently supports Channel, Query, Wallops, Notice and Servernotices
It's definitely cutting edge. Bugfixes will show up in SVN very early. New features, however, won't show up in SVN before they have somewhat stabilized. This means that SVN versions usually are very stable, but may still contain unknown bugs. If you'd like to help make ZNC better, you are invited to check out the latest revision from SVN and give it a whirl.


=== How do I get the latest SVN revision? ===
== Format ==
There basically are two ways. One way is to use the svn client utility from your command line:
svn co https://znc.svn.sourceforge.net/svnroot/znc/trunk znc
Without subversion you can use http://znc.in/nightly/znc-svn-latest.tar.gz to get a tarball of the trunk. A new nightly tarball is generated every night, so if there has been a fresh update to SVN, it will usually take some hours before the nightly has the update as well.


Alternatively, you can try to get a tarball from Sourceforge: http://znc.svn.sourceforge.net/viewvc/znc/trunk.tar.gz?view=tar
strftime arguments can be used for the timestamps, more details and arguments can be found at opengroup.org[http://opengroup.org/onlinepubs/007908799/xsh/strftime.html].


=== Where do experimental patches etc. go? ===
  %a - the locale's abbreviated weekday name.  
You can find stuff like that on git (another version control system). You can browse git here: http://git.znc.in/?p=psychon/znc.git;a=summary and here: http://git.znc.in/?p=kroimon/znc.git;a=summary.
  %A - the locale's full weekday name.
  %b - the locale's abbreviated month name.
  %B - the locale's full month name.
  %c - the locale's appropriate date and time representation.
  %C - the century number (the year divided by 100 and truncated to an integer) as a decimal number [00-99].
  %d - the day of the month as a decimal number [01,31].  
  %D - same as %m/%d/%y.
  %e - the day of the month as a decimal number [1,31]; a single digit is preceded by a space.
  %h - same as %b.  
  %H - the hour (24-hour clock) as a decimal number [00,23].  
  %I - the hour (12-hour clock) as a decimal number [01,12].
  %j - the day of the year as a decimal number [001,366].
  %m - the month as a decimal number [01,12].
  %M - the minute as a decimal number [00,59].
  %n - a newline character.
  %p - the locale's equivalent of either a.m. or p.m.
  %r - the time in a.m. and p.m. notation; in the POSIX locale this is equivalent to %I:%M:%S %p.
  %R - the time in 24 hour notation (%H:%M).
  %S - the second as a decimal number [00,61].
  %t - a tab character.
  %T - the time (%H:%M:%S).
  %u - the weekday as a decimal number [1,7], with 1 representing Monday.
  %U - the week number of the year (Sunday as the first day of the week) as a decimal number [00,53].
  %V - the week number of the year (Monday as the first day of the week) as a decimal number [01,53]. If the week containing 1 January has four or more
      days in the new year, then it is considered week 1. Otherwise, it is the last week of the previous year, and the next week is week 1.
  %w - the weekday as a decimal number [0,6], with 0 representing Sunday.  
  %W - the week number of the year (Monday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Monday
      are considered to be in week 0.
  %x - the locale's appropriate date representation.
  %X - the locale's appropriate time representation.
  %y - the year without century as a decimal number [00,99].  
  %Y - the year with century as a decimal number.
  %Z - the timezone name or abbreviation, or by no bytes if no timezone information exists.
  %% - %.


=== SVN Repository Structure ===
== Scripts ==
'''branches''' on svn.kuja.in: contains the development branches of the users working there, currently it's only crox
=== KVIrc ===
This script '''requires''' these settings for your user:


'''tags''': empty as of now
TimestampFormat = {%H:%M:%S}
AppendTimestamp = false
PrependTimestamp = true


'''trunk''': the main directory for development is here, though don't use the trunk on svn.kuja.in, it's broken
and here is it:


To see the latest changes in the SVN repository structure check here: http://znc.svn.sourceforge.net/viewvc/znc/
event(OnWallops,zncid)
{
%timefront = $str.lefttofirst($3,$char(32))
%timeappend = $str.rightfromlast($3,$char(32))
if($str.matchnocase(\{**\:**\:**\},%timefront))
{
%time = %timefront
%msg = $str.rightfromfirst($3,\})
} else {
if($str.matchnocase(\{**\:**\:**\},%timeappend))
{
%time = %timeappend
%msg = $str.lefttofirst($3,\{)
}
}
if($str.matchnocase(\{**\:**\:**\},%time))
{
echo -n -i=$msgtype(Wallops) $k($option(uinttimestampforeground))%time$k WALLOPS von $0 \[$1\@$2\] $str.rightfromfirst($3,\})
}
halt
}
event(OnServerNotice,zncid)
{
%chan = $window.list(channel,$ic)
%con = $window.list(console,$ic)
%x = 0
while(%x < %chan[]#)
{
if($window.hasUserFocus(%chan[%x]))
{
%outchan = %con
break;
} else {
%outchan = %con
}
if(%x < %chan[]#)
{
%x = $(%x + 1)
} else {
break;
}
}
%timefront = $str.lefttofirst($1,$char(32))
%timeappend = $str.rightfromlast($1,$char(32))
if($str.matchnocase(\{**\:**\:**\},%timefront))
{
%time = %timefront
%msg = $str.rightfromfirst($1,\})
} else {
if($str.matchnocase(\{**\:**\:**\},%timeappend))
{
%time = %timeappend
%msg = $str.lefttofirst($1,\{)
}
}
if($str.matchnocase(\{**\:**\:**\},%time))
{
echo -n  -w=%con -i=$msgtype(ServerNotice) $k($option(uinttimestampforeground))%time$k [$0] $str.rightfromfirst($1,\})
halt
}
}
event(OnQueryNotice,zncid)
{
%chan = $window.list(channel,$ic)
%con = $window.list(console,$ic)
%x = 0
while(%x < %chan[]#)
{
if($window.hasUserFocus(%chan[%x]))
{
%outchan = %chan[%x]
break;
} else {
%outchan = %con
}
if(%x < %chan[]#)
{
%x = $(%x + 1)
} else {
break;
}
}
%timefront = $str.lefttofirst($3,$char(32))
%timeappend = $str.rightfromlast($3,$char(32))
if($str.matchnocase(\{**\:**\:**\},%timefront))
{
%time = %timefront
%msg = $str.rightfromfirst($3,\})
} else {
if($str.matchnocase(\{**\:**\:**\},%timeappend))
{
%time = %timeappend
%msg = $str.lefttofirst($3,\{)
}
}
if($str.matchnocase(\{**\:**\:**\},%time))
{
echo -n  -w=%outchan -i=$msgtype(QueryNotice) $k($option(uinttimestampforeground))%time$k *$0* $str.rightfromfirst($3,\})
halt
}
}
event(OnQueryMessage,zncid)
{
%timefront = $str.lefttofirst($3,$char(32))
%timeappend = $str.rightfromlast($3,$char(32))
if($str.matchnocase(\{**\:**\:**\},%timefront))
{
%time = %timefront
%msg = $str.rightfromfirst($3,\})
} else {
if($str.matchnocase(\{**\:**\:**\},%timeappend))
{
%time = %timeappend
%msg = $str.lefttofirst($3,\{)
}
}
if($str.matchnocase(\{**\:**\:**\},%time))
{
echo -n -i=$msgtype(ChannelPrivateMessage) $k($option(uinttimestampforeground))%time$k $option(stringextendedprivmsgprefix)%status$0$option(stringextendedprivmsgpostfix)%msg
halt
}
}
event(OnChannelMessage,zncid)
{
if(%Win{$window} > 0)
{
%timefront = $str.lefttofirst($3,$char(32))
%timeappend = $str.rightfromlast($3,$char(32))
if(($option(boolshowchanneluserflaginprivmsgview)) && ($chan.ison($0)) && ($chan.isvoice($0)))%status = $chan.getflag($0)
if($str.matchnocase(\{**\:**\:**\},%timefront))
{
%time = %timefront
%msg = $str.rightfromfirst($3,\})
} else {
if($str.matchnocase(\{**\:**\:**\},%timeappend))
{
%time = %timeappend
%msg = $str.lefttofirst($3,\{)
}
}
if($str.matchnocase(\{**\:**\:**\},%time))
{
                if($str.containsnocase(%msg,$me))
                          {
          echo -n -i=$msgtype(Highlight) $k($option(uinttimestampforeground))%time$k $option(stringextendedprivmsgprefix)%status$0$option(stringextendedprivmsgpostfix) %msg
          halt
                          }else{
                          echo -n -i=$msgtype(ChannelPrivateMessage) $k($option(uinttimestampforeground))%time$k $option(stringextendedprivmsgprefix)%status$0$option(stringextendedprivmsgpostfix) %msg
          halt
                          }
}
}
if($0 == "***")
{
if($3 == "Buffer Playback...")
{
%Win{$window} = 1
}
if($3 == "Playback Complete.")
{
%Win{$window} = 0
}
}
}
event(OnAction,zncid)
{
if(%Win{$window}  > 0)
{
%timefront = $str.lefttofirst($4,$char(32))
%timeappend = $str.rightfromlast($4,$char(32))
if($str.matchnocase(\{**\:**\:**\},%timefront))
{
%time = %timefront
%msg = $str.rightfromfirst($4,\})
} else {
if($str.matchnocase(\{**\:**\:**\},%timeappend))
{
%time = %timeappend
%msg = $str.lefttofirst($4,\{)
}
}
if($chan.ison($0))%status = $chan.getflag($0)
if($str.matchnocase(\{**\:**\:**\},%time))
{
echo -n -i=$msgtype(Action) $k($option(uinttimestampforeground))%time$k $0 %msg
halt
}
}
}


=== What is the crox repository/branch? ===
=== mIRC ===
The [[SVN]] repository on Sourceforge is the primary repository, the code in that repository will definitely find its way into a new release.
This script '''requires''' these settings for your user:


The [[SVN]] repository on svn.kuja.in has been used for development work that didn't find its way into the Sourceforge one mostly because either the stuff there needs to be tested, isn't considered ready for merging by the developers or is made by non-[[ZNC]] developers and isn't merged into mainline yet.
TimestampFormat = [%H:%M:%S]
'''It's very outdated, currently!''' If you want to have a look anyway:
AppendTimestamp = false
svn co svn://svn.kuja.in/znc/branches/crox znc
PrependTimestamp = true
 
Otherwise you have to adjust the regex pattern in the script that grabs the timestamp.
 
It handles
* Channel messages
* Savebuff output
* Channel notices
* Channel actions
 
==== Configuration (optional) ====
If lines are too long to fit the window width they are wrapped so that the wrapped lines will line up after the nick. To disable that behavior, set <tt>%INDENT_LINES</tt> to <tt>$false</tt>.
 
Nicks will be prefixed with their mode identifier (so "nick" becomes "@nick" for example). To disable this behavior, set <tt>%PREFIX_NICKS</tt> to <tt>$false</tt>.
 
The beginning and end of buffer playback are marked with the default line separator by default. This can be changed to <tt>NORMAL</tt> to display the usual <tt>*** Buffer Playback.</tt> and <tt>*** Playback Complete</tt> messages or to <tt>NONE</tt> to not show any status message at all.
 
If you run into problems like all messages being displayed twice because of other <tt>ON TEXT</tt> processing scripts, try to set <tt>%EXTERNAL_RENDERER</tt> to <tt>$false</tt>.
 
The script also allows the use of spaces.dll to preserve consecutive spaces. To enable it just put <tt>spaces.dll</tt> (http://www.xise.nl/mirc/) into your <tt>Application Data</tt> folder and set <tt>%USE_SPACES_DLL</tt> to <tt>$true</tt>.
 
==== Script ====
Information about loading mIRC scripts can be found [http://chanops.org/faqs/clients/how-to-load-an-mirc-script-into-your-main-mirc-program.html here].
alias -l config {
  ; Mandatory settings
  var %TIMESTAMP_PATTERN = ^\[(\d\d:\d\d:\d\d)\].*$
  var %PLAYBACK_BEGIN    = Buffer Playback...
  var %PLAYBACK_END      = Playback Complete.
  var %VARIABLE_PREFIX  = gbuffer
  ; Optional settings
  ; Indent wrapped lines
  var %INDENT_LINES = $true
  ; Add the mode prefix to the nick (if possible)
  var %PREFIX_NICKS = $true
  ; Are there other ON TEXT processors in place?
  var %EXTERNAL_RENDERER = $false
  ; Possible values are NORMAL/LINESEP/NONE
  var %STATUS_DISPLAY = LINESEP
  ; Make use of space-preserving spaces.dll
  var %USE_SPACES_DLL = $true
  return $eval( $+( %, $1 ), 2 )
}
alias -l makeNick {
  var %nick = $nick( $1, $2 ).pnick
  if ( ( 0 == $len( %nick ) ) || ( $true != $config( PREFIX_NICKS ) ) ) %nick = $2
  return %nick
}
alias -l handleMessage {
  var %chan = $1
  var %nick = $2
  var %color = $3
  var %pattern = $4
  var %text = $5
  var %pnick = $makeNick( %chan, %nick )
  ; Buffered input
  if ( $true == $eval( $+( %, $config( VARIABLE_PREFIX ), ., $cid, ., %chan, ., playback ), 2 ) ) {
    noop $regex( %text, $config( TIMESTAMP_PATTERN ) ) )
    var %timestamp = $regml( 1 )
    var %params
    if ( $config( INDENT_LINES ) ) %params = $+( i, $calc( $len( %timestamp ) + $len( %pnick ) + 4 ) )
    if ( %nick != $me ) %params = $+( %params, lmr )
    if ( 0 != $len( %params ) ) %params = $+( -, %params )
    if ( %nick == $me ) {
      if ( $true == $config( USE_SPACES_DLL ) ) {
        var %result
        noop $regex( %text, ^.*? (.*)$ )
        noop $regsub( %pattern, &TEXT&, $regml( 1 ), %result )
        noop $regsub( %result , &NICK&, %pnick, %result )
        noop $dll( spaces.dll, echo, $color( own  ) %params $chan %timestamp %result )
      }
      else {
        echo $color( own ) %params $chan %timestamp $replacecs( %pattern, &NICK&, %pnick, &TEXT&, $gettok( %text, 2-, 32 ) )
      }
    }
    else {
      if ( $true == $config( USE_SPACES_DLL ) ) {
        var %result
        noop $regex( %text, ^.*? (.*)$ )
        noop $regsub( $regml( 1 ), /\\/g, \\\\, %result )
        noop $regsub( %pattern, &TEXT&, %result, %result )
        noop $regsub( %result , &NICK&, %pnick, %result )
        noop $dll( spaces.dll, echo, $color( %color ) %params $chan %timestamp %result )
      }
      else {
        echo $color( %color ) %params $chan %timestamp $replacecs( %pattern, &NICK&, %pnick, &TEXT&, $gettok( %text, 2-, 32 ) )
      }
    }
  }
  else {
    ; Current events (optional)
    if ( $true == $config( EXTERNAL_RENDERER ) ) return $false
    if ( $true == $config( USE_SPACES_DLL ) ) {
      var %result
      noop $regsub( %pattern, &NICK&, %pnick, %result )
      noop $regsub( %text, /\\/g, \\\\, %text )
      noop $regsub( %result, &TEXT&, %text, %result )
      noop $dll( spaces.dll, echo, $color( %color ) $+( -i, $calc( $len( $timestamp ) + $len( %pnick ) + 5 ), lmrt ) $chan %result )
    }
    else {
      echo $color( %color ) $+( -i, $calc( $len( $timestamp ) + $len( %pnick ) + 4 ), lmrt ) $chan $replacecs( %pattern, &NICK&, %pnick, &TEXT&, %text )
    }
  }
  return $true
}
on ^*:text:*:#:{
  ; Handle savebuff output
  if ( $nick == *savebuff ) {
    var %nick = $gettok( $2, 1, $asc( ! ) )
    var %timestamp = $asctime( $1, $timestampfmt )
    if ( $3 == MODE )    echo $color( mode ) $chan %timestamp * %nick sets mode: $4-
    elseif ( $3 == JOIN ) echo $color( join ) $chan %timestamp * %nick ( $+ $gettok( $2, 2, $asc( ! ) ) $+ ) has joined $chan
    elseif ( $3 == QUIT ) echo $color( quit ) $chan %timestamp * %nick ( $+ $gettok( $2, 2, $asc( ! ) ) $+ ) Quit ( $+ $4- $+ )
    elseif ( $3 == PART ) echo $color( part ) $chan %timestamp * %nick ( $+ $gettok( $2, 2, $asc( ! ) ) $+ ) has left $chan
    elseif ( $3 == NICK ) echo $color( nick ) $chan %timestamp * %nick is now known as $4
    elseif ( $3 == KICK ) echo $color( kick ) $chan %timestamp * $2 was kicked by $gettok( $4, 1, $asc( ! ) ) ( $+ $5- $+ )
    else                  echo $color( erro ) $chan *** UNHANDLED LINE < $+ $1- $+ >
  }
  ; Handle playback state notifications
  elseif ( $nick == *** ) {
    if ( $1- == $config( PLAYBACK_BEGIN ) ) {
      set -e $+( %, $config( VARIABLE_PREFIX ), ., $cid, ., $chan, ., playback ) $true
    }
    elseif ( $1- == $config( PLAYBACK_END ) ) {
      unset $eval( $+( %, $config( VARIABLE_PREFIX ), ., $cid, ., $chan, ., playback ), 1 )
    }
    if ( $config( STATUS_DISPLAY ) == NORMAL ) {
      echo $color( notice ) $chan *** $1-
    }
    elseif ( $config( STATUS_DISPLAY ) == LINESEP ) {
      linesep $chan
    }
  }
  ; Handle usual input
  else {
    var %pattern = ^:.*? :(.*)$
    noop $regex( $rawmsg, %pattern )
    if ( $false == $handleMessage( $chan, $nick, normal, <&NICK&> &TEXT&, $regml( 1 ) ) ) return
  }
  halt
}
on ^*:action:*:#:{
  ;noop $dll( spaces.dll, echo, $chan $rawmsg )
  var %pattern = ^:.*? :\x01ACTION (.*)\x01$
  noop $regex( $rawmsg, %pattern )
  if ( $true == $handleMessage( $chan, $nick, action, * &NICK& &TEXT&, $regml( 1 ) ) ) halt
}
on ^*:notice:*:#:{
  ;noop $dll( spaces.dll, echo, $chan $rawmsg )
  var %pattern = ^:.*? :(.*)$
  noop $regex( $rawmsg, %pattern )
  if ( $true == $handleMessage( $chan, $nick, notice, -&NICK&- &TEXT&, $regml( 1 ) ) ) halt
}
 
=== irssi ===
This script '''requires''' these settings for your user:
 
TimestampFormat = [%H:%M:%S]
AppendTimestamp = false
PrependTimestamp = true
 
Otherwise you have to adjust the regex pattern in the script that grabs the timestamp.
 
Download the script from: http://cba.si/stuff/znc_timestamp.pl
 
Put it into ~/.irssi/scripts, then '''/script load znc_timestamp''' .
 
=== WeeChat ===
* [http://www.weechat.org/files/scripts/unofficial/znc-playback.py znc-playback.py]

Revision as of 11:32, 31 March 2014

Usage

If you want real timestamps you should use these settings for your user:

TimestampFormat = [%H:%M:%S]
AppendTimestamp = false
PrependTimestamp = true

It currently supports Channel, Query, Wallops, Notice and Servernotices

Format

strftime arguments can be used for the timestamps, more details and arguments can be found at opengroup.org[1].

 %a - the locale's abbreviated weekday name. 
 %A - the locale's full weekday name. 
 %b - the locale's abbreviated month name. 
 %B - the locale's full month name. 
 %c - the locale's appropriate date and time representation. 
 %C - the century number (the year divided by 100 and truncated to an integer) as a decimal number [00-99]. 
 %d - the day of the month as a decimal number [01,31]. 
 %D - same as %m/%d/%y. 
 %e - the day of the month as a decimal number [1,31]; a single digit is preceded by a space. 
 %h - same as %b. 
 %H - the hour (24-hour clock) as a decimal number [00,23]. 
 %I - the hour (12-hour clock) as a decimal number [01,12]. 
 %j - the day of the year as a decimal number [001,366]. 
 %m - the month as a decimal number [01,12]. 
 %M - the minute as a decimal number [00,59]. 
 %n - a newline character. 
 %p - the locale's equivalent of either a.m. or p.m. 
 %r - the time in a.m. and p.m. notation; in the POSIX locale this is equivalent to %I:%M:%S %p. 
 %R - the time in 24 hour notation (%H:%M). 
 %S - the second as a decimal number [00,61]. 
 %t - a tab character. 
 %T - the time (%H:%M:%S). 
 %u - the weekday as a decimal number [1,7], with 1 representing Monday. 
 %U - the week number of the year (Sunday as the first day of the week) as a decimal number [00,53]. 
 %V - the week number of the year (Monday as the first day of the week) as a decimal number [01,53]. If the week containing 1 January has four or more
      days in the new year, then it is considered week 1. Otherwise, it is the last week of the previous year, and the next week is week 1. 
 %w - the weekday as a decimal number [0,6], with 0 representing Sunday. 
 %W - the week number of the year (Monday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Monday
      are considered to be in week 0. 
 %x - the locale's appropriate date representation. 
 %X - the locale's appropriate time representation. 
 %y - the year without century as a decimal number [00,99]. 
 %Y - the year with century as a decimal number. 
 %Z - the timezone name or abbreviation, or by no bytes if no timezone information exists. 
 %% - %.

Scripts

KVIrc

This script requires these settings for your user:

TimestampFormat = {%H:%M:%S}
AppendTimestamp = false
PrependTimestamp = true

and here is it:

event(OnWallops,zncid)
{
	%timefront = $str.lefttofirst($3,$char(32))
	%timeappend = $str.rightfromlast($3,$char(32))
	
	if($str.matchnocase(\{**\:**\:**\},%timefront))
	{
	%time = %timefront
	%msg = $str.rightfromfirst($3,\})
	} else {
		if($str.matchnocase(\{**\:**\:**\},%timeappend))
		{
		%time = %timeappend
		%msg = $str.lefttofirst($3,\{)
		}
	}
	
	if($str.matchnocase(\{**\:**\:**\},%time))
	{
	echo -n -i=$msgtype(Wallops) $k($option(uinttimestampforeground))%time$k WALLOPS von $0 \[$1\@$2\] $str.rightfromfirst($3,\})
	}
	halt
}

event(OnServerNotice,zncid)
{
	%chan = $window.list(channel,$ic)
	%con = $window.list(console,$ic)
	%x = 0
	while(%x < %chan[]#)
		{
		if($window.hasUserFocus(%chan[%x]))
			{
			%outchan = %con
			break;
			} else {
			%outchan = %con
			}
		if(%x < %chan[]#)
			{
			%x = $(%x + 1)
			} else {
			break;
			}
		}

	%timefront = $str.lefttofirst($1,$char(32))
	%timeappend = $str.rightfromlast($1,$char(32))
	
	if($str.matchnocase(\{**\:**\:**\},%timefront))
	{
	%time = %timefront
	%msg = $str.rightfromfirst($1,\})
	} else {
		if($str.matchnocase(\{**\:**\:**\},%timeappend))
		{
		%time = %timeappend
		%msg = $str.lefttofirst($1,\{)
		}
	}
	
	if($str.matchnocase(\{**\:**\:**\},%time))
	{
	echo -n  -w=%con -i=$msgtype(ServerNotice) $k($option(uinttimestampforeground))%time$k [$0] $str.rightfromfirst($1,\})
	halt
	}
}

event(OnQueryNotice,zncid)
{
	%chan = $window.list(channel,$ic)
	%con = $window.list(console,$ic)
	%x = 0
	while(%x < %chan[]#)
		{
		if($window.hasUserFocus(%chan[%x]))
			{
			%outchan = %chan[%x]
			break;
			} else {
			%outchan = %con
			}
		if(%x < %chan[]#)
			{
			%x = $(%x + 1)
			} else {
			break;
			}
		}
		
	%timefront = $str.lefttofirst($3,$char(32))
	%timeappend = $str.rightfromlast($3,$char(32))
	
	if($str.matchnocase(\{**\:**\:**\},%timefront))
	{
	%time = %timefront
	%msg = $str.rightfromfirst($3,\})
	} else {
		if($str.matchnocase(\{**\:**\:**\},%timeappend))
		{
		%time = %timeappend
		%msg = $str.lefttofirst($3,\{)
		}
	}
	
	if($str.matchnocase(\{**\:**\:**\},%time))
	{
	echo -n  -w=%outchan -i=$msgtype(QueryNotice) $k($option(uinttimestampforeground))%time$k *$0* $str.rightfromfirst($3,\})
	halt
	}
}

event(OnQueryMessage,zncid)
{
	%timefront = $str.lefttofirst($3,$char(32))
	%timeappend = $str.rightfromlast($3,$char(32))
	
	if($str.matchnocase(\{**\:**\:**\},%timefront))
	{
	%time = %timefront
	%msg = $str.rightfromfirst($3,\})
	} else {
		if($str.matchnocase(\{**\:**\:**\},%timeappend))
		{
		%time = %timeappend
		%msg = $str.lefttofirst($3,\{)
		}
	}
	
	if($str.matchnocase(\{**\:**\:**\},%time))
		{
		echo -n -i=$msgtype(ChannelPrivateMessage) $k($option(uinttimestampforeground))%time$k $option(stringextendedprivmsgprefix)%status$0$option(stringextendedprivmsgpostfix)%msg
		halt
		}
}

event(OnChannelMessage,zncid)
{
	if(%Win{$window} > 0)
	{
	%timefront = $str.lefttofirst($3,$char(32))
	%timeappend = $str.rightfromlast($3,$char(32))
	if(($option(boolshowchanneluserflaginprivmsgview)) && ($chan.ison($0)) && ($chan.isvoice($0)))%status = $chan.getflag($0)
	
	if($str.matchnocase(\{**\:**\:**\},%timefront))
	{
	%time = %timefront
	%msg = $str.rightfromfirst($3,\})
	} else {
		if($str.matchnocase(\{**\:**\:**\},%timeappend))
		{
		%time = %timeappend
		%msg = $str.lefttofirst($3,\{)
		}
	}
	
	if($str.matchnocase(\{**\:**\:**\},%time))
		{
               if($str.containsnocase(%msg,$me))
                         {
		          echo -n -i=$msgtype(Highlight) $k($option(uinttimestampforeground))%time$k $option(stringextendedprivmsgprefix)%status$0$option(stringextendedprivmsgpostfix) %msg
		          halt
                         }else{
                         echo -n -i=$msgtype(ChannelPrivateMessage) $k($option(uinttimestampforeground))%time$k $option(stringextendedprivmsgprefix)%status$0$option(stringextendedprivmsgpostfix) %msg
		          halt
                         }
		}
	}
	
	if($0 == "***")
		{
		
		if($3 == "Buffer Playback...")
			{
			%Win{$window} = 1
			}
		if($3 == "Playback Complete.")
			{
			%Win{$window} = 0
			}
		}
}

event(OnAction,zncid)
{
	if(%Win{$window}  > 0)
		{
		
		%timefront = $str.lefttofirst($4,$char(32))
		%timeappend = $str.rightfromlast($4,$char(32))
	
		if($str.matchnocase(\{**\:**\:**\},%timefront))
		{
		%time = %timefront
		%msg = $str.rightfromfirst($4,\})
		} else {
		if($str.matchnocase(\{**\:**\:**\},%timeappend))
		{
		%time = %timeappend
		%msg = $str.lefttofirst($4,\{)
		}
	}
		
		if($chan.ison($0))%status = $chan.getflag($0)
		if($str.matchnocase(\{**\:**\:**\},%time))
			{
			echo -n -i=$msgtype(Action) $k($option(uinttimestampforeground))%time$k $0 %msg
			halt
			}
		}
}

mIRC

This script requires these settings for your user:

TimestampFormat = [%H:%M:%S]
AppendTimestamp = false
PrependTimestamp = true

Otherwise you have to adjust the regex pattern in the script that grabs the timestamp.

It handles

  • Channel messages
  • Savebuff output
  • Channel notices
  • Channel actions

Configuration (optional)

If lines are too long to fit the window width they are wrapped so that the wrapped lines will line up after the nick. To disable that behavior, set %INDENT_LINES to $false.

Nicks will be prefixed with their mode identifier (so "nick" becomes "@nick" for example). To disable this behavior, set %PREFIX_NICKS to $false.

The beginning and end of buffer playback are marked with the default line separator by default. This can be changed to NORMAL to display the usual *** Buffer Playback. and *** Playback Complete messages or to NONE to not show any status message at all.

If you run into problems like all messages being displayed twice because of other ON TEXT processing scripts, try to set %EXTERNAL_RENDERER to $false.

The script also allows the use of spaces.dll to preserve consecutive spaces. To enable it just put spaces.dll (http://www.xise.nl/mirc/) into your Application Data folder and set %USE_SPACES_DLL to $true.

Script

Information about loading mIRC scripts can be found here.

alias -l config {
  ; Mandatory settings
  var %TIMESTAMP_PATTERN = ^\[(\d\d:\d\d:\d\d)\].*$
  var %PLAYBACK_BEGIN    = Buffer Playback...
  var %PLAYBACK_END      = Playback Complete.
  var %VARIABLE_PREFIX   = gbuffer
  ; Optional settings

  ; Indent wrapped lines
  var %INDENT_LINES = $true

  ; Add the mode prefix to the nick (if possible)
  var %PREFIX_NICKS = $true

  ; Are there other ON TEXT processors in place?
  var %EXTERNAL_RENDERER = $false

  ; Possible values are NORMAL/LINESEP/NONE
  var %STATUS_DISPLAY = LINESEP

  ; Make use of space-preserving spaces.dll
  var %USE_SPACES_DLL = $true

  return $eval( $+( %, $1 ), 2 )
}

alias -l makeNick {
  var %nick = $nick( $1, $2 ).pnick
  if ( ( 0 == $len( %nick ) ) || ( $true != $config( PREFIX_NICKS ) ) ) %nick = $2
  return %nick
}

alias -l handleMessage {
  var %chan = $1
  var %nick = $2
  var %color = $3
  var %pattern = $4
  var %text = $5

  var %pnick = $makeNick( %chan, %nick )

  ; Buffered input
  if ( $true == $eval( $+( %, $config( VARIABLE_PREFIX ), ., $cid, ., %chan, ., playback ), 2 ) ) {
    noop $regex( %text, $config( TIMESTAMP_PATTERN ) ) )
    var %timestamp = $regml( 1 )

    var %params
    if ( $config( INDENT_LINES ) ) %params = $+( i, $calc( $len( %timestamp ) + $len( %pnick ) + 4 ) )
    if ( %nick != $me ) %params = $+( %params, lmr )
    if ( 0 != $len( %params ) ) %params = $+( -, %params )

    if ( %nick == $me ) {
      if ( $true == $config( USE_SPACES_DLL ) ) {
        var %result
        noop $regex( %text, ^.*? (.*)$ )
        noop $regsub( %pattern, &TEXT&, $regml( 1 ), %result )
        noop $regsub( %result , &NICK&, %pnick, %result )
        noop $dll( spaces.dll, echo, $color( own  ) %params $chan %timestamp %result )
      }
      else {
        echo $color( own ) %params $chan %timestamp $replacecs( %pattern, &NICK&, %pnick, &TEXT&, $gettok( %text, 2-, 32 ) )
      }
    } 
    else {
      if ( $true == $config( USE_SPACES_DLL ) ) {
        var %result
        noop $regex( %text, ^.*? (.*)$ )
        noop $regsub( $regml( 1 ), /\\/g, \\\\, %result )
        noop $regsub( %pattern, &TEXT&, %result, %result )
        noop $regsub( %result , &NICK&, %pnick, %result )
        noop $dll( spaces.dll, echo, $color( %color ) %params $chan %timestamp %result )
      }
      else {
        echo $color( %color ) %params $chan %timestamp $replacecs( %pattern, &NICK&, %pnick, &TEXT&, $gettok( %text, 2-, 32 ) )
      }
    }
  }

  else {
    ; Current events (optional)
    if ( $true == $config( EXTERNAL_RENDERER ) ) return $false

    if ( $true == $config( USE_SPACES_DLL ) ) {
      var %result
      noop $regsub( %pattern, &NICK&, %pnick, %result )
      noop $regsub( %text, /\\/g, \\\\, %text )
      noop $regsub( %result, &TEXT&, %text, %result )
      noop $dll( spaces.dll, echo, $color( %color ) $+( -i, $calc( $len( $timestamp ) + $len( %pnick ) + 5 ), lmrt ) $chan %result )
    }
    else {
      echo $color( %color ) $+( -i, $calc( $len( $timestamp ) + $len( %pnick ) + 4 ), lmrt ) $chan $replacecs( %pattern, &NICK&, %pnick, &TEXT&, %text )
    }
  }
  return $true
}

on ^*:text:*:#:{
  ; Handle savebuff output
  if ( $nick == *savebuff ) {
    var %nick = $gettok( $2, 1, $asc( ! ) )
    var %timestamp = $asctime( $1, $timestampfmt )
    if ( $3 == MODE )     echo $color( mode ) $chan %timestamp * %nick sets mode: $4-
    elseif ( $3 == JOIN ) echo $color( join ) $chan %timestamp * %nick ( $+ $gettok( $2, 2, $asc( ! ) ) $+ ) has joined $chan
    elseif ( $3 == QUIT ) echo $color( quit ) $chan %timestamp * %nick ( $+ $gettok( $2, 2, $asc( ! ) ) $+ ) Quit ( $+ $4- $+ )
    elseif ( $3 == PART ) echo $color( part ) $chan %timestamp * %nick ( $+ $gettok( $2, 2, $asc( ! ) ) $+ ) has left $chan
    elseif ( $3 == NICK ) echo $color( nick ) $chan %timestamp * %nick is now known as $4
    elseif ( $3 == KICK ) echo $color( kick ) $chan %timestamp * $2 was kicked by $gettok( $4, 1, $asc( ! ) ) ( $+ $5- $+ )
    else                  echo $color( erro ) $chan *** UNHANDLED LINE < $+ $1- $+ >
  }

  ; Handle playback state notifications
  elseif ( $nick == *** ) {
    if ( $1- == $config( PLAYBACK_BEGIN ) ) {
      set -e $+( %, $config( VARIABLE_PREFIX ), ., $cid, ., $chan, ., playback ) $true
    }
    elseif ( $1- == $config( PLAYBACK_END ) ) {
      unset $eval( $+( %, $config( VARIABLE_PREFIX ), ., $cid, ., $chan, ., playback ), 1 )
    }

    if ( $config( STATUS_DISPLAY ) == NORMAL ) {
      echo $color( notice ) $chan *** $1-
    }
    elseif ( $config( STATUS_DISPLAY ) == LINESEP ) {
      linesep $chan
    }
  } 

  ; Handle usual input
  else {
    var %pattern = ^:.*? :(.*)$
    noop $regex( $rawmsg, %pattern )
    if ( $false == $handleMessage( $chan, $nick, normal, <&NICK&> &TEXT&, $regml( 1 ) ) ) return
  }

  halt
}

on ^*:action:*:#:{
  ;noop $dll( spaces.dll, echo, $chan $rawmsg )
  var %pattern = ^:.*? :\x01ACTION (.*)\x01$
  noop $regex( $rawmsg, %pattern )
  if ( $true == $handleMessage( $chan, $nick, action, * &NICK& &TEXT&, $regml( 1 ) ) ) halt
}

on ^*:notice:*:#:{
  ;noop $dll( spaces.dll, echo, $chan $rawmsg )
  var %pattern = ^:.*? :(.*)$
  noop $regex( $rawmsg, %pattern )
  if ( $true == $handleMessage( $chan, $nick, notice, -&NICK&- &TEXT&, $regml( 1 ) ) ) halt
}

irssi

This script requires these settings for your user:

TimestampFormat = [%H:%M:%S]
AppendTimestamp = false
PrependTimestamp = true

Otherwise you have to adjust the regex pattern in the script that grabs the timestamp.

Download the script from: http://cba.si/stuff/znc_timestamp.pl

Put it into ~/.irssi/scripts, then /script load znc_timestamp .

WeeChat