#NEWLINE# def run( message ) : #NEWLINE# #INDENT# '\n        Run\n\n        Run the custom plugin specific code. A returned\n        string is the message that will be sent back\n        to the user.\n\n        --\n        @param  message:dict    The message sent by the user\n\n        @return str\n    ' #NEWLINE# text = message [ 'text' ] #NEWLINE# if text . startswith ( '@' ) : #NEWLINE# #INDENT# text = text . split ( ' ' , 1 ) [ 1 ] . strip ( ) #NEWLINE# #UNINDENT# if text . startswith ( '/' ) : #NEWLINE# #INDENT# text = text . replace ( '/' , '' , 1 ) . strip ( ) #NEWLINE# #UNINDENT# action = text . split ( ' ' ) [ 0 ] . strip ( ) #NEWLINE# if ( action not in commands ( ) ) : #NEWLINE# #INDENT# return "Sorry, I don't know what to do with: {command}" . format ( command = action ) #NEWLINE# #UNINDENT# for command in commands ( ) : #NEWLINE# #INDENT# text = ignore_case_replace ( command , '' , text ) . strip ( ) #NEWLINE# #UNINDENT# parts = _extract_parts ( text ) #NEWLINE# if parts [ 'error' ] : #NEWLINE# #INDENT# error_message = 'Reminder not set. Error was: {e}.\n\n{help}' . format ( e = parts [ 'error_message' ] , help = _show_help ( None ) ) #NEWLINE# return error_message #NEWLINE# #UNINDENT# if ( parts [ 'action' ] in [ 'show' , 'stop' , 'help' ] ) : #NEWLINE# #INDENT# handle_action = { #NEWLINE# #INDENT# 'show' : _show_all_reminders , #NEWLINE# 'stop' : _stop_reminder , #NEWLINE# 'help' : _show_help , #NEWLINE# #UNINDENT# } #NEWLINE# return handle_action [ parts [ 'action' ] ] ( message ) #NEWLINE# #UNINDENT# handle_recurrence_types = { #NEWLINE# #INDENT# 'once' : _set_once_reminder , #NEWLINE# 'every' : _set_recurring_reminder , #NEWLINE# #UNINDENT# } #NEWLINE# handle_recurrence_types [ parts [ 'recurrence' ] ] ( parts , message ) #NEWLINE# response = 'Reminder set for: {t} with message: {m}' . format ( t = parts [ 'parsed_time' ] , m = parts [ 'message' ] ) #NEWLINE# return response