| 1 | package Bot::BasicBot::Pluggable::Module::Status; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Bot::BasicBot::Pluggable::Module; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use base qw(Bot::BasicBot::Pluggable::Module); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 0 | ▶ | sub init { | ||||||||||||||||||||||||||
|
Subroutine
init: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 10 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 11 | 0 | $self->{uptime} = time(); | |||||||||||||||||||||||||||
| 12 | } | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 0 | ▶ | sub said { | ||||||||||||||||||||||||||
|
Subroutine
said: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||
| 15 | 0 | my ($self, $mess, $pri) = @_; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 0 | my $body = $mess->{body}; | |||||||||||||||||||||||||||
| 18 | 0 | my $who = $mess->{who}; | |||||||||||||||||||||||||||
| 19 | 0 | my $address = $mess->{address}; | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 0 | ▶ | return unless ($pri == 2); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | 0 | ▶ | return unless $body =~ /^\s*status/i && $address; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$body =~ /^\s*status/i and $address
MC/DC0%0/2
$body =~ /^\s*status/i and $address
$body =~ /^\s*status/i
$address
Truth table0%0/3
A and B
A= $body =~ /^\s*status/iB= $address
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 0 | my $started = $self->{uptime}; | |||||||||||||||||||||||||||
| 25 | 0 | my $uptime = time() - $started; | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 0 | my $day = 24*60*60; | |||||||||||||||||||||||||||
| 28 | 0 | my $hour = 60*60; | |||||||||||||||||||||||||||
| 29 | 0 | my $min = 60; | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 0 | my $days = int($uptime/$day); $uptime %= $day; | |||||||||||||||||||||||||||
| 32 | 0 | my $hours = int($uptime/$hour); $uptime %= $hour; | |||||||||||||||||||||||||||
| 33 | 0 | my $mins = int($uptime/$min); $uptime %= $min; | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 0 | my $store = $self->bot->store; | |||||||||||||||||||||||||||
| 37 | 0 | ▶ | return "Errk, couldn't get to factoids" unless defined $store; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | my @keys = $store->keys('Infobot'); | |||||||||||||||||||||||||||
| 40 | 0 | ▶ | $self->reply($mess,"I don't think you've loaded the Infobot module") unless @keys; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 0 | my $factoids = 0; | |||||||||||||||||||||||||||
| 44 | 0 | my $mods = 0; | |||||||||||||||||||||||||||
| 45 | 0 | foreach my $key (@keys) { | |||||||||||||||||||||||||||
| 46 | 0 | ▶ | next unless $key =~ /^infobot_/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | 0 | foreach my $atom (@{$store->get('Infobot',$key)->{factoids}}) { | |||||||||||||||||||||||||||
| 48 | 0 | $factoids++; | |||||||||||||||||||||||||||
| 49 | #$mods++ if $atom->{create_time} >= $self->{uptime}; | ||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 0 | my $return = ""; | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | # if (@keys) { | ||||||||||||||||||||||||||||
| 56 | # $return .= "Since ".localtime($started)." there ha". | ||||||||||||||||||||||||||||
| 57 | # $return .= "".(($mods!=1)?"ve":"s"); | ||||||||||||||||||||||||||||
| 58 | # $return .= " been $mods modification"; | ||||||||||||||||||||||||||||
| 59 | # $return .= "s" if $mods != 1; | ||||||||||||||||||||||||||||
| 60 | # $return .= ". "; | ||||||||||||||||||||||||||||
| 61 | # } | ||||||||||||||||||||||||||||
| 62 | 0 | $return .= "I have been awake $days days, $hours hours, $mins minutes, $uptime seconds this session"; | |||||||||||||||||||||||||||
| 63 | 0 | ▶ | if (@keys) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | 0 | $return .= ", and currently reference $factoids factoid"; | |||||||||||||||||||||||||||
| 65 | 0 | ▶ | $return .= "s" if $factoids != 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | 0 | $return .= ". "; | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | 0 | return $return; | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 0 | ▶ | sub help { | ||||||||||||||||||||||||||
|
Subroutine
help: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 72 | 0 | return "Commands: 'status'"; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 1 | 1; | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | __END__ | ||||||||||||||||||||||||||||