| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Hubot::Scripts::op; | 
| 2 |  |  |  |  |  |  | $Hubot::Scripts::op::VERSION = '0.1.9'; | 
| 3 | 1 |  |  | 1 |  | 1531 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 40 |  | 
| 4 | 1 |  |  | 1 |  | 6 | use warnings; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 8849 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  | sub load { | 
| 7 | 0 |  |  | 0 | 0 |  | my ( $class, $robot ) = @_; | 
| 8 |  |  |  |  |  |  |  | 
| 9 | 0 |  | 0 |  |  |  | my $nickserv = $ENV{HUBOT_IRC_NICKSERV} || 'NickServ'; | 
| 10 | 0 |  | 0 |  |  |  | my @allow_accounts = split( /,/, $ENV{HUBOT_OP_ACCOUNTS} || '' ); | 
| 11 | 0 |  |  |  |  |  | my $room = ''; | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | $robot->enter( | 
| 14 |  |  |  |  |  |  | sub { | 
| 15 | 0 |  |  | 0 |  |  | my $msg = shift; | 
| 16 |  |  |  |  |  |  |  | 
| 17 | 0 |  |  |  |  |  | $room = $msg->message->user->{room}; | 
| 18 | 0 |  |  |  |  |  | my $user = $msg->message->user->{name}; | 
| 19 |  |  |  |  |  |  | ## support IRC adapter only | 
| 20 | 0 | 0 |  |  |  |  | if ( 'Hubot::Adapter::Irc' eq ref $robot->adapter ) { | 
| 21 | 0 |  |  |  |  |  | my $to = $robot->userForName($nickserv); | 
| 22 |  |  |  |  |  |  | ## maybe need more common interface for adapters | 
| 23 | 0 |  |  |  |  |  | $robot->adapter->irc->send_srv( 'WHOIS' => $user ); | 
| 24 |  |  |  |  |  |  | } | 
| 25 |  |  |  |  |  |  | } | 
| 26 | 0 |  |  |  |  |  | ); | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | $robot->notice( | 
| 29 |  |  |  |  |  |  | sub { | 
| 30 | 0 |  |  | 0 |  |  | my $msg = shift; | 
| 31 |  |  |  |  |  |  |  | 
| 32 | 0 |  |  |  |  |  | my $text = $msg->message->text; | 
| 33 | 0 | 0 |  |  |  |  | if ( my ( $nick, $account ) | 
| 34 |  |  |  |  |  |  | = $text =~ m/^([^ ]+) is logged in as (.+)$/ ) | 
| 35 |  |  |  |  |  |  | { | 
| 36 |  |  |  |  |  |  | ## freenode only? | 
| 37 | 0 | 0 |  |  |  |  | return unless grep { $account eq $_ } @allow_accounts; | 
|  | 0 |  |  |  |  |  |  | 
| 38 | 0 | 0 |  |  |  |  | if ( $robot->mode eq '+o' ) { | 
| 39 |  |  |  |  |  |  | ## maybe need more common interface for adapters | 
| 40 | 0 |  |  |  |  |  | $robot->adapter->irc->send_srv( 'MODE', $room, '+o', | 
| 41 |  |  |  |  |  |  | $nick ); | 
| 42 |  |  |  |  |  |  | } | 
| 43 |  |  |  |  |  |  | } | 
| 44 |  |  |  |  |  |  | } | 
| 45 | 0 |  |  |  |  |  | ); | 
| 46 |  |  |  |  |  |  | } | 
| 47 |  |  |  |  |  |  |  | 
| 48 |  |  |  |  |  |  | 1; | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  | =head1 NAME | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  | Hubot::Scripts::op | 
| 53 |  |  |  |  |  |  |  | 
| 54 |  |  |  |  |  |  | =head1 VERSION | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | version 0.1.9 | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 59 |  |  |  |  |  |  |  | 
| 60 |  |  |  |  |  |  | op - hubot will `/op <nick>` to configured account if hubot can | 
| 61 |  |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  | =head1 CONFIGURATION | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  | C<HUBOT_OP_ACCOUNTS> | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | account is needed, not nickname. separated by comma. | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | =head1 AUTHOR | 
| 69 |  |  |  |  |  |  |  | 
| 70 |  |  |  |  |  |  | Hyungsuk Hong <hshong@perl.kr> | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | =cut |