--// bsplayer.lua Spams bsplayer info to DC!

local spamfile = DC():GetAppPath() .."/scripts/BStoTxt_out.txt"

function nowPlaying(hub)
   local fileContents = {}
   file = io.open(spamfile,"r")
   if file then
      for line in file:lines() do table.insert(fileContents,line) end
      file:close()
      if fileContents[7] then
         hub:sendChat("BS Player playing: "..fileContents[2].." length "..fileContents[4]..":"..fileContents[5]..":"..fileContents[6]) -- here the number [i] refers to the ith line
      else
         hub:addLine("BS Player Currently not running (empty file)")
      end
   else
      hub:addLine("BStoTxt_out.txt not present")
   end
end

dcpp:setListener("ownChatOut","bsplayer",function(hub,message,ret)
   if string.find(message,"^/bs%s*") then
      nowPlaying(hub)
      return 1
   end
end)

DC():PrintDebug("  ** Loaded bsplayer.lua **")
