summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2002-03-09 12:17:32 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2002-03-09 12:17:32 +0000
commit34e5a316738976d31cb1fa1c073d1ecd261b685f (patch)
treee4791c4d081241a6a56f1ce5b24b1a76d75f0de9 /src
parentfe3c11b77ded08f45f70ef3fc9b558ae570b3eac (diff)
downloadirssi-34e5a316738976d31cb1fa1c073d1ecd261b685f.zip
"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
Diffstat (limited to 'src')
-rw-r--r--src/perl/common/Irssi.pm27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/perl/common/Irssi.pm b/src/perl/common/Irssi.pm
index ce35c52e..14d3f4dc 100644
--- a/src/perl/common/Irssi.pm
+++ b/src/perl/common/Irssi.pm
@@ -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,14 +39,25 @@ 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;
-@Irssi::Channel::ISA = qw(Irssi::Windowitem);
-@Irssi::Query::ISA = qw(Irssi::Windowitem);
+if (!in_irssi()) {
+ print "Warning: This script should be run inside irssi\n";
+} else {
+ bootstrap Irssi $VERSION if (!$static);
-Irssi::init();
+ @Irssi::Channel::ISA = qw(Irssi::Windowitem);
+ @Irssi::Query::ISA = qw(Irssi::Windowitem);
-Irssi::EXPORT_ALL();
+ Irssi::init();
+
+ Irssi::EXPORT_ALL();
+}
1;