I wrote this because all scripts that do the same thing that I found on the internet were rubbish. I apologise for the sloppy programming, I started learning ruby the night before I wrote this.
This script requires rubygems, libjson-ruby and libcmdparse2-ruby.
Debian/Probably ubuntu too
sudo apt-get install rubygems libjson-ruby libcmdparse2-ruby
require 'rubygems' require 'socket' require "net/http" require "uri" require "json" $version = "0.1" $omegle_active = false $to_omegle $from_omegle $status_omegle $session_id $trollmode = true $irc_mitm = false $botenabled = true $hostname = "remo.failnet.net" $channel = "#penis" $nick = "TestStranger" $s = TCPSocket.open($hostname, 6667) def irc $s.print "USER Stranger kichimi.co.uk WH :Stranger\n" $s.print "NICK " + $nick + "\n" $s.print "JOIN " + $channel + "\n" while line = $s.gets # Read lines from the socket if not line == nil then normalmessage = true puts line.chop # And print with platform line terminator line.chop! ircmessage = line.split(":") #line = line.chop bits = line.split(" ") command = bits[3] command = command.to_s command.slice!(0) if bits[0] == "PING" then $s.print "PONG " + bits[1] +"\n" normalmessage = false end if command == "!turn" then if bits[4] == $nick then if bits[5] == "on" then $botenabled = true statusirc("I am now enabled :)",$channel) else statusirc("I am now disabled :(",$channel) $botenabled = false end end normalmessage = false end if $botenabled == true then if command == "!mitm" then if bits[4] == "on" then $irc_mitm = true else $irc_mitm = false end normalmessage = false end if command == "!status" then if $trollmode == true then statusirc(" * Trollmode is Enabled",$channel) else statusirc(" * Trollmode is Disabled",$channel) end normalmessage = false end if command == "!about" then statusirc("This is version " + $version,$channel) statusirc("Omegle to IRC bridge written by kichimi, http://kichimi.co.uk",$channel) normalmessage = false end if command == "!test" then $s.print "PRIVMSG "+bits[2]+" :what\n" normalmessage = false end if command == "!stop" then $t2.terminate disconnect = URI.parse("http://omegle.com/disconnect") Net::HTTP.post_form(disconnect, {"id" => $session_id}) statusirc(" [x] The conversation has been terminated",$channel) $session_id = "" normalmessage = false end if command == "!start" then $t2 = Thread.new{omegle()} $t2.join normalmessage = false end if command == "!trollmode" then if bits[4] == 'on' then statusirc(" * Trollmode Enabled",$channel) $trollmode = true else $trollmode = false statusirc(" * Trollmode Disabled",$channel) end normalmessage = false end if command == "!warning" then sendtoomegle("Hi there, instead of talking to just one person, you are talking to an entire room filled with people!",$session_id) normalmessage=false end if command == "!next" then #$s.print "PRIVMSG "+bits[2]+" : * Starting omegle shitter\n" if $session_id then disconnectomegle($session_id) $session_id = "" $session_open = false $omegle_active = false $t2.terminate sleep(1) $t2 = Thread.new{omegle()} end $omegle_active = true puts $omegle_active normalmessage = false end if normalmessage == true then if bits[1] == "PRIVMSG" then nick = ircmessage[1].split("!") nick = nick[0] puts nick if $botenabled == true then message = ircmessage[2].split('') puts ircmessage puts message[0] if not message[0] == ";" then ircmessage.delete_at(0) ircmessage.delete_at(0) nicemessage = ircmessage.join(":") if $trollmode == true then sendtoomegle(nicemessage,$session_id) else sendtoomegle(nick + " says: " + nicemessage,$session_id) end end end end end end end end end def omegle puts " **** LOADING OMEGLE ****" count = URI.parse("http://omegle.com/count") start = URI.parse("http://omegle.com/start") events = URI.parse("http://omegle.com/events") send = URI.parse("http://omegle.com/send") disconnect = URI.parse("http://omegle.com/disconnect") while true if $omegle_active == true then response = Net::HTTP.get_response(count) #response = Net::HTTP.get_print(count) #$s.print "PRIVMSG " + $channel + " : There are " + response.body + " people online\n" statusirc("There are " + response.body + " people online", $channel) response = Net::HTTP.get_response(start) $session_id = response.body.slice!(0) $session_id = response.body.chop! statusirc("My session id is " + $session_id ,$channel) if $trollmode == true then statusirc("Trollmode is Enabled",$channel) else statusirc("Trollmode is Disabled",$channel) end $session_open = true while $session_open == true puts "Loopy" response = Net::HTTP.post_form(events, {"id" => $session_id}) puts response.body data = response.body event = JSON.parse data event = event[0] #puts event[0] + "|" + event[1] + "|" + event[2] #puts data puts event if event[0] == "connected" then puts " *** CONNECTED_1" sirc(" => Stranger Connected",$channel) sleep(2) if not $trollmode == true then sendtoomegle("Hi there, instead of talking to just one person, you are talking to an entire room filled with people!",$session_id) end end if event[1] == "connected" then puts " *** CONNECTED" statusirc(" => Stranger Connected",$channel) if not $trollmode == true then sendtoomegle("Hi there, instead of talking to just one person, you are talking to an entire room filled with people!",$session_id) end end if event[0] == "gotMessage" then sirc(event[1],$channel) puts " *** GOT MESSAGE" end if event[0] == "strangerDisconnected" then statusirc(" <= Stranger Disconnected",$channel) puts " *** DISCONNECTED" $session_open = false end end $omegle_active = false end #puts "At Main Loop" sleep(1) end puts " **** ENDING OMEGLE ****" end def statusirc(message,chan) if $irc_mitm == true then sirc("; " + message,chan) else sirc(message,chan) end end def sirc(message,chan) if $botenabled == true then $s.print "PRIVMSG " + chan + " :" + message + "\n" end end def sendtoomegle(message,sessionid) if $session_open == true then puts message puts sessionid puts " *** SENDING '"+message+"' WITH ID '"+sessionid+"'" send = URI.parse("http://omegle.com/send") response = Net::HTTP.post_form(send, {"id" => sessionid, "msg" => message}) end end def disconnectomegle(sessionid) if $session_open == true then puts sessionid disconnect = URI.parse("http://omegle.com/disconnect") response = Net::HTTP.post_form(disconnect, {"id" => sessionid}) end end t1 = Thread.new{irc()} $t2 = Thread.new{omegle()} t1.join $t2.join
This software is licensed under the GNU General Public License