blib/lib/POE/Component/IRC/Plugin/IRCDHelp.pm

filter: Statementstmt 71.4% 5 / 7 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 80.0% 8 / 10 CC 1 SCAR 0.9
CC
1
Cov
71%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
↑ Summary
1 package POE::Component::IRC::Plugin::IRCDHelp;
2 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 $POE::Component::IRC::Plugin::IRCDHelp::AUTHORITY = 'cpan:SCILLEY';
4 }
5 {
6 $POE::Component::IRC::Plugin::VERSION = '0.01';
7 }
8
9 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 0 ▶use POE::Component::IRC::Plugin qw( :ALL );
Subroutine BEGIN: called CC=1 SCAR=2.6
11
12 sub PCI_register {
13 my ( $self, $irc ) = @_;
14
15 $irc->plugin_register( $self, 'SERVER', qw( public ) );
16
17 return 1;
18 }
19
20 sub PCI_unregister {
21 my ( $self, $irc ) = @_;
22
23 return 1;
24 }
25
26 sub new {
27
28 my $class = shift;
29 my $self = {};
30 return bless $self, $class;
31
32 }
33
34 sub _default {
35 my ($self, $irc, $event) = splice @_, 0, 3;
36
37 print "Default called for $event\n";
38
39 # Return an exit code
40 return PCI_EAT_NONE;
41 }
42
43 # Someone asked for help in a chan, return list.
44 # Either this isnt loading or something is wrong here
45 # When giving the command !help, nothing gets printed to the channel
46 sub S_public {
47 my ($self, $irc) = splice @_, 0, 2;
48
49 # Parameters are passed as scalar-refs including arrayrefs.
50 my $nick = ( split /!/, ${ $_[0] } )[0];
51 my $channel = ${ $_[1] }->[0];
52 my $msg = ${ $_[2] };
53
54 if (my ($in) = $msg =~ /^!help/) {
55 $in =~ tr[a-zA-Z][n-za-mN-ZA-M];
56
57 # Print the contents to the channel
58 $irc->yield( privmsg => $channel => "Hello $nick, Welcome to Help");
59 $irc->yield( privmsg => $channel => "Type !NickServ to get assistance with the Nick Services");
60 $irc->yield( privmsg => $channel => "Type !ChanServ to get assistance with the Channel Services");
61 $irc->yield( privmsg => $channel => "Type !MemoServ to get assistance with the Memo Services");
62 $irc->yield( privmsg => $channel => "Type !ChangeNick to get assistance with Changing Your Nick");
63 }
64
65 if (my ($in) = $msg =~ /^!NickServ/) {
66 $in =~ tr[a-zA-Z][n-za-mN-ZA-M];
67
68 # Print the contents to the channel
69 $irc->yield( privmsg => $channel => "Using Nick Services");
70 $irc->yield( privmsg => $channel => "Please type /msg NickServ HELP");
71 $irc->yield( privmsg => $channel => "The Nick Service will send you all of it\'s help options");
72 }
73
74 if (my ($in) = $msg =~ /^!ChanServ/) {
75 $in =~ tr[a-zA-Z][n-za-mN-ZA-M];
76
77 # Print the contents to the channel
78 $irc->yield( privmsg => $channel => "Using Channel Services");
79 $irc->yield( privmsg => $channel => "Please type /msg ChanServ HELP");
80 $irc->yield( privmsg => $channel => "The Channel Service will send you all of it\'s help options");
81 }
82
83 if (my ($in) = $msg =~ /^!MemoServ/) {
84 $in =~ tr[a-zA-Z][n-za-mN-ZA-M];
85
86 # Print the contents to the channel
87 $irc->yield( privmsg => $channel => "Using Memo Services");
88 $irc->yield( privmsg => $channel => "Please type /msg MemoServ HELP");
89 $irc->yield( privmsg => $channel => "The Memo Service will send you all of it\'s help options");
90 }
91
92 if (my ($in) = $msg =~ /^!ChangeNick/) {
93 $in =~ tr[a-zA-Z][n-za-mN-ZA-M];
94
95 # Print the contents to the channel
96 $irc->yield( privmsg => $channel => "Changing your Nick");
97 $irc->yield( privmsg => $channel => "$nick, Changing your Nick is very simple");
98 $irc->yield( privmsg => $channel => "just type /nick yournewnick");
99 $irc->yield( privmsg => $channel => "EXAMPLE: I want to change my nick to something else");
100 $irc->yield( privmsg => $channel => "I would simply type /nick ServerBot thus using ServerBot as my new nick");
101 $irc->yield( privmsg => $channel => "That is all there is to it.");
102
103 }
104 else {
105 $irc->yield( privmsg => $channel => "$nick, I am sorry, I do not understand that command, please type !help");
106
107 # We don't want other plugins to process this
108 return PCI_EAT_PLUGIN;
109 }
110
111 # Default action is to allow other plugins to process it.
112 return PCI_EAT_NONE;
113 }
114
115 1;
116
117 __END__
↑ Summary