| 1 | package IRC::Bot::Seen; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use vars qw($VERSION @ISA @EXPORT); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use Cache::FileCache; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 1 | require Exporter; | |||||||||
| 10 | 1 | @ISA = qw(Exporter AutoLoader); | |||||||||
| 11 | 1 | @EXPORT = qw(); | |||||||||
| 12 | 1 | $VERSION = '0.02'; | |||||||||
| 13 | |||||||||||
| 14 | 1 | my $cache = new Cache::FileCache( { 'namespace' => 'BotSeen' } ); | |||||||||
| 15 | |||||||||||
| 16 | # Set us up the bomb | ||||||||||
| 17 | 1 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 18 | |||||||||||
| 19 | 1 | my $class = shift; | |||||||||
| 20 | 1 | my $self = {}; | |||||||||
| 21 | 1 | return bless $self, $class; | |||||||||
| 22 | |||||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | # Store seen data | ||||||||||
| 26 | 0 | ▶ | sub log_seen { | ||||||||
|
Subroutine
log_seen: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 27 | |||||||||||
| 28 | 0 | my ( $self, $who, $message ) = @_; | |||||||||
| 29 | 0 | $message = $message . " on " . scalar(localtime); | |||||||||
| 30 | 0 | $cache->set( $who, $message, "never" ); | |||||||||
| 31 | |||||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | # Recieves list of names from your script | ||||||||||
| 35 | # to load current channel users. | ||||||||||
| 36 | 0 | ▶ | sub load_current { | ||||||||
|
Subroutine
load_current: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 37 | |||||||||||
| 38 | 0 | my ( $self, $names, $channel ) = @_; | |||||||||
| 39 | 0 | my @names = split ( / /, $names ); | |||||||||
| 40 | 0 | $channel =~ s/=//; | |||||||||
| 41 | 0 | $channel =~ s/\s+//; | |||||||||
| 42 | 0 | $channel =~ s/\n+//; | |||||||||
| 43 | 0 | my $msg = "On $channel as of " . scalar(localtime); | |||||||||
| 44 | |||||||||||
| 45 | 0 | foreach my $name (@names) { | |||||||||
| 46 | 0 | $name =~ s/^@//; | |||||||||
| 47 | 0 | $name =~ s/^\+//; | |||||||||
| 48 | 0 | $name =~ s/^\%//; | |||||||||
| 49 | 0 | $cache->set( $name, $msg, "never" ); | |||||||||
| 50 | } | ||||||||||
| 51 | |||||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | # Got a seen request, handle it. | ||||||||||
| 55 | 0 | ▶ | sub get_seen { | ||||||||
|
Subroutine
get_seen: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 56 | |||||||||||
| 57 | 0 | my ( $self, $who ) = @_; | |||||||||
| 58 | |||||||||||
| 59 | 0 | $who =~ s/\s+//; | |||||||||
| 60 | |||||||||||
| 61 | 0 | my $mesg = $cache->get($who); | |||||||||
| 62 | |||||||||||
| 63 | 0 | ▶ | if ( defined $mesg ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 64 | 0 | return "Saw $who $mesg"; | |||||||||
| 65 | } | ||||||||||
| 66 | else { | ||||||||||
| 67 | 0 | return "Haven't Seen $who"; | |||||||||
| 68 | } | ||||||||||
| 69 | } | ||||||||||
| 70 | |||||||||||
| 71 | # Clear cache of unwanted seen data | ||||||||||
| 72 | 0 | ▶ | sub clear_seen { | ||||||||
|
Subroutine
clear_seen: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 73 | |||||||||||
| 74 | 0 | my $self = shift; | |||||||||
| 75 | 0 | $cache->clear(); | |||||||||
| 76 | |||||||||||
| 77 | } | ||||||||||
| 78 | |||||||||||
| 79 | 1 | 1; | |||||||||
| 80 | __END__ | ||||||||||