File: privmsg-log.pl

package info (click to toggle)
dircproxy 1.0.5-5etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 1,120 kB
  • ctags: 740
  • sloc: ansic: 9,466; sh: 2,946; makefile: 113; perl: 70
file content (72 lines) | stat: -rwxr-xr-x 1,605 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/perl
# Logs private messages to seperate files.
#
# To use, set the following in dircproxyrc:
#   other_log_program "/path/to/privmsg-log.pl"
#

use vars qw/$logdir/;
use strict;

# Directory to store files in
$logdir = '/tmp';


#------------------------------------------------------------------------------#

# The first argument to this script is the source of the text.  Its in the
# following formats
#
# -dircproxy-
#     Notice from dircproxy
#
# -servername-
#     Notice from a server
#
# <nick!username@host>
#     Private message from a person
#
# -nick!username@host-
#     Notice from a person
#
# [nick!username@host]
#     Unfiltered CTCP message (usually an ACTION) from a person
#

my $source = shift(@ARGV);
die "No source given by dircproxy" unless $source && length $source;

my $nickname;
if ($source =~ /^[<-\[]([^!]*)![^\@]*\@.*[>-\]]$/) {
	$nickname = $1;
} else {
	# Not a private message, don't want it
	exit 0;
}


#------------------------------------------------------------------------------#

# The second argument to this script is who it was to (your nickname or
# a channel name)

my $dest = shift(@ARGV);
if ($dest =~ /^#/) {
	# A channel message, don't want it
	exit 0;
}


#------------------------------------------------------------------------------#

# The text to log is on the standard input.

my $text = <STDIN>;
die "No text given by dircproxy" unless $text && length $text;


#------------------------------------------------------------------------------#

open LOGFILE, ">>$logdir/$nickname";
print LOGFILE $source . " " . $text;
close LOGFILE;