From eccd082bf75c4a290345cca1df0f71164580ed84 Mon Sep 17 00:00:00 2001 From: Dominik Hassler Date: Sat, 18 May 2024 09:58:24 +0000 Subject: [PATCH] fenix: replace default handler with something more useful --- lib/Fenix/Model/Handler/Help.pm | 20 +++++++++---- lib/Fenix/Model/Handler/Hi.pm | 50 --------------------------------- 2 files changed, 14 insertions(+), 56 deletions(-) delete mode 100644 lib/Fenix/Model/Handler/Hi.pm diff --git a/lib/Fenix/Model/Handler/Help.pm b/lib/Fenix/Model/Handler/Help.pm index 8b94c46..8684538 100644 --- a/lib/Fenix/Model/Handler/Help.pm +++ b/lib/Fenix/Model/Handler/Help.pm @@ -3,18 +3,26 @@ use Mojo::Base 'Fenix::Model::Handler::base', -signatures; use Mojo::Promise; -has priority => 100; +# default handler, lowest priority. +# if we get mentioned but don't know what to do we +# DM the user information about our capabilities +has priority => 9999; has generic => 0; has dm => 1; sub process_p($self, $chan, $from, $msg, $mentioned = 0) { - return undef if !$mentioned || $msg !~ /\bhelp\b/i; + return undef if !$mentioned || $self->utils->muted(\$self->mutemap->{help}, $from); + + my $preface = $msg =~ /\bhelp\b/i + ? "Hi $from, I am glad you asked!\n" + . 'To get my attention, just mention my name in a message to the channel.' + : "Hi $from, it seems that you tried to get my attention.\n" + . 'However, I am afraid I did not understand your request.'; return Mojo::Promise->resolve([ split /\n/, <<"END" ]); -Hi $from, I am glad you asked! -To get my attention, just mention my name in a message to the channel. +$preface I can look up Redmine issues with 'illumos ', 'issue ' or '#' -For Joyent/SmartOS issues, use the issue type and number together, e.g. OS-1234. +For SmartOS issues, use the issue type and number together, e.g. OS-1234. I can also find IPDs - 'IPD123', 'IPD-123' or 'IPD 123' as well as OpenSolaris issues with a seven digit bug ID. If you want me to, I can also dig very deeply and find stuff in the OpenSolaris ARC Material Archive, just use e.g. FWARC/2004/510. @@ -29,7 +37,7 @@ __END__ =head1 COPYRIGHT -Copyright 2023 OmniOS Community Edition (OmniOSce) Association. +Copyright 2024 OmniOS Community Edition (OmniOSce) Association. =head1 LICENSE diff --git a/lib/Fenix/Model/Handler/Hi.pm b/lib/Fenix/Model/Handler/Hi.pm deleted file mode 100644 index c1206c9..0000000 --- a/lib/Fenix/Model/Handler/Hi.pm +++ /dev/null @@ -1,50 +0,0 @@ -package Fenix::Model::Handler::Hi; -use Mojo::Base 'Fenix::Model::Handler::base', -signatures; - -use Mojo::Promise; -use Time::Piece; - -# default handler, lowest priority. -#if we get mentioned but don't know what to do we -# are at least polite and say 'Hi'. -has priority => 9999; - -sub process_p($self, $chan, $from, $msg, $mentioned = 0) { - return undef if !$mentioned || $self->utils->muted(\$self->mutemap->{user}, $from); - - # little friday is special - return Mojo::Promise->resolve([ - gmtime->day_of_week == 4 ? "Happy little Friday $from!" : "Hi $from" - ]); -} - -1; - -__END__ - -=head1 COPYRIGHT - -Copyright 2021 OmniOS Community Edition (OmniOSce) Association. - -=head1 LICENSE - -This program is free software: you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the Free -Software Foundation, either version 3 of the License, or (at your option) -any later version. -This program is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -more details. -You should have received a copy of the GNU General Public License along with -this program. If not, see L. - -=head1 AUTHOR - -Shadfl@omnios.orgE> - -=head1 HISTORY - -2021-01-08 had Initial Version - -=cut