# HIST.IRC # Written by tijiez # # Logging and windows must be enabled for this script to function $ver = 0.3; set HIST_ECHO { return "\b!\c30h\b\c40-\t$0-"; } sub echof { local('$pref'); $pref = getProperty("log.enabled"); if($pref eq "true") { setProperty("log.enabled", "false"); } echo(parseSet("HIST_ECHO", $1)); setProperty("log.enabled", $pref); } if(getProperty("hist.version") ne $ver) { echof("\bH\bIST.IRC v\b" . $ver . "\b"); echof("/hist \bhelp\b for more information."); setProperty("hist.version", $ver); setProperty("hist.logSize", "5"); } alias hist { if(lc($1) eq "help") { echof("Commands:"); echof("/hist \bon\b|\boff\b toggles the script."); echof("/hist num \b#\b modifies the history size."); } else if(lc($1) eq "on" || lc($1) eq "off") { setProperty("hist.showHistory", iff(lc($1) eq "on", "true", "false")); echof("History turned \b" . lc($1) . "\b."); } else if(lc($1) eq "num" && $2 > 0) { setProperty("hist.logSize", $2); echof("History size [\b" . $2 . "\b] modified."); } else { halt; } } on open { if(-isSetT "hist.showHistory" && -isSetF "log.enabled") { local('$num $log'); $num = getProperty("hist.logSize"); $log = getLogFile($active); if(-exists "$log" && -canread "$log") { $handle = openf($log); @data = readAll($handle); $n = iff($num > size(@data), "0", size(@data) - $num); for( ; $n < size(@data); $n++) { echof(strip(@data[$n])); } if(checkError($error)) { echof("\be\bek: " . $error); } } closef($handle); } else { echof("History for [" . getActiveWindow() . "] disabled."); } }