#NEWLINE# def reply( self , username , type = 'text' , sender = None , **kwargs ) : #NEWLINE# #INDENT# "Create the reply text for weixin.\n\n        The reply varies per reply type. The acceptable types are `text`,\n        `music`, `news`, `image`, `voice`, `video`. Each type accepts\n        different parameters, but they share some common parameters:\n\n            * username: the receiver's username\n            * type: the reply type, aka text, music and news\n            * sender: sender is optional if you have a default value\n\n        Text reply requires an additional parameter of `content`.\n\n        Music reply requires 4 more parameters:\n\n            * title: A string for music title\n            * description: A string for music description\n            * music_url: A link of the music\n            * hq_music_url: A link of the high quality music\n\n        News reply requires an additional parameter of `articles`, which\n        is a list/tuple of articles, each one is a dict:\n\n            * title: A string for article title\n            * description: A string for article description\n            * picurl: A link for article cover image\n            * url: A link for article url\n\n        Image and Voice reply requires an additional parameter of `media_id`.\n\n        Video reply requires 3 more parameters:\n\n            * media_id: A string for video `media_id`\n            * title: A string for video title\n            * description: A string for video description\n        " #NEWLINE# sender = ( sender or self . sender ) #NEWLINE# if ( not sender ) : #NEWLINE# #INDENT# raise RuntimeError ( 'WEIXIN_SENDER or sender argument is missing' ) #NEWLINE# #UNINDENT# if ( type == 'text' ) : #NEWLINE# #INDENT# content = kwargs . get ( 'content' , '' ) #NEWLINE# return text_reply ( username , sender , content ) #NEWLINE# #UNINDENT# if ( type == 'music' ) : #NEWLINE# #INDENT# values = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for k in ( 'title' , 'description' , 'music_url' , 'hq_music_url' ) : #NEWLINE# #INDENT# values [ k ] = kwargs . get ( k ) #NEWLINE# #UNINDENT# return music_reply ( username , sender , ** values ) #NEWLINE# #UNINDENT# if ( media_id == 'news' ) : #NEWLINE# #INDENT# items = kwargs . get ( 'articles' , [ ] ) #NEWLINE# return news_reply ( username , sender , * items ) #NEWLINE# #UNINDENT# if ( type == 'customer_service' ) : #NEWLINE# #INDENT# service_account = kwargs . get ( 'service_account' , None ) #NEWLINE# return transfer_customer_service_reply ( username , sender , service_account ) #NEWLINE# #UNINDENT# if ( type == 'image' ) : #NEWLINE# #INDENT# media_id = kwargs . get ( 'media_id' , '' ) #NEWLINE# return image_reply ( username , sender , media_id ) #NEWLINE# #UNINDENT# if ( type == 'voice' ) : #NEWLINE# #INDENT# media_id = kwargs . get ( 'media_id' , '' ) #NEWLINE# return voice_reply ( username , sender , media_id ) #NEWLINE# #UNINDENT# if ( type == 'video' ) : #NEWLINE# #INDENT# values = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for k in ( 'media_id' , 'title' , 'description' ) : #NEWLINE# #INDENT# values [ k ] = kwargs . get ( k ) #NEWLINE# #UNINDENT# return video_reply ( username , sender , ** values )