Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated plugins #11

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 35 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,32 @@

## Installing

### Ubuntu Prerequisites

Tested on Ubuntu 10.04.

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:

Expand All @@ -25,6 +38,25 @@ 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 USER memo;
\password memo
ALTER USER memo WITH CREATEDB;
\q

Now we need to import the database (not SQL any more).

psql -h localhost -U memo -d postgres < schema-memo.sql

## Configuring

cp mathetes-config.yaml.sample mathetes-config.yaml
Expand Down
95 changes: 48 additions & 47 deletions lib/mathetes/plugins/github-hook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
12 changes: 12 additions & 0 deletions lib/mathetes/plugins/github-issue.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module Mathetes; module Plugins
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}" }
end
end
end
end; end
5 changes: 3 additions & 2 deletions lib/mathetes/plugins/google.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 href="?([^"]+)" class=l.*?>(.+?)<\/a>/m do |match|
#html.read.scan /<a class="l" href="?([^"]+)".*?>(.+?)<\/a>/m do |match|
html.read.scan /<a href="?\/url\?q=([^"&]+).*?".*?>(.+?)<\/a>/m do |match|
url, title = match
title.gsub!( /<.+?>/, "" )
ua = unescaped_arg.gsub( /-?site:\S+/, '' ).strip
Expand Down
14 changes: 10 additions & 4 deletions lib/mathetes/plugins/memo.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
require 'rubygems'
require 'm4dbi'
require 'rdbi-driver-postgresql'

module Mathetes; module Plugins

Expand All @@ -16,6 +18,7 @@ class MemoManager
PUBLIC_READING_THRESHOLD = 2

def initialize( mathetes )
print "step 1"
@mathetes = mathetes
@mathetes.hook_privmsg(
:regexp => /^!memo\b/
Expand All @@ -29,7 +32,9 @@ def initialize( mathetes )
handle_join message
end

@dbh = DBI.connect( "DBI:Pg:reby-memo: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 )
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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' ]
)
Expand Down
Loading