views:

81

answers:

1

Google Wave allows two or more participants to speak privately within a wave. When my robot is added to the wave, I recognize the WAVELET_SELF_ADDED event and call the method below. However, nothing happens.

I can tell that the code is executed because of the Debug and Info statements in the logs. Is there any reason why the robot does not start a private blip when it's added?

def start_private_wavelet(properties, context):
    """Start a private conversation between the robot and some participants."""
    participants = []
    participants.append('[email protected]')
    participants.append('[email protected]')

    logging.debug('Getting wave info')

    root_wavelet = context.GetRootWavelet()
    root_wave_id = root_wavelet.GetWaveId()
    root_wave = context.GetWaveById(root_wave_id)

    logging.debug('Creating private wave in %s' % root_wave_id)

    private_wavelet = root_wave.CreateWavelet(participants)
    message = private_wavelet.CreateBlip()
    message.GetDocument().SetText("This is a private conversation...")

    logging.debug('Private wave created')
+2  A: 

A private conversion is created through a Wavelet.

So, using the Python API, I think you're looking for OpBasedWave.CreateWavelet.

participants = []
participants.append('[email protected]')
participants.append('[email protected]') # Remember to add your robot!

private_wavelet = root_wave.CreateWavelet(participants)
message = private_wavelet.CreateBlip()
message.GetDocument().SetText("Hi there, this is just a secret!")
Brian McKenna
Thank you for the response. However, I can't quite get this to work. I thought I needed to add the line "root_wave = context.GetRootWavelet()" to your code, but that didn't work either. Perhaps creating a wavelet privately only works with certain events?
Wraith
With `context.GetRootWavelet()` you're getting the root __Wavelet__. Now that you have the root Wavelet you can find the root __Wave__ via `root_wave_id = root_wavelet.GetWaveId()` and `root_wave = context.GetWaveById(root_wave_id)`. You can find more information about Wave entities here: http://code.google.com/apis/wave/guide.html#WaveEntities
Brian McKenna
I've incorporated your feedback into the question, but the blip is still not created. Is there anything I'm missing?
Wraith
I haven't gotten this working yet, but I wanted to accept because this is a great start. Once I find out about the limitations for private replies I will post.
Wraith