Frug / AJAX-Chat

A fully customizable web chat implemented in JavaScript, PHP and MySQL which integrates nicely with common forum systems like phpBB, MyBB, FluxBB, SMF and vBulletin. A Flash and Ruby based socket connection can be used to boost performance.
http://frug.github.io/AJAX-Chat/
547 stars 300 forks source link

Make adding custom commands easier #141

Open Frug opened 10 years ago

Frug commented 10 years ago

Instead of leaving it to users to override the parseCustomCommands function in their customAJAXChat file, store custom commands as an array like 'commandName' => function() { }

Then check if the command exists as an array key and call it if it does.

This would make it a matter of adding keys to an array, instead of overriding a whole function, to add custom commands on the php side.

ghost commented 10 years ago

I would love to see this get implemented. I do have a couple of suggestions to enhance this even further. If I am not mistaken, the current flow of how the chat parses commands is that it checks for the built in commands first and then checks for custom commands. But I would like it to be the other way around. That it checks for custom commands first, and if present, the chat don't proceed with checking for built in commands. That way users can easily replace built in commands with their own commands. For example, if I want to replace the command "/ban", I would just put in the customAJAXChat and then the chat parses the custom command and NOT the built in command. That way I don't have to comment out/change anything in the core files. In current state, it's a massive job to add/change everything if I want to update the chat's core files. Is this something you can consider to change in regards of implementing the above change?

Frug commented 10 years ago

That's a good idea, I'll put the check for custom commands first.