| 1 | package Bot::Backbone::Service::Role::Responder; | ||
| 2 | $Bot::Backbone::Service::Role::Responder::VERSION = '0.161950'; | ||
| 3 | use v5.10; | ||
| 4 | use Moose::Role; | ||
| 5 | |||
| 6 | # ABSTRACT: A role for services that respond to messages | ||
| 7 | |||
| 8 | |||
| 9 | sub send_reply { | ||
| 10 | my ($self, $message, $options) = @_; | ||
| 11 | |||
| 12 | $self->send_message({ | ||
| 13 | chat => $message->chat, | ||
| 14 | group => $message->group, | ||
| 15 | to => $message->from->username, | ||
| 16 | %$options, | ||
| 17 | }); | ||
| 18 | } | ||
| 19 | |||
| 20 | |||
| 21 | sub send_message { | ||
| 22 | my ($self, $options) = @_; | ||
| 23 | |||
| 24 | my $chat = delete $options->{chat}; | ||
| 25 | |||
| 26 | $chat->send_message($options); | ||
| 27 | } | ||
| 28 | |||
| 29 | 1; | ||
| 30 | |||
| 31 | __END__ |