summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2020-05-15 14:47:58 +0200
committerPatrick Spek <p.spek@tyil.nl>2020-05-15 14:47:58 +0200
commita3b65272998f98aa23b3a52ec98ce6d062ff5f13 (patch)
tree9da7cf7eae30388a34133b76141e50454712b309
parentd74977669af547ae2b03fde6fc2a237f97cd8c5d (diff)
downloadIRC::Client::Plugin::NickServ-a3b65272998f98aa23b3a52ec98ce6d062ff5f13.tar.gz
IRC::Client::Plugin::NickServ-a3b65272998f98aa23b3a52ec98ce6d062ff5f13.tar.bz2
Move configuration around
-rw-r--r--lib/IRC/Client/Plugin/NickServ.pm668
1 files changed, 36 insertions, 32 deletions
diff --git a/lib/IRC/Client/Plugin/NickServ.pm6 b/lib/IRC/Client/Plugin/NickServ.pm6
index a6c8972..180ed4f 100644
--- a/lib/IRC/Client/Plugin/NickServ.pm6
+++ b/lib/IRC/Client/Plugin/NickServ.pm6
@@ -6,42 +6,46 @@ use Config;
use IRC::Client;
#| The IRC::Client::Plugin to deal with NickServ interaction.
-class IRC::Client::Plugin::NickServ does IRC::Client::Plugin
-{
- has Config $.config;
-
- #| Identify with NickServ. This is done on IRC code 376 (end of MOTD),
- #| since this is what most servers accept as the earliest time to start
- #| interacting with the server.
- method irc-n376($e)
- {
- # Extract the config parameters
- my Str $user = $!config<nickserv><nickname> // $!config<bot><nickname>;
- my Str $pass = $!config<nickserv><password>;
-
- # Nothing to do if we don't have a username and a password
- if (!$user || !$pass) {
- note "Missing username or password for NickServ auth";
- return;
- }
-
- # Send the identify command
- $e.irc.send-cmd: "NS identify $user $pass";
+unit class IRC::Client::Plugin::NickServ does IRC::Client::Plugin;
+
+#| A Config instance to hold all configuration.
+has Config $.config;
+
+#| Identify with NickServ. This is done on IRC code 376 (end of MOTD),
+#| since this is what most servers accept as the earliest time to start
+#| interacting with the server.
+method irc-n376 (
+ $event,
+) {
+ # Extract the config parameters
+ my $user = $!config.get('irc.plugins.nickserv.account');
+ my $pass = $!config.get('irc.plugins.nickserv.password');
+
+ # Nothing to do if we don't have a username and a password
+ if (!$user || !$pass) {
+ .critical('Missing username or password for NickServ auth') with $*LOG;
+ return;
}
- multi method irc-notice($e where m:i/"you are now identified"/)
- {
- return if $e.server.current-nick eq $e.server.nick.first;
+ # Send the identify command
+ $event.irc.send-cmd: "NS identify $user $pass";
+}
- # Ghost our nick
- $e.irc.send-cmd: "NS GHOST {$e.server.nick.first}";
- }
+multi method irc-notice (
+ $event where *.text.contains('you are now identified', :i),
+) {
+ # Nothing to do if we already have our preferred nickname
+ return if $event.server.current-nick eq $event.server.nick.first;
- multi method irc-notice($e where m:i/"has been ghosted"/)
- {
- # Use our nick
- $e.irc.nick: $e.server.nick.first;
- }
+ # Ghost our nick
+ $event.irc.send-cmd: "NS GHOST {$event.server.nick.first}";
+}
+
+multi method irc-notice (
+ $event where *.text.contains('has been ghosted', :i),
+) {
+ # Use our nick
+ $event.irc.nick: $event.server.nick.first;
}
# vim: ft=perl6 noet