Created
August 12, 2012 18:51
Revisions
-
techbelly created this gist
Aug 12, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,48 @@ #!/usr/bin/env ruby require 'rubygems' require 'tinder' require 'open3' require 'eventmachine' # CHANGE THESE TO FIT config = { # CAMPFIRE USER DETAILS :campfire_subdomain => 'techbelly', :campfire_user => 'FROTZ', :campfire_token => 'PUT YOUR TOKEN HERE, EVILDOERS', :campfire_room_name => 'FICTIONAL', # ZCODE DETAILS :dfrotz => './dfrotz', :game => './Wishbrin.z3' } # editing this on the server campfire = Tinder::Campfire.new config[:campfire_subdomain], :token => config[:campfire_token] room = campfire.find_room_by_name config[:campfire_room_name] EventMachine::run do frotzin, frotzout, frotzerr = Open3.popen3("#{config[:dfrotz]} -Z0 -w 3000 -p #{config[:game]}") room.speak "FROTZ STARTED" room.speak "Send messages to the game in ALL CAPS." def send_message_to_game? msg msg && msg == msg.upcase end Thread.new do loop do while output = select([frotzout,frotzerr],nil,nil,0.25) output[0].each do |stream| room.speak(stream.gets) end end end end room.listen do |m| message = m[:body] frotzin.puts(message) if send_message_to_game?(message) end