X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=videosite.pl;h=0c5b650eae97ff6406c9462ff9da3d96f2b8746e;hb=084471fd4f199ed9bb10eb1b8a423d7ec50f9701;hp=35c0809371becc31aab39e3925685afa568e21fd;hpb=0e960b95a2d7eadb3c748ff82035f33670406172;p=videosite.git diff --git a/videosite.pl b/videosite.pl index 35c0809..0c5b650 100644 --- a/videosite.pl +++ b/videosite.pl @@ -79,7 +79,7 @@ sub check_for_link { } # Look if we should ignore this line - if ($message =~ m,(?:\s|^)/nosave,) { + if ($message =~ m,(?:\s|^)/nosave(?:\s|$),) { return; } @@ -96,9 +96,16 @@ sub check_for_link { sub cmd_save { - open(CONF, '>'.$conffile); - print CONF XML::Simple::XMLout($conf, KeepRoot => 1, KeyAttr => ['module', 'key']); - close(CONF); + eval { + open(CONF, '>'.$conffile) or die 'Could not open config file'; + print CONF XML::Simple::XMLout($conf, KeepRoot => 1, KeyAttr => {'config' => 'module', 'option' => 'key'}); + close(CONF); + }; + if ($@) { + write_irssi(undef, 'Could not save config: %s', $@); + } else { + write_irssi(undef, 'Saved config'); + } } sub cmd_set { @@ -154,7 +161,16 @@ sub cmd_help { } write_irssi(undef, 'No such module'); } else { - write_irssi(undef, "Supported commands:\n save: Save the current configuration\n help [modulename]: Display this help, or module specific help\n show [modulename]: Show loaded modules, or the current parameters of a module\n set modulename parameter value: set a module parameter to a new value\n getter [modulename]: display or set the getter to use"); + write_irssi(undef, <<'EOT'); +Supported commands: + save: Save the current configuration + help [modulename]: Display this help, or module specific help + show [modulename]: Show loaded modules, or the current parameters of a module + set modulename parameter value: set a module parameter to a new value + getter [modulename]: display or set the getter to use + debug: enable debugging messages + nodebug: disable debugging messages +EOT } } @@ -231,7 +247,7 @@ sub init_videosite { my $p; - unless(-r $conffile && defined($conf = XML::Simple::XMLin($conffile, ForceArray => ['config', 'option'], KeepRoot => 1, KeyAttr => ['module', 'key']))) { + unless(-r $conffile && defined($conf = XML::Simple::XMLin($conffile, ForceArray => ['config', 'option'], KeepRoot => 1, KeyAttr => {'config' => 'module', 'option' => 'key'}))) { # No config, start with an empty one write_debug(undef, 'No config found, using defaults'); $conf = { 'videosite' => { 'getter' => '' }};