Before that, you need to answer whether a machine can even feel pain or not, not whether it is telling the truth or not. We feel pain because we have a nervous system that reacts to the physical world and it is an indicator that something is wrong. That doesn't translate at all to any machine I know of. If we end up building a nervous system and a basic functioning brain and hook it up to a machine then sure its an interesting question
you can feel pain without an external influence stimulating it. purely mental processes are sufficient to experience suffering.