alaingilbert / Turntable-API

Allows you to create bots for turntable.fm
http://alaingilbert.github.com/Turntable-API/
MIT License
317 stars 98 forks source link

how to get at userid in getUserId ( name:string, callback:fn ) #135

Closed samuri51 closed 11 years ago

samuri51 commented 11 years ago

so i'm trying to write something like

if getUserId ( name:string, callback:fn ) === undefined than do nothing else give the information

but it seems no matter what i do i get the retarded undefined msg.tostring error

anyone know how to do this?

samuri51 commented 11 years ago

nevermind figured this one out

technobly commented 11 years ago

Thanks for sharing -_-

samuri51 commented 11 years ago

here ya go dude :), didn't know anyone was interested, should be able to use it as is

heres the format:

use space and @ symbol or two spaces in between the persons name

/userid @DubbyTT

the number after it should be a valid userid and u need one space

/username 152151251515111

bot.on('speak', function (data)
{
    var text = data.text;
    if (text.match('/userid'))
    {
        var ban8 = data.text.slice(9);
        var checkUser8 = bot.getUserId(ban8, function (data)
        {
            var userid56 = data.userid;
            if (typeof (userid56) !== 'undefined')
            {
                bot.speak(userid56);
            }
            else
            {
                bot.speak('I\'m sorry that userid is undefined');
            }
        });
    }
    else if (text.match('/username'))
    {
        var ban50 = data.text.slice(10);
        var tmp94 = bot.getProfile(ban50, function (data)
        {
            bot.speak(data.name);
        });
    }
});
samuri51 commented 11 years ago

there i added it to the wiki since it seemed like something that everyone should know how to do