#NEWLINE# @ gen . coroutine #NEWLINE# def _respond_commands( self , update_response ) : #NEWLINE# #INDENT# if update_response . exception ( ) : #NEWLINE# #INDENT# LOGGER . error ( str ( update_response . exception ( ) ) ) #NEWLINE# #UNINDENT# update_content = update_response . result ( ) . body #NEWLINE# if ( not update_content ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# update_content = json . loads ( update_content ) #NEWLINE# #UNINDENT# for update in update_content [ 'result' ] : #NEWLINE# #INDENT# if ( not update [ 'message' ] . get ( 'text' ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# message = update [ 'message' ] [ 'text' ] . encode ( 'utf-8' ) #NEWLINE# msp = message . split ( ) #NEWLINE# self . _last_update = update [ 'update_id' ] #NEWLINE# if ( ( len ( msp ) > 1 ) and msp [ 0 ] . startswith ( '/activate' ) ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# chat_id = update [ 'message' ] [ 'chat' ] [ 'id' ] #NEWLINE# if ( ( msp [ 1 ] == self . bot_ident ) and ( chat_id not in self . _chats ) ) : #NEWLINE# #INDENT# LOGGER . debug ( 'Adding chat [%s] to notify list.' , chat_id ) #NEWLINE# self . _chats . append ( chat_id ) #NEWLINE# ( yield self . client . fetch ( ( self . url + 'sendMessage' ) , body = json . dumps ( { #NEWLINE# #INDENT# 'chat_id' : update [ 'message' ] [ 'chat' ] [ 'id' ] , #NEWLINE# 'reply_to_message_id' : update [ 'message' ] [ 'message_id' ] , #NEWLINE# 'text' : 'Activated!' , #NEWLINE# #UNINDENT# } ) , method = 'POST' , headers = { #NEWLINE# #INDENT# 'Content-Type' : 'application/json' , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( msp [ 1 ] == self . bot_ident ) and ( chat_id in self . _chats ) ) : #NEWLINE# #INDENT# ( yield self . client . fetch ( ( self . url + 'sendMessage' ) , body = json . dumps ( { #NEWLINE# #INDENT# 'chat_id' : update [ 'message' ] [ 'chat' ] [ 'id' ] , #NEWLINE# 'reply_to_message_id' : update [ 'message' ] [ 'message_id' ] , #NEWLINE# 'text' : 'This chat is already activated.' , #NEWLINE# #UNINDENT# } ) , method = 'POST' , headers = { #NEWLINE# #INDENT# 'Content-Type' : 'application/json' , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# except : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# continue