Previous Messages

Suggest features you'd like to see in the future. You're not likely to get it without writing the code, but it can't hurt to try :)

Previous Messages

Postby DjiXas » 16 Oct 2006 20:26

When chatting in private, would like to see something like "Click Here to view old messages" and see 10/50 last messages we wrote last time and then "click here for full log" after it, xchat could open .txt with full log.
DjiXas
 
Posts: 35
Joined: 28 Feb 2005 18:33

Postby jlh » 19 Oct 2006 21:33

This is a very simple script I use. In any tab you type '/viewlog' and it then opens an external viewer of your choice for the log file of that window. It works in channels, private chats and on server tabs.

This is for linux/unix, but it might probably work for windows too, if you set the $viewer variable accordingly. However I'm not sure about the handling of forking; you just need to make sure that the system() call returns immediately, so that xchat will not hang.

Code: Select all
#!/usr/bin/perl

# Simple external log viewer for xchat, by jlh at gmx dot ch
# This code is public domain

# May 2006     Initial version 1.0
# April 2007   Fix for channel/nick names with shell meta-characters, v1.1
# May 2007     ^ -> ~ conversion, v1.2
# June 2007    Added support for all of strftime's %codes (Note that it does
#              not work correctly in _all_ situation involving a '%%'.  v1.3

use strict;
use warnings;
use POSIX qw(strftime);

# The $viewer variable contains the command to launch.  #q or #Q will be
# replaced by the file name (properly shell escaped) to load.
# NOTE: For commands that do not fork by themselves, you must add a & at the
#       end, to start a background process.  Otherwise, xchat will stop
#       responding until the viewer is closed.
# NOTE: use #q for normal shell escapes and #Q for double escape (which is a
#       bit tricky).  it's simplest if you just adapt the examples.

# simple xterm + less viewer
#my $viewer = 'xterm -e "less #Q" &';

# some VIM viewers
my $viewer = 'xterm -e "view #Q" &';
#my $viewer = "gview #q";
#my $viewer = "eview #q";

# add your own...
#my $viewer = "...";

sub irc_lc {
   # the IRC specifications (RFC 1459) says (section 2.2): "Because of
   # IRC's scandanavian origin, the characters {}| are considered to be
   # the lower case equivalents of the characters []\, respectively. This
   # is a critical issue when determining the equivalence of two
   # nicknames."  Thus we need our own version of 'lc'.

   my $s = shift;
   $s =~ tr/A-Z[]\\^/a-z{}|~/;
   return $s;
}

# return the log file name for the current window

sub get_file_name {
   my $mask = Xchat::get_prefs('irc_logmask');
   my $channel = &irc_lc(Xchat::get_info('channel'));
   my $network = Xchat::get_info('network');
   my $server = Xchat::get_info('server');
   $mask =~ s/\%c/$channel/g;
   $mask =~ s/\%n/$network/g;
   $mask =~ s/\%s/$server/g;
   $mask = strftime($mask, localtime);
   return Xchat::get_info('xchatdir') . '/xchatlogs/' . $mask;
}

sub viewlog {
   my $v = $viewer;
   my $f = &get_file_name;
   my %repl = (q => $f, Q => $f);
   $repl{q} =~ s/'/'\\''/g;
   $repl{q} = "'$repl{q}'";
   $repl{Q} =~ s/'/'\\\\''/g;
   $repl{Q} = "'$repl{Q}'";
   $v =~ s{#(\w)}{$repl{$1}}ge;
   system($v);
   return Xchat::EAT_ALL;
}

Xchat::register('External log viewer', '1.3', 'Command /viewlog lauches an external viewer for the current window');
Xchat::hook_command('viewlog', \&viewlog);

Edit: 2007-06-06 New version 1.2
Edit: 2007-06-10 New version 1.3
Last edited by jlh on 10 Jun 2007 16:41, edited 1 time in total.
jlh
 
Posts: 248
Joined: 14 Jul 2004 19:38
Location: Switzerland

Postby DjiXas » 06 Jun 2007 19:14

Um, how to use it? :oops:
DjiXas
 
Posts: 35
Joined: 28 Feb 2005 18:33

Postby Alchera » 08 Jun 2007 00:08

DjiXas wrote:Um, how to use it? :oops:

Copy & paste it into a file and then load it?

"Pay per Click" links in signatures; am surprised the forum Administrator hasn't removed it already.
"Live Outside The Square You Live In"
"Vivez hors du quartier où vous habitez"
User avatar
Alchera
 
Posts: 939
Joined: 28 May 2005 16:30
Location: Ballarat Victoria, Australia

Postby DjiXas » 08 Jun 2007 16:26

Alchera wrote:
DjiXas wrote:Um, how to use it? :oops:

Copy & paste it into a file and then load it?

"Pay per Click" links in signatures; am surprised the forum Administrator hasn't removed it already.


Why should he?
DjiXas
 
Posts: 35
Joined: 28 Feb 2005 18:33

Postby jlh » 08 Jun 2007 22:50

All four links point to a 404 for me anyway. A reason more to remove them.
jlh
 
Posts: 248
Joined: 14 Jul 2004 19:38
Location: Switzerland

Postby Khisanth » 08 Jun 2007 22:59

Alchera wrote:"Pay per Click" links in signatures; am surprised the forum Administrator hasn't removed it already.


I don't think anyone is in the habit of clicking every link on a page. :)
Khisanth
 
Posts: 1724
Joined: 10 Jun 2004 05:23

Postby Alchera » 09 Jun 2007 00:14

Khisanth wrote:
Alchera wrote:"Pay per Click" links in signatures; am surprised the forum Administrator hasn't removed it already.


I don't think anyone is in the habit of clicking every link on a page. :)

You'd be surprised how many gullible people are out there.
"Live Outside The Square You Live In"
"Vivez hors du quartier où vous habitez"
User avatar
Alchera
 
Posts: 939
Joined: 28 May 2005 16:30
Location: Ballarat Victoria, Australia

Postby DjiXas » 09 Jun 2007 10:36

Alchera wrote:
Khisanth wrote:
Alchera wrote:"Pay per Click" links in signatures; am surprised the forum Administrator hasn't removed it already.


I don't think anyone is in the habit of clicking every link on a page. :)

You'd be surprised how many gullible people are out there.




404 is because, hdd corrupted now, techs fixing.

About ppc stuff... I don't think you understood what are those links for :-)

That's mine sites, I don't get paid if anyone clicks on those links...
DjiXas
 
Posts: 35
Joined: 28 Feb 2005 18:33

Postby Alchera » 10 Jun 2007 02:29

Tested the script and it cannot find the actual log(s).

I have them neatly sorted into Network/Year/Month/Day and all I get is a blank page (vim) with it "finding" .xchat2/network name/%Y/%B/%d/#channel.log which, of course, doesn't exist.

I know nothing of Perl and have no way of figuring it out. :lol:
"Live Outside The Square You Live In"
"Vivez hors du quartier où vous habitez"
User avatar
Alchera
 
Posts: 939
Joined: 28 May 2005 16:30
Location: Ballarat Victoria, Australia

Postby jlh » 10 Jun 2007 16:20

It doesn't handle anything other than %s, %n and %c (which are the only I ever use). I'll try to fix that, assuming you always want the latest log file to open.

Edit: Done. It's in the post above. It works for me for the log mask "%n/%Y/%B/%d/%c.log", which I assume is what you use. However, I didn't try it with other locales that "C" (I don't have any installed), but it probably should work. (If you want a literal percent sign in the log mask (via '%%'), then it might not work correctly, but it's not likely people want that. But it would be fixable if someone really needs it.)
jlh
 
Posts: 248
Joined: 14 Jul 2004 19:38
Location: Switzerland

Postby Alchera » 11 Jun 2007 00:39

Thanks jlh, works like a dream. :)

I have xchat log format set for "%n/%Y/%B/%d/%c.log". That's about as fancy as I will ever get. :D
"Live Outside The Square You Live In"
"Vivez hors du quartier où vous habitez"
User avatar
Alchera
 
Posts: 939
Joined: 28 May 2005 16:30
Location: Ballarat Victoria, Australia


Return to Feature Requests

Who is online

Users browsing this forum: No registered users and 1 guest