Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add !topic #209

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

add !topic #209

wants to merge 4 commits into from

Conversation

noonels
Copy link
Contributor

@noonels noonels commented Oct 12, 2018

#74

Copy link
Member

@euank euank left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a good start!

The linter still isn't happy.. it's kinda unfortunately picky, so it helps to have an eslint plugin in your editor that suggests stylistic changes as you go.

I left some additional small suggestions too.

Thanks for picking this one up!

topic(a, parts, b, c, user, channel) {
let msg;
chan = bot.client.chanData(channel);
switch(parts[0]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that you could also make it something like:

module.exports.commands {
  topic: {
    help(_, parts, reply, _, ...) {
      ...
    }
  }
}

The sugar for defining commands as object keys does allow nesting.

You can define a function named _default under topic if you e.g. want !topic with no additional parts to print out help as well.

chan = bot.client.chanData(channel);
switch(parts[0]) {
case 'help':
bot.client.say(channel, helpMsg);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, the reply object passed in to the module should be used whenever possible. bot.client is not meant to be a stable interface, so we should use it as little as possible.

};

module.exports.commands = {
topic(a, parts, b, c, user, channel) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible this could be called from privmsg session too (e.g. /msg bot !topic).

One solution could be to use the bot.isChannel(channel) check and handle it appropriately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants