summaryrefslogtreecommitdiffstats
path: root/lib/ASM/Config.pm
diff options
context:
space:
mode:
authorLibravatarJanik Kleinhoff <ilbelkyr@shalture.org>2016-09-05 01:09:49 +0000
committerLibravatarJanik Kleinhoff <ilbelkyr@shalture.org>2016-10-07 22:42:33 +0000
commite29b1456c06576b607fd255f5da34a3cc3e97ca2 (patch)
treefeeb5925dd9f0b6e9e692e34b7b8dca1ecbd8275 /lib/ASM/Config.pm
parente3e5402155786931fffd78e71bb2a7324a677ff0 (diff)
Extirpate traces of XML
Summary: Resolve T6 and use the opportunity to get rid of our dependency on `XML::Simple` once and for all. Test Plan: Run the bot with JSON config files. Reviewers: Unit193 Reviewed By: Unit193 Tags: #antispammeta Maniphest Tasks: T6 Differential Revision: https://asm.shalture.org/D1
Diffstat (limited to 'lib/ASM/Config.pm')
-rw-r--r--lib/ASM/Config.pm44
1 files changed, 8 insertions, 36 deletions
diff --git a/lib/ASM/Config.pm b/lib/ASM/Config.pm
index de0bb21..ff6f745 100644
--- a/lib/ASM/Config.pm
+++ b/lib/ASM/Config.pm
@@ -4,10 +4,8 @@ use warnings;
use strict;
use feature 'state';
-use XML::Simple qw(:strict);
use JSON;
use IO::All;
-no if $] >= 5.017011, warnings => 'experimental::smartmatch';
our $json = JSON->new->utf8->pretty->canonical;
@@ -18,41 +16,15 @@ sub deserialize {
return $json->decode(@_);
}
-sub readXML {
- my ( $p ) = $::cset;
- my @fchan = ( 'event', keys %::RISKS );
- my $xs1 = XML::Simple->new( KeyAttr => ['id'], Cache => [ qw/memcopy/ ]);
- $::settings = $xs1->XMLin( "$p/settings.xml", ForceArray => ['host'],
- 'GroupTags' => { altnicks => 'altnick', server => 'host',
- autojoins => 'autojoin' });
- $::channels = $xs1->XMLin( "$p/channels.xml", ForceArray => \@fchan );
- $::users = $xs1->XMLin( "$p/users.xml", ForceArray => 'person');
- $::mysql = $xs1->XMLin( "$p/mysql.xml", ForceArray => ['ident', 'geco'],
- 'GroupTags' => { ignoredidents => 'ident', ignoredgecos => 'geco' });
- $::dnsbl = $xs1->XMLin( "$p/dnsbl.xml", ForceArray => []);
- $::rules = $xs1->XMLin( "$p/rules.xml", ForceArray => []);
- $::restrictions = $xs1->XMLin( "$p/restrictions.xml", ForceArray => ['host', 'nick', 'account']);
- $::blacklist = $xs1->XMLin( "$p/blacklist.xml", ForceArray => 'string');
-}
-
sub readConfig {
- if (!-e "$::cset/settings.json") {
- state $in_readconfig = 0;
- die "Unexpected readConfig recursion" if $in_readconfig++;
- readXML();
- writeConfig();
- readConfig();
- }
- else {
- $::settings = deserialize(io->file("$::cset/settings.json")->all);
- $::channels = deserialize(io->file("$::cset/channels.json")->all);
- $::users = deserialize(io->file("$::cset/users.json")->all);
- $::mysql = deserialize(io->file("$::cset/mysql.json")->all);
- $::dnsbl = deserialize(io->file("$::cset/dnsbl.json")->all);
- $::rules = deserialize(io->file("$::cset/rules.json")->all);
- $::restrictions = deserialize(io->file("$::cset/restrictions.json")->all);
- $::blacklist = deserialize(io->file("$::cset/blacklist.json")->all);
- }
+ $::settings = deserialize(io->file("$::cset/settings.json")->all);
+ $::channels = deserialize(io->file("$::cset/channels.json")->all);
+ $::users = deserialize(io->file("$::cset/users.json")->all);
+ $::mysql = deserialize(io->file("$::cset/mysql.json")->all);
+ $::dnsbl = deserialize(io->file("$::cset/dnsbl.json")->all);
+ $::rules = deserialize(io->file("$::cset/rules.json")->all);
+ $::restrictions = deserialize(io->file("$::cset/restrictions.json")->all);
+ $::blacklist = deserialize(io->file("$::cset/blacklist.json")->all);
}
sub writeConfig {