#NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM # # /´¯/) # ,/¯ // # / / / # /´¯/' '/´¯¯`·¸ # /'/ / / /¨¯\ # ('( ´( ´ ,~/' ') # \ \/ / # \ _ ·´ # \ ( # \ \ # # hay guise, i are nopinsult # i'm in ur nophost, insultin' ur hosts # # made with luv by Jake E. Efgee for great justice! # # dedicated to these mountains which i heart! # # nopinsult is free software; you can redistribute it and/or refuckulate # it under the terms of the GNU General Pubic Lice as published by # Cory & Trevor; either version 2 of the License, or # (at your option) cookies. # # nopinsult is distributed in the certainty that it will be useless, # but WITHOUT ANY GUARANA; without even the implied warrant of # CHERRYPIE or FITNESS FOR A PERPENDICULAR HIKE. See the # ORZ General Public License for more *sauce". # # You should have received a copy of the GNU General Public License # along with booze; if not, complain to the Free Booze # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # #NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM $LOAD_PATH << File.expand_path(File.dirname(__FILE__)) require('uri') require('rexml/document') ############################################################################### # all ur inline SVGs are belong to us!!! $svgimg_data = < END_OF_STRING $svgicon_data = < image/svg+xml END_OF_STRING $svgimg = REXML::Document.new($svgimg_data).root.to_s $svgicon = REXML::Document.new($svgicon_data).root.to_s ############################################################################### module NopMC require('fcntl') STATUS_READY = 0 STATUS_UNABLETOCONNECT = 1 STATUS_CONNECTIONLOST = 2 def error(message) puts("nopmcp.rb: #{message}") end class Field def initialize(name, value) @name = name; @value = value; end def name() return @name end def value() return @value end end class Job @@uniqueId = -1 def initialize(type) @type = type @id = (@@uniqueId += 1) @fields = {} end def id() return @id end def addField(name,value) @fields[name] = value end def write(file) rootNode = REXML::Element.new("job") rootNode.add_attribute("type",@type) rootNode.add_attribute("id",@id) @fields.each() { |key,value| rootNode.add(REXML::Element.new(key).add_text(value)) } doc = REXML::Document.new() doc.add(rootNode) begin doc.write(file) file.write("<<") file.flush() rescue return false end end end class JobOutput def initialize(type, fields) @type = type @fields = fields end def type() return @type end def fields() return @fields end def fieldValue(fieldName) @fields.each() { |field| if field.name() == fieldName then return field.value(); end } return "" end end class NetEvent def initialize(type, fields) @type = type @fields = fields end def type() return @type end def fields() return @fields end def fieldValue(fieldName) @fields.each() { |field| if field.name() == fieldName then return field.value(); end } return "" end end class NopMC def initialize() @ready = false @jobs = Hash.new() @debugCallback = nil @errorCallback = nil @statusCallback = nil @neteventCallback = nil end def ready?() return @ready end def setDebugCallback(callback = nil, &block) @debugCallback = callback != nil ? callback : block end def setErrorCallback(callback = nil, &block) @errorCallback = callback != nil ? callback : block end def setStatusCallback(callback = nil, &block) @statusCallback = callback != nil ? callback : block end def setNetEventCallback(callback = nil, &block) @neteventCallback = callback != nil ? callback : block end def start(args = nil) if @statusCallback == nil error('You need to call setStatusCallback() before calling start()') return false end # start wimc begin command = @debugCallback == nil ? "nopmcp" : "nopmcp -D" if args != nil args.each() { |arg| command << " #{arg}" } end @wimc = IO.popen(command,'r+') @wimcPID = @wimc.pid() rescue error('Can\'t start nopmcp, make sure nopmcp is in your $PATH.') return false end # start a thread to read data from nopmcp Thread.abort_on_exception = true @readThread = Thread.new() { while true begin output = @wimc.gets("<<")[0..-3] rescue error('Error reading from nopmcp.') break end self.parseOutput(output) end } return true end def processJob(job, callback = nil, &block) @jobs[job] = callback != nil ? callback : block if job.write(@wimc) == false error('Error writing to nopmcp.') return false end return true end def parseOutput(string) doc = REXML::Document.new(string) root = doc.root() type = root.name().downcase() if type == 'debug' && @debugCallback != nil @debugCallback.call(root.text()) elsif type == 'error' && @errorCallback != nil @errorCallback.call(root.text()) elsif type == 'status' code = root.text().to_i() if code == 0 then @ready = true; end @statusCallback.call(code) elsif type == 'netevent' && @neteventCallback != nil type = root.attributes['type'].downcase() fields = Array.new() root.elements().each() { |node| field = Field.new(node.name(), node.text()) fields.push(field) } netevent = NetEvent.new(type, fields) @neteventCallback.call(netevent) elsif type == 'jobcompleted' id = root.attributes['id'].to_i() successful = root.attributes['successful'] == 'true' ? true : false type = root.attributes['output'].downcase() fields = Array.new() root.elements().each() { |node| field = Field.new(node.name(), node.text()) fields.push(field) } @jobs.each() { |job, callback| if job.id() == id && callback != nil jobOutput = JobOutput.new(type, fields) callback.call(successful, jobOutput) @jobs.delete(job) break end } end end end end # modue NopMC ############################################################################### require 'base64' $fortune_mode = false $insults = [ "You suck!", "Fail!", "Ask me about LOOM!", "TITS or GTFO!", "You use PERL!", "You like JAVA!", "Become an hero!", "gb2/gaia gaiafag!", "You got into one little fight and your mom got scared..." ] def random_insult() if $fortune_mode return `fortune` else x = (rand*$insults.length).to_i return $insults[x] end end def error(msg) puts(msg) end def newStatus(status) if status == NopMC::STATUS_READY # register cocos interface... job = NopMC::Job.new("enablerequest") job.addField("interface","controllerinterface") job.addField("type","configure nopinsult") $mc.processJob(job) { |success, output| if success == false errorDesc = output.fieldValue("desc") error("Unable to register cocos::nopinsult-request: #{errorDesc}") exit(1) end } # register external insult request type... job = NopMC::Job.new("enablerequest") job.addField("interface","hostinterface") job.addField("type","silly insult") $mc.processJob(job) { |success, output| if success == false errorDesc = output.fieldValue("desc") error("Unable to register insult-request: #{errorDesc}") exit(1) end } elsif status == NopMC::STATUS_UNABLETOCONNECT error("Unable to connect to host.") exit(1) elsif status == NopMC::STATUS_CONNECTIONLOST error("Lost connection to host.") exit(1) end end def newNetEvent(netevent) if netevent.type() == "newrequest" type = netevent.fieldValue("type") request = netevent.fieldValue("request") if type == "configure nopinsult" data = Base64.decode64(netevent.fieldValue("data")) case data when "/ICON" result = $svgicon when "/NAME" result = "nopinsult" when "/VERSION" result = "dumb" when "/DESC" result = "i'm in ur host, providin' insults" when "/WEB" result = "teh matrix" when "/AUTHORS" result = "made with luv by Jake E. Efgee for great justice!" else html = "" html += "" html += "" begin uri = URI.parse(data) query = {} if uri.query != nil uri.query.split("&").each { |s| tuple = s.split("=") if tuple[0] != nil query[URI.unescape(tuple[0])] = tuple[1] == nil ? nil : URI.unescape(tuple[1]) end } end if uri.path == "/del" idx = query['idx'] $insults.delete_at(idx.to_i) elsif uri.path == "/add" insult = query['insult'].gsub("+"," ") $insults << insult elsif uri.path == "/togglemode" $fortune_mode = !$fortune_mode end rescue html += "Unable to understand your query!
" end insult = random_insult() html += "Your data: #{data}
" html += "
" html += "

nopinsult

" html += "

cocos interface

" html += "

#{$svgimg}

" html += "

" + insult + "

" html += "
" html += "

" if $fortune_mode html += "

fortune mode


" html += "(deactivate)

" else html += "

insult mode


" html += "(activate fortune mode)

" html += "

current insults:

" $insults.each_index { |i| html += "#{$insults[i]} (delete)
" } html += "
" html += "" html += "" html += "
" end html += "

" html += "
" html += "" result = html end job = NopMC::Job.new("answerrequest") job.addField("request",request) job.addField("data", Base64.encode64(result)) $mc.processJob(job) else insult = random_insult() job = NopMC::Job.new("answerrequest") job.addField("request",request) job.addField("data", Base64.encode64(insult)) $mc.processJob(job) end end end # parse command line arguments... ARGV.each() { |arg| if arg == "-h" || arg == "--help" puts( "NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM\n" \ "amidoinitrite: nopinsult [-h] [-f]\n" \ " -h, --help show how to shot web\n" \ " -f, --fortune serve fortunes instead of insults\n" \ "NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM NOM" ) exit(0) elsif arg == "-f" || arg == "--fortune" $fortune_mode = true else puts("ur doin it wrong!\ntype nopinsult -h to receive bacon.") exit(1) end } puts( <