From 22e7b4b543738acf1c5e9ece7435eb95fea55dc5 Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Mon, 17 Dec 2018 05:29:14 +0100 Subject: Add .editorconfig --- .editorconfig | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..3e899fd --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true +max_line_length = 80 + +[*.json] +indent_style = space +indent_size = 4 -- cgit v1.1 From d28cf05eedae3cd41246773d997dbfb523e552e6 Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Mon, 17 Dec 2018 05:30:24 +0100 Subject: Add tyil to CONTRIBUTORS --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b0ca508..f22e563 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ Zoffix Znet (http://zoffix.com/) #### CONTRIBUTORS +[tyil](https://www.tyil.nl/) [MasterDuke17](https://github.com/zoffixznet/perl6-IRC-Client/commits?author=MasterDuke17) #### LICENSE -- cgit v1.1 From b8f67601e0086d7a2403e4f47ca720e3df3c5365 Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Mon, 17 Dec 2018 06:22:24 +0100 Subject: Make auto-prefixing nicks optional This patch adds the :autoprefix option, which is True by default. When set to False, the .reply method should no longer prefix the message with the triggering user's nick. --- lib/IRC/Client.pm6 | 4 ++++ lib/IRC/Client/Message.pm6 | 13 +++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/IRC/Client.pm6 b/lib/IRC/Client.pm6 index cd2348e..f0bc7a8 100644 --- a/lib/IRC/Client.pm6 +++ b/lib/IRC/Client.pm6 @@ -21,6 +21,7 @@ has $.debug; has Lock $!lock = Lock.new; has Channel $!event-pipe = Channel.new; has Channel $!socket-pipe = Channel.new; +has Bool $.autoprefix = True; my &colored = (try require Terminal::ANSIColor) === Nil && sub (Str $s, $) { $s } || @@ -44,9 +45,12 @@ submethod BUILD ( Str:D :$userhost = 'localhost', Str:D :$userreal = 'Perl6 IRC Client', :$channels = ('#perl6',), + Bool:D :$autoprefix = True, ) { @!filters = @$filters; @!plugins = @$plugins; + $!autoprefix = $autoprefix; + my %servers = %$servers; my %all-conf = :$port, :$password, :$host, :$nick, :$alias, diff --git a/lib/IRC/Client/Message.pm6 b/lib/IRC/Client/Message.pm6 index 79ef7d8..ff307ef 100644 --- a/lib/IRC/Client/Message.pm6 +++ b/lib/IRC/Client/Message.pm6 @@ -40,8 +40,10 @@ role Privmsg does M { role Privmsg::Channel does Privmsg { has $.channel; method reply ($text, :$where) { - $.irc.send-cmd: 'PRIVMSG', $where // $.channel, $text, - :$.server, :prefix("$.nick, "); + $.irc.autoprefix + ?? $.irc.send-cmd: 'PRIVMSG', $where // $.channel, $text, :$.server, :prefix("$.nick, ") + !! $.irc.send-cmd: 'PRIVMSG', $where // $.channel, $text, :$.server + ; } } role Privmsg::Me does Privmsg { @@ -60,8 +62,11 @@ role Notice does M { role Notice::Channel does Notice { has $.channel; method reply ($text, :$where) { - $.irc.send-cmd: 'NOTICE', $where // $.channel, $text, - :$.server, :prefix("$.nick, "); + $.irc.autoprefix + ?? $.irc.send-cmd: 'NOTICE', $where // $.channel, $text, :$.server, :prefix("$.nick, ") + !! $.irc.send-cmd: 'NOTICE', $where // $.channel, $text, :$.server + ; + $.replied = True; } } -- cgit v1.1