Thank you for you comment. However my system is a bit difference from the others. I have a chat bot which receive user message from the most popular instance messaging tools (yahoo messenger, gtalk, skype, fb-chat), and then do search on our q2a website.
As a convenient function, users can create an account with the same IM's account they got (by typing a sentence to have account created by the system). That's why I want to write a script to automatically generate account if needed.