diff --git a/PBot/Commands.pm b/PBot/Commands.pm index 159b8733..865c7ba7 100644 --- a/PBot/Commands.pm +++ b/PBot/Commands.pm @@ -120,9 +120,9 @@ sub interpreter { } else { return undef if $stuff->{referenced}; if ($admin_level == 0) { - return "/msg $stuff->{nick} You must login to use this command."; + return "/msg $stuff->{nick} You must be an admin to use this command."; } else { - return "/msg $stuff->{nick} You are not authorized to use this command."; + return "/msg $stuff->{nick} Your level is too low to use this command."; } } } diff --git a/PBot/FactoidCommands.pm b/PBot/FactoidCommands.pm index 2563c2e6..8a6c346c 100644 --- a/PBot/FactoidCommands.pm +++ b/PBot/FactoidCommands.pm @@ -581,7 +581,7 @@ sub factset { if ($meta_level > 0) { if ($level == 0) { - return "You must login to set '$key'"; + return "You be an admin to set '$key'"; } elsif ($level < $meta_level) { return "You must be at least level $meta_level to set '$key'"; } @@ -673,7 +673,7 @@ sub factunset { if ($meta_level > 0) { if ($level == 0) { - return "You must login to unset '$key'"; + return "You be an admin to unset '$key'"; } elsif ($level < $meta_level) { return "You must be at least level $meta_level to unset '$key'"; } diff --git a/PBot/Users.pm b/PBot/Users.pm index fdfd2265..a407520d 100644 --- a/PBot/Users.pm +++ b/PBot/Users.pm @@ -257,10 +257,11 @@ sub loggedin_admin { sub login { my ($self, $channel, $hostmask, $password) = @_; my $user = $self->find_user($channel, $hostmask); + my $channel_text = $channel eq '.*' ? '' : " for $channel"; if (not defined $user) { $self->{pbot}->{logger}->log("Attempt to login non-existent [$channel][$hostmask] failed\n"); - return "You do not have an account in $channel."; + return "You do not have a user account$channel_text."; } if (defined $password and $user->{password} ne $password) { @@ -269,8 +270,8 @@ sub login { } $user->{loggedin} = 1; - $self->{pbot}->{logger}->log("$hostmask logged into $channel\n"); - return "Logged into $channel."; + $self->{pbot}->{logger}->log("$hostmask logged into $user->{name} ($hostmask)$channel_text.\n"); + return "Logged into $user->{name} ($hostmask)$channel_text."; } sub logout { @@ -301,19 +302,42 @@ sub logincmd { $arguments = $2; } - if ($self->loggedin($channel, "$nick!$user\@$host")) { - return "/msg $nick You are already logged into channel $channel."; + my ($user_channel, $user_hostmask) = $self->find_user_account($channel, "$nick!$user\@$host"); + + if (not defined $user_channel) { + return "/msg $nick You do not have a user account."; } - my $result = $self->login($channel, "$nick!$user\@$host", $arguments); + my $u = $self->{users}->{hash}->{$user_channel}->{$user_hostmask}; + my $channel_text = $user_channel eq '.*' ? '' : " for $user_channel"; + + if ($u->{loggedin}) { + return "/msg $nick You are already logged into $u->{name} ($user_hostmask}$channel_text."; + } + + my $result = $self->login($user_channel, $user_hostmask, $arguments); return "/msg $nick $result"; } sub logoutcmd { my ($self, $from, $nick, $user, $host, $arguments) = @_; - return "/msg $nick Uh, you aren't logged into channel $from." if (not $self->loggedin($from, "$nick!$user\@$host")); - $self->logout($from, "$nick!$user\@$host"); - return "/msg $nick Good-bye, $nick."; + + $from = $arguments if length $arguments; + my ($user_channel, $user_hostmask) = $self->find_user_account($from, "$nick!$user\@$host"); + + if (not defined $user_channel) { + return "/msg $nick You do not have a user account."; + } + + my $u = $self->{users}->{hash}->{$user_channel}->{$user_hostmask}; + my $channel_text = $user_channel eq '.*' ? '' : " for $user_channel"; + + if (not $u->{loggedin}) { + return "/msg $nick You are not logged into $u->{name} ($user_hostmask)$channel_text."; + } + + $self->logout($user_channel, $user_hostmask); + return "/msg $nick Logged out of $u->{name} ($user_hostmask)$channel_text."; } sub useradd {