From c3f0825e5d8320888348d3a6ea4619506af7a23c Mon Sep 17 00:00:00 2001 From: Sam Gleske Date: Mon, 5 Mar 2012 18:17:13 -0500 Subject: [PATCH 01/16] Added Ubuntu packages to the install instructions. --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index a4c094b..d4ad325 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,12 @@ ## Installing +### Ubuntu Prerequisites + + sudo apt-get install ruby rubygems + +### Plugin Prerequisites + Clone the repository: git clone git://github.com/Pistos/Mathetes.git From 5011b726870e6b1303ca756fec843aa159c60bc6 Mon Sep 17 00:00:00 2001 From: Sam Gleske Date: Mon, 5 Mar 2012 18:28:08 -0500 Subject: [PATCH 02/16] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d4ad325..f837578 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ### Ubuntu Prerequisites - sudo apt-get install ruby rubygems + sudo apt-get install ruby ruby-dev rubygems ### Plugin Prerequisites From b0ac033f6e97961b725e8053f0c72af8175c7e58 Mon Sep 17 00:00:00 2001 From: Sam Gleske Date: Mon, 5 Mar 2012 18:39:32 -0500 Subject: [PATCH 03/16] Update README.md --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f837578..0b89a4d 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,12 @@ ### Ubuntu Prerequisites - sudo apt-get install ruby ruby-dev rubygems + sudo apt-get install ruby ruby-dev + +Install the latest rubygems (not from the repository). Visit rubygems.org and download the latest and then run... + + ruby setup.rb + ### Plugin Prerequisites From cb18fdf5239bef40fe21a36c0fee7adfa727eca5 Mon Sep 17 00:00:00 2001 From: Sam Gleske Date: Mon, 5 Mar 2012 18:43:32 -0500 Subject: [PATCH 04/16] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0b89a4d..f2648f1 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ### Ubuntu Prerequisites - sudo apt-get install ruby ruby-dev + sudo apt-get install ruby ruby-dev libpq-dev Install the latest rubygems (not from the repository). Visit rubygems.org and download the latest and then run... From 1597a33be733706eefb8142eb28c9dbc3839913b Mon Sep 17 00:00:00 2001 From: Sam Gleske Date: Mon, 5 Mar 2012 18:48:33 -0500 Subject: [PATCH 05/16] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f2648f1..b48bec8 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ### Ubuntu Prerequisites - sudo apt-get install ruby ruby-dev libpq-dev + sudo apt-get install ruby ruby-dev libpq-dev libxml2 libxml2-dev Install the latest rubygems (not from the repository). Visit rubygems.org and download the latest and then run... From efc7b9d222956de25a1987b1a2d93ce08ac9129b Mon Sep 17 00:00:00 2001 From: Sam Gleske Date: Mon, 5 Mar 2012 18:54:31 -0500 Subject: [PATCH 06/16] Finished updating all Ubuntu prerequisites. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b48bec8..f483d7e 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ### Ubuntu Prerequisites - sudo apt-get install ruby ruby-dev libpq-dev libxml2 libxml2-dev + sudo apt-get install ruby ruby-dev libpq-dev libxml2 libxml2-dev libxslt1.1 libxslt1-dev Install the latest rubygems (not from the repository). Visit rubygems.org and download the latest and then run... From 24e1f6cbe2e2bfaf1a4faf8daec3c8483ed01a68 Mon Sep 17 00:00:00 2001 From: Sam Gleske Date: Mon, 5 Mar 2012 18:55:14 -0500 Subject: [PATCH 07/16] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f483d7e..741f020 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ ### Ubuntu Prerequisites +Tested on Ubuntu 10.04. + sudo apt-get install ruby ruby-dev libpq-dev libxml2 libxml2-dev libxslt1.1 libxslt1-dev Install the latest rubygems (not from the repository). Visit rubygems.org and download the latest and then run... From 6b740486884f8eef142ad13862ac51642010464d Mon Sep 17 00:00:00 2001 From: Sam Gleske Date: Mon, 5 Mar 2012 19:29:28 -0500 Subject: [PATCH 08/16] Update README.md --- README.md | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 741f020..4692c50 100644 --- a/README.md +++ b/README.md @@ -6,28 +6,28 @@ Tested on Ubuntu 10.04. - sudo apt-get install ruby ruby-dev libpq-dev libxml2 libxml2-dev libxslt1.1 libxslt1-dev + sudo su - + apt-get install ruby ruby-dev libpq-dev libxml2 libxml2-dev libxslt1.1 libxslt1-dev Install the latest rubygems (not from the repository). Visit rubygems.org and download the latest and then run... ruby setup.rb - ### Plugin Prerequisites Clone the repository: - git clone git://github.com/Pistos/Mathetes.git + git clone git://github.com/sag47/Mathetes.git Pull in some requirements: [silverplatter-irc](http://github.com/apeiros/silverplatter-irc) - git clone git://github.com/apeiros/silverplatter-irc.git + git clone git://github.com/sag47/silverplatter-irc.git [silverplatter-log](git://github.com/apeiros/silverplatter-irc.git) - git clone git://github.com/apeiros/silverplatter-log.git + git clone git://github.com/sag47/silverplatter-log.git The plugins have dependencies: @@ -38,6 +38,26 @@ The plugins have dependencies: gem install dbd-pg gem install nokogiri +### Set up memo plugin + +Install postgresql and import the database. + + apt-get install postgresql + su - postgres -c 'psql -U postgres -d postgres' + +Change the password for postgres user in the psql database and create a new user and database for memo. The following are SQL commands for psql after logging into the database as the postgres user. + + \password postgres + CREATE DATABASE rubymemo; + CREATE USER memo; + \password memo + GRANT ALL PRIVILEGES ON DATABASE rubymemo TO memo; + \q + +Now we need to import the database (not SQL any more). + + psql + ## Configuring cp mathetes-config.yaml.sample mathetes-config.yaml From 0190bb7e301e28586f4f8e276deb1f5fe9f8ecf5 Mon Sep 17 00:00:00 2001 From: Sam Gleske Date: Mon, 5 Mar 2012 19:53:33 -0500 Subject: [PATCH 09/16] Update lib/mathetes/plugins/memo.rb --- lib/mathetes/plugins/memo.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mathetes/plugins/memo.rb b/lib/mathetes/plugins/memo.rb index 658fa88..b1c51b2 100644 --- a/lib/mathetes/plugins/memo.rb +++ b/lib/mathetes/plugins/memo.rb @@ -29,7 +29,7 @@ def initialize( mathetes ) handle_join message end - @dbh = DBI.connect( "DBI:Pg:reby-memo:localhost", "memo", "memo" ) + @dbh = DBI.connect( "DBI:Pg:rubymemo:localhost", "memo", "memo" ) end def memos_for( recipient ) From 0b10831b3b08ed98eab790783e347cb4fb2ef496 Mon Sep 17 00:00:00 2001 From: Sam Gleske Date: Mon, 5 Mar 2012 20:21:01 -0500 Subject: [PATCH 10/16] Update README.md --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4692c50..d7f3cd4 100644 --- a/README.md +++ b/README.md @@ -48,15 +48,14 @@ Install postgresql and import the database. Change the password for postgres user in the psql database and create a new user and database for memo. The following are SQL commands for psql after logging into the database as the postgres user. \password postgres - CREATE DATABASE rubymemo; CREATE USER memo; \password memo - GRANT ALL PRIVILEGES ON DATABASE rubymemo TO memo; + ALTER USER memo WITH CREATEDB; \q Now we need to import the database (not SQL any more). - psql + psql -h localhost -U memo -d postgres < schema-memo.sql ## Configuring From 3a3d577d96d060eb1cee0d2f02d6671626275af4 Mon Sep 17 00:00:00 2001 From: Sam Gleske Date: Mon, 5 Mar 2012 20:37:05 -0500 Subject: [PATCH 11/16] Updated the schema for a new database name and a better create database command. Thanks to RhodiumToad, ilmari, and peerce from #postgresql for all the help! --- schema-memo.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/schema-memo.sql b/schema-memo.sql index 9b80e92..cfd7fc4 100644 --- a/schema-memo.sql +++ b/schema-memo.sql @@ -9,13 +9,13 @@ SET client_min_messages = warning; SET escape_string_warning = off; -- --- Name: reby-memo; Type: DATABASE; Schema: -; Owner: - +-- Name: rubymemo; Type: DATABASE; Schema: -; Owner: - -- -CREATE DATABASE "reby-memo" WITH TEMPLATE = template0 ENCODING = 'SQL_ASCII'; +CREATE DATABASE "rubymemo" WITH TEMPLATE = template0 ENCODING = 'SQL_ASCII' LC_COLLATE = 'C' LC_CTYPE = 'C'; -\connect "reby-memo" +\connect "rubymemo" SET client_encoding = 'SQL_ASCII'; SET standard_conforming_strings = off; From 80e766f50b363dc4f62b461c0e4923c72286a76b Mon Sep 17 00:00:00 2001 From: Sam Gleske Date: Mon, 5 Mar 2012 23:34:06 -0500 Subject: [PATCH 12/16] Wrote a service script for Mathetes and added a plugin for the #openphoto channel which simply replies a github issue URL when people are talking about issues. --- lib/mathetes/plugins/github-issue.rb | 17 +++ mathetes.service | 162 +++++++++++++++++++++++++++ 2 files changed, 179 insertions(+) create mode 100644 lib/mathetes/plugins/github-issue.rb create mode 100755 mathetes.service diff --git a/lib/mathetes/plugins/github-issue.rb b/lib/mathetes/plugins/github-issue.rb new file mode 100644 index 0000000..493f467 --- /dev/null +++ b/lib/mathetes/plugins/github-issue.rb @@ -0,0 +1,17 @@ +module Mathetes; module Plugins + class Sample + def initialize( mathetes ) + mathetes.hook_privmsg( + :regexp => /#[0-9]+/ + ) do |message| + issues = message.text[ /#([0-9]+)/, 1 ] + issues.each { |issue| message.answer "https://github.com/openphoto/frontend/issues/#{issue}" } + #handle_privmsg message + end + end + + def handle_privmsg( message ) + message.answer "Foo to you!" + end + end +end; end diff --git a/mathetes.service b/mathetes.service new file mode 100755 index 0000000..fccffa1 --- /dev/null +++ b/mathetes.service @@ -0,0 +1,162 @@ +#!/bin/bash +#(03:17:05 PM) Sarteck: http://www.clubbleach.org/forums/showthread.php?92129-Alchemist-Chat-Thread&p=4780193&viewfull=1#post4780193 +# (03:29:25 PM) Sarteck: Nah, not as root, just as a regular user. :P +# (03:29:29 PM) Sarteck: Oh +# (03:29:30 PM) Sarteck: Oh +# (03:29:33 PM) Sarteck: Um +# (03:29:42 PM) Sarteck: Could you please include in the script +# (03:29:50 PM) Sarteck: EXPORT MALLOC_CHECK=4 +# (03:30:14 PM) Sarteck: Not sure why, but I have to do that before EggDrop runs after I updated a few months ago.%s + + + +######### +#settings for eggdrop service script +#with any settings do not leave and trailing semicolons (;) +######### + +#service name +SERVICE_NAME="Mathetes bot" + +#full path to service binary +SERVICE_BIN="/usr/local/Mathetes/run.sh" + +#leave blank to run service as root user, otherwise start service by specifying a user +USER="mathetes" + +#if left blank then script runs normally. otherwise it will cd to the directory and then start the service. +WORKING_DIRECTORY="/usr/local/Mathetes/" + +#specify any special actions to run before any other command, multiple commands separated by semicolon +CMD_START="" + +#where would you like logging from the output of the service script to happen? +#if left blank it will log to /dev/null +CONSOLE="" + +#location of the PID file +PIDFILE="/usr/local/Mathetes/mathetes.pid" + + + + +######### +#end of settings, do not edit beyon this point +######### + +#This comment block is for RedHat systems integration compatibility +# chkconfig: 2345 0 0 +# description: eggdrop chkconfig compatibility +### BEGIN INIT INFO +# Provides: eggdrop +# Defalt-Start: 2 3 4 5 +# Short-Description: start and stop eggdrop +# Description: eggdrop chkconfig compatibility + + +#import service functions, the script can be extended to use them if you want in the future +#Debian only +if [ -f /lib/lsb/init-functions ]; then +. /lib/lsb/init-functions +fi +#Redhat like distros only +if [ -f /etc/rc.d/init.d/functions ]; then +. /etc/rc.d/init.d/functions +fi +#NOTE! Neither of the above includes are used in this script, I included them if you wanted +#to optionally modify the script + +if [ "$UID" != "0" ];then # Will the real "root" please stand up? + echo "$0 service must be controlled by root!" + exit 1 +fi + +#how are we gonna subit? +if [ -z "$USER" ]; then + SUBIT="su - -c " +else + SUBIT="su - $USER -c " +fi + +if [ ! -z "$WORKING_DIRECTORY" ];then + if [ ! -z "$CMD_START" ];then + CMD_START="$CMD_START;cd $WORKING_DIRECTORY" + else + CMD_START="cd $WORKING_DIRECTORY" + fi +fi + +if [ -z $CONSOLE ];then + CONSOLE="/dev/null" +fi + +#custom functions for starting and stopping the service +start() { + #this is to stop the service from being an asshole + mypid=`ps $(cat $PIDFILE) 2>/dev/null | grep $(cat $PIDFILE) 2>/dev/null | awk '{print $1}'` + if [ ! -z $mypid ];then + echo "$SERVICE_NAME is already running. Stop trying to start shit." + status + exit 1 + fi + echo "CMD_START = $CMD_START;$SERVICE_BIN >$CONSOLE 2>&1 &" + $SUBIT "$CMD_START;$SERVICE_BIN >$CONSOLE 2>&1 &" + sleep 1 + status +} + +wait() { #wait for boogy and woogy to close before finishing up any commands + while true;do + mypid=`ps $(cat $PIDFILE) 2>/dev/null | grep $(cat $PIDFILE) 2>/dev/null | awk '{print $1}'` + if [ -z $mypid ];then + return 0 + else + sleep 1 + echo -n "." + fi + done +} + +status() { + mypid=`ps $(cat $PIDFILE) 2>/dev/null | grep $(cat $PIDFILE) 2>/dev/null | awk '{print $1}'` + if [ ! -z $mypid ];then + echo "$SERVICE_NAME is running." + else + echo "$SERVICE_NAME is dead." + fi +} + +stop() { + #Sam's custom kill command for jboss + kill -s 15 $(cat $PIDFILE) 2> /dev/null + stopcode="$?" + if [ "$stopcode" -eq "0" ];then + echo -n "$SERVICE_NAME is stopping." + wait && echo " SUCCESS!" + else + echo "$SERVICE_NAME has not been started." + fi + if [ -e "$PIDFILE" ];then + rm -f $PIDFILE; + fi +} + +#here is where all the magic happens for starting, stopping and whatnot +case "$1" in +start) + start + ;; +stop) + stop + ;; +status) + status + ;; +restart) + stop + start + ;; +*) + echo "usage: $0 (start|stop|status|restart|help)" +esac + From c646c9687c9093e63ed27196520b7b2581234a40 Mon Sep 17 00:00:00 2001 From: Sam Gleske Date: Mon, 5 Mar 2012 23:38:24 -0500 Subject: [PATCH 13/16] Took the generic sample stuff out of the github-issue plugin. --- lib/mathetes/plugins/github-issue.rb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/mathetes/plugins/github-issue.rb b/lib/mathetes/plugins/github-issue.rb index 493f467..b4008ab 100644 --- a/lib/mathetes/plugins/github-issue.rb +++ b/lib/mathetes/plugins/github-issue.rb @@ -1,17 +1,12 @@ module Mathetes; module Plugins - class Sample + class GitHubIssue def initialize( mathetes ) mathetes.hook_privmsg( :regexp => /#[0-9]+/ ) do |message| issues = message.text[ /#([0-9]+)/, 1 ] issues.each { |issue| message.answer "https://github.com/openphoto/frontend/issues/#{issue}" } - #handle_privmsg message end end - - def handle_privmsg( message ) - message.answer "Foo to you!" - end end end; end From e9b670bd50ecc732891e1b69724c8b8eecd4e965 Mon Sep 17 00:00:00 2001 From: Sam Gleske Date: Tue, 6 Mar 2012 01:31:15 -0500 Subject: [PATCH 14/16] Fixed the google search plugin used by Mathedes. --- lib/mathetes/plugins/google.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/mathetes/plugins/google.rb b/lib/mathetes/plugins/google.rb index e685b23..ccb7f84 100644 --- a/lib/mathetes/plugins/google.rb +++ b/lib/mathetes/plugins/google.rb @@ -35,9 +35,10 @@ def initialize( mathetes ) arg = CGI.escape( arg ) - open( "http://www.google.com/search?q=#{ CGI.escape( args ) }&safe=active" ) do |html| + open( "https://www.google.com/search?q=#{ CGI.escape( args ) }&safe=active" ) do |html| counter = 0 - html.read.scan /(.+?)<\/a>/m do |match| + #html.read.scan /(.+?)<\/a>/m do |match| + html.read.scan /(.+?)<\/a>/m do |match| url, title = match title.gsub!( /<.+?>/, "" ) ua = unescaped_arg.gsub( /-?site:\S+/, '' ).strip From 99e6a5904f3e79621ab947b93e434a42a0ffa212 Mon Sep 17 00:00:00 2001 From: Sam Gleske Date: Tue, 6 Mar 2012 03:00:41 -0500 Subject: [PATCH 15/16] Updated the github hook chat rooms. --- lib/mathetes/plugins/github-hook.rb | 95 +++++++++++++++-------------- 1 file changed, 48 insertions(+), 47 deletions(-) diff --git a/lib/mathetes/plugins/github-hook.rb b/lib/mathetes/plugins/github-hook.rb index 4c3ad42..05b3a4d 100644 --- a/lib/mathetes/plugins/github-hook.rb +++ b/lib/mathetes/plugins/github-hook.rb @@ -15,53 +15,54 @@ module GitHubHookServer # Mapping of repo names to interested channels REPOS = { - 'better-benchmark' => [ '#mathetes', ], - 'buildmybike' => [ '#ramaze', ], - 'diakonos' => [ '#mathetes', ], - 'dk-git' => [ '#mathetes', ], - 'dk-selector' => [ '#mathetes', ], - 'epoxy' => [ '#ruby-dbi', ], - 'ffi-tk' => [ '#ver', ], - 'firewatir-enhancements' => [ '#mathetes', '#watir' ], - 'github' => [ '#mathetes' ], - 'hashpipe' => [ '#ruby-dbi', ], - 'hoptoad-notifier-ramaze' => [ '#mathetes', '#ramaze' ], - 'ideone-gem' => [ '#mathetes', ], - 'innate' => [ '#mathetes', '#ramaze', ], - 'linistrac' => [ '#mathetes', '#ramaze', ], - 'm4dbi' => [ '#mathetes', '#ruby-dbi', ], - 'Mathetes' => [ '#mathetes', ], - 'mailit' => [ '#ramaze', ], - 'methlab' => [ '#ruby-dbi', ], - 'nagoro' => [ '#mathetes', '#ramaze' ], - 'Ramalytics' => [ '#mathetes', '#ramaze' ], - 'Reby' => [ '#mathetes', ], - 'rack' => [ '#rack', '#ramaze', ], - 'ramaze' => [ '#ramaze', ], - 'ramaze-book' => [ '#ramaze' ], - 'ramaze-proto' => [ '#ramaze' ], - 'ramaze.net' => [ '#ramaze', ], - 'ramaze-wiki-pages' => [ '#ramaze' ], - 'rdbi' => [ '#ruby-dbi', ], - 'rdbi-dbd-mysql' => [ '#ruby-dbi', ], - 'rdbi-dbd-postgresql' => [ '#ruby-dbi', ], - 'rdbi-dbd-sqlite3' => [ '#ruby-dbi', ], - 'rdbi-driver-mock' => [ '#ruby-dbi', ], - 'rdbi-driver-mysql' => [ '#ruby-dbi', ], - 'rdbi-driver-postgresql' => [ '#ruby-dbi', ], - 'rdbi-driver-sqlite3' => [ '#ruby-dbi', ], - 'rdbi-result-driver-json' => [ '#ruby-dbi', ], - 'ruby-dbi' => [ '#ruby-dbi', ], - 'rvm' => [ '#rvm', ], - 'rvm-site' => [ '#rvm', ], - 'selfmarks' => [ '#mathetes', ], - 'sociar' => [ '#ramaze' ], - 'Thankful-Eyes' => [ '#mathetes', ], - 'typelib' => [ '#ruby-dbi', ], - 'ver' => [ '#ver' ], - 'watir-mirror' => [ '#mathetes', '#watir' ], - 'weewar-ai' => [ '#mathetes' ], - 'zepto-url' => [ '#mathetes', '#ramaze', ], + 'frontend' => [ '#openphoto', '#fartroom', ], +# 'better-benchmark' => [ '#mathetes', ], +# 'buildmybike' => [ '#ramaze', ], +# 'diakonos' => [ '#mathetes', ], +# 'dk-git' => [ '#mathetes', ], +# 'dk-selector' => [ '#mathetes', ], +# 'epoxy' => [ '#ruby-dbi', ], +# 'ffi-tk' => [ '#ver', ], +# 'firewatir-enhancements' => [ '#mathetes', '#watir' ], +# 'github' => [ '#mathetes' ], +# 'hashpipe' => [ '#ruby-dbi', ], +# 'hoptoad-notifier-ramaze' => [ '#mathetes', '#ramaze' ], +# 'ideone-gem' => [ '#mathetes', ], +# 'innate' => [ '#mathetes', '#ramaze', ], +# 'linistrac' => [ '#mathetes', '#ramaze', ], +# 'm4dbi' => [ '#mathetes', '#ruby-dbi', ], +# 'Mathetes' => [ '#mathetes', ], +# 'mailit' => [ '#ramaze', ], +# 'methlab' => [ '#ruby-dbi', ], +# 'nagoro' => [ '#mathetes', '#ramaze' ], +# 'Ramalytics' => [ '#mathetes', '#ramaze' ], +# 'Reby' => [ '#mathetes', ], +# 'rack' => [ '#rack', '#ramaze', ], +# 'ramaze' => [ '#ramaze', ], +# 'ramaze-book' => [ '#ramaze' ], +# 'ramaze-proto' => [ '#ramaze' ], +# 'ramaze.net' => [ '#ramaze', ], +# 'ramaze-wiki-pages' => [ '#ramaze' ], +# 'rdbi' => [ '#ruby-dbi', ], +# 'rdbi-dbd-mysql' => [ '#ruby-dbi', ], +# 'rdbi-dbd-postgresql' => [ '#ruby-dbi', ], +# 'rdbi-dbd-sqlite3' => [ '#ruby-dbi', ], +# 'rdbi-driver-mock' => [ '#ruby-dbi', ], +# 'rdbi-driver-mysql' => [ '#ruby-dbi', ], +# 'rdbi-driver-postgresql' => [ '#ruby-dbi', ], +# 'rdbi-driver-sqlite3' => [ '#ruby-dbi', ], +# 'rdbi-result-driver-json' => [ '#ruby-dbi', ], +# 'ruby-dbi' => [ '#ruby-dbi', ], +# 'rvm' => [ '#rvm', ], +# 'rvm-site' => [ '#rvm', ], +# 'selfmarks' => [ '#mathetes', ], +# 'sociar' => [ '#ramaze' ], +# 'Thankful-Eyes' => [ '#mathetes', ], +# 'typelib' => [ '#ruby-dbi', ], +# 'ver' => [ '#ver' ], +# 'watir-mirror' => [ '#mathetes', '#watir' ], +# 'weewar-ai' => [ '#mathetes' ], +# 'zepto-url' => [ '#mathetes', '#ramaze', ], } def say_rev( rev, message, destination ) From 2e7d6c579516d45243f6d23c4cb2d48ed05fb704 Mon Sep 17 00:00:00 2001 From: Sam Gleske Date: Tue, 6 Mar 2012 07:17:36 -0500 Subject: [PATCH 16/16] Fixed the memo plugin for the latest m4dbi and latest ruby. --- lib/mathetes/plugins/memo.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/mathetes/plugins/memo.rb b/lib/mathetes/plugins/memo.rb index b1c51b2..e030839 100644 --- a/lib/mathetes/plugins/memo.rb +++ b/lib/mathetes/plugins/memo.rb @@ -1,4 +1,6 @@ +require 'rubygems' require 'm4dbi' +require 'rdbi-driver-postgresql' module Mathetes; module Plugins @@ -16,6 +18,7 @@ class MemoManager PUBLIC_READING_THRESHOLD = 2 def initialize( mathetes ) + print "step 1" @mathetes = mathetes @mathetes.hook_privmsg( :regexp => /^!memo\b/ @@ -29,7 +32,9 @@ def initialize( mathetes ) handle_join message end - @dbh = DBI.connect( "DBI:Pg:rubymemo:localhost", "memo", "memo" ) + print "step 2" + #@dbh = DBI.connect( "DBI:PostgreSQL:rubymemo:localhost", "memo", "memo" ) + @dbh = M4DBI.connect("PostgreSQL", :database => "rubymemo", :username => 'memo', :hostname => 'localhost', :password => 'memo' ) end def memos_for( recipient ) @@ -53,6 +58,7 @@ def memos_for( recipient ) end def record_memo( privmsg ) + print "Step 3" args = privmsg.text[ /^\S+\s+(.*)/, 1 ] sender = nick = privmsg.from.nick @@ -65,7 +71,7 @@ def record_memo( privmsg ) if recipient =~ %r{^/(.*)/$} recipient_regexp = Regexp.new $1 - @dbh.do( + @dbh.execute( "INSERT INTO memos ( sender, recipient_regexp, message ) VALUES ( ?, ?, ? )", sender, recipient_regexp.source, @@ -76,7 +82,7 @@ def record_memo( privmsg ) if memos_for( recipient ).size >= MAX_MEMOS_PER_PERSON privmsg.answer "The inbox of #{recipient} is full." else - @dbh.do( + @dbh.execute( "INSERT INTO memos ( sender, recipient, message ) VALUES ( ?, ?, ? )", sender, recipient, @@ -109,7 +115,7 @@ def handle_privmsg( message ) age.gsub( /^(.*)(\d+):(\d+):(\d+)/, "\\1 \\2h \\3m \\4s" ) end @mathetes.say( "#{nick}: [#{age} ago] <#{memo['sender']}> #{memo['message']}", dest ) - @dbh.do( + @dbh.execute( "UPDATE memos SET time_told = NOW() WHERE id = ?", memo[ 'id' ] )