summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorbw12017-03-19 10:44:29 +0100
committerbw12017-03-19 10:44:29 +0100
commitffc8d6eba59d24fd048ee2560168f9df7074f2b9 (patch)
treee35ac52bb4b4c998fd1be7a466a34a423e9f44b3 /scripts
parent6bc10c44ab71d688135e7668053789890d3adbd4 (diff)
downloadscripts.irssi.org-ffc8d6eba59d24fd048ee2560168f9df7074f2b9.tar.bz2
[wordcompletition] add a init for the database
Diffstat (limited to 'scripts')
-rw-r--r--scripts/wordcompletition.pl22
1 files changed, 15 insertions, 7 deletions
diff --git a/scripts/wordcompletition.pl b/scripts/wordcompletition.pl
index 0aa5e52..d08ae03 100644
--- a/scripts/wordcompletition.pl
+++ b/scripts/wordcompletition.pl
@@ -1,9 +1,10 @@
#!/usr/bin/perl
use Irssi;
use DBI;
+use DBD::SQLite;
use strict;
use vars qw($VERSION %IRSSI);
-$VERSION = "0.1";
+$VERSION = "0.2";
%IRSSI = (
authors => "Jesper Lindh",
contact => "rakblad\@midgard.liu.se",
@@ -11,17 +12,24 @@ $VERSION = "0.1";
description => "Adds words from IRC to your tab-completion list",
license => "Public Domain",
url => "http://midgard.liu.se/~n02jesli/perl/",
- changed => "2004-03-12"
+ changed => "2017-03-19",
+ modules => "DBD::SQLite"
);
-my ($dsn) = "DBI:mysql:yourdatabase:databashostname";
-my ($user_name) = "yourusername";
-my ($password) = "yourpassword";
+
+my $bd= Irssi::get_irssi_dir();
+my $fndb="wordcompletition.db";
+#my ($dsn) = "DBI:mysql:yourdatabase:databashostname";
+my ($dsn) = "DBI:SQLite:dbname=$bd/$fndb";
+my ($user_name) = "";
+my ($password) = "";
my ($dbh, $sth);
my (@ary);
my $query;
my $connect = 1;
$dbh = DBI->connect ($dsn, $user_name, $password, { RaiseError => 1 });
+$dbh->do("create table if not exists words (word varchar(30), prio int)");
+
sub wordsearch
{
my $sw = shift;
@@ -32,7 +40,7 @@ sub wordsearch
$sth->execute();
while (@ary = $sth->fetchrow_array ())
{
- $retar[$i++] = join ("", @ary), "\n";
+ push @retar,$ary[0];
}
$sth->finish();
return @retar;
@@ -78,7 +86,7 @@ sub word_complete
{
my ($complist, $window, $word, $linestart, $want_space) = @_;
$word =~ s/([^a-zA-Z0-9åäöÅÄÖ])//g;
- @$complist = wordsearch($word);
+ push @$complist , wordsearch($word);
};
sub word_message
{