#NEWLINE# @ responder ( pattern = '^subscribe (?P<event>\\S+)' , form = 'subscribe <event>|all' , help = 'Subscribe to event notifications' ) #NEWLINE# def subscribe( conversation , event ) : #NEWLINE# #INDENT# subscriptions = set ( conversation . context . get ( 'subscriptions' , set ( ) ) ) #NEWLINE# if ( event == 'all' ) : #NEWLINE# #INDENT# events = Event . objects #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# events = [ Event ( event ) ] #NEWLINE# #UNINDENT# for event in events : #NEWLINE# #INDENT# conversation . say ( ( 'Subscribed to %s events' % event . name ) ) #NEWLINE# subscriptions . add ( event . name ) #NEWLINE# event . subscribe ( conversation . notify ) #NEWLINE# #UNINDENT# conversation . context [ 'subscriptions' ] = subscriptions