From 8952828886427b0c29e5f5d714acc9700836083c Mon Sep 17 00:00:00 2001 From: eleksir Date: Fri, 22 Apr 2022 15:00:04 +0300 Subject: [PATCH] Use command sign from config, when misc->bot_nick is not supplied, it defaults to empty string --- data/config_sample.json | 5 ++++- lib/Craniac.pm | 11 +++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/data/config_sample.json b/data/config_sample.json index 3478179..e430ebc 100644 --- a/data/config_sample.json +++ b/data/config_sample.json @@ -25,7 +25,10 @@ # maximal amount of message forwardings, to avoid endless loops "forwards_max" : 5, - "lat" : { + # Command prefix aka command sign + "csign" : "!", + +"lat" : { "brain" : "data/lat/brain.sqlite", "src" : "data/lat.txt" } diff --git a/lib/Craniac.pm b/lib/Craniac.pm index 966bd20..0d17cac 100644 --- a/lib/Craniac.pm +++ b/lib/Craniac.pm @@ -160,22 +160,21 @@ my $parse_message = sub { } unless (defined $m->{misc}->{csign}) { - $m->{misc}->{csign} = '!'; + $m->{misc}->{csign} = $c->{csign}; } - # TODO: не проставлять дефолтный ник! unless (defined $m->{misc}->{bot_nick}) { - $m->{misc}->{bot_nick} = 'aleesa'; + $m->{misc}->{bot_nick} = ''; } } else { $m->{misc}->{answer} = 1; - $m->{misc}->{csign} = '!'; - $m->{misc}->{bot_nick} = 'aleesa'; + $m->{misc}->{csign} = $c->{csign}; + $m->{misc}->{bot_nick} = ''; } my $csign = $m->{misc}->{csign}; - if (defined $m->{misc}->{bot_nick}) { + if ($m->{misc}->{bot_nick} ne '') { # Если нам сообщили ник бота, попробуем вымарать его из оригинального текста сообщения, в большинстве случаев он # нам не интересн. $phrase =~ s/\s*\,?\s*($m->{misc}->{bot_nick})\s*\,?\s*/ /gui;