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

Cannot "listen" for AttachmentMessages #303

Open
humatic opened this issue Oct 23, 2018 · 4 comments · May be fixed by #305
Open

Cannot "listen" for AttachmentMessages #303

humatic opened this issue Oct 23, 2018 · 4 comments · May be fixed by #305

Comments

@humatic
Copy link

humatic commented Oct 23, 2018

I want to create a bot that listens for file uploads so that it can perform an action on them. However, whenever passing an attachment, the following listener causes an error. Best as I can tell, the hubot code is treating the AttachmentMessage as if it were a normal TextMessage.

module.exports = (robot) => {
  robot.listen(
    function(message) {
      if (message && message.attachment && message.attachment.type == 'file') {
        return true;
      }
      return false;
    },
    function(response) {
      response.reply('reply');
    }
  );
}

Error:

ERROR TypeError: Cannot convert object to primitive value
    at executeListener (/home/asdf/Desktop/hubot-rocketchat-boilerplate/node_modules/hubot/src/listener.js:77:77)
    at allDone (/home/asdf/Desktop/hubot-rocketchat-boilerplate/node_modules/hubot/src/middleware.js:56:7)
    at /home/asdf/Desktop/hubot-rocketchat-boilerplate/node_modules/async/lib/async.js:274:13
    at Object.async.eachSeries (/home/asdf/Desktop/hubot-rocketchat-boilerplate/node_modules/async/lib/async.js:142:20)
    at async.reduce (/home/asdf/Desktop/hubot-rocketchat-boilerplate/node_modules/async/lib/async.js:268:15)
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
    at process._tickCallback (internal/process/next_tick.js:104:9)
@ith-harvey
Copy link

Yes, this is happening to me as well @humatic

@texm texm linked a pull request Dec 11, 2018 that will close this issue
@sharebear
Copy link

Stumbled upon this one myself just now, great to see a PR open already 👍 frustrating to have the hubot code die on debug logging...

@mayankhardiya
Copy link

@humatic how you resolve "Cannot convert object to primitive value error" ?

@mayankhardiya
Copy link

@ith-harvey can you tell me what is solution of this error??

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 a pull request may close this issue.

4 participants