Module OnChat script: rewritten