MyBB Community Forums
[DEV] Embedded Discord Channel - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Extensions (https://community.mybb.com/forum-201.html)
+--- Forum: Plugins (https://community.mybb.com/forum-73.html)
+---- Forum: Plugin Development (https://community.mybb.com/forum-68.html)
+---- Thread: [DEV] Embedded Discord Channel (/thread-210513.html)

Pages: 1 2


[DEV] Embedded Discord Channel - klin - 2017-05-19

snipppp


RE: [DEV] Embedded Discord Channel - EscortPay - 2017-05-19

Great plugin . I would be waiting for the release date . Any fixed date ?


RE: [DEV] Embedded Discord Channel - Tactrus - 2017-05-19

Woah, looks promising. Nice job so far!


RE: [DEV] Embedded Discord Channel - klin - 2017-05-19

(2017-05-19, 03:08 PM)EscortPay Wrote: Great plugin . I would be waiting for the release date . Any fixed date ?

No fixed date. This is just a rough proof of concept to show that yes, this is possible and also resource efficient. (The problem with most chatbox plugins is that they rely on HTTP requests to fetch messages, which puts a strain on the client and server. This proof of concept is using websockets to maintain a persistent connection, alleviating this strain.) Additionally, I'm moving next weekend, so I've got a lot of other irons in the fire. (:

But I can provide a rough roadmap:
  • Publish the initial Github repository. 
  • Move POST action (used to send messages) into the back end to make it more secure.
  • Move GET action (used to get message history on page reload) into the back end, also to make it more secure.
  • Handle MESSAGE_UPDATE event and figure out how to properly edit displayed messages to reflect the new, edited content.
  • Add new setting to allow specified groups to delete messages.
  • Make the presentation prettier and actually use the embedded_discord_message template rather than hardcoding it in the JavaScript.
  • Add pagination to the embedded channel instead of just dumping out all <=100 messages.
  • (Maybe add settings for messages per page and max number of messages to display. Currently hardcoded to 100.)
  • Write documentation on setting up the plugin—i.e., how to create a bot and obtain its token, how to add a webhook to a channel, and how to obtain a channel ID.
Once I complete all of these points (which isn't a significant amount of work, despite how it may look), I will look into publishing a BETA VERSION of the plugin, to be used at your own risk. I'm aiming to achieve this within two weeks (but hopefully faster! but possibly slower).

As a developer, I aim for three things: community involvement (have a feature? find an issue? tell me!), transparency (keeping up-to-date changelogs, detailing breaking changes, etc.), and good code (readable, self-documenting, and well-commented where things need clarifying), so I hope that anyone interested will feel welcome to communicate with me and look through the code (once I get the repository up)!


RE: [DEV] Embedded Discord Channel - klin - 2017-05-24

Changelog 5/24/17
  • Websocket manages heartbeat correctly and (probably) resumes when the connection is dropped.
  • Chat is paginated using JavaScript. Currently only has "Next" and "Previous" buttons to step through the pages.
  • Last 100 messages are fetched and displayed server-side. 
  • Nickname and avatar URL fields display for guests, if guests have messaging permission (as determined in the Embedded Discord Channel settings).
  • Add setting for guest nickname format. Defaults to "{username} (Guest)" if blank.
  • Initially fetched messages show nicknames styled using the member's user group or display group style. Assumes that if a Discord nickname exists as a MyBB username, it is the same person. (Perhaps a faulty assumption, but unsure of a way around this one.)
  • I've moved the request that uses the Discord webhook (to send a message) into the back-end for security and instead call it with an Ajax request in the front-end. This unfortunately adds to the server load, but it's the only way to hide this sensitive information from potentially malicious snoopers.
Technical
  • I've added a users cache of key-value pairs where the key is the username and the values are an array of uid, usergroup, display group, and avatar. Right now, the users cache updates when it is 1 hour old. I need to add a hook on user registration that adds the new account to the cache. The users cache is used in styling names for the embedded channel.

Technical Hurdles
  • The message history is fetched via a GET request every page load. I can't think of a decent way to cache this information, considering how quickly a channel can move.
  • Though usernames are styled for the message history, they are currently not styled when a new message is received. This would require a new request to the back-end, which would increase server load by a lot, if my inexperienced guess is correct. (I've never dealt much with HTTP requests.)
    • I could pass in the users cache as a JavaScript variable, a cookie, or into local storage, but this seems like a bad idea, even though it would make things a lot simpler.
    • Actually, it looks like that's what another websocket chat plugin (Miuna) is doing—stashing name styles in local storage. Bears investigating.
Next Steps
  • Investigate how other websocket chat plugins style names.
  • Add support for additional events, e.g. when a user joins a server, when a message is updated, when a message is pinned.
  • Convert markdown styling into HTML, e.g. **this** will become <b>this</b>.
  • Add pagination for individual pages rather than just Previous and Next.



RE: [DEV] Embedded Discord Channel - Lewis L - 2017-05-26

Excellent job so far! Amazing Big Grin


RE: [DEV] Embedded Discord Channel - UzGz - 2017-07-09

Damn this look amazing !! Great work ! If I read right there's no major security issue in last version ?
Maybe this can be tried on live board ?


RE: [DEV] Embedded Discord Channel - Azah - 2017-07-11

[Image: a8JXpeV.png]

Correct me if I'm wrong.

New messages are streamed from Discord via WebSockets via a JS file on the browser side, right?
If so, have you considered using something like this?

https://github.com/teamreflex/DiscordPHP

Also, if too many messages flow without any rate-limiting on your side, you might be rate-limited *hard* by Discord.
And it might constitute API abuse. Discord *do not* mess around when it comes to API abuse.
Discord has guild-level rate-limits and global rate-limits. X messages per second. It might be difficult to manage this without centralising it into one connection.

Anyway, these are my two cents. Could be wrong, but never hurts to be careful.


RE: [DEV] Embedded Discord Channel - UzGz - 2017-07-28

I'm also really interested in this, do you plan to release alpha / beta any time soon ? I'd enjoy to test it Wink


RE: [DEV] Embedded Discord Channel - WallBB - 2017-07-29

Wow, this will be a really big addition for all MyBB forums, good work klin Smile
+rep