modubot / modubot.js

Modubot: the scalable and extensible IRC bot.
https://modubot.net
BSD 3-Clause "New" or "Revised" License
19 stars 3 forks source link

Google plugin always includes either "g" or "google" in the search #14

Closed reynir closed 10 years ago

reynir commented 10 years ago

For example, when a client types .g <query> the plugin will give the search results for the string g <query>.

Possible fixes

kamaln7 commented 10 years ago

Ignore the first argument, i.e. use args.splice(1) instead of args

I think this is how we should do it. @clone1018 opinion?

Do not send the first bit as argument to the plugin -- the plugin can make a callback for each plugin-command if necessary. I don't know if this works with the factoid plugin.

I'm not sure what you mean, can you please explain? Thanks.

reynir commented 10 years ago

I'm not sure what you mean, can you please explain? Thanks.

@KamalN7 I meant that bot.js should filter out the command. In code it would be something like this:

this.emit('command.' + command, from, to, filterOutFirstWord(message), message.split(' ').splice(1));

The plugin should know what the string is anyway -- they can always make one callback/hook per plugin command if they need to know exactly which command triggered it.

I figure most plugins would filer out the first word / element anyway.

kamaln7 commented 10 years ago

Oh, got it.

Fixed it in db8796d until @clone1018 responds