X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=libvideosite.pm;h=bd4e46a947ff9b7e709a2d039d683e98055a8ac4;hb=b5479a104fa874bc5c0cd9784825eba9fd4bf69e;hp=55dacd0e69c68d45ee48b14507e75c2616510c9d;hpb=2aeee8280846afb6cdad3af3149e83cce27bdad9;p=videosite.git diff --git a/libvideosite.pm b/libvideosite.pm index 55dacd0..bd4e46a 100644 --- a/libvideosite.pm +++ b/libvideosite.pm @@ -51,6 +51,24 @@ my $defaultconfig = { }; # +# This is a list of default values for the remote API. These +# are used if the values are not registered by the library user. +# +my $remote_api = { + io => sub { print @_, "\n" }, + config_init => \&_builtin_config_init, + config_get => \&_builtin_config_get, + config_set => \&_builtin_config_set, + config_has => \&_builtin_config_has, + config_save => \&_builtin_config_save, + config_del => \&_builtin_config_del, + color => sub { return '' }, + module_path => sub { return dirname(realpath($0)) }, + quote => sub { return $_ }, + reset => sub {}, +}; + +# # List of known commands and handlers # my $videosite_commands = { @@ -83,7 +101,7 @@ my $videosite_commands = { }, 'reload' => sub { - init(); + $remote_api->{reset}->(); }, 'mode' => sub { @@ -112,23 +130,6 @@ my $videosite_commands = { }; # -# This is a list of default values for the remote API. These -# are used if the values are not registered by the library user. -# -my $remote_api = { - io => sub { print @_, "\n" }, - config_init => \&_builtin_config_init, - config_get => \&_builtin_config_get, - config_set => \&_builtin_config_set, - config_has => \&_builtin_config_has, - config_save => \&_builtin_config_save, - config_del => \&_builtin_config_del, - color => sub { return '' }, - module_path => sub { return dirname(realpath($0)) }, - quote => sub { return $_ }, -}; - -# # Output a string on the client. # Works like (s)printf in that it takes a format string and a list of # values to be replaced. Undefined values will be printed as '(undef)' @@ -367,9 +368,9 @@ sub _config_list_del { } _debug("Removing %s from list %s", $item, join('.', @{$path})); - @c = map { $item ne $_ } split(/\s*,\s*/, _config_get($path)); + @c = grep { $item ne $_ } split(/\s*,\s*/, _config_get($path)); - _config_set($path, join('.', @c)); + _config_set($path, join(',', @c)); } # @@ -721,6 +722,11 @@ sub _cmd_connector { $name = lc($name); + unless($name =~ m|^[a-z]+$|) { + _io("%s is not a valid connector name (only letters are allowed)", $name); + return; + } + if (_config_list_has(['defined-connectors'], $name)) { _io("Connector already exists"); return; @@ -987,11 +993,15 @@ sub check_for_link { my $m; my $p; my $skip; + my $mode = _config_get(['mode']); - # Look if we should ignore this line + # + # If /nosave is present in the message switch to display mode, regardless + # of config setting + # if ($message =~ m,(?:\s|^)/nosave(?:\s|$),) { - return; + $mode = 'display'; } _push_output($event->{ewpf}); @@ -1009,7 +1019,7 @@ sub check_for_link { $skip = $remote_api->{link_callback}->($m); } unless($skip) { - if ('download' eq _config_get(['mode'])) { + if ('download' eq $mode) { _io( sprintf('%s>>> %sSaving %s%%s%s %s%%s', _colorpair('*red'), @@ -1024,7 +1034,7 @@ sub check_for_link { unless($getter->get($m)) { _io(sprintf('%s>>> FAILED', _colorpair('*red'))); } - } elsif ('display' eq _config_get(['mode'])) { + } elsif ('display' eq $mode) { _io( sprintf('%s>>> %sSaw %s%%s%s %s%%s', _colorpair('*magenta'),