mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-26 05:49:27 +01:00
Improve login/logout related messages
This commit is contained in:
parent
cc710fc478
commit
539e599b61
@ -120,9 +120,9 @@ sub interpreter {
|
|||||||
} else {
|
} else {
|
||||||
return undef if $stuff->{referenced};
|
return undef if $stuff->{referenced};
|
||||||
if ($admin_level == 0) {
|
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 {
|
} 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.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -581,7 +581,7 @@ sub factset {
|
|||||||
|
|
||||||
if ($meta_level > 0) {
|
if ($meta_level > 0) {
|
||||||
if ($level == 0) {
|
if ($level == 0) {
|
||||||
return "You must login to set '$key'";
|
return "You be an admin to set '$key'";
|
||||||
} elsif ($level < $meta_level) {
|
} elsif ($level < $meta_level) {
|
||||||
return "You must be at least level $meta_level to set '$key'";
|
return "You must be at least level $meta_level to set '$key'";
|
||||||
}
|
}
|
||||||
@ -673,7 +673,7 @@ sub factunset {
|
|||||||
|
|
||||||
if ($meta_level > 0) {
|
if ($meta_level > 0) {
|
||||||
if ($level == 0) {
|
if ($level == 0) {
|
||||||
return "You must login to unset '$key'";
|
return "You be an admin to unset '$key'";
|
||||||
} elsif ($level < $meta_level) {
|
} elsif ($level < $meta_level) {
|
||||||
return "You must be at least level $meta_level to unset '$key'";
|
return "You must be at least level $meta_level to unset '$key'";
|
||||||
}
|
}
|
||||||
|
@ -257,10 +257,11 @@ sub loggedin_admin {
|
|||||||
sub login {
|
sub login {
|
||||||
my ($self, $channel, $hostmask, $password) = @_;
|
my ($self, $channel, $hostmask, $password) = @_;
|
||||||
my $user = $self->find_user($channel, $hostmask);
|
my $user = $self->find_user($channel, $hostmask);
|
||||||
|
my $channel_text = $channel eq '.*' ? '' : " for $channel";
|
||||||
|
|
||||||
if (not defined $user) {
|
if (not defined $user) {
|
||||||
$self->{pbot}->{logger}->log("Attempt to login non-existent [$channel][$hostmask] failed\n");
|
$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) {
|
if (defined $password and $user->{password} ne $password) {
|
||||||
@ -269,8 +270,8 @@ sub login {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$user->{loggedin} = 1;
|
$user->{loggedin} = 1;
|
||||||
$self->{pbot}->{logger}->log("$hostmask logged into $channel\n");
|
$self->{pbot}->{logger}->log("$hostmask logged into $user->{name} ($hostmask)$channel_text.\n");
|
||||||
return "Logged into $channel.";
|
return "Logged into $user->{name} ($hostmask)$channel_text.";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub logout {
|
sub logout {
|
||||||
@ -301,19 +302,42 @@ sub logincmd {
|
|||||||
$arguments = $2;
|
$arguments = $2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($self->loggedin($channel, "$nick!$user\@$host")) {
|
my ($user_channel, $user_hostmask) = $self->find_user_account($channel, "$nick!$user\@$host");
|
||||||
return "/msg $nick You are already logged into channel $channel.";
|
|
||||||
|
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";
|
return "/msg $nick $result";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub logoutcmd {
|
sub logoutcmd {
|
||||||
my ($self, $from, $nick, $user, $host, $arguments) = @_;
|
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");
|
$from = $arguments if length $arguments;
|
||||||
return "/msg $nick Good-bye, $nick.";
|
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 {
|
sub useradd {
|
||||||
|
Loading…
Reference in New Issue
Block a user