[prev in list] [next in list] [prev in thread] [next in thread]
List: xchat-discuss
Subject: PATCH: IRC::notify_list perl function
From: Matthew Gabeler-Lee <msg2 () po ! cwru ! edu>
Date: 2001-03-29 2:04:55
[Download RAW message or body]
OK, patch done and attached (done against xchat 1.7.1). That was much
easier than I expected.
The basics of how it works:
IRC::notify_list() returns a flat list of stuff in your notify list.
This list is grouped with the following elements:
Nickname
Zero or more server entries
":"
Note that there may be no server entries at all when the user isn't
connected to a server! In this case the list would look like:
Nick1, :, Nick2, :, Nick3, :
Each server entry has the following elements:
Servername
lastseen
laston
lastoff
ison
"::"
The last* entries are standard unix integer times. 0 seems to denote
'Never'. The ison entry is a boolean entry (is the user currently
online). For formatting them into human readable strings, look at the
asctime, ctime, and strftime functions in perl's POSIX module (/me hopes
that loading the POSIX module from within a script will work ...).
To help aleviate confusion, I have also written a demo script that
parses this information into a mutli-level hash and prints it out.
Please tell me what you think of this.
--
-Matt
One father is more than a hundred schoolmasters.
-- George Herbert
["patch.msg2.perl.notifylist.xchat-1.7.1.gz" (APPLICATION/x-gzip)]
["notlist.pl" (TEXT/PLAIN)]
#!/usr/bin/perl -w
@nl = IRC::notify_list();
%not = ();
$i = 0;
while ($i <= $#nl)
{
# first comes the nick
$nick = $nl[$i];
$i++;
# we create an empty hash just for printing purposes
%{$not{$nick}} = ();
# then comes the list of servers
while ($nl[$i] ne ":")
{
# IRC::print("sentry: " . join(", ", @nl[$i..$i+4
$server = $nl[$i];
$not{$nick}{$server}{laston} = $nl[$i+1];
$not{$nick}{$server}{lastseen} = $nl[$i+2];
$not{$nick}{$server}{lastoff} = $nl[$i+3];
$not{$nick}{$server}{ison} = $nl[$i+3];
# we discard the 6th item, "::"
$i += 6;
}
# we discard the last item, a ":" delimiter
$i++;
}
foreach $nick (keys %not)
{
IRC::print("Nick: $nick\n");
foreach $server (keys %{$not{$nick}})
{
IRC::print(" Server: $server\n");
foreach $var (keys %{$not{$nick}{$server}})
{
IRC::print(" $var = $not{$nick}{$server}{$var}\n");
}
}
}
IRC::print("Done\n");
-
XChat-discuss: mailing list for XChat users
Archive: http://mail.nl.linux.org/lists/
Posted By: Matthew Gabeler-Lee <msg2@po.cwru.edu>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic