From 98cee4deebfba64dd7143f97675788b175fb8fb4 Mon Sep 17 00:00:00 2001 From: Zoffix Znet Date: Fri, 1 Jan 2016 09:00:37 -0500 Subject: Add server password support (Relates to #3) --- Changes | 6 +++--- README.md | 10 ++++++++++ lib/IRC/Client.pm6 | 4 +++- lib/IRC/Client/Plugin.pm6 | 2 +- lib/IRC/Client/Plugin/Debugger.pm6 | 2 +- lib/IRC/Client/Plugin/PingPong.pm6 | 2 +- lib/IRC/Grammar.pm6 | 2 +- lib/IRC/Grammar/Actions.pm6 | 2 +- lib/IRC/Parser.pm6 | 2 +- 9 files changed, 22 insertions(+), 10 deletions(-) diff --git a/Changes b/Changes index cbe634b..4ecf8b8 100644 --- a/Changes +++ b/Changes @@ -1,9 +1,9 @@ Revision History for 'IRC::Client' Perl 6 Distribution -2.002002 2016-01-01 +2.002001 2016-01-01 - Fix grammar parsing errors that ignored nicks/usernames with underscores - and digit 0 - - + and digit 0 (#8) + - Added server password support (#3) 2.001002 2015-12-30 - Minor doc updates and fixed missing prepreqs in META.info file diff --git a/README.md b/README.md index 2bb94a5..25fc9bd 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,7 @@ method irc-all-events ($irc, $e) { - [`new`](#new) - [`debug`](#debug) - [`host`](#host) + - [`password`](#password) - [`port`](#port) - [`nick`](#nick) - [`username`](#username) @@ -147,6 +148,7 @@ my $irc = IRC::Client.new; my $irc = IRC::Client.new( debug => False, host => 'localhost', + password => 's3cret', port => 6667, nick => 'Perl6IRC', username => 'Perl6IRC', @@ -177,6 +179,14 @@ will be printed by the modules on the STDOUT. **Defaults to:** `False` Specifies the hostname of the IRC server to connect to. **Defaults to:** `localhost` +### `password` + +```perl6 + password => 's3cret', +``` +Specifies the password for the IRC server. (on Freenode, for example, this +is the NickServ password that identifies to services). + ### `port` ```perl6 diff --git a/lib/IRC/Client.pm6 b/lib/IRC/Client.pm6 index 8c0b2c1..49d1cff 100644 --- a/lib/IRC/Client.pm6 +++ b/lib/IRC/Client.pm6 @@ -2,9 +2,10 @@ use v6; use IRC::Parser; # parse-irc use IRC::Client::Plugin::PingPong; use IRC::Client::Plugin; -class IRC::Client:ver<2.001001> { +class IRC::Client:ver<2.002001> { has Bool:D $.debug = False; has Str:D $.host = 'localhost'; + has Str:D $.password; has Int:D $.port where 0 <= $_ <= 65535 = 6667; has Str:D $.nick = 'Perl6IRC'; has Str:D $.username = 'Perl6IRC'; @@ -23,6 +24,7 @@ class IRC::Client:ver<2.001001> { await IO::Socket::Async.connect( $!host, $!port ).then({ $!sock = .result; + $.ssay("PASS $!password\n") if $!password.defined; $.ssay("NICK $!nick\n"); $.ssay("USER $!username $!username $!host :$!userreal\n"); $.ssay("JOIN {@!channels[]} x\n"); diff --git a/lib/IRC/Client/Plugin.pm6 b/lib/IRC/Client/Plugin.pm6 index 83703d7..8244013 100644 --- a/lib/IRC/Client/Plugin.pm6 +++ b/lib/IRC/Client/Plugin.pm6 @@ -1,3 +1,3 @@ constant IRC_HANDLED = "irc plugin handled \x1"; constant IRC_NOT_HANDLED = "irc plugin not-handled \x2"; -unit class IRC::Client::Plugin:ver<2.001001>; +unit class IRC::Client::Plugin:ver<2.002001>; diff --git a/lib/IRC/Client/Plugin/Debugger.pm6 b/lib/IRC/Client/Plugin/Debugger.pm6 index c959cc2..a2cb9a2 100644 --- a/lib/IRC/Client/Plugin/Debugger.pm6 +++ b/lib/IRC/Client/Plugin/Debugger.pm6 @@ -1,6 +1,6 @@ use Data::Dump; use IRC::Client::Plugin; -unit class IRC::Client::Plugin::Debugger:ver<2.001001> is IRC::Client::Plugin; +unit class IRC::Client::Plugin::Debugger:ver<2.002001> is IRC::Client::Plugin; method irc-all-events ($irc, $e) { say Dump $e, :indent(4); diff --git a/lib/IRC/Client/Plugin/PingPong.pm6 b/lib/IRC/Client/Plugin/PingPong.pm6 index b499051..abecd96 100644 --- a/lib/IRC/Client/Plugin/PingPong.pm6 +++ b/lib/IRC/Client/Plugin/PingPong.pm6 @@ -1,2 +1,2 @@ -unit class IRC::Client::Plugin::PingPong:ver<2.001001>; +unit class IRC::Client::Plugin::PingPong:ver<2.002001>; method irc-ping ($irc, $e) { $irc.ssay("PONG {$irc.nick} $e[0]") } diff --git a/lib/IRC/Grammar.pm6 b/lib/IRC/Grammar.pm6 index f1303ee..e20d0e4 100644 --- a/lib/IRC/Grammar.pm6 +++ b/lib/IRC/Grammar.pm6 @@ -1,4 +1,4 @@ -unit grammar IRC::Grammar:ver<2.001001>; +unit grammar IRC::Grammar:ver<2.002001>; token TOP { + } token SPACE { ' '+ } token message { [':' ]? \n } diff --git a/lib/IRC/Grammar/Actions.pm6 b/lib/IRC/Grammar/Actions.pm6 index e7f5292..b8bf75c 100644 --- a/lib/IRC/Grammar/Actions.pm6 +++ b/lib/IRC/Grammar/Actions.pm6 @@ -1,4 +1,4 @@ -unit class IRC::Grammar::Actions:ver<2.001001>; +unit class IRC::Grammar::Actions:ver<2.002001>; method TOP ($/) { $/.make: $>>.made } method message ($/) { my $pref = $/; diff --git a/lib/IRC/Parser.pm6 b/lib/IRC/Parser.pm6 index 77de768..16cc8b1 100644 --- a/lib/IRC/Parser.pm6 +++ b/lib/IRC/Parser.pm6 @@ -1,6 +1,6 @@ use IRC::Grammar; use IRC::Grammar::Actions; -unit class IRC::Parser:ver<2.001001>; +unit class IRC::Parser:ver<2.002001>; sub parse-irc (Str:D $input) is export { IRC::Grammar.parse($input, actions => IRC::Grammar::Actions).made // []; -- cgit v1.1