Save scrollback to file [PITC v1.0]

By TMFKSOFT on Sep 17, 2012

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");
    }
}
?>

Comments

Sign in to comment.
TMFKSOFT   -  Sep 20, 2012

It' seems very bare bones but It tends to pay more attention to detail plus the API will allow people to expand more and add extra features using the scripts. Basically acting like a blank canvas.

 Respond  
Hawkee   -  Sep 20, 2012

Not bad, it seems functional enough to get around IRC at least.

 Respond  
Hawkee   -  Sep 20, 2012

Neat, I'll have to try it out.

 Respond  
TMFKSOFT   -  Sep 20, 2012

Done Hawkee :)

 Respond  
Hawkee   -  Sep 18, 2012

It would be helpful to add a link to PITC and maybe give a brief explanation of what it is.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.