Skip to content

Plugin Development

Have a question about building a plugin? Ask here
425 Topics 1.9k Posts
  • 0 Votes
    2 Posts
    1k Views
    yariplusY

    Using only the currently logged in nodebb user and minecraft player.

    Two routes needed:

    Server-only route: POST route. Requires a unique key parameter. Only the forum and the minecraft server know the key. e.g. /mc/link?key=key User route: GET route. Used to link accounts, requires a UUID and a unique player key. e.g. /mc/link/:uuid/:key

    Minimum two DB keys need:

    {uuid}:key String key, stores the unique player key for the UUID. (Could also be a hash to store additional data.) user:{uid}:uuid String key, stores the UUID linked to the user. (Could also be stored on the user hash, or made into a set for multiple linkings.) Process:

    https://www.lucidchart.com/documents/view/382333e7-c772-43b7-8061-57b3bbd83e97

    Minecraft player types a command. Server users server-only route to tell the forum it needs a registration link. Sending the unique key to verify the request is valid. Forum creates a unique player key and stores it in the DB, then sends the player key to the server. Server gives a link to the player, using the unique player key and the players' UUID. User visits link, if the user is logged in, and the uuid-key pair matches what is already in the DB, then the accounts are linked, using additional DB entries. The player key is deleted. Concerns: The player key should expire relatively quickly, like 5 minutes. Invalid requests to the user route should be monitored and blocked after a low threshold, like 3 tries. NodeBB middleware already validates the logged in user, which is why we do no additional checks. Note:

    On the last line in the diagram, I send a confirmation message, but we can't actually do this because we have not established a persistent connection. You could solve this by either having an http server on the server, or creating a socket connection to the forum.



    Or you could use Minecraft-Integration 😉

  • Upvote Notifications

    3
    2 Votes
    3 Posts
    1k Views
    B

    @exodo said in Upvote Notifications:

    working without core modifications?

    Yep. Only lightly tested so far (but based on my previous code that had automated tests written).

    Next I'd like to figure out how to make automated integration tests for plugins.

  • inline commands @gif

    1
    2 Votes
    1 Posts
    766 Views
    E

    this post should go on plugin request @Global-Moderators

    Having inline commands on composer like telegram does could be epic
    like adding new gifs from giphy with @gif command

    alt text

    Link Preview Image Introducing Inline Bots

    Inline bots: A new way to interact with bots and send bot-generated content to any chat, group or channel.

    favicon

    Telegram (telegram.org)

    anyone up? @3rd-Party-Developers

  • 0 Votes
    1 Posts
    1k Views
    D

    Suppose there are two files.

    library.js in the /nodebb-plugin-namePlugin
    file.js in /nodebb-plugin-namePlugin/static/lib

    Now I must do a lot of operation in my library.js and I must check when user is created. So I use the hook and It's everything ok, but, after I must my check in library I need to send a message to my file.js to change background color of a component. The proble is that I used this to communicate:

    websockets = module.parent.require('./socket.io'), //library.js websockets.in('uid_' + data.uid).emit('hash', { 'username': data.data.username }); //file.js socket.on('hash',function(){ console.log("DOG); });

    The problem is that I don't have data.uid value because I'm checking before that an user can registrate himself. Anyone can help me to use websocket without uid or can suggest me other methods?

  • [nodebb-plugin-embed-imgur] Embed Imgur

    3
    2 Votes
    3 Posts
    2k Views
    S

    @a_5mith This plugin in great! But I couldn't find this in the Download Plugin page? How to bring it back?

  • This topic is deleted!

    4
    0 Votes
    4 Posts
    108 Views
  • Composer Button Tooltips

    3
    0 Votes
    3 Posts
    1k Views
    NedFodderN

    @baris Just tried out 3.0.27, works great, thanks! There's still one difference: with filter:composer.formatting the text is run through the translator automagically, but with composer.addButton() I have to translate it first. Not a big deal, just pointing that out...

  • 0 Votes
    3 Posts
    1k Views
    Fredrik MelénF

    Thank you very much! Awesome! @yariplus

  • Social Share Callback

    Unsolved
    8
    0 Votes
    8 Posts
    4k Views
    N

    @PitaJ I think their JS SDK support, i tried googling. They have the share function with response id as callback. We can check for the response id to check if the content is actually shared.

  • This topic is deleted!

    1
    0 Votes
    1 Posts
    15 Views
  • This topic is deleted!

    2
    0 Votes
    2 Posts
    41 Views
  • NodeBB Plugin best practices

    1
    1 Votes
    1 Posts
    1k Views
    PitaJP

    I'm thinking it would be good if we establish some best practices for NodeBB plugin development.

    Feel free to contribute by replying and I'll add it to the list.

    Database keys should start with plugin:[your-plugin-name]: ex: if the plugin is nodebb-plugin-mentions then the database keys would start with plugin:mentions: Use sockets instead of ajax Use CSS transitions instead of jQuery animations, trigger them by toggling classes on the elements Use Bootstrap elements as much as possible or not at all your suggestion here
  • nodebb-plugin-sso-steam-refactor

    3
    0 Votes
    3 Posts
    2k Views
    H

    Of course, however I just felt more comfortable trying to understand what each line of code did! This was more of a learning experience ~

  • 0 Votes
    2 Posts
    1k Views
    barisB

    It is available in the client side config object. You can use it as config.maximumFileSize

  • Async problem in async.each

    2
    0 Votes
    2 Posts
    1k Views
    yariplusY

    You need to use async.map, which creates the new array based on the old one.

    function(setUsername,next){ async.map(setUsername, function(uid, call) { db.getSortedSetRange(set + uid, start,end, function(err, test) { // You need to ignore errors here, and just mark test as null. if (!test) test = null; // The callback will push to the new array. call(null, { 'uid': uid, 'test': test }); }); }, function (err, array) { if (err) { next(err); } // Filter out empty values. array = array.filter(function(el){ return el.test; }); next(null, array); }); }
  • This topic is deleted!

    6
    0 Votes
    6 Posts
    16 Views
  • 0 Votes
    1 Posts
    680 Views
    D

    I need to use in my controllers.js the value of function that I write in another file utils.js. The file "utils.js" in the same folder (lib) of my controllers.js. So in my controllers I import the file utils.js with this:

    var utils=module.require('./utils');

    and I import database in the file utils.js in this way:

    var db = module.parent.parent.require('./database'),

    That is the same import that I use also in my controllers.js. But I obtain "cannot find module ./database" in my utils.js . Anyone can help me?

  • How to get Chat Name from Websocket?

    5
    0 Votes
    5 Posts
    2k Views
    A

    @baris said in How to get Chat Name from Websocket?:

    There is a method to get the raw content of a message by its message id

    interestingly so does sockbot although i recon the two different methods serve rather different purposes. 😉

    @baris said in How to get Chat Name from Websocket?:

    there is no method to load all the data of a message yet.

    ah. trhen my interface shall throw E_UNSUPPORTED for now until a certain vixen makes a PR to fix that. 😉

  • 0 Votes
    2 Posts
    3k Views
    frissdiegurkeF

    you need to wrap it like {"value": [{"uid":1,"name":["Andreas"]}]}. Arrays are no (direct) instances of Objects; Thus not allowed to be used within db.setObject.

    EDIT: Actually [] instanceof Object === true. It's just not allowed by the database clients since Arrays are no conventional key/value stores.

  • How to get the website url

    4
    0 Votes
    4 Posts
    2k Views
    julianJ

    @lewismcmahon There's no way to know what the full url is besides what's presented in config.json, since multiple URLs can point to the same NodeBB.

    The nconf solution is the easiest.