#NEWLINE# def run( self , result , channel , user = None , whisper = False ) : #NEWLINE# #INDENT# endpoint = self . config [ 'endpoint' ] #NEWLINE# if ( not endpoint ) : #NEWLINE# #INDENT# raise ValueError ( 'Missing "endpoint" config option' ) #NEWLINE# #UNINDENT# url = urljoin ( headers , '/hubot/st2' ) #NEWLINE# headers = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# headers [ 'Content-Type' ] = 'application/json' #NEWLINE# body = { #NEWLINE# #INDENT# 'channel' : channel , #NEWLINE# 'message' : self . _get_message ( result ) , #NEWLINE# #UNINDENT# } #NEWLINE# if user : #NEWLINE# #INDENT# body [ 'user' ] = user #NEWLINE# #UNINDENT# if ( whisper is True ) : #NEWLINE# #INDENT# body [ 'whisper' ] = whisper #NEWLINE# #UNINDENT# data = json . dumps ( body ) #NEWLINE# self . logger . info ( data ) #NEWLINE# response = requests . post ( url = url , headers = headers , data = data ) #NEWLINE# if ( response . status_code == httplib . OK ) : #NEWLINE# #INDENT# self . logger . info ( 'Message successfully posted' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . logger . exception ( ( 'Failed to post message: %s' % response . text ) ) #NEWLINE# #UNINDENT# return True