DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Emad has posted 58 posts at DZone. View Full User Profile

Wikipedia IRC bot

03.02.2014
| 2097 views |
  • submit to reddit
#!/usr/bin/env ruby
require 'cinch' # gem install cinch --no-ri --no-rdoc
require 'askwiki' # gem install askwiki --no-ri --no-rdoc

bot = Cinch::Bot.new do
  configure do |c|

    c.server = "irc.freenode.org"
    c.nick = "Ask_wikipedia"
    c.channels = ["#cinch-bots"]
    
  end

  on :message do |m|
  	if m.message.start_with? 'askwiki'
  		query = m.message.gsub('askwiki','').strip
    	m.reply Askwiki.ask(query), true
	end
  end
end

bot.start