Last Updated: February 25, 2016
·
642
· blazeeboy

IRC Bot For wikipedia using ruby

it is very easy with ruby as there is too many IRC frameworks written for ruby i used one of them, also i used my latest gem Askwiki for asking wikipedia and forwarding the answer to IRC as response

#!/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