DubAPI icon indicating copy to clipboard operation
DubAPI copied to clipboard

support for private messages?

Open axelmoreen opened this issue 9 years ago • 15 comments

is this possible? I couldn't exactly find an api endpoint for it, but I could be missing something important.

axelmoreen avatar Jan 05 '16 01:01 axelmoreen

Private messages are not currently supported by DubAPI. Though are potentially something for a future release.

Current Dubtrack PM endpoints are

  • GET https://api.dubtrack.fm/message - Get conversations
  • POST https://api.dubtrack.fm/message - Create conversation
  • GET https://api.dubtrack.fm/message/new - Poll for new messages
  • GET https://api.dubtrack.fm/message/%CONVID% - Get messages in a given conversation
  • POST https://api.dubtrack.fm/message/%CONVID% - Send message in given conversation
  • POST https://api.dubtrack.fm/message/%CONVID%/read - Mark conversation as read

anjanms avatar Jan 05 '16 06:01 anjanms

Is this a feature that will be pursued in the future? Sending commands to the Bot via PM's would be awesome.

nine1six avatar Feb 23 '16 00:02 nine1six

Yes, it's something I'd like to do. I just haven't been able to work on DubAPI as much as I'd like to.

anjanms avatar Mar 01 '16 23:03 anjanms

I've started work on this over in my fork, and there's currently support for sending PMs. It's kind of annoying that you have to poll for new messages, rather than being able to receive them via PubNub (slower too), but I'll look into implementing that next.

hedgehog1029 avatar Jun 15 '16 19:06 hedgehog1029

+1 for this feature request

FranciscoG avatar Sep 25 '16 21:09 FranciscoG

Gonna revive this - I haven't tested merging the latest commits with my fork, but now we're on a regular websocket connection, does dubtrack finally have support for receiving DMs over it? The way it's handled by dubtrack currently is fine for the web client but terrible for bots.

hedgehog1029 avatar Jan 25 '17 13:01 hedgehog1029

@hedgehog1029 I've asked on the discord developer channel to see if the last major update changed the way DM's work. I know they switched from using a third party (PubNub) to rolling their own websockets pubsub server.

I'm ok with with polling, there's an expectation of chat being real-time, but DMs don't need to be. You can set up a polling of something like every minute and I'd be fine with that.

FranciscoG avatar Jan 25 '17 15:01 FranciscoG

Polling is annoying, given that we have a websocket connection anyway, but just about acceptable. The real issue is the way Dubtrack polls and downloads DMs - it polls one endpoint (/new) but then calls another endpoint to actually download the DMs, and they get downloaded as one big JSON blob, rather than giving you only new DMs. This also means you get the entire DM history of the account, which is gonna be a pain for big bots. Polling on the client only downloads the number of unread DMs, which it then displays as the little notification.

hedgehog1029 avatar Jan 25 '17 15:01 hedgehog1029

yeah I'm realizing this now as I'm trying to figure this out myself. so annoying. I'm trying to see if there's something lodash can do to compare previous download of messages to a subsequent one... and also after polling, comparing to check for new, we also have to mark each new one as read via a separate call. geez

FranciscoG avatar Jan 25 '17 16:01 FranciscoG

@FranciscoG one of the front-end devs on Discord mentioned that the websocket now has a new-message event for dealing with DMs.

hedgehog1029 avatar Jan 25 '17 18:01 hedgehog1029

that's awesome! so much better than polling.

I assume we still have to mark that message as read. This only replaces the GET https://api.dubtrack.fm/message/new - Poll for new messages

FranciscoG avatar Jan 25 '17 18:01 FranciscoG

so I tried listening to the new-message event, but getting nothing so far. Maybe @anjanms needs to make an update to eventHandler.js

FranciscoG avatar Jan 25 '17 20:01 FranciscoG

try listening to the * event and dumping the result with console.dir

hedgehog1029 avatar Jan 26 '17 13:01 hedgehog1029

Just bumping this...

qaisjp avatar Jun 02 '17 12:06 qaisjp

A quick test with my personal library shows absolutely no websocket events are recieved when a DM is recieved. My library isn't quite ready for release but I'll look into implementing both sending and polling for DMs at some point.

hedgehog1029 avatar Jun 02 '17 13:06 hedgehog1029