alaingilbert / Turntable-API

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

bot.getProfile() is still not working, with TTAPI 3.0.1 #237

Closed ghost closed 11 years ago

ghost commented 11 years ago

I installed the latest version of ttapi, 3.0.1, and bot.getProfile() is still not working. VeggieBot is still pming himself, whenever i pm him, and when he does his room greeting.

gizmotronic commented 11 years ago

Um, what? getProfile() is working fine. Here's a simple bit of CoffeeScript you can use to prove it to yourself.

If you could elaborate how this is connected to PMs or your room greeting, it might help.

AUTH='xxxxxxxxxxxxxxxxxxxxxxxx'
ROOMID='xxxxxxxxxxxxxxxxxxxxxxxx'
USERID='xxxxxxxxxxxxxxxxxxxxxxxx'

Bot = require('ttapi')

bot = new Bot AUTH, USERID
bot.debug = false

bot.on 'ready', (data) ->
  bot.getUserId 'VeggieBot', (data) ->
    if data.success
      bot.getProfile data.userid, (result) ->
        console.log 'someone else', JSON.stringify result, null, 2
  bot.getProfile (result) ->
    console.log 'me (implicit)', JSON.stringify result, null, 2
alaingilbert commented 11 years ago

I tested it out, and it seems to work properly:

Here is the result.

me (implicit) {
  "name": "agilbert_bot",
  "success": true,
  "created": 1360196161.273213,
  "msgid": 4,
  "laptop": "mac",
  "userid": "5112f241eb35c11229940e02",
  "registered": 1360196161.273213,
  "acl": 0,
  "fans": 0,
  "points": 0,
  "images": {
    "fullfront": "/roommanager_assets/avatars/3/fullfront.png",
    "headfront": "/roommanager_assets/avatars/3/headfront.png"
  },
  "avatarid": 3,
  "fanofs": 3,
  "soundcloud": "test"
}
someone else {
  "website": "",
  "fanofs": 97,
  "about": "Bot Created by God's Vegetables",
  "hangout": "",
  "name": "VeggieBot",
  "twitter": "",
  "created": 1359677257.895826,
  "msgid": 5,
  "laptop": "pc",
  "laptop_version": null,
  "userid": "510b0749eb35c135fbe7370c",
  "success": true,
  "topartists": "",
  "fans": 16,
  "points": 95,
  "facebook": "",
  "images": {
    "fullfront": "/roommanager_assets/avatars/7/fullfront.png",
    "headfront": "/roommanager_assets/avatars/7/headfront.png"
  },
  "acl": 0,
  "avatarid": 7,
  "registered": 1359677257.895826
}
ghost commented 11 years ago

PM works fine on VeggieBot but, for the room greeting, he greets himself before anyone else.

Here's the Code for the Greeting:

bot.on('registered', function (data)
{
    setTimeout(function ()
    {
        bot.speak(data.user[0].name + ', welcome to the room, and have fun being entertained by awesome music!'); //send it in the chatbox
        bot.pm('welcome to the room, and have fun being entertained by awesome music!', data.user[0].userid); //send it in the pm    
    }, 3 * 1000); //slow it down 3 seconds
});
gizmotronic commented 11 years ago

This is expected because you will see a registered event for your bot when it first joins the room.

ghost commented 11 years ago

ok, thanks for clearing it up. I was kinda confused.