def nickname_commands(*command_list):
 def add_attribute(function):
  if (not hasattr(function, u'rule')):
   function.rule = []
  rule = u'\n        ^\n        $nickname[:,]? # Nickname.\n        \\s+({command}) # Command as group 1.\n        (?:\\s+         # Whitespace to end command.\n        (              # Rest of the line as group 2.\n        (?:(\\S+))?     # Parameters 1-4 as groups 3-6.\n        (?:\\s+(\\S+))?\n        (?:\\s+(\\S+))?\n        (?:\\s+(\\S+))?\n        .*             # Accept anything after the parameters. Leave it up to\n                       # the module to parse the line.\n        ))?            # Group 1 must be None, if there are no parameters.\n        $              # EoL, so there are no partial matches.\n        '.format(command=u'|'.join(command_list))
  function.rule.append(rule)
  return function
 return add_attribute

def nickname_commands ( * command_list ) : def add_attribute ( function ) : if ( not hasattr ( function , u'rule' ) ) : function . rule = [ ] rule = u'\n        ^\n        $nickname[:,]? # Nickname.\n        \\s+({command}) # Command as group 1.\n        (?:\\s+         # Whitespace to end command.\n        (              # Rest of the line as group 2.\n        (?:(\\S+))?     # Parameters 1-4 as groups 3-6.\n        (?:\\s+(\\S+))?\n        (?:\\s+(\\S+))?\n        (?:\\s+(\\S+))?\n        .*             # Accept anything after the parameters. Leave it up to\n                       # the module to parse the line.\n        ))?            # Group 1 must be None, if there are no parameters.\n        $              # EoL, so there are no partial matches.\n        ' . format ( command = u'|' . join ( command_list ) ) function . rule . append ( rule ) return function return add_attribute
decorate a function to trigger on lines starting with "$nickname: command" .