When clearing the buffer, you should use the buffer and not the inputline.
tree1deddd379c1072d7e414abe29d223e31767c54a8
-rw-r--r-- 1034 chat.css
-rw-r--r-- 1320 chat.html
-rw-r--r-- 4222 chat.js
-rw-r--r-- 4001 date.format.js
-rw-r--r-- 1079 loading.gif
drwxr-xr-x - xmpphp