diff --git a/examples/adhoc_user.py b/examples/adhoc_user.py index 30e83f9b..738b22cd 100755 --- a/examples/adhoc_user.py +++ b/examples/adhoc_user.py @@ -137,74 +137,6 @@ class CommandUserBot(sleekxmpp.ClientXMPP): # handler is provided. self['xep_0050'].terminate_command(session) - def _handle_command(self, iq, session): - """ - Respond to the intial request for a command. - - Arguments: - iq -- The iq stanza containing the command request. - session -- A dictionary of data relevant to the command - session. Additional, custom data may be saved - here to persist across handler callbacks. - """ - form = self['xep_0004'].makeForm('form', 'Greeting') - form.addField(var='greeting', - ftype='text-single', - label='Your greeting') - - session['payload'] = form - session['next'] = self._handle_command_complete - session['has_next'] = False - - # Other useful session values: - # session['to'] -- The JID that received the - # command request. - # session['from'] -- The JID that sent the - # command request. - # session['has_next'] = True -- There are more steps to complete - # session['allow_complete'] = True -- Allow user to finish immediately - # and possibly skip steps - # session['cancel'] = handler -- Assign a handler for if the user - # cancels the command. - # session['notes'] = [ -- Add informative notes about the - # ('info', 'Info message'), command's results. - # ('warning', 'Warning message'), - # ('error', 'Error message')] - - return session - - def _handle_command_complete(self, payload, session): - """ - Process a command result from the user. - - Arguments: - payload -- Either a single item, such as a form, or a list - of items or forms if more than one form was - provided to the user. The payload may be any - stanza, such as jabber:x:oob for out of band - data, or jabber:x:data for typical data forms. - session -- A dictionary of data relevant to the command - session. Additional, custom data may be saved - here to persist across handler callbacks. - """ - - # In this case (as is typical), the payload is a form - form = payload - - greeting = form['values']['greeting'] - self.send_message(mto=session['from'], - mbody="%s, World!" % greeting) - - # Having no return statement is the same as unsetting the 'payload' - # and 'next' session values and returning the session. - - # Unless it is the final step, always return the session dictionary. - - session['payload'] = None - session['next'] = None - - return session - if __name__ == '__main__': # Setup the command line arguments.