mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
"use Irssi" now prints a warning if it's used outside irssi, but doesn't
die. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2543 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
fe3c11b77d
commit
34e5a31673
@ -5,7 +5,7 @@
|
||||
package Irssi;
|
||||
|
||||
use strict;
|
||||
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
|
||||
use vars qw($VERSION $in_irssi @ISA @EXPORT @EXPORT_OK);
|
||||
|
||||
sub VERSION {
|
||||
my $version = $_[1];
|
||||
@ -18,6 +18,10 @@ sub EXPORT_ALL () {
|
||||
@EXPORT_OK = grep { /[a-z]/ && defined *{$_}{CODE} } keys %Irssi::;
|
||||
}
|
||||
|
||||
sub in_irssi {
|
||||
return $in_irssi;
|
||||
}
|
||||
|
||||
$VERSION = "0.9";
|
||||
|
||||
require Exporter;
|
||||
@ -35,7 +39,17 @@ require DynaLoader;
|
||||
);
|
||||
@EXPORT_OK = qw();
|
||||
|
||||
bootstrap Irssi $VERSION if (!Irssi::Core::is_static());
|
||||
my $static = 0;
|
||||
|
||||
eval {
|
||||
$static = Irssi::Core::is_static();
|
||||
};
|
||||
$in_irssi = $@ ? 0 : 1;
|
||||
|
||||
if (!in_irssi()) {
|
||||
print "Warning: This script should be run inside irssi\n";
|
||||
} else {
|
||||
bootstrap Irssi $VERSION if (!$static);
|
||||
|
||||
@Irssi::Channel::ISA = qw(Irssi::Windowitem);
|
||||
@Irssi::Query::ISA = qw(Irssi::Windowitem);
|
||||
@ -43,6 +57,7 @@ bootstrap Irssi $VERSION if (!Irssi::Core::is_static());
|
||||
Irssi::init();
|
||||
|
||||
Irssi::EXPORT_ALL();
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user