Usually when they break you can't repair them. A new one will only cost �3-�5 and can be replaced in minutes. Remember though that electricity can dangerous, so if you do it your self make sure the power is off and if you are not sure ask an expert
There is a sort of "slider" that goes up and down to operate the switch when you pull the cord. With power off unscrew the cup on the ceiling and put a little WD40 on the slider and that should solve the problem.