unitycoders / uc_pircbotx

A bot for #unity-coders using pircbotx
GNU General Public License v3.0
3 stars 2 forks source link

Use Json configuration for commands #40

Open javax-swing opened 11 years ago

javax-swing commented 11 years ago

Json could be used to configure commands and aliases (now that json is used for the main app configuration).

This is only a suggestion, however it would be good to have this easily configurable without having to rebuild.

Something like. {"Class1",["alias1","alias2

javax-swing commented 11 years ago

Damn didnt finish: {"Class1",["alias1","alias2"]}

To create a map of class name to alias. Then the commands could be instantiated reflectively.

If reflection is frowned upon perhaps some type of enumerated factory?

webpigeon commented 11 years ago

reflection is fine, in fact, it's how the whole command processor works (reflecting the annotations to get the commands and paramters). I've got a branch which includes rudimentary support for loading modules by classname using a similar syntax :).

javax-swing commented 11 years ago

Awesome that sounds good to me.

I think my initial syntax sucks a bit, perhaps instead having a list of CommandProcessorLoader.

This could have String clazz; Object [] params; String[] aliases;

This could mean that if a processor had params you could have mutliple instances with different parameters? Such as the markov chain command etc.

What do you think? On 30 Oct 2013 23:21, "Joseph Walton-Rivers" notifications@github.com wrote:

reflection is fine, in fact, it's how the whole command processor works (reflecting the annotations to get the commands and paramters). I've got a branch which includes rudimentary support for loading modules by classname using a similar syntax :).

— Reply to this email directly or view it on GitHubhttps://github.com/unitycoders/uc_pircbotx/issues/40#issuecomment-27448632 .

webpigeon commented 8 years ago

There is some basic configuration support now for aliases (register a module twice with the same name) and the ability to define regular expression rewrite rules (similar to apache's mod-rewrite).