def map_message_to_irc(message)
      user_for_message(message) do |message, user|

        # needed in most cases
        name = user ? irc_name(user.name) : nil

        # strip Message off the type to simplify readability
        type = message.type.sub(/Message$/, '')

        if %w(Text Tweet Sound Paste Upload).include?(type) && name == client.nick
            logger.debug "skipping message from myself: #{message.type} #{message.body}"
          next
        end

        case type
        when "Timestamp", "Advertisement"
          # ignore these

        when "Lock"
          client.campfire_reply :mode, name, channel, "+i"

        when "Unlock"
          client.campfire_reply :mode, name, channel, "-i"

        when "DisallowGuests"
          name = irc_name(user.name)
          client.campfire_reply :mode, name, channel, "+s"

        when "AllowGuests"
          name = irc_name(user.name)
          client.campfire_reply :mode, name, channel, "-s"

        when "Idle"
          if u = users[user.id]
            u.idle = true
          end

        when "Unidle"
          if u = users[user.id]
            u.idle = false
          end

        when "Enter"
          unless users[user.id]
            client.campfire_reply :join, name, channel
            users[user.id] = User.new(user)
          end

        when "Leave", "Kick" # kick is used for idle timeouts
          client.campfire_reply :part, name, channel, "Leaving..."
          users.delete user.id

        when "Paste"
          lines = message.body.split(/\n|\r\n|\r/)

          lines[0..2].each do |line|
            client.campfire_reply :privmsg, name, channel, ":> " + line
          end

          if lines.size > 3
            client.campfire_reply :privmsg, name, channel, ":> more: " +
              "https://#{client.subdomain}.campfirenow.com/room/#{room.id}/paste/#{message.id}"
          end

        when "Sound"
          text = case message.body
          when "crickets"
            "hears crickets chirping"
          when "rimshot"
            "plays a rimshot"
          when "trombone"
            "plays a sad trombone"
          when "vuvuzela"
            "======<() ~ ♪ ~♫"
          else
            "played a #{message.body} sound"
          end

          client.campfire_reply :privmsg, name, channel, "\x01ACTION #{text}\x01"

        # when "System"
        #   # NOTICE from :camper_van to channel?

        when "Text"
          if message.body =~ /^\*.*\*$/
            client.campfire_reply :privmsg, name, channel, ":\01ACTION " + message.body[1..-2] + "\01"
          else
            matched = users.values.detect do |user|
              message.body =~ /^#{Regexp.escape(user.name)}(\W+(\s|$)|$)/
            end

            if matched
              body = message.body.sub(/^#{matched.name}/, matched.nick)
            else
              body = message.body
            end
            body.split(/[\r\n]+/).each do |line|
              client.campfire_reply :privmsg, name, channel, ":" + line
            end
          end

        when "TopicChange"
          client.campfire_reply :topic, name, channel, message.body
          room.topic = message.body
          # client.numeric_reply :rpl_topic, channel, ':' + message.body

        when "Upload"
          room.connection.http(:get, "/room/#{message.room_id}/messages/#{message.id}/upload.json") do |data|
            client.campfire_reply :privmsg, name, channel, ":\01ACTION uploaded " + data[:upload][:full_url]
          end

        when "Tweet"
          message.body.split(/\n|\r\n|\r/).each do |line|
            client.campfire_reply :privmsg, name, channel, line
          end

        else
          logger.warn "unknown message #{message.type}: #{message.body}"
        end
      end
    end
def map_message_to_irc(message)
      user_for_message(message) do |message, user|

        # needed in most cases
        name = user ? irc_name(user.name) : nil

        # strip Message off the type to simplify readability
        type = message.type.sub(/Message$/, '')

        if %w(Text Tweet Sound Paste Upload).include?(type) && name == client.nick
            logger.debug "skipping message from myself: #{message.type} #{message.body}"
          next
        end

        case type
        when "Timestamp", "Advertisement"
          # ignore these

        when "Lock"
          client.campfire_reply :mode, name, channel, "+i"

        when "Unlock"
          client.campfire_reply :mode, name, channel, "-i"

        when "DisallowGuests"
          name = irc_name(user.name)
          client.campfire_reply :mode, name, channel, "+s"

        when "AllowGuests"
          name = irc_name(user.name)
          client.campfire_reply :mode, name, channel, "-s"

        when "Idle"
          if u = users[user.id]
            u.idle = true
          end

        when "Unidle"
          if u = users[user.id]
            u.idle = false
          end

        when "Enter"
          unless users[user.id]
            client.campfire_reply :join, name, channel
            users[user.id] = User.new(user)
          end

        when "Leave", "Kick" # kick is used for idle timeouts
          client.campfire_reply :part, name, channel, "Leaving..."
          users.delete user.id

        when "Paste"
          lines = message.body.split(/\n|\r\n|\r/)

          lines[0..2].each do |line|
            client.campfire_reply :privmsg, name, channel, ":> " + line
          end

          if lines.size > 3
            client.campfire_reply :privmsg, name, channel, ":> more: " +
              "https://#{client.subdomain}.campfirenow.com/room/#{room.id}/paste/#{message.id}"
          end

        when "Sound"
          text = case message.body
          when "crickets"
            "hears crickets chirping"
          when "rimshot"
            "plays a rimshot"
          when "trombone"
            "plays a sad trombone"
          when "vuvuzela"
            "======<() ~ ♪ ~♫"
          else
            "played a #{message.body} sound"
          end

          client.campfire_reply :privmsg, name, channel, "\x01ACTION #{text}\x01"

        # when "System"
        #   # NOTICE from :camper_van to channel?

        when "Text"
          if message.body =~ /^\*.*\*$/
            client.campfire_reply :privmsg, name, channel, ":\01ACTION " + message.body[1..-2] + "\01"
          else
            matched = users.values.detect do |user|
              message.body =~ /^#{Regexp.escape(user.name)}(\W+(\s|$)|$)/
            end

            if matched
              body = message.body.sub(/^#{matched.name}/, matched.nick)
            else
              body = message.body
            end
            body.split(/[\r\n]+/).each do |line|
              client.campfire_reply :privmsg, name, channel, ":" + line
            end
          end

        when "TopicChange"
          client.campfire_reply :topic, name, channel, message.body
          room.topic = message.body
          # client.numeric_reply :rpl_topic, channel, ':' + message.body

        when "Upload"
          room.connection.http(:get, "/room/#{message.room_id}/messages/#{message.id}/upload.json") do |data|
            client.campfire_reply :privmsg, name, channel, ":\01ACTION uploaded " + data[:upload][:full_url]
          end

        when "Tweet"
          message.body.split(/\n|\r\n|\r/).each do |line|
            client.campfire_reply :privmsg, name, channel, line
          end

        else
          logger.warn "unknown message #{message.type}: #{message.body}"
        end
      end
    end
Map a campfire message to one or more IRC commands for the client

 message - the campfire message to map to IRC

 Returns nothing, but responds according to the message