From b1e795877f2447bc634cbb4b269f9ac8bebd67f3 Mon Sep 17 00:00:00 2001 From: Zoffix Znet Date: Sun, 7 Aug 2016 22:58:46 -0400 Subject: Add `:alias` feature Closes #22 --- docs/02-event-reference.md | 14 ++++++++------ docs/03-method-reference.md | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+), 6 deletions(-) (limited to 'docs') diff --git a/docs/02-event-reference.md b/docs/02-event-reference.md index cb3de1d..ab4e702 100644 --- a/docs/02-event-reference.md +++ b/docs/02-event-reference.md @@ -83,9 +83,11 @@ irc-addressed ▶ irc-to-me ▶ irc-notice-channel ▶ irc-notice ▶ This event chain is triggered when the client is addressed in a channel either via a `PRIVMSG` or `NOTICE` IRC message. 'Addressed' means the message line -starts with the current nickname of the client, followed by `;` or `,` +starts with the current nickname of the client or one of its aliases, +followed by `;` or `,` characters, followed by any number of whitespace; or -in regex terms, matches `/^ $nick <[,:]> \s* /`. This prefix portion will be +in regex terms, matches `/^ [$nick | @aliases] <[,:]> \s* /`. +This prefix portion will be **stripped** from the actual message. Possible message objects received by event handler: @@ -140,8 +142,8 @@ irc-mentioned ▶ irc-notice-channel ▶ irc-notice ▶ irc-all This event chain is triggered when the client is mentioned in a channel either via a `PRIVMSG` or `NOTICE` IRC message. Being mentioned means the message -contains our nick delimited by word boundaries on both sides; or in regex -terms, matches `/ << $nick >> /`. +contains our nick or one of the aliases delimited by word boundaries on both +sides; or in regex terms, matches `/ << [$nick | @aliases] >> /`. Possible message objects received by event handler: * `IRC::Client::Message::Privmsg::Channel` @@ -306,8 +308,8 @@ irc-addressed ▶ irc-to-me ▶ irc-notice-channel ▶ irc-notice ▶ This event chain is triggered when the client is addressed in a channel via a `PRIVMSG` or `NOTICE` IRC message or receives a private or notice message directly. In cases where the trigger happened due to being addressed -in channel, the prefix used for addressing (nick + `,` or `.` + whitespace) -will be stripped from the message. +in channel, the prefix used for addressing (nick|aliases + `,` or `.` + +whitespace) will be stripped from the message. Possible message objects received by event handler: * `IRC::Client::Message::Privmsg::Channel` diff --git a/docs/03-method-reference.md b/docs/03-method-reference.md index 9c5f1fa..6963d64 100644 --- a/docs/03-method-reference.md +++ b/docs/03-method-reference.md @@ -354,6 +354,10 @@ the channel and the value is its password. A list of nicks the client uses on this server. If one nick is taken, next one in the list will be attempted to be used. +#### `.alias` + +A list of aliases on this server. + #### `.host` The host of the server. @@ -445,6 +449,7 @@ my $irc = IRC::Client.new: :password :channels<#perl #perl6 #rust-lang> :nick + :alias('foo', /b.r/) :username :userhost :userreal('Mah awesome bot!') @@ -515,8 +520,22 @@ generate three additional nicknames that have underscores appended If one of the given nicks is in use, the client will attempt to use the next one in the list. +##### `:alias` + **Defaults to:** `P6Bot` +```perl6 + :alias('foo', /b.r/) +``` + +A list of `Str` or `Regex` objects that in the context of +`irc-addressed`, `irc-to-me`, and `irc-mentioned` events will be used +as alternative nicks. In other words, specifying `'bot'` as alias will allow +you to address the bot using `bot` nick, regardless of the actual nick the +bot is currently using. + +**Defaults to:** empty list + ##### `:password` The server password to use. On some networks (like Freenode), the server -- cgit v1.1