From 06dbd894829ec90b4735fdaf342a5b4439dc73b5 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Thu, 4 Dec 2014 16:59:56 +0100 Subject: Implemented REGISTER --- Avalon.pm | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Avalon.pm b/Avalon.pm index ba73ae3..a5708ec 100644 --- a/Avalon.pm +++ b/Avalon.pm @@ -1,6 +1,6 @@ package Bot::BasicBot::Pluggable::Module::Avalon; { - $Avalon::Arthur::VERSION = '0.02'; + $Avalon::Arthur::VERSION = '0.03'; }; use strict; @@ -92,7 +92,20 @@ sub told { my ( $command, @args ) = split /\s+/, $mess->{body}; given ($command) { - when ("REGISTER") {} + when ("REGISTER") { + return 'ERR_BAD_ARGUMENTS' if scalar @args != 3; + my ( $owner, $bot_version, $protocol_version ) = @args; + return 'ERR_PROTOCOL_MISMATCH' if $protocol_version ne $Avalon::Arthur::VERSION; + my $record = $avdb->get('REGISTRATIONS', $who); + if ($record) { + return 'ERR_NICK_RESERVED' if $record ne $mess->{raw_nick}; + return 'ERR_BANNED' if $avdb->get('BANS', $who . $bot_version); + } else { + $avdb->set('REGISTRATIONS', $who, $mess->{raw_nick}); + } + $av->{registered}->{$who} = { owner => $owner, version => $bot_version }; + $self->say( channel => $av->{config}->{'game.channel'}, body => "REGISTERED $who" ); + } when ("REGISTERED") {} when ("UNREGISTER") {} when ("UNREGISTERED") {} -- cgit v1.2.3