Yes it is kongregate related but you were asking for code, which your best chances of finding it would be in the programming section where thats the main part of the discussion in there. whereas in here its more about what could be added to kongregate,users and what not. As for your question maybe try getting with a staff member on that or even arcanecoder.
I dont think we have a public implementation of the badges system yet. BenV is the man for that. In the meantime, head over to the Programming Forum (as suggested) and read the Statistics/Challenges API sticky. That will instruct you how to tie into the challenge API, which I believe translates over to badges when supported. You’ll have to coordinate the rest with Greg or another staff member.