Move chat delegate to new file

cause it's fun. Oh, and I fixed another stupid mistake causing an
infinite loop.