Переглянути джерело

Should be ready for testing on cPanel systems now.

Andy Baugh 7 роки тому
батько
коміт
a24a83d2fd

+ 3 - 1
README.md

@@ -4,7 +4,7 @@ Extra "Contact Manager" Providers for cPanel and WHM
 Current plugins:
 ================
 * XMPP  -- Stable XMPP provider (well, as stable as Net::XMPP is, anyways). See issue #2
-* IRC   -- Still WIP, don't use this, as it is completely untested and currently no-op on send.
+* IRC   -- New provider, needs more testing by users out in the wild. "Works for Me"
 * Slack -- Works presuming you have an incoming WebHook URL, much like CpanelRicky's MatterMost plugin.
 
 Installation and Use:
@@ -46,3 +46,5 @@ and write out .xmpptestrc in the toplevel directory of this git repository with
 
 You'll note these correspond to the values in the Provider's Schema module. With that set, you should spam yourself with
 a message if the t/Cpanel-iContact-Provider-XMPP.t test passes.
+
+Same goes for the IRC provider... use the same keys as in the schema module for dopeouts in its' test.

+ 3 - 4
lib/Cpanel/iContact/Provider/IRC.pm

@@ -24,9 +24,9 @@ sub send {
 	eval {
 		my $response;
 		$self->_send(
-			'channels' => @{ $args_hr->{'to'} },
-			'subject' => $subject,
-			'content' => $body
+			'destination' => $args_hr->{'to'},
+			'subject'     => $subject,
+			'content'     => $body
 		);
 	};
 	push( @errs, $@ ) if $@;
@@ -39,7 +39,6 @@ sub send {
     return 1;
 }
 
-my $conf;
 my $conn;
 sub _send {
     my ( $self, %args ) = @_;

+ 12 - 3
lib/Cpanel/iContact/Provider/Schema/IRC.pm

@@ -5,9 +5,9 @@ use warnings;
 
 sub get_settings {
     my $help1 = <<HALP;
-<p>The IRC <em>channels</em> you wish to send cPanel & WHM notifications <em>to</em>.<br />
-For multiple channels, delimit them with commas.<br />
-Example: "#YOLO,#swag"</p>
+<p>The IRC <em>channel</em> you wish to send cPanel & WHM notifications <em>to</em>.<br />
+Multiple channels currently are not supported.<br />
+Example: "#YOLO"</p>
 HALP
     my $help2 = <<HALP;
 <p>The IRC <em>nickname</em> you wish for cPanel & WHM notifications to use.<br />
@@ -44,6 +44,15 @@ HALP
         'IRCNICK' => {
             'shadow'   => 1,
             'type'     => 'text',
+            'checkval' => sub {
+                my $value = shift();
+                $value =~ s/^\s+|\s+$//g; # Trim
+
+                # TODO get full list of "invalid characters". RFC doesn't specify.
+                die "IRC nicknames can't contain spaces!" if index( $value, " ") != -1;
+
+                return $value;
+            },
             'label' => 'IRC Notification Bot Nickname',
             'help' => $help2,
         },

+ 5 - 6
t/Cpanel-iContact-Provider-IRC.t

@@ -5,7 +5,7 @@ use Cwd qw{abs_path};
 use File::Basename qw{dirname};
 use lib abs_path( dirname(__FILE__) . "/../lib" );
 
-use Test::More 'tests' => 5;
+use Test::More 'tests' => 3;
 use Test::Fatal;
 use IO::Socket::INET ();
 use IO::Socket::SSL  ();
@@ -15,21 +15,20 @@ is( exception { require Cpanel::iContact::Provider::IRC; }, undef, 'Module at le
 isa_ok( my $bot = Cpanel::iContact::Provider::IRC->new(), "Cpanel::iContact::Provider::IRC" );
 my $sent;
 {
+    # TODO finish unit test.
     no warnings qw{redefine once};
     #is( exception { $sent = $bot->send(); }, undef, 'send() did not throw' );
-	pass("wha");
 }
 #ok( $sent, "...and the message appears to have actually sent." );
-pass("dup");
 
 SKIP: {
     my $conf_file = abs_path( dirname(__FILE__) . "/../.irctestrc" );
     skip "Skipping functional testing, needful not supplied", 1 if !$ENV{'AUTHOR_TESTS'} || !-f $conf_file;
     my $test_conf = { Config::Simple->import_from($conf_file)->vars() };
     my %args = (
-        'destination' => $test_conf->{'CONTACTIRC'},
-        'subject' => 'My Super cool test notification',
-        'content' => "This is a test of Cpanel::iContact::Provider::IRC. Please Ignore",
+        'destination' => [ $test_conf->{'CONTACTIRC'} ],
+        'subject'     => 'My Super cool test notification',
+        'content'     => "This is a test of Cpanel::iContact::Provider::IRC. Please Ignore",
     );
 
     {