Replaced document events by plugin events in chatstates

Replaced document events by plugin events in chatstates.