Skip to content

Instantly share code, notes, and snippets.

@grumpymaker
Created April 25, 2011 02:57
Show Gist options
  • Save grumpymaker/940095 to your computer and use it in GitHub Desktop.
Save grumpymaker/940095 to your computer and use it in GitHub Desktop.
Simple IRC Bot in Ruby
require 'rubygems'
require 'ponder'
require 'wikipedia'
@ponder = Ponder::Thaum.new
@ponder.configure do |c|
c.nick = 'FUN_BOT'
c.username = 'FUN_BOT'
c.real_name = 'FUN_BOT'
c.server = 'servername.com'
c.port = 6668
end
channel = '#chat'
# On Connect, join #chat.
@ponder.on :connect do
@ponder.join channel
end
# "+roks", grabs a random mineral from Wikipedia's list of minerals.
minerals = Wikipedia.find('List of Minerals').content.scan(/\*\[\[(.*)\]\]/)
@ponder.on :channel, /\+roks/ do |e|
@ponder.message channel, "http://en.wikipedia.org/wiki" + minerals[Random.new.rand(0..minerals.size-1)][0]
end
# Connect to the server.
@ponder.connect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment