]> git.99rst.org Git - irssi-scripts.irssi.org.git/commitdiff
[emaildb] version 1.1
authorpleia2 <redacted>
Mon, 18 Feb 2019 15:16:43 +0000 (16:16 +0100)
committerbw1 <redacted>
Tue, 19 Feb 2019 16:08:33 +0000 (17:08 +0100)
scripts/emaildb.pl [moved from scripts/emaildb1.0.pl with 77% similarity]

similarity index 77%
rename from scripts/emaildb1.0.pl
rename to scripts/emaildb.pl
index bf661f2f29138db3e0549ef791b01bc0b37b5e20..16a76c08f050f9fbe4c994f8ac085363368708b0 100644 (file)
@@ -32,7 +32,7 @@
 # R2D2
 # Time
 #
-# AND uncomment the 3 sections indicatated in the script
+# AND uncomment the 2 sections indicatated in the script
 #
 # I never created an interface to add new nicknames, email, and birthday, 
 # so you will need to manually insert this information into the database
 # results of any nicknames with a 't' i nthem)
 # 
 # Personally, I run this in an ircbot, as the owner of this script cannot use
-# the ~search command themselves
+# the ~nick command themselves
 #
 # 
 # ... That's about it, enjoy!
 # 
 
-use strict;
+
 use Irssi;
 use DBI;
 use vars qw($VERSION %IRSSI);
 
-$VERSION = "1.0";
+$VERSION = "1.1";
 %IRSSI = (
-    authors => 'PrincessLeia2',
+    author => 'PrincessLeia2',
     contact => 'lyz\@princessleia.com ',
     name => 'emaildb',
     description => 'a script for accessing an email mysql database through irc',
@@ -66,39 +66,36 @@ $VERSION = "1.0";
 
 
 # uncomment the following commented (and replace '/home/user' with your home directory) lines for user restricted access.
-#
-# open ( LIST, "</home/lyz/.irssi/users" ) or die "can't open users:$!\n";
-#  chomp( @user = <LIST> );
-#         close LIST;
 
-my $d = ('database');
-my $u = ('user');
-my $p = ('password');
+ open ( LIST, "</home/lyz/.irssi/users" ) or die "can't open users:$!\n";
+  chomp( @user = <LIST> );
+         close LIST;
+
+$d = ('database');
+$u = ('user');
+$p = ('password');
 
 
 sub event_privmsg {
 my ($server, $data, $nick, $mask, $target) =@_;
 my ($target, $text) = $data =~ /^(\S*)\s:(.*)/;
   if ($text =~ /^~search */i ) {
-
-# Uncomment the following commented lines for user restricted access
-#    foreach $person (@user) {
-#      if ($nick =~ /^$person$/i) {
-
+    foreach $person (@user) {
+      if ($nick =~ /^$person$/i) {
                my ($nickname) = $text =~ /^~search (.*)/;
 
-        my $dbh = DBI->connect("DBI:mysql:$d","$u","$p")
+        $dbh = DBI->connect("DBI:mysql:$d","$u","$p")
                 or die "Couldn't connect to database: " . DBI->errstr;
-        my $sth = $dbh->prepare("SELECT * FROM 13th where nickname like \"\%$nickname\%\";")
-                or die "Cant prepare statement: $dbh->errstr\n";
-        my $rv = $sth->execute
+        $sth = $dbh->prepare("SELECT * FROM 13th where nickname like \"\%$nickname\%\";")
+                or die "Cant prepare $statement: $dbh->errstr\n";
+        $rv = $sth->execute
                 or die "cant execute the query: $sth->errstr\n";
 if ($rv >= 1) {
   my @row;
   while ( @row = $sth->fetchrow_array(  ) ) {
-       my $n = "$row[0]\n";
-       my $e = "$row[1]\n";
-       my $b = "$row[2]\n";
+       $n = "$row[0]\n";
+       $e = "$row[1]\n";
+       $b = "$row[2]\n";
                 $server->command ( "msg $nick Nickname : $n" );
                 $server->command ( "msg $nick Email : $e" );
                 $server->command ( "msg $nick Birthday : $b" );
@@ -108,11 +105,8 @@ else    {
            $server->command ( "msg $nick Sorry, No Results Match Your Query\n" );
        }
 
-# Uncomment the following commented lines for user restricted access
-#}
-#}
-
 }
 }
-
+}
+}
 Irssi::signal_add('event privmsg', 'event_privmsg');
git clone https://git.99rst.org/PROJECT