This script adds /log to PITC when loaded.
With it you can save the scrollback of any open window to file
It will be named #channel.log in the 'logs' directory.
Loading Instructions
Paste the snippet into a file in the scripts directory e.g. log.php
and run /load scripts/log.php to load the script.
Usage
Use /log ID/Name to save the scrollback
Info
This only works on PITC v1.0 as v0.9 lacks an API.
PITC, What is that?
PITC is an IRC Client coded entirely in PHP, It runs as a Terminal IRC
Client and does not require any extra plugins or scripts in order to run.
The current stable release is v0.9, The upcoming release is v1.0 which
will bring a fully fledged API allowing you to hook into vital events on IRC
as well as User events such as commands.
PITC, Where can I get it?
Both the latest stable and Development releases can be found at
http://pitc.x10.mx/
The client currently DOES work on Mac and Linux systems.
What's this script for?
This script is both a useful script to enhance your experience using PITC
as well as a demonstration to show how PITC's API can be used!
Have fun!
If you post a script on Hawkee for PITC please add [PITC] to the end and to the
tags so others can find you script!
One last thing...
This script will NOT do anything when ran standalone with PHP, it needs the PITC
API to actually become useful.
<?php
if (!file_exists("logs")) {
mkdir("logs");
}
$api->addCommand("log","save_log");
function save_log($irc) {
global $api,$windows,$scrollback;
if (isset($irc['1'])) {
if (is_numeric($irc['1'])) {
if (isset($windows[$irc['1']])) {
$cname = $windows[$irc['1']];
$id = $irc['1'];
}
else {
$api->pecho(" = No such window! =");
}
}
else {
$id = getWid($irc['1']);
if (isset($windows[$id])) {
$cname = $irc['1'];
}
else {
$api->pecho(" = No such window! =");
}
}
if (isset($id)) {
$api->pecho("Saving log of {$cname} to logs/".$cname.".log");
$log = implode("\n",$scrollback[$id]);
file_put_contents("logs/".$cname.".log",$log);
if (file_exists("logs/".$cname.".log")) {
$api->pecho("Saved log of {$cname} to logs/".$cname.".log");
}
else {
$api->pecho("Error Saving log of {$cname} to logs/".$cname.".log!");
}
}
}
else {
$api->pecho("Usage: /log ID/Name");
}
}
?>