| 1 | package Hubot::Scripts::help; | ||||||||||
| 2 | 6 | $Hubot::Scripts::help::VERSION = '0.2.8'; | |||||||||
| 3 | 6 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 6 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 5 | ▶ | sub load { | ||||||||
|
Subroutine
load: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 7 | 5 | my ( $class, $robot ) = @_; | |||||||||
| 8 | $robot->respond( | ||||||||||
| 9 | qr/help\s*(.*)?$/i, | ||||||||||
| 10 | 6 | ▶ | sub { | ||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.1
| |||||||||||
| 11 | 6 | my $msg = shift; # Hubot::Response | |||||||||
| 12 | 6 | my @helps = $robot->helps; | |||||||||
| 13 | |||||||||||
| 14 | 6 | my $robotName = $robot->name; | |||||||||
| 15 | 6 | ▶ | unless ( $robotName =~ m/^hubot$/ ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | 0 | map {s/hubot/$robotName/ig} @helps; | |||||||||
| 17 | } | ||||||||||
| 18 | |||||||||||
| 19 | 6 | ▶ | if ( $msg->match->[0] ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | 5 | my $regex = $msg->match->[0]; | |||||||||
| 21 | 5 | @helps = grep { $_ =~ /$regex/i } @helps; | |||||||||
| 22 | } | ||||||||||
| 23 | |||||||||||
| 24 | 6 | map {s/^/\# /} @helps; | |||||||||
| 25 | 6 | $msg->send(@helps); | |||||||||
| 26 | } | ||||||||||
| 27 | 5 | ); | |||||||||
| 28 | |||||||||||
| 29 | $robot->respond( | ||||||||||
| 30 | qr/commands? *$/i, | ||||||||||
| 31 | 1 | ▶ | sub { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 32 | 1 | my $msg = shift; | |||||||||
| 33 | 1 | $msg->send( join( ', ', $robot->commands ) ); | |||||||||
| 34 | } | ||||||||||
| 35 | 5 | ); | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 6 | 1; | |||||||||
| 39 | |||||||||||
| 40 | =pod | ||||||||||
| 41 | |||||||||||
| 42 | =encoding utf-8 | ||||||||||
| 43 | |||||||||||
| 44 | =head1 NAME | ||||||||||
| 45 | |||||||||||
| 46 | Hubot::Scripts::help | ||||||||||
| 47 | |||||||||||
| 48 | =head1 VERSION | ||||||||||
| 49 | |||||||||||
| 50 | version 0.2.8 | ||||||||||
| 51 | |||||||||||
| 52 | =head1 SYNOPSIS | ||||||||||
| 53 | |||||||||||
| 54 | hubot commands - Displays all commands at oneline | ||||||||||
| 55 | hubot help - Displays all of the help commands that Hubot knows about | ||||||||||
| 56 | hubot help <query> - Displays all help commands that match <query> | ||||||||||
| 57 | |||||||||||
| 58 | =head1 DESCRIPTION | ||||||||||
| 59 | |||||||||||
| 60 | These commands are grabbed from pod at the C<SYNOPSIS> section each file. | ||||||||||
| 61 | |||||||||||
| 62 | =head1 AUTHOR | ||||||||||
| 63 | |||||||||||
| 64 | Hyungsuk Hong <hshong@perl.kr> | ||||||||||
| 65 | |||||||||||
| 66 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 67 | |||||||||||
| 68 | This software is copyright (c) 2012 by Hyungsuk Hong. | ||||||||||
| 69 | |||||||||||
| 70 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 71 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 72 | |||||||||||
| 73 | =cut | ||||||||||