If your chat control does postback then you probably need to move this code:
WebChat2.UserName = HttpContext.Current.User.Identity.Name;
WebChat2.Visible = false;
so that it is not inside a check for IsPostback because it needs to set that also on postbacks
I don't know what you mean by it works for custom module but not for custom feature, those are the same thing to me.
The best thing to do is to set breakpoints in your code and step through it to find out if things are happening as you expect them or not.
Hope that helps,