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

Help with replying to PMs (Python) #54

Closed BenTheHokie closed 12 years ago

BenTheHokie commented 12 years ago

Could someone whip up a quick example for replying to PMs in Python (something like the chat bot example except for PMming)? I'm having trouble trying to understand how to use it.

Thanks in advance.

alaingilbert commented 12 years ago
from ttapi import Bot
bot = Bot(AUTH, USERID, ROOMID)

# Define callback
def pmmed(data):
   sender = data['senderid']
   text = data['text']
   print 'You received %s from %s' % (text, sender)

   # Send a message to the sender !
   bot.pm('Hey !', sender)

# Bind listener
bot.on('pmmed', pmmed)

# Start the bot
bot.start()

Does it help ?

BenTheHokie commented 12 years ago

Yes thanks a bunch