irssi_quotes.pl

About:

irssi_quotes.pl is a simple PERL script for the Irssi IRC client that allows users in an IRC Channel to add, view, and delete random quotes from a mysql database, by using simple '!triggers'.

This is more of a novalty item for use in IRC channels when someone says something that is either ridiculous or worthy of quotation.

e.g. <@higherEd> !addquote <publicEd> What's on the other-side of the sun?

This script is Open Source and is released under the GNU/General Public License (GPL).

Requirements:

Download:

Current Version: 1.13 (07/04/2007)

Changelog:

Rev. 1.13

Rev. 1.12


Installation:

1) Download the archive

$ wget http://www.seanodonnell.com/projects/irssi/quotes/irssi_quotes.tar.gz

2) Decompress the archive

$ tar -zxf irssi_quotes.tar.gz

3) Edit the 'irssi_quotes_mysql[4|5].sql' script

Included are 2 different SQL Scripts. The 'irssi_quotes_mysql4.sql' script should work for MySQL4, and the 'irssi_quotes_mysql5.sql' script should work for mysql5. I haven't tested this on mysql3, but the mysql4 script *should* be able to work for mysql3 as well.

You'll want to edit the SQL script (that reflects your version, 4 or 5) by modifying the username and password for the script-specific user account.

MySQL4

$ vim irssi_quotes_mysql4.sql

MySQL5

$ vim irssi_quotes_mysql5.sql

This will ensure a limited amount of access to your mysql server by the irssi_quotes.pl script and irc users in general. We DO want to allow them to INSERT, SELECT, and DELETE records from the irssi_quotes.tbl_quotes table only, so in order to do so, you should edit the following query in the sql script that will work with your version of mysql (version 4 or 5).

GRANT SELECT , INSERT , DELETE ON irssi_quotes.tbl_quotes TO 'example_username'@'localhost' IDENTIFIED BY 'example_password' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 ;

Note: You should replace 'example_username' and 'example_password' with your desired username and password for the irssi_quotes-specific user account.

4) Use the 'irssi_quotes_mysql*.sql' script to create the MySQL Database/Table and Script-Specific User Account

After you've edited the SQL Script that is compatible with your version of MySQL Server, you can then run the script to create your database, table, and/or user account.

MySQL4

$ mysql -h hostname -u username -p < irssi_quotes_mysql4.sql

MySQL5

$ mysql -h hostname -u username -p < irssi_quotes_mysql5.sql

5) Define the database connection variables within the irssi_quotes.pl script

$ vim irssi_quotes.pl

You'll need to edit the following default settings: (Lines: 52-64)

# mysql server
my $mysql_hostname = 'localhost'; 

# mysql user login/name
my $mysql_username = 'example_username';

# mysql user password
my $mysql_password = 'example_password';

# mysql database name
my $mysql_db = 'irssi_quotes';

# mysql database table name
my $mysql_db_table = 'tbl_quotes';

6) Copy the 'irssi_quotes.pl' script to your '~/.irssi/scripts' directory

$ cp irssi_quotes.pl ~/.irssi/scripts/irssi_quotes.pl

7) Make Irssi Auto-load the script on startup

$ cd ~/.irssi/scripts/autorun/; ln -s ../irssi_quotes.pl .

8) Load the script to your Irssi Client Interface

If Irssi is already running in a different terminal, then simply type the following command to your Irssi client interface:

/script load irssi_quotes.pl

If Irssi is NOT already running, then you can simply run Irssi to load it, as step #7 should make the irssi_quotes script load automatically upon your next start-up.

$ irssi -c irc.someserver.net

Trigger Usage:

The irssi_quotes script listens for the following triggers that are sent to an IRC channel:

!addquote [string]

The '!addquote' trigger allows users in a channel to add quotes to the database.

!quote

The '!quote' trigger without a trailing string or integar, returns a random quote.

!quote [id]

The '!quote' trigger with a trailing integar, returns a quote that matches a record according to the tbl_quotes.id database column.

!quote [string]

The '!quote' trigger with a trailing string, returns a random quote that matches the string.

!rmquote [id]

The '!rmquote' trigger with a (required) trailing integar, removes a quote from the database that matches a record according to the tbl_quotes.id database column.

!help

Sends a list of commands to the user in a private message window.


Copyright © 2006, 2007 Sean O'Donnell <sean@seanodonnell.com>

This script is released under the GNU/General Public License (GPL).