-
Notifications
You must be signed in to change notification settings - Fork 4
/
cfbot_tester.pm
executable file
·74 lines (60 loc) · 1.26 KB
/
cfbot_tester.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env perl
=pod
=head1 SYNOPSIS
This is used by the test suite. This bot will talk to cfbot and the
test suite will test for the correct replies.
=cut
use Carp 'croak';
use strict;
use warnings;
my $bot = cfbot_tester->new(
server => 'localhost',
port => 6667,
channels => [ '#bottest' ],
username => 'cftester',
name => 'user to test cfbot',
nick => 'cftester',
);
if ( -e 'testing.log' ) {
unlink 'testing.log' or croak "Cannot remove old log [$!]";
}
$bot->run;
package cfbot_tester;
use Carp;
use base 'Bot::BasicBot';
use strict;
use warnings;
sub log {
my $self = shift;
open my $log_fh, '>>', 'testing.log'
or croak "Cannot open testing.log [$!]";
for (@_) {
my $log_entry = $_;
print $log_fh $log_entry."\n";;
}
close $log_fh;
return;
}
sub said {
my $self = shift;
my $msg = shift;
$self->log( $msg->{body} );
}
sub tick {
my $self = shift;
my @msgs = (
'help',
'Test topic',
'bug xxxxx','#484', '#999999',
'function data_expand',
'function regcmp',
'cfbot canonify this is a 45 *.()string',
# Hush must be last
'cfbot: hush',
);
for my $msg ( @msgs ) {
$bot->say( body => $msg, channel => '#bottest' );
}
return 60;
}
1;