8bcb682e203b9252378cca9f471fd3f64382f840
[app-fonbot-daemon.git] / lib / App / FonBot / Plugin / Config.pm
1 package App::FonBot::Plugin::Config;
2
3 our $VERSION = '0.000_5';
4
5 use v5.14;
6 use strict;
7 use warnings;
8
9 use parent qw/Exporter/;
10
11 use Apache2::Authen::Passphrase;
12 use Log::Log4perl qw//;
13
14 our @EXPORT_OK=qw/$oftc_enabled $oftc_nick @oftc_channels $oftc_nickserv_password $bitlbee_enabled $bitlbee_nick $bitlbee_server $bitlbee_port $bitlbee_password $dir $user $group @supplementary_groups $httpd_port $email_batch_seconds $email_from $email_subject/;
15
16 ##################################################
17
18 our ($oftc_enabled, $oftc_nick, @oftc_channels, $oftc_nickserv_password);
19 our ($bitlbee_enabled, $bitlbee_nick, $bitlbee_server, $bitlbee_port, $bitlbee_password);
20 our ($dir, $user, $group, @supplementary_groups);
21 our ($email_batch_seconds, $email_from, $email_subject);
22
23 ##################################################
24
25 my $log=Log::Log4perl->get_logger(__PACKAGE__);
26
27 sub init{
28 $log->info('reading config file');
29 unless (my $ret = do '/etc/fonbotd/config.pl') {
30 die "Cannot parse config file: $@" if $@;
31 die "Cannot run config file: $!" unless $ret;
32 }
33 }
34
35 sub fini{
36 #no-op
37 }
38
39 1;
40
41 __END__
42
43 =encoding utf-8
44
45 =head1 NAME
46
47 App::FonBot::Plugin::Config - FonBot plugin for reading configuration files
48
49 =head1 SYNOPSIS
50
51 use App::FonBot::Plugin::Config qw/$oftc_enabled $oftc_nick @oftc_channels $oftc_nickserv_password $bitlbee_enabled $bitlbee_nick $bitlbee_server $bitlbee_port $bitlbee_password $user $group @supplementary_groups $httpd_port/;
52 App::FonBot::Plugin::Config->init;
53
54 # Variables used in App::FonBot:Plugin::OFTC
55 say "The OFTC plugin is ".($oftc_enabled ? 'enabled' : 'disabled');
56 say "The OFTC NickServ password is $oftc_nickserv_password";
57 say "The OFTC nickname is $oftc_nick";
58 say "The OFTC channels are @oftc_channels";
59
60 # Variables used in App::FonBot::Plugin::BitlBee
61 say "The BitlBee plugin is ".($bitlbee_enabled ? 'enabled' : 'disabled');
62 say "The BitlBee server runs on port $bitlbee_port of host $bitlbee_server"
63 say "The BitlBee nickname is $bitlbee_nick";
64 say "The BitlBee password is $bitlbee_password";
65
66 # Variables used in App::FonBot::Plugin::Common
67 say "The storage directory is $dir";
68 say "The user is $user";
69 say "The primary group is $group";
70 say "The supplementary groups are @supplementary_groups";
71
72 # Variables used in App::FonBot::Plugin::HTTPD
73 say "The HTTPD listens on port $httpd_port"
74
75 # Variables used in App::FonBot::Plugin::Email
76 say "The email batch delay is $email_batch_seconds";
77 say "The email plugin sends emails from $email_from";
78 say "The email plugin sends emails with subject $email_subject";
79
80 =head1 DESCRIPTION
81
82 This FonBot plugin reads a configuration file (hardcoded to F</etc/fonbot/config.pl>) and provides configuration variables to the other plugins. It is a required plugin, since all other plugins depend on it.
83
84 The configuration variables are described in detail in the plugins that use it.
85
86 =head1 METHODS
87
88 =over
89
90 =item C<App::FonBot::Plugin::Config-E<gt>init>
91
92 (Re-)reads the configuration file, populating the configuration variables. The configuration file is a regular perl script, hardcoded to F</etc/fonbot/config.pl>.
93
94 =item C<App::FonBot::Plugin::Config-E<gt>fini>
95
96 Currently a no-op. It is recommended to call this after finishing using this module, since it might do something in a future release.
97
98 =back
99
100 =head1 AUTHOR
101
102 Marius Gavrilescu C<< <marius@ieval.ro> >>
103
104 =head1 COPYRIGHT AND LICENSE
105
106 Copyright 2013 Marius Gavrilescu
107
108 This file is part of fonbotd.
109
110 fonbotd is free software: you can redistribute it and/or modify
111 it under the terms of the GNU Affero General Public License as published by
112 the Free Software Foundation, either version 3 of the License, or
113 (at your option) any later version.
114
115 fonbotd is distributed in the hope that it will be useful,
116 but WITHOUT ANY WARRANTY; without even the implied warranty of
117 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
118 GNU Affero General Public License for more details.
119
120 You should have received a copy of the GNU Affero General Public License
121 along with fonbotd. If not, see <http://www.gnu.org/licenses/>
122
123
124 =cut
This page took 0.026621 seconds and 3 git commands to generate.