Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Synergy/CommandPost.pm
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ sub _generate_command_system ($class, $, $arg, $) {
},
help => sub ($name, $arg, $text = undef) {
# Can be called as help(foo => "Text") or help(foo => {...} => "Text")
if (! defined) {
if (! defined $text) {
$text = $arg;
$arg = {};
}
Expand Down
31 changes: 15 additions & 16 deletions lib/Synergy/Reactor/HighFive.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ use utf8;
package Synergy::Reactor::HighFive;

use Moose;
with 'Synergy::Role::Reactor::EasyListening';
with 'Synergy::Role::HTTPEndpoint';
with 'Synergy::Role::Reactor::CommandPost',
'Synergy::Role::HTTPEndpoint';

use namespace::clean;
use Synergy::CommandPost;
use Synergy::Logger '$Logger';

use DBI;
use Future::AsyncAwait;
use JSON::MaybeXS qw(encode_json);

has '+http_path' => (
Expand Down Expand Up @@ -126,20 +128,17 @@ sub http_app ($self, $env) {
];
}

sub listener_specs {
return {
name => 'highfive',
method => 'highfive',
targeted => 1,
predicate => sub ($, $e) {
$e->text =~ /^(highfive|:raised_hands:(?::skin-tone-\d:)?|$HIGHFIVE_EMOJI)\s/in;
},
help_entries => [{
title => 'highfive',
text => '*highfive WHO: REASON* - give someone a high five for a job well done',
}],
};
}
responder highfive => {
targeted => 1,
help => '*highfive WHO: REASON* - give someone a high five for a job well done',
matcher => sub ($self, $text, $event) {
return [] if $text =~ /^(highfive|:raised_hands:(?::skin-tone-\d:)?|$HIGHFIVE_EMOJI)\s/in;
return;
},
} => async sub ($self, $event) {
$self->highfive($event);
return;
};

sub highfive ($self, $event, $arg = {}) {
$event->mark_handled;
Expand Down
Loading
Loading