Commit Diff
Diff:
37ca25b658006ff7782dbad70f1f8ee6e3e87a14
6e28212dc089e20351348d8b951bb4b097a3605c
Commit:
6e28212dc089e20351348d8b951bb4b097a3605c
Tree:
0e370adfbe6cb9ec096099a6e26d583077c93848
Author:
jrmu <jrmu@ircnow.org>
Committer:
jrmu <jrmu@ircnow.org>
Date:
Mon Oct 12 11:16:30 2020 UTC
Message:
Fixed SQLite bug
blob - /dev/null
blob + 3149b97ef215e865770db53d14a81cd9a7c8d3f0 (mode 644)
--- /dev/null
+++ Commands
@@ -0,0 +1,107 @@
+Output
+========
+
+putserv BOT TEXT
+
+Sends text to the IRC server. Returns nothing.
+
+Bind
+========
+
+bind BOT TYPE FLAGS MASK PROC
+
+Binds perl procedures to events. Currently flags and mask are ignored. Returns the name of the command that was added.
+
+1. MSG
+
+bind BOT "MSG" FLAGS COMMAND PROC
+procname NICK USERHOST HANDLE TEXT
+
+Called on /msg commands. The first word of the msg is the command, and the rest
+the text.
+
+bind($bot, "msg", "", "admin", $proc);
+sub proc {
+ my ($nick, $userhost, $hand, $text) = @_;
+ ...
+}
+
+2. PUB
+
+bind BOT "PUB" FLAGS COMMAND PROC
+procname NICK USERHOST HANDLE CHANNEL TEXT
+
+bind($bot, "pub", "", "help", $proc);
+sub proc {
+ my ($nick, $userhost, $hand, $chan, $text) = @_;
+ ...
+}
+
+Called on commands in a channel. The first word of the msg is the command, and the rest
+the text.
+
+3. MSGM (stackable)
+
+bind BOT "MSGM" FLAGS MASK PROC
+procname NICK USERHOST HANDLE TEXT
+
+bind($bot, "msgm", "", "", $proc);
+sub proc {
+ my ($nick, $userhost, $hand, $text) = @_;
+ ...
+}
+
+Match all text from a /msg. MSGM binds are processed before MSG binds.
+
+4. PUBM (stackable)
+
+bind BOT "PUBM" FLAGS MASK PROC
+procname NICK USERHOST HANDLE CHAN TEXT
+
+bind($bot, "pubm", "", "", $proc);
+sub proc {
+ my ($nick, $userhost, $hand, $chan, $text) = @_;
+ ...
+}
+
+Match all text from a message on a channel. PUBM binds are processed before PUB binds.
+
+5. NOTC (stackable)
+
+bind BOT "NOTC" FLAGS MASK PROC
+procname NICK USERHOST HANDLE TEXT DEST
+
+bind($bot, "notc", "", "", $proc);
+sub proc {
+ my ($nick, $userhost, $hand, $text, $dest) = @_;
+ ...
+}
+
+Called when a notice is sent. $dest is either the bot's nickname or channel.
+You should not respond to a /notice, so this is useful for logging and analytics.
+
+6. JOIN (stackable)
+
+bind BOT "JOIN" FLAGS MASK PROC
+procname NICK USERHOST HANDLE CHANNEL
+
+bind($bot, "join", "", "", $proc);
+sub proc {
+ my ($nick, $userhost, $hand, $chan) = @_;
+ ...
+}
+
+Called when someone joins a channel.
+
+7. PART (stackable)
+
+bind BOT "PART" FLAGS MASK PROC
+procname NICK USERHOST HANDLE CHANNEL TEXT
+
+bind($bot, "part", "", "", $proc);
+sub proc {
+ my ($nick, $userhost, $hand, $chan, $text) = @_;
+ ...
+}
+
+Called when someone parts a channel.
blob - 709af20fa2724f79b8a2880bbc6625d077486ba4
blob + 382dcc8c8b561c26d01c711eac135623638aa955
--- SQLite.pm
+++ SQLite.pm
@@ -168,11 +168,11 @@ sub connectdb {
my $user = "";
my $password = "";
$dbh = DBI->connect($dsn, $user, $password, {
- PrintError => 0,
+ PrintError => 1,
RaiseError => 1,
AutoCommit => 1,
FetchHashKeyName => 'NAME_lc',
- }) or die "Couldn't connect to database: " . DBI->errstr;
+ }) or die "Couldn't connect to database: " . $DBI::errstr;
if (!(-s "$dbpath")) {
my $sql = main::readstr('table.sql');
my @sql = split /;/m, $sql;
@@ -264,10 +264,10 @@ sub userset {
my ($vhost, $key, $val) = @_;
if (!defined($records)) { getrecords(); }
my $ret;
- if (!defined($records->{$vhost})) {
- $ret = insertrow("vhost,$key", "\"$vhost\",\"$val\"") > 0;
- } else {
+ if (defined($records->{$vhost}) && keys %{$records->{$vhost}}) {
$ret = updaterow($vhost, $key, $val) > 0;
+ } else {
+ $ret = insertrow("vhost,$key", "\"$vhost\",\"$val\"") > 0;
}
$records->{$vhost}->{$key} = $val; # autovivifies
return $ret;
@@ -312,20 +312,5 @@ sub firstval {
}
return;
}
-#sub msave {
-# my ($bot, $nick, $host, $hand, $text) = @_;
-# if ($staff !~ /$nick/) { return; }
-# if (savedb()) { main::putserv($bot, "PRIVMSG $nick :Records saved."); }
-#}
-#sub savedb {
-# if (!defined($records)) { getrecords(); }
-# while (my ($vhost, $record) = each (%$records)) {
-# foreach my $key (keys %$record) {
-# updaterow($vhost, $key, $record->{$key});
-# if ($verbose >= 3) { print "$vhost $key => ".$record->{$key}."\n"; }
-# }
-# }
-# return 1;
-#}
1; # MUST BE LAST STATEMENT IN FILE
blob - 5d073a75c485252cfe0c559b21ead662a3afee2d
blob + e93038460b1c941fbd9a3fbcc6af70ea41e78d32
--- WWW.pm
+++ WWW.pm
@@ -6,12 +6,16 @@ use strict;
use warnings;
use OpenBSD::Pledge;
use OpenBSD::Unveil;
-our $wwwpath = "/var/www/htdocs/botnow"; # Web folder path
-our $dbpath = "/var/www/botnow/botnow.db";
-our $database = "/var/www/botnow/"; # database path
-our $records;
-our $dbh;
-our $verbose = 3;
+my $wwwpath = "/var/www/htdocs/botnow"; # Web folder path
+my $dbpath = "/var/www/botnow/botnow.db";
+my $database = "/var/www/botnow/"; # database path
+my $staff;
+my $verbose;
+
+sub init {
+ $staff = $main::conf{staff};
+ $verbose = $main::conf{verbose};
+}
sub www {
my( $username, $email, $password, $service )=@_;
blob - 0744432dea0b96fd7e5bbc733ca2f5e3ad1f1459
blob + d0691a05cad4870dd6793f36bae7a097d5266876
--- networks
+++ networks
@@ -257,7 +257,7 @@ virtualife irc.virtualife.org ~6697
w3 irc.w3.org 6667
wenet irc.wenet.ru 6667
#whatnet irc.whatnet.org ~6697
-wnet irc.wnet.tk ~6667
+wnet irc.wnet.tk ~6697
#wnet bantam.wnet.tk ~6697
xertion irc.xertion.org +6697
zairc irc.zairc.net ~6697