commit - 166ac4ea24eeb6b169040d1a333fbfd79309d661
commit + 102b2e6e6634df3e03066f106bc46286831cd18f
blob - fcfec55c54b5ee70d0a8bc4865067d055d38956d
blob + ba922b7604d9d33f2dd10e4ca0de13f97ab866e7
--- botnow
+++ botnow
close $fh;
}
+# Returns date in YYYYMMDD format
+sub date {
+ my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
+ my $localtime = sprintf("%04d%02d%02d", $year+1900, $mon+1, $mday);
+ return $localtime;
+}
+
+# Returns timestamp in "Day MM DD HH:MM:SS" format
+sub gettime {
+ my @months = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
+ my @days = qw(Sun Mon Tue Wed Thu Fri Sat Sun);
+ my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
+ my $localtime = sprintf("%s %s %d %02d:%02d:%02d", $days[$wday], $months[$mon], $mday, $hour, $min, $sec);
+ return $localtime;
+}
+
# Path to configuration file
my $confpath = "botnow.conf";
}
my @bots;
-my @months = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
-my @days = qw(Sun Mon Tue Wed Thu Fri Sat Sun);
my @chans = split /[,\s]+/m, $conf{chans};
my @teamchans;
if (defined($conf{teamchans})) { @teamchans = split /[,\s]+/m, $conf{teamchans}; }
putserv($bot, "PONG :$1");
} elsif ($response =~ /^:irc.znc.in (.*) (.*) :(.*)\r\n$/) {
my ($type, $target, $text) = ($1, $2, $3);
- if ($type eq "001" && $target =~ /^$nick.?$/ && $text eq "Welcome to ZNC") {
- } elsif ($type eq "NOTICE" && $target =~ /^$nick.?$/ && $text eq "*** To connect now, you can use /quote PASS <username>:<password>, or /quote PASS <username>/<network>:<password> to connect to a specific network.") {
- } elsif ($type eq "NOTICE" && $target =~ /^$nick.?$/ && $text eq "*** You need to send your password. Configure your client to send a server password.") {
- } elsif ($type eq "464" && $target =~ /^$nick.?$/ && $text eq "Password required") {
+ if ($type eq "464" && $target =~ /^$nick.?$/ && $text eq "Password required") {
putserv($bot, "PASS $nick/$bot->{name}:$pass");
if ($bot->{name} =~ /^$localnet$/i) {
putserv($bot, "OPER $nick $pass");
} elsif ($type eq "464" && $target =~ /^$nick.?$/ && $text eq "Invalid Password") {
die "ERROR: Wrong Username/Password: $bot->{name}";
} else {
- debug(ERRORS, "ERROR: Unexpected type: $type, target: $target, text: $text");
+ debug(ALL, "Debug type: $type, target: $target, text: $text");
}
} elsif($response =~ /^:(([^!]+)!([^@]+@[^@ ]+)) PRIVMSG ([^ ]+) :(.*)\r\n$/i) {
my ($hostmask, $sendnick, $host, $target, $text) = ($1, $2, $3, $4, $5);
}
}
putserv($botlocalnet, $text);
-}
-
-
-sub date {
- my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
- my $localtime = sprintf("%04d%02d%02d", $year+1900, $mon+1, $mday);
- return $localtime;
}
-sub gettime {
- my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
- my $localtime = sprintf("%s %s %d %02d:%02d:%02d", $days[$wday], $months[$mon], $mday, $hour, $min, $sec);
- return $localtime;
-}
sub whois {
my( $socket, $target )=@_;