Here's a plugin to append timestamps to lines (I still think there are better ways to get it done, but whatever):
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Friday, June 03, 2005, 10:00 PM -->
<!-- MuClient version 3.66 -->
<!-- Plugin "Timestamp" generated by Plugin Wizard -->
<!--
The reason this is in JScript is because it's the only language in which it's easy to deal with milliseconds.
This is an ugly plugin, because it destroys all sembalance of order in the lines.
I suggest adding color to the timestamp (for the append) do that with the
ANSI function (since we're dealing with packets, you need to insert ANSI sequences).
It's in the OnPluginPacketRecieved function, the only line that does much in that function,
easy enough to find.
I do suggest if you're only using it for a couple of lines, that you just omit a line, and renote it
(or just note the time afterwards or whatnot).
This plugin has functions to do only that as well.
Check the :now alias for a pretty cut and dry example.
Also, you can include hours by toggling the comments in the GetTime function as well.
-->
<muclient>
<plugin
name="Timestamp"
author="Flannel"
id="89596abf2cfcc625086f8255"
language="JScript"
purpose="Keep track of times between lines and optionally append a timestamp"
save_state="y"
date_written="2005-06-03 21:58:32"
requires="3.59"
version="1.0"
>
<description trim="y">
<![CDATA[
timestamp:on - turn timestamping on
timestamp:off - turn timestamping off
timestamp:reset - reset the start time
timestamp:now - note the current time
timestamp:help - display this page
]]>
</description>
</plugin>
<!-- Get our standard constants -->
<include name="constants.js"/>
<!-- Aliases -->
<aliases>
<alias
name="Reset"
match="^timestamp:reset$"
enabled="y"
regexp="y"
send_to="12"
ignore_case="y"
keep_evaluating="y"
sequence="100"
>
<send>var now = new Date();
setvariable("zerotime", now.getTime());
note("Timestamp Reset to Zero");</send>
</alias>
<alias
name="Toggle"
match="^timestamp:(on|off)$"
enabled="y"
regexp="y"
send_to="12"
ignore_case="y"
keep_evaluating="y"
sequence="100"
>
<send>var toggle = "%1".toLowerCase();
if (toggle == "on")
{
setvariable("enabled",1);
note("Timestamp Enabled");
}
else if (toggle == "off")
{
setvariable("enabled",0);
note("Timestamp Disabled");
}</send>
</alias>
<alias
name="Now"
match="^timestamp:now$"
enabled="y"
regexp="y"
send_to="12"
omit_from_output="y"
ignore_case="y"
keep_evaluating="y"
sequence="100"
>
<send>note(GetTime());</send>
</alias>
</aliases>
<!-- Variables -->
<variables>
</variables>
<!-- Script -->
<script>
<![CDATA[
function OnPluginPacketReceived (s)
{
if (GetVariable("enabled") == 1)
{
s = s.replace(/(\r\n|\r|\n)/g," - " + GetTime() + "$1");
}
return(s);
}
function FormatNumber (i,d)
{ //i is integer, d is digits (min)
//returns a string
var str = i.toString();
var digits = str.length;
for (var j = digits; j < d;j++)
{
str = "0" + str;
}
return (str);
}
function GetTime ()
{
var now = new Date();
var then = getvariable("zerotime");
var diff = now.getTime()-then;
var mill = diff % 1000;
diff = Math.round(diff / 1000);
var sec = diff % 60;
diff = Math.round(diff / 60);
/* //if you want hours, uncomment this
* var min = diff % 60;
* diff = Math.round(diff / 60);
* note(diff + ":" + FormatNumber(min,2) + ":" + FormatNumber(sec,2) + "." + FormatNumber(mill,3));
*/
return (diff + ":" + FormatNumber(sec,2) + "." + FormatNumber(mill,3));
}
]]>
</script>
<!-- Plugin help -->
<aliases>
<alias
script="OnHelp"
match="^timestamp:help$"
enabled="y"
regexp="y"
ignore_case="y"
>
</alias>
</aliases>
<script>
<![CDATA[
function OnHelp (sName, sLine, wildcards)
{
world.Note (world.GetPluginInfo (world.GetPluginID, 3));
}
]]>
</script>
</muclient>
|