wm: irc-h2o-bot

Download patch

ref: 5c482500316fb1964e64db9c42322b839dfc0606
parent: 564d4ac9075fba971a480d20ba59d2adc6a0e768
author: 0x4A4D00 <scorpion_rn@yahoo.com>
date: Thu Jul 20 19:49:53 EDT 2023

Cinch Installed for Test but not worked

--- /dev/null
+++ b/Test_cinch.rb
@@ -1,0 +1,35 @@
+require 'cinch'
+require 'open-uri'
+require 'nokogiri'
+require 'cgi'
+
+bot = Cinch::Bot.new do
+  configure do |c|
+    c.server   = "irc.ircnow.org"
+    c.nick     = "moz"
+    c.channels = ["#fpc"]
+  end
+
+  helpers do
+    # Extremely basic method, grabs the first result returned by Google
+    # or "No results found" otherwise
+    def google(query)
+      url = "http://www.google.com/search?q=#{CGI.escape(query)}"
+      res = Nokogiri.parse(open(url).read).at("h3.r")
+
+      title = res.text
+      link = res.at('a')[:href]
+      desc = res.at("./following::div").children.first.text
+    rescue
+      "No results found"
+    else
+      CGI.unescape_html "#{title} - #{desc} (#{link})"
+    end
+  end
+
+  on :message, /^!google (.+)/ do |m, query|
+    m.reply google(query)
+  end
+end
+
+bot.start
\ No newline at end of file