plugCubed / plugAPI

A generic API for creating plug.dj bots
MIT License
78 stars 45 forks source link

Room Description #163

Closed moongoesrawr closed 5 years ago

moongoesrawr commented 5 years ago

I apologize if this has been covered, I can't find anything, and I hope I'm just missing something. Does bot.changeRoomDescription(); work? I have tried bot.changeRoomDescription('text'); and it does not change my room description. Any insight would be helpful. Thank you!

avatarkava commented 5 years ago

I believe it does, but I'm not in front of the computer to test right now - does your bot have a high enough role (permissions level) in the room to be able to change the description?

moongoesrawr commented 5 years ago

Yes, it is a co-host. I think I'm not very good with this. There is a lot I want to do, but frankly have no clue how to do. I kind of just brute force my way through things sometimes. I figured this would be straight forward like bot.changeRoomName(); and bot.changeRoomWelcome(); are. Thanks in advance for any help. :)

moongoesrawr commented 5 years ago

Gentle reminder nudge. :)

Talos51 commented 5 years ago

Hi @moongoesrawr ,

Just ran some test and i can confirm it seems that bot.changeRoomDescription("your description") does nothing even with co-host permissions. PlugAPI is deprecated on that point and need some update on changeRoomDescription() method since Plug.DJ does now have a "short description" and "detailed description" in room info meta ( https://plug.dj/_/rooms/state ) and not using actively description anymore.

I think an update is needed in client.js to include some new methods ChangeRoomDescription ( for short description ) and ChangeRoomLongDescription ( for detailed description ).

Maybe something like that ?

    changeRoomDescription(description, callback) {
        if (!store(this)._room.getRoomMeta().slug || !this.havePermission(undefined, PlugAPI.ROOM_ROLE.COHOST) || Object.is(store(this)._room.getRoomMeta().short_description, description) || this.guest) {
            return false;
        }

        store(this)._queueREST('POST', endpoints.ROOM_INFO, {
            name: undefined,
            short_description: description,
            long_description: undefined,
            minChatLevel: undefined,
            welcome: undefined
        }, callback);

        return true;
    }

    changeRoomLongDescription(longDescription, callback) {
        if (!store(this)._room.getRoomMeta().slug || !this.havePermission(undefined, PlugAPI.ROOM_ROLE.COHOST) || Object.is(store(this)._room.getRoomMeta().longDescription, longDescription) || this.guest) {
              return false;
        }

        store(this)._queueREST('POST', endpoints.ROOM_INFO, {
            name: undefined,
            short_description: undefined,
            long_description: longDescription,
            minChatLevel: undefined,
            welcome: undefined
        }, callback);

        return true;
    }

I've tested this modification on test environment and it worked fine.

const PlugAPI = require('plugapi');

new PlugAPI({
    email: 'Your_MAIL',
    password: 'Your_PASSWORD'
}, (err, bot) => {
    if (!err) {
        bot.connect('YourRoom'); // The part after https://plug.dj

        bot.on(PlugAPI.events.ROOM_JOIN, (room) => {
            console.log(`Joined ${room}`);
bot.multiLine = true;
bot.multiLineLimit = 5;

bot.sendChat("#1 - Changing Room Short Description");
bot.changeRoomDescription("THIS IS MY SHORT DESC", function(){
        bot.sendChat("Changed room description !");
});

bot.sendChat("Sleeping for 5sec !");

setTimeout(function() {
        bot.sendChat("#2 - Changing Room Long Description");
        bot.changeRoomLongDescription("THIS IS A DETAILED DESCRIPTION ALSO CALLED LONG DESCRIPTION", function(){
                bot.sendChat("Changed room long description !");
        });
}, 5000);

        });

} else {
        console.log(`Error initializing plugAPI: ${err}`);
    }
});

Capture

Regards, Talos.

thedark1337 commented 5 years ago

Hi,

We aren't deprecated as much as ... busy with life. I apologize for not having responded in a timely manner but you're right, Plug changed it so that there's both a long and short description now. A lot of stuff still needs to be fixed with plugAPI to get it working 100% and any help we can get is much appreciated.

If you'd like to, you can either pull request to have that added or I can add it in myself and release a minor version to add it in.

Thanks,

Talos51 commented 5 years ago

164

@thedark1337 Just did a pull request to address this issue. Once again thanks for bringing us PlugAPI and I didn't mean to disrespect you when i mentioned this project as "deprecated".

thedark1337 commented 5 years ago

No offense taken, thanks for your help! I'll be updating dependencies as well, before releasing a version that will fix this issue

moongoesrawr commented 5 years ago

Wow, thanks guys!