basicBot / source

A not so basic bot for plug.dj
89 stars 594 forks source link

Crashes when trying to get roominfo since plug.dj latest update #151

Closed WiBla closed 6 years ago

WiBla commented 6 years ago

Plug.dj recently pushed an update that changes the way the room description is displayed. When the bot is looking for the community's description basicBot.js#L180 it errors out because it can no longer access this information, not only because the classes changed, but also because it isn't pre-loaded anymore. You now have to open the community's about section before you can even attempt to access it.

To remedy this issue, I would strongly advise switching up to an ajax get request pointing to the rooms/state endpoint in order to obtain the community's description. This is much more reliable and future-proof. The only downside I can see of using this method is if you're spamming the API for some reason, the request will not succeed and you won't be able to gather up the room's details. This would however, not prevent basic (and custom repos for that matter) to load as it is currently the case.

In hope this helps :)

thedark1337 commented 6 years ago

Alternatively instead of using AJAX you could muck about with the requireJS modules, which would be more efficient and avoid any spam warnings from plug ;)

_.find(require.s.contexts._.defined, (module) => module && module.attributes && 'hostID' in module.attributes).get('description');
WiBla commented 6 years ago

Forgot it was a thing, thanks for pointing that out!

samhmills commented 6 years ago

Hey guys,

@WiBla @thedark1337 is there anything that needs to be actioned here to fix this?

Can someone submit a pull request or a fix?

Hench,

WiBla commented 6 years ago

Replacing the line that causes the issue with @thedark1337 's one will do the trick.