-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #117 from StartAutomating/obs-powershell-updates
obs-powershell 0.1.8
- Loading branch information
Showing
665 changed files
with
35,652 additions
and
2,863 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
github: [StartAutomating, nyanhp, I-Am-Jakoby] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
function Get-OBSEffect | ||
{ | ||
<# | ||
.SYNOPSIS | ||
Gets OBS Effects | ||
.DESCRIPTION | ||
Gets effects currently loaded into OBS-PowerShell. | ||
An effect can be thought of as a name with a series of messages to OBS. | ||
Those messages can be defined in a .json file or a script, in any module that tags OBS. | ||
They can also be defined in a function or script named like: | ||
* `*.OBS.FX.*` | ||
* `*.OBS.Effect.*` | ||
* `*.OBS.Effects.*` | ||
.LINK | ||
Import-OBSEffect | ||
.LINK | ||
Remove-OBSEffect | ||
#> | ||
param( | ||
# The name of the effect. | ||
[Parameter(ValueFromPipelineByPropertyName)] | ||
[Alias('EffectName')] | ||
[string] | ||
$Name | ||
) | ||
|
||
begin { | ||
if (-not $script:OBSFX) { | ||
$script:OBSFX = [Ordered]@{} | ||
} | ||
} | ||
|
||
process { | ||
|
||
if (-not $Name) { | ||
$script:OBSFX.Values | ||
} elseif ($script:OBSFX[$name]) { | ||
$script:OBSFX[$name] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
function Import-OBSEffect | ||
{ | ||
<# | ||
.SYNOPSIS | ||
Imports Effects | ||
.DESCRIPTION | ||
Imports obs-powershell effects | ||
.EXAMPLE | ||
Import-OBSEffect -Path (Get-Module obs-powershell) | ||
.LINK | ||
Get-OBSEffect | ||
#> | ||
param( | ||
# The source location of the effect. | ||
# This can be a string, file, directory, command, or module. | ||
[vfp(vbn,Mandatory)] | ||
[Alias( | ||
'FromPath', | ||
'FromModule', | ||
'FromScript', | ||
'FromFunction', | ||
'FullName', | ||
'Path', | ||
'Source' | ||
)] | ||
[ValidateTypes(TypeName={ | ||
[string], | ||
[IO.FileInfo], | ||
[IO.DirectoryInfo] | ||
[Management.Automation.CommandInfo] | ||
[Management.Automation.PSModuleInfo] | ||
})] | ||
$From | ||
) | ||
|
||
begin { | ||
if (-not $script:OBSFX) { | ||
$script:OBSFX = [Ordered]@{} | ||
} | ||
|
||
$newEffects = @() | ||
$obsEffectsPattern = [Regex]::new(' | ||
(?> | ||
^OBS.(?>fx|effects?)\p{P} | ||
| | ||
[\p{P}-[-]]OBS\.(?>fx|effects?)$ | ||
| | ||
\p{P}OBS.(?>fx|effects?)\.(?>ps1|json)$ | ||
) | ||
','IgnoreCase,IgnorePatternWhitespace') | ||
} | ||
|
||
process { | ||
# Since -From can be many things, but a metric has to be a command, | ||
# the purpose of this function is to essentially resolve many things to a command, | ||
# and then cache that command. | ||
|
||
# If -From was a string | ||
if ($From -is [string]) { | ||
# It could be a module, so check those first. | ||
:ResolveFromString do { | ||
foreach ($loadedModule in @(Get-Module)) { | ||
# If we find the module, don't try to resolve -From as a path | ||
break ResolveFromString | ||
if ($loadedModule.Name -eq $from) { | ||
# (just set -From again and let the function continue) | ||
$from = $fromModule = $loadedModule | ||
} | ||
} | ||
# If we think from was a path | ||
$resolvedPath = $ExecutionContext.SessionState.Path.GetResolvedPSPathFromPSPath($from) | ||
# attempt to resolve it | ||
if ($resolvedPath) { | ||
$from = Get-Item -LiteralPath $resolvedPath | ||
} | ||
} while ($false) | ||
} | ||
|
||
# If -From is a module | ||
if ($from -is [Management.Automation.PSModuleInfo]) { | ||
# recursively call ourselves with all matching commands | ||
@($from.ExportedCommands.Values) -match $obsEffectsPattern | | ||
Import-OBSEffect | ||
# then, make -From a directory | ||
if ($from.Path) { | ||
$from = Get-Item ($from.Path | Split-Path) -ErrorAction SilentlyContinue | ||
} | ||
} | ||
|
||
# If -From is a directory | ||
if ($from -is [IO.DirectoryInfo]) { | ||
$FromDirectory = $from | ||
# recursively call ourselves with all matching scripts | ||
Get-ChildItem -LiteralPath $from.FullName -Recurse -File | | ||
Where-Object Name -match '\.obs\.(?>fx|effects?).(?>ps1|json)$' | | ||
Import-OBSEffect | ||
return | ||
} | ||
|
||
# If -From is a file | ||
if ($from -is [IO.FileInfo]) { | ||
# and it matches the naming convention | ||
return if $from.Name -notmatch '\.obs\.(?>fx|effects?).(?>ps1|json)$' | ||
# make -From a command. | ||
$from = $ExecutionContext.SessionState.InvokeCommand.GetCommand($from.FullName, 'ExternalScript,Application') | ||
} | ||
|
||
# If -From is a command | ||
if ($from -is [Management.Automation.CommandInfo]) { | ||
# decorate the command | ||
if ($from.pstypenames -notcontains 'OBS.PowerShell.Effect') { | ||
$from.pstypenames.insert(0,'OBS.PowerShell.Effect') | ||
} | ||
|
||
if ($from -is [Management.Automation.ApplicationInfo]) { | ||
$effectName = $from.Name -replace '\.obs\.(?>fx|effects?).(?>ps1|json)$' | ||
$newEffect = [PSCustomObject][Ordered]@{ | ||
PSTypeName = 'OBS.PowerShell.Effect' | ||
Messages = Get-Content -Raw -Path $From.Source | ConvertFrom-Json | ||
EffectName = $effectName | ||
TypeName = $TypeName | ||
} | ||
$script:OBSFX[$effectName] = $newEffect | ||
$newEffects += $newEffect | ||
$newEffect | ||
} else { | ||
if ($from.pstypenames -notcontains 'OBS.PowerShell.Effect.Command') { | ||
$from.pstypenames.insert(0,'OBS.PowerShell.Effect.Command') | ||
} | ||
# and add it to our list of new metrics | ||
$newEffects+= $from | ||
$script:OBSFX[$from.EffectName] = $from | ||
$from | ||
} | ||
} | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.