From c1f4ea82fb17225ae0f4964f1c272b3c29b454f5 Mon Sep 17 00:00:00 2001 From: Thumbscrew <thumbscrw@pm.me> Date: Tue, 5 Apr 2022 15:56:22 +0100 Subject: [PATCH] Add custom MatrixMessage type --- PSMatrix.psd1 | 6 ++++-- PSMatrixTypes.ps1xml | 31 +++++++++++++++++++++++++++++++ public/Get-MatrixRoomMessages.ps1 | 1 + 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 PSMatrixTypes.ps1xml diff --git a/PSMatrix.psd1 b/PSMatrix.psd1 index 69f46a7..967e652 100644 --- a/PSMatrix.psd1 +++ b/PSMatrix.psd1 @@ -9,7 +9,7 @@ @{ # Script module or binary module file associated with this manifest. -# RootModule = '' +RootModule = 'PSMatrix.psm1' # Version number of this module. ModuleVersion = '0.0.1' @@ -60,7 +60,9 @@ PowerShellVersion = '7.0' # ScriptsToProcess = @() # Type files (.ps1xml) to be loaded when importing this module -# TypesToProcess = @() +TypesToProcess = @( + 'PSMatrixTypes.ps1xml' +) # Format files (.ps1xml) to be loaded when importing this module # FormatsToProcess = @() diff --git a/PSMatrixTypes.ps1xml b/PSMatrixTypes.ps1xml new file mode 100644 index 0000000..611fe6d --- /dev/null +++ b/PSMatrixTypes.ps1xml @@ -0,0 +1,31 @@ +<Types> + <Type> + <Name>MatrixMessage</Name> + <Members> + <NoteProperty> + <Name>EventID</Name> + <Value>EventID</Value> + </NoteProperty> + <NoteProperty> + <Name>Sender</Name> + <Value>Sender</Value> + </NoteProperty> + <NoteProperty> + <Name>Body</Name> + <Value>Body</Value> + </NoteProperty> + <NoteProperty> + <Name>Format</Name> + <Value>Format</Value> + </NoteProperty> + <NoteProperty> + <Name>FormattedBody</Name> + <Value>FormattedBody</Value> + </NoteProperty> + <NoteProperty> + <Name>MsgType</Name> + <Value>MsgType</Value> + </NoteProperty> + </Members> + </Type> +</Types> \ No newline at end of file diff --git a/public/Get-MatrixRoomMessages.ps1 b/public/Get-MatrixRoomMessages.ps1 index 53d76ef..7244d68 100644 --- a/public/Get-MatrixRoomMessages.ps1 +++ b/public/Get-MatrixRoomMessages.ps1 @@ -70,6 +70,7 @@ function Get-MatrixRoomMessages { FormattedBody = $_.content.formatted_body MsgType = $_.content.msgtype } + $formattedEvent.PSObject.TypeNames.Insert(0, 'MatrixMessage') $formattedEvents += $formattedEvent }