You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
scripts/matrix_room_untag.ps1

31 lines
973 B
PowerShell

[CmdletBinding()]
Param (
[Array]$Exceptions = @('m.lowpriority','m.favourite'),
[String]$HomeServer = 'https://imninja.net',
[String]$MxId = '@lub:imninja.net',
[String]$AccessToken
)
function Invoke-MatrixMethod {
Param (
$Method = 'Get',
$Endpoint
)
# add authorization header
$Headers = $Headers+@{'authorization' = 'Bearer '+$AccessToken}
$uri = $HomeServer+$Endpoint
Invoke-RestMethod -Method $Method -Headers $Headers -Uri $uri
}
foreach($room in (Invoke-MatrixMethod -Endpoint '/_matrix/client/r0/joined_rooms').joined_rooms) {
foreach($tag in (Invoke-MatrixMethod -Endpoint ('/_matrix/client/r0/user/'+$MxId+'/rooms/'+$room+'/tags')).tags) {
$tag = ($tag | Get-Member)[4].Name
if($tag -and $tag -notin $Exceptions) {
'delete '+$tag
Invoke-MatrixMethod -Method Delete -Endpoint ('/_matrix/client/r0/user/'+$MxId+'/rooms/'+$room+'/tags/'+$tag)
}
}
}