diff --git a/PBot/StdinReader.pm b/PBot/StdinReader.pm index 8b88f0f0..94738621 100644 --- a/PBot/StdinReader.pm +++ b/PBot/StdinReader.pm @@ -25,19 +25,23 @@ sub initialize { $self->{pbot} = $conf{pbot} // Carp::croak("Missing pbot reference in StdinReader"); # create implicit bot-admin account for bot - if (not $self->{pbot}->{users}->find_admin('.*', '*!stdin@pbot')) { + my $user = $self->{pbot}->{users}->find_user('.*', '*!stdin@pbot'); + if (not defined $user or not $self->{pbot}->{capabilities}->userhas($user, 'botowner')) { my $botnick = $self->{pbot}->{registry}->get_value('irc', 'botnick'); - $self->{pbot}->{logger}->log("Adding stdin admin *!stdin\@pbot...\n"); - $self->{pbot}->{users}->add_user($botnick, '.*', '*!stdin@pbot', 100, undef, 1); + $self->{pbot}->{logger}->log("Adding stdin botowner *!stdin\@pbot...\n"); + $self->{pbot}->{users}->add_user($botnick, '.*', '*!stdin@pbot', 'botowner', undef, 1); $self->{pbot}->{users}->login($botnick, "$botnick!stdin\@pbot", undef); $self->{pbot}->{users}->save; } # used to check whether process is in background or foreground, for stdin reading - open TTY, "{tty_fd} = fileno(TTY); - - $self->{pbot}->{select_handler}->add_reader(\*STDIN, sub { $self->stdin_reader(@_) }); + if (not $self->{pbot}->{registry}->get_value('general', 'daemon')) { + open TTY, "{tty_fd} = fileno(TTY); + $self->{pbot}->{select_handler}->add_reader(\*STDIN, sub { $self->stdin_reader(@_) }); + } else { + $self->{pbot}->{logger}->log("Starting in daemon mode.\n"); + } } sub stdin_reader {