Created
April 25, 2011 02:57
-
-
Save erikbuild/940095 to your computer and use it in GitHub Desktop.
Simple IRC Bot in Ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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