• If you need help or want to discuss things, you now can also join us on our Discord Server!
  • A first preview of the unlimited version of SinusBot can be found in the Upcoming Changes thread. A version for Windows will follow, but we don't have a release date, yet.

EN [HELP] Setting Nick as Song Title with Radio

Status
Not open for further replies.

Doggy Doggo

Member
Hey guys I currently have a script that changes the nick of the bot to the song title. It works for requested songs and for YouTube. Now it works for when I switch to radio, but when the song changes on the radio it doesn't update. Is there anyway I can do this? This is the code so far. Any help would be greatly appreciated. Thanks in advance.

Code:
registerPlugin({
    name: 'Set Bot Name To Song Title',
    version: '1.0',
    description: 'Changes the bots song title for requested songs, radio and YouTube™.',
    author: 'Smallo',
    vars: {}
},    function (sinusbot, config)    {
    var fulltitle;
    sinusbot.on('track', function(ev) {
        if (fulltitle = ev.tempTitle) {
            //Nothing
        } else if (fulltitle = ev.title){
            //Nothing
        } else {
            if (typeof ev.tempTitle != 'undefined'){
                fulltitle = ev.tempTitle;
            } else if (ev.title != 'undefined') {
                fulltitle = ev.title;
            }
        }
            if (fulltitle.length > 27){
                fulltitle = fulltitle.substring(0,26);
            }
            var nick = '♫ ' + fulltitle + ' ♫';
            setNick(nick);
    });
    sinusbot.on('trackEnd', function(ev) {
        if (typeof ev.tempTitle != 'undefined'){
            fulltitle = ev.tempTitle;
        } else if (ev.title != 'undefined') {
            fulltitle = ev.title;
        }
    });
});
 

mxschmitt

Moderator
Staff member
is awesome!
V.I.P.
is uber awesome!
Contributor
Insider
There are two possibilities:
  • You can check every XXX seconds if the trackinfo has been changed with the JavaScript function setInterval
  • Or you use an event like trackinfo, which should be triggered, when the trackinfo has been changed ( idk if that works)
Now you must try to figure it out :)
 

Doggy Doggo

Member
Alright I got it working with this. Thanks for the help.

Code:
registerPlugin({
    name: 'Set Bot Name To Song Title',
    version: '1.0',
    description: 'Changes the bots song title for requested songs, radio and YouTube™.',
    author: 'Smallo',
    vars: {}
},    function (sinusbot, config)    {
    var fulltitle;
    var MyTimer;
    var currentnick = sinusbot.getNick();
    sinusbot.on('trackInfo', function(ev) {
        var MyTimer = setTimeout(ChangeNick, 5000);
    });
    function ChangeNick() {
        var track = sinusbot.getCurrentTrack();
            if (typeof track.tempTitle != 'undefined') {
                fulltitle = track.tempTitle;
            } else if (track.title != 'undefined') {
                fulltitle = track.title;
            }
            if (fulltitle.length > 27){
                fulltitle = fulltitle.substring(0,26);
            }
            var nick = '♫ ' + fulltitle + ' ♫';
            setNick(nick);
        //}
    }
});

Only issue is if I use %i (getting the username) in the announce-string it sends the announce-string twice. But I guess I will just remove %i.
 
Status
Not open for further replies.
Top