X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=Xchat%2FXPI.pm;h=6811e63b3bc0355bc355b7841b77eb343aa51f54;hb=dd329bf05f9a50bd10d79e522334761f9785d7ab;hp=ff98ec762b9150f59e1ed50a680eded1469113d5;hpb=9db5de0ec290fd8b82a9c510e0d627b31e44d9bd;p=perl%2Fscripts%2Fxchat.git diff --git a/Xchat/XPI.pm b/Xchat/XPI.pm index ff98ec7..6811e63 100644 --- a/Xchat/XPI.pm +++ b/Xchat/XPI.pm @@ -23,7 +23,8 @@ sub new { $class = ref($class) || $class; my %opts = @_; - my $caller = (caller 0)[0]; + my ($caller, $file) = (caller 0)[0, 1]; + unless (defined $opts{tag}) { $opts{tag} = ($caller =~ /([^:]*):*$/) ? $1 : 'UNKNOWN'; } @@ -39,11 +40,11 @@ sub new { $opts{version} = $version; } unless (defined $opts{banner}) { - my $email = $opts{email}; - $email = "<$email>" if defined $email; - my $who = join ', ', grep defined, $opts{author}, $email, $opts{url}; + my $author = defined $opts{author} ? $opts{author} : 'unknown hacker'; + my $email = defined $opts{email} ? "<$opts{email}>" : undef; + my $who = join ', ', grep defined, $email, $opts{url}; $who = " ($who)" if length $who; - $opts{banner} = $opts{desc} . $who; + $opts{banner} = $opts{desc} . " by $author$who"; } my $ph = bless \do { local *PH }, $class; @@ -52,6 +53,10 @@ sub new { *$ph->{$_} = $opts{$_} for @attributes; *$ph->{buf} = ''; + my $internal_pkg = Xchat::Embed::file2pkg($file); + no warnings 'redefine'; + local *Xchat::Embed::find_pkg = sub { $internal_pkg, $caller }; + local *HexChat::Embed::find_pkg = sub { $internal_pkg, $caller }; Xchat::register(@opts{qw}, sub { $ph->flush; if (*$ph->{atexit_id}) {