collectiveidea/tinder — Issue #32: NoMethodError: undefined method `bytesize' for #<Hash:0x007fbf759e5520>
Author: iamruinous
Created: 2011-10-20 15:25:53+00:00
State: open

Trying to create a simple bot to listen in a room and upload an image. Every time I call the upload method, I get the following backtrace.

got an error! "NoMethodError: undefined method `bytesize' for #\n\t/Users/jmeskill/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:1735:in `send_request_with_body'\n\t/Users/jmeskill/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:1724:in `exec'\n\t/Users/jmeskill/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:1189:in `transport_request'\n\t/Users/jmeskill/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:1177:in `request'\n\t/Users/jmeskill/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:1170:in `block in request'\n\t/Users/jmeskill/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:627:in `start'\n\t/Users/jmeskill/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:1168:in `request'\n\t/Users/jmeskill/.rvm/gems/ruby-1.9.2-p290@scrumbot/gems/faraday-0.7.5/lib/faraday/adapter/net_http.rb:62:in `call'\n\t/Users/jmeskill/.rvm/gems/ruby-1.9.2-p290@scrumbot/gems/faraday-0.7.5/lib/faraday/response.rb:8:in `call'\n\t/Users/jmeskill/.rvm/gems/ruby-1.9.2-p290@scrumbot/gems/faraday-0.7.5/lib/faraday/response.rb:8:in `call'\n\t/Users/jmeskill/.rvm/gems/ruby-1.9.2-p290@scrumbot/gems/faraday-0.7.5/lib/faraday/response.rb:8:in `call'\n\t/Users/jmeskill/.rvm/gems/ruby-1.9.2-p290@scrumbot/gems/faraday-0.7.5/lib/faraday/response.rb:8:in `call'\n\t/Users/jmeskill/.rvm/gems/ruby-1.9.2-p290@scrumbot/gems/faraday-0.7.5/lib/faraday/connection.rb:207:in `run_request'\n\t/Users/jmeskill/.rvm/gems/ruby-1.9.2-p290@scrumbot/gems/faraday-0.7.5/lib/faraday/connection.rb:94:in `post'\n\t/Users/jmeskill/.rvm/gems/ruby-1.9.2-p290@scrumbot/gems/tinder-1.7.0/lib/tinder/connection.rb:92:in `raw_post'\n\t/Users/jmeskill/.rvm/gems/ruby-1.9.2-p290@scrumbot/gems/tinder-1.7.0/lib/tinder/room.rb:251:in `raw_post'\n\t/Users/jmeskill/.rvm/gems/ruby-1.9.2-p290@scrumbot/gems/tinder-1.7.0/lib/tinder/room.rb:210:in `upload'\n\tmybot.rb:22:in `block in listen'\n\t/Users/jmeskill/.rvm/gems/ruby-1.9.2-p290@scrumbot/gems/tinder-1.7.0/lib/tinder/room.rb:158:in `block (2 levels) in listen'\n\t/Users/jmeskill/.rvm/gems/ruby-1.9.2-p290@scrumbot/gems/twitter-stream-0.1.14/lib/twitter/json_stream.rb:277:in `call'\n\t/Users/jmeskill/.rvm/gems/ruby-1.9.2-p290@scrumbot/gems/twitter-stream-0.1.14/lib/twitter/json_stream.rb:277:in `parse_stream_line'\n\t/Users/jmeskill/.rvm/gems/ruby-1.9.2-p290@scrumbot/gems/twitter-stream-0.1.14/lib/twitter/json_stream.rb:208:in `block in receive_stream_data'\n\t/Users/jmeskill/.rvm/gems/ruby-1.9.2-p290@scrumbot/gems/twitter-stream-0.1.14/lib/twitter/json_stream.rb:207:in `each'\n\t/Users/jmeskill/.rvm/gems/ruby-1.9.2-p290@scrumbot/gems/twitter-stream-0.1.14/lib/twitter/json_stream.rb:207:in `receive_stream_data'\n\t/Users/jmeskill/.rvm/gems/ruby-1.9.2-p290@scrumbot/gems/twitter-stream-0.1.14/lib/twitter/json_stream.rb:121:in `call'\n\t/Users/jmeskill/.rvm/gems/ruby-1.9.2-p290@scrumbot/gems/twitter-stream-0.1.14/lib/twitter/json_stream.rb:121:in `<<'\n\t/Users/jmeskill/.rvm/gems/ruby-1.9.2-p290@scrumbot/gems/twitter-stream-0.1.14/lib/twitter/json_stream.rb:121:in `receive_data'\n\t/Users/jmeskill/.rvm/gems/ruby-1.9.2-p290@scrumbot/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine'\n\t/Users/jmeskill/.rvm/gems/ruby-1.9.2-p290@scrumbot/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'\n\t/Users/jmeskill/.rvm/gems/ruby-1.9.2-p290@scrumbot/gems/tinder-1.7.0/lib/tinder/room.rb:151:in `listen'\n\tmybot.rb:20:in `listen'\n\tmybot.rb:32:in `

'"!
/Users/jmeskill/.rvm/gems/ruby-1.9.2-p290@scrumbot/gems/tinder-1.7.0/lib/tinder/room.rb:162:in `block (2 levels) in listen'
/Users/jmeskill/.rvm/gems/ruby-1.9.2-p290@scrumbot/gems/twitter-stream-0.1.14/lib/twitter/json_stream.rb:268:in `call'
/Users/jmeskill/.rvm/gems/ruby-1.9.2-p290@scrumbot/gems/twitter-stream-0.1.14/lib/twitter/json_stream.rb:268:in `receive_error'
/Users/jmeskill/.rvm/gems/ruby-1.9.2-p290@scrumbot/gems/twitter-stream-0.1.14/lib/twitter/json_stream.rb:212:in `rescue in receive_stream_data'
/Users/jmeskill/.rvm/gems/ruby-1.9.2-p290@scrumbot/gems/twitter-stream-0.1.14/lib/twitter/json_stream.rb:206:in `receive_stream_data'
/Users/jmeskill/.rvm/gems/ruby-1.9.2-p290@scrumbot/gems/twitter-stream-0.1.14/lib/twitter/json_stream.rb:121:in `call'
/Users/jmeskill/.rvm/gems/ruby-1.9.2-p290@scrumbot/gems/twitter-stream-0.1.14/lib/twitter/json_stream.rb:121:in `<<'
/Users/jmeskill/.rvm/gems/ruby-1.9.2-p290@scrumbot/gems/twitter-stream-0.1.14/lib/twitter/json_stream.rb:121:in `receive_data'
/Users/jmeskill/.rvm/gems/ruby-1.9.2-p290@scrumbot/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine'
/Users/jmeskill/.rvm/gems/ruby-1.9.2-p290@scrumbot/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'
/Users/jmeskill/.rvm/gems/ruby-1.9.2-p290@scrumbot/gems/tinder-1.7.0/lib/tinder/room.rb:151:in `listen'
mybot.rb:20:in `listen'
mybot.rb:32:in `

'

Here's my code:

require 'rubygems'

require 'tinder'

class Mybot

CAMPFIRE_SUBDOMAIN = 'subdomain'
CAMPFIRE_TOKEN = 'abcdef00000'
CAMPFIRE_ROOM = 'A Room'

def campfire
@campfire ||= Tinder::Campfire.new(CAMPFIRE_SUBDOMAIN, :token => CAMPFIRE_TOKEN)
end

def room
@room ||= campfire.find_room_by_name(CAMPFIRE_ROOM)
end

def listen
room.listen do |m|
if m[:body] =~ /trollface/i
room.upload('trollface.png')
end
end
end
end

begin
mybot = Mybot.new

mybot.listen
rescue => e
puts e.message
puts e.backtrace.join("\n")
exit
end