Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancements #51

Merged
merged 3 commits into from
Jun 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.2.2]

- Fixed ```Send-TelegramPoll``` bug where Quiz mode answer could not specify first option correctly.
- Minor spelling corrections throughout
- Build/dev improvements
- Changed Pester configuration from static property to ```New-PesterConfiguration```
- Updated VSCode tasks to no longer use legacy Pester parameters
- Bumped module versions to latest available

## [2.2.0]

- Added Protected Content parameter:
Expand Down
2 changes: 1 addition & 1 deletion .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ available at [https://www.contributor-covenant.org/version/1/4/code-of-conduct.h

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see [https://www.contributor-covenant.org/faq](https://www.contributor-covenant.org/faq)
For answers to common questions about this code of conduct, see [https://www.contributor-covenant.org/faq](https://www.contributor-covenant.org/faq)
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ This project has a [Code of Conduct](CODE_OF_CONDUCT.md).

## Licensing

See the [LICENSE](LICENSE.txt) file for our project's licensing.
See the [LICENSE](LICENSE.txt) file for our project's licensing.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ assignees: ''
### Steps to Reproduce
<!--- Provide a link to a live example, or an unambiguous set of steps to -->
<!--- reproduce this bug. Include code to reproduce, if relevant -->

1.
2.
3.
Expand Down
29 changes: 29 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,51 @@
"files.trimTrailingWhitespace": true,
"powershell.codeFormatting.preset": "Stroustrup",
"cSpell.words": [
"Allman",
"backoff",
"botname",
"buildspec",
"Catesta",
"channelusername",
"cmdlets",
"customlog",
"datetime",
"diagvresults",
"geordi",
"getbytes",
"getidsbot",
"Gifs",
"hashtable",
"jakemorrison",
"Janeway",
"markdownv",
"Mycommand",
"Nausicaan",
"notmatch",
"OTBS",
"photourl",
"poshgram",
"psobject",
"pwsh",
"riker",
"shortcode",
"shortlink",
"shortlinks",
"slotmachine",
"Starfleet",
"strikethrough",
"Stroustrup",
"Syndec",
"telegramx",
"Tobu",
"troi",
"videourl",
"webp",
"wontfix",
"worf"
],
"cSpell.enableFiletypes": [
"markdown",
"powershell"
]
}
4 changes: 2 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
{
"label": "Pester-Single-Coverage",
"type": "shell",
"command": "Import-Module -Name '${workspaceFolder}/src/PoshGram/PoshGram.psm1';Invoke-Pester '${workspaceFolder}/src/Tests/Unit/${input:functionName}.Tests.ps1' -CodeCoverage '${workspaceFolder}/src/PoshGram/*/${input:functionName}.ps1'",
"command": "Import-Module -Name '${workspaceFolder}/src/PoshGram/PoshGram.psm1';$pesterConfiguration = New-PesterConfiguration;$pesterConfiguration.Run.Path = '${workspaceFolder}/src/Tests/Unit/${input:functionName}.Tests.ps1';$pesterConfiguration.CodeCoverage.Enabled = $true;$pesterConfiguration.CodeCoverage.Path = '${workspaceFolder}/src/PoshGram/*/${input:functionName}.ps1';Invoke-Pester -Configuration $pesterConfiguration",
"problemMatcher": "$pester",
"presentation": {
"echo": false,
Expand All @@ -236,7 +236,7 @@
{
"label": "DevCC-Single",
"type": "shell",
"command": "Import-Module -Name '${workspaceFolder}/src/PoshGram/PoshGram.psm1';Invoke-Pester '${workspaceFolder}/src/Tests/Unit/${input:functionName}.Tests.ps1' -CodeCoverage '${workspaceFolder}/src/PoshGram/*/${input:functionName}.ps1' -CodeCoverageOutputFile '${workspaceFolder}/cov.xml'",
"command": "Import-Module -Name '${workspaceFolder}/src/PoshGram/PoshGram.psm1'; $pesterConfiguration = New-PesterConfiguration;$pesterConfiguration.Run.Path = '${workspaceFolder}/src/Tests/Unit/${input:functionName}.Tests.ps1';$pesterConfiguration.CodeCoverage.Enabled = $true;$pesterConfiguration.CodeCoverage.Path = '${workspaceFolder}/src/PoshGram/*/${input:functionName}.ps1';$pesterConfiguration.CodeCoverage.OutputPath = '${workspaceFolder}/cov.xml';Invoke-Pester -Configuration $pesterConfiguration",
"problemMatcher": "$pester",
"presentation": {
"echo": false,
Expand Down
6 changes: 3 additions & 3 deletions actions_bootstrap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ $modulesToInstall = [System.Collections.ArrayList]::new()
# https://github.com/pester/Pester
$null = $modulesToInstall.Add(([PSCustomObject]@{
ModuleName = 'Pester'
ModuleVersion = '5.3.1'
ModuleVersion = '5.3.3'
}))
# https://github.com/nightroman/Invoke-Build
$null = $modulesToInstall.Add(([PSCustomObject]@{
ModuleName = 'InvokeBuild'
ModuleVersion = '5.9.7'
ModuleVersion = '5.9.10'
}))
# https://github.com/PowerShell/PSScriptAnalyzer
$null = $modulesToInstall.Add(([PSCustomObject]@{
Expand Down Expand Up @@ -56,4 +56,4 @@ foreach ($module in $modulesToInstall) {
" - $message"
throw $message
}
}
}
2 changes: 1 addition & 1 deletion docs/PoshGram-Sticker-Info.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ You also provide the emoji shortcode of the emoji you are trying to convey.
* Some sticker authors have the same emoji linked to multiple stickers
* This method will make a best attempt to look up the sticker pack you specify and send a sticker that matches the corresponding emoji shortcode.

If you don't want to have a *best attempt* scenario, use ***Get-TelegramStickerPackInfo*** to determine the exact file_id's from the sticker pack you'd like to send.
If you don't want to have a *best attempt* scenario, use ***Get-TelegramStickerPackInfo*** to determine the exact file_id's from the sticker pack you'd like to send.
4 changes: 2 additions & 2 deletions docs/PoshGram.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
Module Name: PoshGram
Module Guid: 277b92bc-0ea9-4659-8f6c-ed5a1dfdfda2
Download Help Link: NA
Help Version: 2.2.0
Help Version: 2.2.2
Locale: en-US
---

# PoshGram Module
## Description
PoshGram provides functionality to send various message types to a specified Telegram chat via the Telegram Bot API. Seperate PowerShell functions are used for each message type. Checks are included to ensure that file extensions, and file size restrictions are adhered to based on Telegram requirements.
PoshGram provides functionality to send various message types to a specified Telegram chat via the Telegram Bot API. Separate PowerShell functions are used for each message type. Checks are included to ensure that file extensions, and file size restrictions are adhered to based on Telegram requirements.

## PoshGram Cmdlets
### [Get-TelegramStickerPackInfo](Get-TelegramStickerPackInfo.md)
Expand Down
4 changes: 4 additions & 0 deletions docs/Send-TelegramPoll.md
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,10 @@ Use the BotFather https://t.me/BotFather
Telegram currently supports questions 1-300 characters
Telegram currently supports 2-10 options 1-100 characters each

Quiz answers are 0-based.
If the first answer is correct, the answer is 0.
If the second answer is correct, the answer is 1, etc.

## RELATED LINKS

[https://github.com/techthoughts2/PoshGram/blob/main/docs/Send-TelegramPoll.md](https://github.com/techthoughts2/PoshGram/blob/main/docs/Send-TelegramPoll.md)
Expand Down
10 changes: 5 additions & 5 deletions install_modules.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
need to specify each module and version that is required for installation. You also need to specify
which version of that module should be installed. Additionally, you will need to specify the S3 bucket
location where that module currently resides, so that it can be downloaded and installed into the build
container at runtime. This neccessitates that you download and upload your required modules to S3 prior to
container at runtime. This necessitates that you download and upload your required modules to S3 prior to
the build being executed.
.EXAMPLE
Save-Module -Name Pester -RequiredVersion 4.4.5 -Path C:\RequiredModules
Expand All @@ -30,13 +30,13 @@ $galleryDownload = $false # set to false to download from S3
$modulesToInstall = [System.Collections.ArrayList]::new()
$null = $modulesToInstall.Add(([PSCustomObject]@{
ModuleName = 'Pester'
ModuleVersion = '5.3.1'
ModuleVersion = '5.3.3'
BucketName = 'ps-invoke-modules'
KeyPrefix = ''
}))
$null = $modulesToInstall.Add(([PSCustomObject]@{
ModuleName = 'InvokeBuild'
ModuleVersion = '5.9.7'
ModuleVersion = '5.9.10'
BucketName = 'ps-invoke-modules'
KeyPrefix = ''
}))
Expand All @@ -54,13 +54,13 @@ $null = $modulesToInstall.Add(([PSCustomObject]@{
}))
$null = $modulesToInstall.Add(([PSCustomObject]@{
ModuleName = 'AWS.Tools.Common'
ModuleVersion = '4.1.30.0'
ModuleVersion = '4.1.98'
BucketName = 'ps-invoke-modules'
KeyPrefix = ''
}))
$null = $modulesToInstall.Add(([PSCustomObject]@{
ModuleName = 'AWS.Tools.SecretsManager'
ModuleVersion = '4.1.30.0'
ModuleVersion = '4.1.98'
BucketName = 'ps-invoke-modules'
KeyPrefix = ''
}))
Expand Down
2 changes: 1 addition & 1 deletion src/PSScriptAnalyzerSettings.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
IncludeDefaultRules = $true
#________________________________________
#Severity
#Specify Severity when you want to limit generated diagnostic records to a sepecific subset: [ Error | Warning | Information ]
#Specify Severity when you want to limit generated diagnostic records to a specific subset: [ Error | Warning | Information ]
Severity = @('Error', 'Warning')
#________________________________________
#CustomRulePath
Expand Down
6 changes: 3 additions & 3 deletions src/PoshGram.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ Add-BuildTask Test {
}
if (Test-Path -Path $script:UnitTestsPath) {

$pesterConfiguration = [PesterConfiguration]::new()
$pesterConfiguration = New-PesterConfiguration
$pesterConfiguration.run.Path = $script:UnitTestsPath
$pesterConfiguration.Run.PassThru = $true
$pesterConfiguration.Run.Exit = $false
Expand Down Expand Up @@ -323,7 +323,7 @@ Add-BuildTask DevCC {
Remove-Module -Name Pester -Force -ErrorAction SilentlyContinue # there are instances where some containers have Pester already in the session
Import-Module -Name Pester -MinimumVersion $script:MinPesterVersion -MaximumVersion $script:MaxPesterVersion -ErrorAction 'Stop'

$pesterConfiguration = [PesterConfiguration]::new()
$pesterConfiguration = New-PesterConfiguration
$pesterConfiguration.run.Path = $script:UnitTestsPath
$pesterConfiguration.CodeCoverage.Enabled = $true
$pesterConfiguration.CodeCoverage.Path = "$PSScriptRoot\$ModuleName\*\*.ps1"
Expand Down Expand Up @@ -515,7 +515,7 @@ Add-BuildTask InfraTest {
Write-Build White " Performing Pester Infrastructure Tests in $($invokePesterParams.path)"


$pesterConfiguration = [PesterConfiguration]::new()
$pesterConfiguration = New-PesterConfiguration
$pesterConfiguration.run.Path = $script:InfraTestsPath
$pesterConfiguration.Run.PassThru = $true
$pesterConfiguration.Run.Exit = $false
Expand Down
6 changes: 3 additions & 3 deletions src/PoshGram/PoshGram.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'PoshGram.psm1'

# Version number of this module.
ModuleVersion = '2.2.0'
ModuleVersion = '2.2.2'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand All @@ -30,7 +30,7 @@
Copyright = '(c) Jake Morrison. All rights reserved.'

# Description of the functionality provided by this module
Description = 'PoshGram provides functionality to send various message types to a specified Telegram chat via the Telegram Bot API. Seperate PowerShell functions are used for each message type. Checks are included to ensure that file extensions, and file size restrictions are adhered to based on Telegram requirements.'
Description = 'PoshGram provides functionality to send various message types to a specified Telegram chat via the Telegram Bot API. Separate PowerShell functions are used for each message type. Checks are included to ensure that file extensions, and file size restrictions are adhered to based on Telegram requirements.'

# Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '6.1.0'
Expand Down Expand Up @@ -184,4 +184,4 @@
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''

}
}
2 changes: 1 addition & 1 deletion src/PoshGram/Private/Confirm-URL.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function Confirm-URL {
Write-Verbose -Message 'Confirmed.'
} #try_Invoke-WebRequest
catch {
Write-Verbose -Message 'Catch on Invoke-WebRequest. This is not neccessarily a bad thing. Checking status code.'
Write-Verbose -Message 'Catch on Invoke-WebRequest. This is not necessarily a bad thing. Checking status code.'
if ([int]$_.Exception.Response.StatusCode -eq 0) {
Write-Warning -Message "$Uri"
Write-Warning -Message 'The URL provided does not appear to be valid'
Expand Down
2 changes: 1 addition & 1 deletion src/PoshGram/Public/Send-TelegramMediaGroup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ function Send-TelegramMediaGroup {
throw 'Telegram media group requirements not met'
}

Write-Verbose -Message 'Forming serialzied JSON for all media files...'
Write-Verbose -Message 'Forming serialized JSON for all media files...'
$form = @{
chat_id = $ChatID;
disable_notification = $DisableNotification.IsPresent
Expand Down
7 changes: 5 additions & 2 deletions src/PoshGram/Public/Send-TelegramPoll.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@

Telegram currently supports questions 1-300 characters
Telegram currently supports 2-10 options 1-100 characters each

Quiz answers are 0-based. If the first answer is correct, the answer is 0. If the second answer is correct, the answer is 1, etc.
.COMPONENT
PoshGram - https://github.com/techthoughts2/PoshGram
.FUNCTIONALITY
Expand Down Expand Up @@ -275,8 +277,9 @@ function Send-TelegramPoll {

if ($PollType -eq 'quiz') {
Write-Verbose -Message 'Processing quiz...'
if ($null -eq $QuizAnswer -or $QuizAnswer -lt 1 -or $QuizAnswer -gt 10) {
throw 'When PollType is quiz, you must supply a QuizAnswer desginator.'
Write-Verbose -Message ('Quiz answer: {0}' -f $QuizAnswer)
if (-not ($QuizAnswer -ge 0 -and $QuizAnswer -le 9)) {
throw 'When PollType is quiz, you must supply a QuizAnswer designator between 0-9.'
}
else {
$Form += @{correct_option_id = $QuizAnswer }
Expand Down
4 changes: 2 additions & 2 deletions src/Tests/Unit/ExportedFunctions.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Describe -Name $ModuleName -Fixture {
Context -Name 'Exported Commands' -Fixture {

Context -Name 'Number of commands' -Fixture {
It -Name 'Exports the same number of public funtions as what is listed in the Module Manifest' -Test {
It -Name 'Exports the same number of public functions as what is listed in the Module Manifest' -Test {
$manifestExported.Count | Should -BeExactly $moduleExported.Count
}
}
Expand Down Expand Up @@ -56,4 +56,4 @@ Describe -Name $ModuleName -Fixture {
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ InModuleScope PoshGram {
{ Send-TelegramLocalAnimation @sendTelegramLocalAnimationSplat } | Should -Throw
} #it

It 'should throw if it cannot successfuly get the file' {
It 'should throw if it cannot successfully get the file' {
Mock Get-Item {
throw 'Fake Error'
} #endMock
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/Unit/Public/Send-TelegramLocalAudio.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ InModuleScope PoshGram {
{ Send-TelegramLocalAudio @sendTelegramLocalAudioSplat } | Should -Throw
} #it

It 'should throw if it cannot successfuly get the file' {
It 'should throw if it cannot successfully get the file' {
Mock Get-Item {
throw 'Fake Error'
} #endMock
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/Unit/Public/Send-TelegramLocalDocument.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ InModuleScope PoshGram {
{ Send-TelegramLocalDocument @sendTelegramLocalDocumentSplat } | Should -Throw
} #it

It 'should throw if it cannot successfuly get the file' {
It 'should throw if it cannot successfully get the file' {
Mock Get-Item {
throw 'Fake Error'
} #endMock
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/Unit/Public/Send-TelegramLocalPhoto.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ InModuleScope PoshGram {
{ Send-TelegramLocalPhoto @sendTelegramLocalPhotoSplat } | Should -Throw
} #it

It 'should throw if it cannot successfuly get the file' {
It 'should throw if it cannot successfully get the file' {
Mock Get-Item {
throw 'Fake Error'
} #endMock
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/Unit/Public/Send-TelegramLocalSticker.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ InModuleScope PoshGram {
{ Send-TelegramLocalSticker @sendTelegramLocalStickerSplat } | Should -Throw
} #it

It 'should throw if it cannot successfuly get the file' {
It 'should throw if it cannot successfully get the file' {
Mock Get-Item {
throw 'Fake Error'
} #endMock
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/Unit/Public/Send-TelegramLocalVideo.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ InModuleScope PoshGram {
{ Send-TelegramLocalVideo @sendTelegramLocalVideoSplat } | Should -Throw
} #it

It 'should throw if it cannot successfuly get the file' {
It 'should throw if it cannot successfully get the file' {
Mock Get-Item {
throw 'Fake Error'
} #endMock
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/Unit/Public/Send-TelegramMediaGroup.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ InModuleScope PoshGram {
{ Send-TelegramMediaGroup @sendTelegramMediaGroupSplat } | Should -Throw
} #it

It 'should throw if it cannot successfuly get the file' {
It 'should throw if it cannot successfully get the file' {
Mock Get-Item {
throw 'Fake Error'
} #endMock
Expand Down
Loading