# 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',
# 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" );
$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');