From 94eba5f16157f04a3c1886330e34a60625d8992c Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Thu, 19 Dec 2019 23:29:56 -0800 Subject: [PATCH] PBot can now be started from any location, even symlinks --- pbot.pl | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/pbot.pl b/pbot.pl index dfba9fe0..0729b604 100755 --- a/pbot.pl +++ b/pbot.pl @@ -10,15 +10,17 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -my $VERSION = "1.0.0"; - use feature 'unicode_strings'; use strict; use warnings; -use lib "."; -use PBot::PBot; +my $bothome; +BEGIN { + use File::Basename; + $bothome = -l __FILE__ ? dirname readlink __FILE__ : dirname __FILE__; + unshift @INC, $bothome; +} # !! NOTICE !! # @@ -31,10 +33,6 @@ use PBot::PBot; # # !! NOTICE !! -# Be sure to set $bothome to the location PBot was extracted (default assumes ~/pbot). -# This location must contain the PBot directory, among others configured below. -my $bothome = "$ENV{HOME}/pbot"; - my %config = ( # ----------------------------------------------------- # Be sure to set your IRC information to a registered NickServ account @@ -134,6 +132,7 @@ $config{quotegrabs_file} = "$config{data_dir}/quotegrabs.sqlite3"; $config{message_history_file} = "$config{data_dir}/message_history.sqlite3"; # Create and initialize bot object +use PBot::PBot; my $pbot = PBot::PBot->new(%config); # Start the bot main loop; doesn't return