my @args=shellwords $msg;
my $cmd=shift @args;
- given($cmd){
- when(/^myid$/i){
- $self->{irc}->yield(privmsg => $nick, $from);
+ local $_ = $cmd;
+ if (/^myid$/i){
+ $self->{irc}->yield(privmsg => $nick, $from);
+ } elsif (/^login$/i) {
+ my ($user, $pass) = @args;
+
+ eval { pwcheck $user, $pass };
+
+ if ($@) {
+ $self->{log}->debug("Login for $user failed");
+ $self->{irc}->yield(privmsg => $nick, 'Bad username/password combination');
+ } else {
+ $self->{log}->debug("Login for $user succeded");
+ $self->{nick_to_username}{$from} = $user;
+ $self->{irc}->yield(privmsg => $nick, "Logged in as $user");
}
-
- when(/^login$/i) {
- my ($user, $pass) = @args;
-
- eval { pwcheck $user, $pass };
-
- if ($@) {
- $self->{log}->debug("Login for $user failed");
- $self->{irc}->yield(privmsg => $nick, 'Bad username/password combination');
- } else {
- $self->{log}->debug("Login for $user succeded");
- $self->{nick_to_username}{$from} = $user;
- $self->{irc}->yield(privmsg => $nick, "Logged in as $user");
- }
- }
-
- when(/^logout$/i){
- delete $self->{nick_to_username}{$from};
- }
-
- when(/^prefix$/i){
- if (defined $username) {
- $self->{prefix}{$username} = [@args];
- } else {
- $self->{irc}->yield(privmsg => $nick, 'You are not logged in. Say "login your_username your_password" (where your_username and your_password are your login credentials) to login.');
- }
+ } elsif (/^logout$/i){
+ delete $self->{nick_to_username}{$from};
+ } elsif (/^prefix$/i){
+ if (defined $username) {
+ $self->{prefix}{$username} = [@args];
+ } else {
+ $self->{irc}->yield(privmsg => $nick, 'You are not logged in. Say "login your_username your_password" (where your_username and your_password are your login credentials) to login.');
}
-
- when(/^noprefix$/i){
- if (defined $username) {
- delete $self->{prefix}{$username}
- } else {
- $self->{irc}->yield(privmsg => $nick, 'You are not logged in. Say "login your_username your_password" (where your_username and your_password are your login credentials) to login.');
- }
+ } elsif (/^noprefix$/i){
+ if (defined $username) {
+ delete $self->{prefix}{$username}
+ } else {
+ $self->{irc}->yield(privmsg => $nick, 'You are not logged in. Say "login your_username your_password" (where your_username and your_password are your login credentials) to login.');
}
-
- default {
- if (defined $username) {
- $ok_user_addresses{"$username $address"}=1;
- $self->{log}->debug("Command $cmd @args from $username");
- if (exists $self->{prefix}{$username}) {
- sendmsg $username, undef, $address, @{$self->{prefix}{$username}}, $cmd, @args;
- } else {
- sendmsg $username, undef, $address, $cmd, @args;
- }
+ } else {
+ if (defined $username) {
+ $ok_user_addresses{"$username $address"}=1;
+ $self->{log}->debug("Command $cmd @args from $username");
+ if (exists $self->{prefix}{$username}) {
+ sendmsg $username, undef, $address, @{$self->{prefix}{$username}}, $cmd, @args;
} else {
- $self->{irc}->yield(privmsg => $nick, 'You are not logged in. Say "login your_username your_password" (where your_username and your_password are your login credentials) to login.');
+ sendmsg $username, undef, $address, $cmd, @args;
}
+ } else {
+ $self->{irc}->yield(privmsg => $nick, 'You are not logged in. Say "login your_username your_password" (where your_username and your_password are your login credentials) to login.');
}
-
}
}