aboutsummaryrefslogtreecommitdiff
path: root/Plugin/Timezone.pm
diff options
context:
space:
mode:
authorDavid Phillips <david@sighup.nz>2018-09-16 23:42:35 +1200
committerDavid Phillips <david@sighup.nz>2018-09-17 00:01:48 +1200
commit5331e8ef6cdb9163e3ec6ee85491b7b286f4cbdc (patch)
tree034e3ffcd6f0f450ba2d6ee51ba54ac3feced716 /Plugin/Timezone.pm
parent0352e7d89441abc913d69ce6cff551872edc1fe9 (diff)
downloadidalius-5331e8ef6cdb9163e3ec6ee85491b7b286f4cbdc.tar.xz
Overhaul config parsing
* makes plugin config more private: The config file now uses sections denoted with [Plugin::Foo] where plugin- private config can be stored. Plugins are now passed the usual, as well as a hashref for their own config section. They are also passed the config section of the core, i.e. those config options not appearing in an explicit section. Generally, these are used for bot-global options, so should be accessible to all plugins, but plugin-specific config shall be hidden * tries to improve parsing of hash-like strings and arrays The previous mechanism of using regex to pull out possible tokens was only ever meant to be temporary, and caused problems with escaping or encapsulation inside strings. I have made steps on hash parsing to allow tokens inside strings. Both array and hash parsing still to provide an escape character to escape the item separator (,)
Diffstat (limited to 'Plugin/Timezone.pm')
-rw-r--r--Plugin/Timezone.pm12
1 files changed, 6 insertions, 6 deletions
diff --git a/Plugin/Timezone.pm b/Plugin/Timezone.pm
index 53f8f4a..b88b6b9 100644
--- a/Plugin/Timezone.pm
+++ b/Plugin/Timezone.pm
@@ -8,10 +8,10 @@ use DateTime;
my %config;
sub configure {
- my $self = $_[0];
- my $cmdref = $_[1];
- my $cref = $_[2];
- %config = %$cref;
+ my $self = shift;
+ my $cmdref = shift;
+ shift; # run_command
+ $config = shift;
$cmdref->("time", sub { $self->time(@_); } );
@@ -22,7 +22,7 @@ sub time {
my ($self, $irc, $logger, $who, $where, $rest, @arguments) = @_;
my $requester = (split /!/, $who)[0];
- my @known_zones = (keys %{$config{timezone}});
+ my @known_zones = (keys %{$config->{timezone}});
return "Syntax: time [nick]" unless @arguments == 1;
@@ -30,7 +30,7 @@ sub time {
my ($case_nick) = grep {/^$nick$/i} @known_zones;
if ($case_nick) {
my $d = DateTime->now();
- $d->set_time_zone($config{timezone}->{$case_nick});
+ $d->set_time_zone($config->{timezone}->{$case_nick});
my $timestr = $d->strftime("%Y-%m-%d %H:%M %Z");
return "$requester: $nick\'s clock reads $timestr";
} else {