Skip to content

Commit

Permalink
added documentation about events and unfinished work
Browse files Browse the repository at this point in the history
  • Loading branch information
lmcalpin committed Feb 29, 2012
1 parent af72470 commit e348cbd
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions Readme.rdoc
Expand Up @@ -6,7 +6,7 @@ created using the Turntable API developed by {Alain Gilbert}[https://github.com/
Example:

bot = TurntableAPI::Bot.new(:auth => "YOURAUTHID", :userid => "YOURUSERID", :logger => logger,
:roomid => '4df1058699968e6b8a00168d')
:roomid => '4df1058699968e6b8a00168d')
thrd = bot.start

# to call the API, call the action (replacing any '.' with '_') as a method and pass hash arguments
Expand Down Expand Up @@ -38,4 +38,30 @@ Actions:
* val = hash(roomid + direction ['up' or 'down'] + songid)
* vh and ph can take hashes of a random number


You can also listen on events from the server using the on_command method:

bot.on_command(:speak) do
name = cmd['name']
# don't respond to yourself!!!
if name != '@mybotname'
bot.room_speak :text => "Hello, #{name}"
end
end

Events you can listen on include:

* snagged: when a user snags your song
* registered: sent when someone joins the current room
* deregistered: sent when someone leaves the room
* add_dj: sent when someone steps up to DJ
* rem_dj: sent when someone steps down from their turntable
* newsong: sent whenever the song changes
* update_votes: sent whenever someone awesomes or lames a song

TODO

Currently unfinished:

* helper methods for voting a song up or down
* we are currently pinned to a single chat server which means many rooms won't work

0 comments on commit e348cbd

Please sign in to comment.