]> git.99rst.org Git - irssi-scripts.irssi.org.git/commitdiff
qchallengeauth: QuakeNet Q auth script
authorDouglas Freed <redacted>
Sat, 23 Aug 2014 12:23:44 +0000 (12:23 +0000)
committerDouglas Freed <redacted>
Sat, 23 Aug 2014 12:23:44 +0000 (12:23 +0000)
_data/scripts.yaml
scripts/qchallengeauth.pl [new file with mode: 0755]

index 3303db7d77d594daef14c8d0f2cfe5d49fda3f1d..646014b40199ebfa57bce13b8a18497b881830d8 100644 (file)
   license: "WTFPL"
   name: "oopsie"
   version: "1.0"
+
+- authors: "Doug Freed"
+  contact: "dwfreed!#irssi@freenode"
+  description: "Authenticates with QuakeNet's Q service upon connection, using their CHALLENGEAUTH protocol"
+  filename: "qchallengeauth.pl"
+  modified: "2014-08-23"
+  license: "GPLv3+"
+  name: "qchallengeauth"
+  version: "1.0"
diff --git a/scripts/qchallengeauth.pl b/scripts/qchallengeauth.pl
new file mode 100755 (executable)
index 0000000..5eae4c2
--- /dev/null
@@ -0,0 +1,55 @@
+use strict;
+use warnings;
+use Irssi;
+use Digest::SHA qw(sha256_hex hmac_sha256_hex);
+use vars qw($VERSION %IRSSI);
+# $Id$
+
+$VERSION = "1.0";
+
+%IRSSI = (
+    authors     => 'Doug Freed',
+    contact     => 'dwfreed!#irssi@freenode',
+    name        => 'qchallengeauth.pl',
+    description => 'Authenticates you to QuakeNet\'s Q immediately on connect using CHALLENGEAUTH',
+    license     => 'GPLv3+',
+);
+
+Irssi::settings_add_str('misc', 'quakenet_server_tag', 'QuakeNet');
+Irssi::settings_add_str('misc', 'quakenet_username', '');
+Irssi::settings_add_str('misc', 'quakenet_password', '');
+
+Irssi::signal_add('server connected', 'server_connected');
+
+sub server_connected() {
+       my ($server) = @_;
+       return unless ($server->{tag} eq Irssi::settings_get_str('quakenet_server_tag'));
+       Irssi::signal_add_first('event connected', 'event_connected');
+}
+
+sub event_connected() {
+       my ($server) = @_;
+       return unless ($server->{tag} eq Irssi::settings_get_str('quakenet_server_tag'));
+       Irssi::signal_add_first('message irc notice', 'message_irc_notice');
+       Irssi::signal_remove('event connected', 'event_connected');
+       $server->send_raw('PRIVMSG Q@cserve.quakenet.org :CHALLENGE');
+       Irssi::signal_stop();
+}
+
+sub message_irc_notice() {
+       my ($server, $message, $nick, $address, $target) = @_;
+       return unless ($server->{tag} eq Irssi::settings_get_str('quakenet_server_tag'));
+       return unless ($target eq $server->{nick});
+       return unless ($nick eq 'Q');
+       if ($message =~ /^CHALLENGE ([[:xdigit:]]+)/){
+               Irssi::signal_stop();
+               my $username = Irssi::settings_get_str('quakenet_username');
+               my $hashed_password = sha256_hex(substr(Irssi::settings_get_str('quakenet_password'), 0, 10));
+               my $key = sha256_hex("$username:$hashed_password");
+               my $response = hmac_sha256_hex($1, $key);
+               $server->send_raw("PRIVMSG Q\@cserve.quakenet.org :CHALLENGEAUTH $username $response HMAC-SHA-256");
+       } else {
+               Irssi::signal_remove('message irc notice', 'message_irc_notice');
+               Irssi::signal_emit('event connected', $server);
+       }
+}
git clone https://git.99rst.org/PROJECT