Coder Social home page Coder Social logo

thedavecarroll / bluebirdps Goto Github PK

View Code? Open in Web Editor NEW
60.0 6.0 10.0 1.59 MB

A Twitter Automation Client for PowerShell 7

Home Page: https://docs.bluebirdps.dev

License: MIT License

PowerShell 63.13% C# 36.87%
twitter-api powershell-module powershell twitter twitter-client powershell-gallery twitterdm tweets tweet twitter-api-v1

bluebirdps's Introduction

Dave Carroll

I started my career almost 30 years ago at a small Mom-and-Pop computer store building and repairing home computer systems and peripherals. Since then, I've worked in the public and private sectors with 17 years in higher education. Currently, I am a DevOps engineer for a finance company and use PowerShell and Python daily.

I got into scripting early. First just DOS batch files, then VBScript. Around 2009, I learned my first bits of PowerShell converting my homegrown identity management system consisting of more than 10,000 lines of VBScript and interfacing with Active Directory, SunOne LDAP, Oracle DB, MySQL, and more. I enjoyed wowing coworkers (and myself) with the data I could collect and collate using just a few commands of PowerShell. It has allowed me to control the systems I manage and interface with various others.

I attempt to promote and evangelize PowerShell, helping new learners with the basics and participating in the online community as often as I can. The best places you can find me are on LinkedIn and in the PowerShell Forums.

I am much less active on Fediverse, but can be found on the Mastodon instance @fosstodon.org/@thedavecarroll.

Also, I have recently gotten into retrocomputing so you may see some content focused on that. The first computer I owned was a Commodore 64, but I would spend more time on my Apple //c that I received a couple years later. My first IBM compatible laptop had an impressive 640K RAM, which I configured part of as a RAM disk, and dual 1.44MB floppy drives.

My Contributions

PowerShell and Technical Blog

Since the middle of 2018, I have been blogging about PowerShell and a smattering of articles on other info tech and interesting topics. Here are the latest articles:

PowerShell Modules

I wrote and maintain the following PowerShell modules:

Name Repo PowerShellGallery Notes
BluebirdPS BluebirdPS PowerShell Gallery Version (including pre-releases) Getting Started Documentation - NO LONGER SUPPORTED
PoShEvents PoShEvents PowerShell Gallery Version (including pre-releases) PowerShell module to query Windows Event Logs and write events with structured EventData or UserData
PoShGroupPolicy PoShGroupPolicy PowerShell Gallery Version (including pre-releases) PowerShell module to assist with Group Policy
PoShDynDnsApi PoShDynDnsApi PowerShell module used to interact with Dyn Managed DNS REST API
PSTemperature PSTemperature Binary module written in C# with PowerShell 7 experimental feature. Converts temperature between Celsius, Fahrenheit, Kelvin, and Rankine.

Iron Scripter Challenge Solutions

I have participated in several Iron Scripter challenges since June 2019. My solutions can be found in my IronScripterSolutions repo.

Contributing Author

My Last Presentation

Date 4/27/2021
Event PowerShell + DevOps Global Summit 2021
Title Creating BluebirdPS: A Twitter Automation Client for PowerShell 7 (Video On Demand)
Abstract In this talk, we will examine the process used in creating BluebirdPS, a PowerShell 7 module for the Twitter REST API. Topics will include learning the API, authentication, module structure, response and error handling, and customizing the output.
Video Recording

GitHub Info

thedavecarroll's Github Stats

Support the DevOps Collective's OnRamp Scholarship

The DevOps Collective’s OnRamp scholarships help younger technology professionals, many from underrepresented groups and disadvantaged backgrounds, learn about IT automation, DevOps practices, and more - all at no cost to them or their families. We’re changing one life at a time and helping to ensure the continuation and advancement of our trade!

100% of the royalties from sales of these books go towards the DevOps Collective's OnRamp scholarship program.

PowerShell Conference Book
Vol 1
PowerShell Conference Book
Vol 2
PowerShell Conference Book
Vol 3
PS7Now
PowerShell Conference Book Volume 1 PowerShell Conference Book Volume 2 PowerShell Conference Book Volume 3 PS7Now

bluebirdps's People

Contributors

alagoutte avatar thedavecarroll avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

bluebirdps's Issues

Add Commands for v1.1 Endpoints

CommandName ApiEndpoint
Add-TwitterList POST lists/create
Add-TwitterListMember POST lists/members/create, POST lists/members/create_all
Add-TwitterListSubscription POST lists/subscribers/create
Get-TwitterListSubscription GET lists/subscriptions
Get-TwitterListMembership GET lists/memberships
Remove-TwitterList POST lists/destroy
Remove-TwitterListMember POST lists/members/destroy, POST lists/members/destroy_all
Remove-TwitterListSubscription POST lists/subscribers/destroy
Set-TwitterList POST lists/update
Set-TwitterMutedUser POST mutes/users/create, POST mutes/users/destroy
Submit-TwitterUserAsSpam POST users/report_spam

Create private functions as required

  • Get-ErrorCategory
  • Get-ExceptionType
  • Get-SendMediaStatus
  • Get-TwitterException
  • Invoke-TwitterVerifyCredentials
  • New-TwitterErrorRecord (updated)
  • New-ValidationErrorRecord
  • Set-BluebirdPSAuthUser
  • Set-TwitterMediaAltImageText (updated)
  • Write-TwitterResponse

Create functions to handle authentication

Create the following functions:

Set-TwitterAuthentication

  • securely reads input from user for 4 necessary keys and secrets
  • updates module scoped variable
  • option to persist - uses Export-TwitterAuthentication

Set-TwitterBearerToken

  • gets bearer token from Twitter with api key and secret
  • updates module scoped variable
  • option to persist - uses Export-TwitterAuthentication

Import-TwitterAuthentication

  • reads encrypted credential file
  • verifies file contains all required keys/attributes
  • if missing, corrupt, or incomplete, prompts user to use Set-TwitterAuthentication
  • called in root module as last item

Export-TwitterAuthentication

  • converts $OAuth module scoped variable to JSON
  • encrypts JSON using SecureString
  • saves encrypted string to $HOME\.TwitterPowerShell\twittercred.sav

Use PowerShell Parameter Validation instead of manual parameter validation

This is more of a discussion point. When going through the code for the Get-TwitterFollowers function I noticed this:

    if ([string]::IsNullOrWhiteSpace($ScreenName) -and [string]::IsNullOrWhiteSpace($UserId)) {
        'You must supply either a ScreenName or UserId.' | Write-Warning
        return
    } elseif ($ScreenName.Length -gt 0 -and $UserId.Length -gt 0) {
        'You must supply a ScreenName or a UserId, but not both.' | Write-Warning
        return
    }

    if ($PSCmdlet.ParameterSetName -eq 'List') {
        if ($ResultsPerPage -and $ResultsPerPage -notin 1..200) {
            'For a list of follower objects, you can only request up to 200 user objects per page.' | Write-Warning
            return
        } else {
            $ResultsPerPage = 50
        }
    } else {
        if ($ResultsPerPage -and $ResultsPerPage -notin 1..5000) {
            'For list of follower ids, you can only request up to 5000 user is per page.' | Write-Warning
            return
        } else {
            $ResultsPerPage = 5000
        }
    }

Was wondering why this isn't being checked in the param() block instead of manually? I always tell people to leverage PowerShell's parameter validation rather than writing your own so this stood out to me.

How Should Rate Limits Be Handled?

Virtually all API endpoints have a rate limit, after which you must wait through a reset period.

Currently, there is a module scoped variable, $RateLimitWarning, that is set to $false when the module is imported.

You can using Get-TwitterRateLimitWarning to see if this Enabled or Disabled and use Set-TwitterRateLimitWarning to update the value.

At the moment, this throws a warning like the following prior to reaching the limit.

WARNING: The rate limit for this resource is 15. There are 1 remaining calls to this resource until 10/11/2020 6:18:52 PM.

When the rate limit is reached, it will throw a terminating error like the following.

Invoke-TwitterCursorRequest: C:\Program Files\Powershell\7\Modules\Twitter\public\Get-TwitterFollowers.ps1:49
Line |
  49 |          Invoke-TwitterCursorRequest -OAuthParameters $OAuthParameters …
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Rate limit of 15 has been reached. Please wait until 10/11/2020 6:18:52 PM before making another attempt for this resource.

For cursored and paged requests, the limit could be reached before all items have been returned. The way I have constructed Invoke-TwitterCursorRequest, the returned data is handed to the end user after each call. (At least, it should be working this way.)

Invoke-TwitterPageRequest will collect all of the returned data until all pages has been processed or the rate limit for that endpoint is reached, then the entire collection will be returned to the end user.


Please vote with the following:

  • 👍 Use Write-Warning and fail softly
  • 👎 Use Write-Error and fail at the Invoke-Twitter*Request level, but not the function
  • ❌ Use PSCmdLet.ThrowTerminatingError($_)

Please discuss below.

Thank you.

Add an About help topic

At some point, it would be very helpful to include an about help topic for the module, especially given the required configurations. This can probably wait until your code base stabalizes.

Add C# Enums as required

To support the Twitter API v2, add an enum for each of the currently available field parameters for their expansion parameters.

  • TweetFields→ tweet.fields
  • UserFields→ user.fields
  • MediaFields→ media.fields
  • PollFields→ poll.fields
  • PlaceFields→ place.fields
  • MediaType
  • TweetIncludes
  • HttpMethod

Additionally, add static method to retrieve CSV list for a given enum.

Add Language and Configuration module variables

Currently, the module variables are the following.

  • $OAuthTokenSavePath
    • Used by Import-TwitterAuthentication and Export-TwitterAuthentication
  • $ApiEndpointsPath
    • Used by Get-TwitterApiEndpoint
  • $OAuth
    • Used by Import-TwitterAuthentication, Export-TwitterAuthentication, Set-TwitterAuthentication, Set-TwitterBearerToken, and Invoke-TwitterRequest. Eventually, it will be used by v2 API calls which will have their own Invoke private functions.
  • $TwitterErrorMapping
    • Used by New-TwitterErrorRecord
  • $RateLimitWarning
    • Used by Write-TwitterResponseData, Get-TwitterRateLimitWarning, and Set-TwitterRateLimitWarning.

Additional module variables should include the following.

Add ReturnValue parameter to Invoke-TwitterCursorRequest

Add a ReturnValue parameter to Invoke-TwitterCursorRequest.

This will allow for tidier code in the public functions.

Instead of wrapping the returned values in an array and returning the required property like this:

$TwitterFollowers = Invoke-TwitterCursorRequest -OAuthParameters $OAuthParameters
@($TwitterFollowers.ids)

or this:

@(Invoke-TwitterCursorRequest -OAuthParameters $OAuthParameters).ids

You can simple provide the property as the ReturnValue, like this:

Invoke-TwitterCursorRequest -OAuthParameters $OAuthParameters -ReturnValue ids

This is a typical return for ids and users from a cursored request.

ids                 : {…}
next_cursor         : 0
next_cursor_str     : 0
previous_cursor     : 0
previous_cursor_str : 0
total_count         :

users               : {@{}...}
next_cursor         : 0
next_cursor_str     : 0
previous_cursor     : 0
previous_cursor_str : 0
total_count         :

Calling 'Get-TwitterFollowers' results in exception

I have setup $OAuth hashtable with the correct keys (I verified they work by using the PSTwitterAPI module):

> $OAuth = @{ ApiKey = 'blah'; ApiSecret = 'blah'; AccessToken = 'blah; AccessTokenSecret = 'blah' }

When I call `Get-TwitterFollowers -Screenname 'pauby' -Verbose' I get this error:

> Get-TwitterFollowers -ScreenName 'pauby' -Verbose
SetValueInvocationException: C:\Users\Paul\git\pauby\others\powershellmodules_twitter\Twitter\classes\OAuthParameters.Class.psm1:202
Line |
 202 |          $this.UriBuilder = $this.BaseUri
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Exception setting "UriBuilder": "Cannot convert value "" to type "System.UriBuilder". Error: "Invalid
     | URI: The hostname could not be parsed.""

InvalidOperation: C:\Users\Paul\git\pauby\others\powershellmodules_twitter\Twitter\public\Get-TwitterFollowers.ps1:70
Line |
  70 |          $OAuthParameters.BaseUri = 'https://api.twitter.com/1.1/follo …
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | The property 'BaseUri' cannot be found on this object. Verify that the property exists and can be set.

InvalidOperation: C:\Users\Paul\git\pauby\others\powershellmodules_twitter\Twitter\public\Get-TwitterFollowers.ps1:73
Line |
  73 |      $OAuthParameters.SetQuery($Query)
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | You cannot call a method on a null-valued expression.

Invoke-TwitterCursorRequest: C:\Users\Paul\git\pauby\others\powershellmodules_twitter\Twitter\public\Get-TwitterFollowers.ps1:79
Line |
  79 |  … owers = Invoke-TwitterCursorRequest -OAuthParameters $OAuthParameters
     |                                                         ~~~~~~~~~~~~~~~~
     | Cannot bind argument to parameter 'OAuthParameters' because it is null

I've only had a cursory look over this at the moment so what I'm about to say may be nonsense 😄

This line sets the $BaseUri to $null?

Update $PSBoundParameters for Special Parameters

For all functions that use the New-TwitterQuery, ensure that $PSBoundParameters is updated, if necessary.

if ($UserId.Count -gt 100) {
    'More than 100 UserIds provided. Processing the first 100 only.'  | Write-Warning
    $PSBoundParameters['UserId'] = $PSBoundParameters['UserId'] | Select-Object -First 100
}
$Query = New-TwitterQuery -ApiParameters $PSBoundParameters

See Get-TwitterFriendship for an example.

Write script to update TwitterApiEndpoints.json

As the Twitter API is vast and contains dozens of endpoints, an attempt was made to collect all of the endpoints into a single JSON file in hopes that the user could find it useful.

The function Get-TwitterApiEndpoint reads <moduleroot>resources\TwitterApiEndpoints.json.

This JSON should be updated to include all of the current endpoints supported by the module, and updated as new commands/endpoints are added.

A script should be written to generate the JSON instead of manual generation.

This documentation could come from the commands and their documentation, such as LINK.

Errors on Import-Module

I installed the module from the PowerShell Gallery:

install-module bluebirdps -scope allusers

But get a number of errors on importing the module.

image

On my Windows 10 box I don't have a value for $env:HOME.

Add function to generate queries

Create New-TwitterQuery that uses $PSBoundParameters of calling function to build new query.

Update functions to use the new function.

This will reduce the amount of duplicated code throughout the module.

Add C# Classes for Output and Processing

Create classes for the following objects:

Namespace BluebirdPS

  • TwitterObject
    • primary class that is inherited by API v1.1 and v2.0 objects
    • used to store and access original object from API
  • Helpers
    • any helper classes
  • OAuthParameters
    • replacement for current PowerShell custom class
  • ResponseData
    • used for storing history and sending information stream

Namespace BluebirdPS.APIV1

  • List : TwitterObject
  • Media : TwitterObject
  • SavedSearch : TwitterObject
  • AccountSettings : TwitterObject
  • DirectMessage : TwitterObject

Namespace BluebirdPS.APIV2

  • UpdateFriendship
    • to show the simple status of adding or removing a friend.

Namespace BluebirdPS.APIV2.Media

  • Media : TwitterObject

Namespace BluebirdPS.APIV2.Media.Metrics

  • Public
  • NonPublic
  • Organic
  • Promoted

Namespace BluebirdPS.APIV2.Objects

  • BaseEntity
  • Annotation : BaseEntity
  • CashTag : BaseEntity
  • HashTag : BaseEntity
  • Mention : BaseEntity
  • UrlTag : BaseEntity
  • Image
  • WithheldContent
  • Poll
  • PollOptions
  • Place

Namespace BluebirdPS.APIV2.TwitterTweet

  • Tweet : TwitterObject
  • ReferencedTweet
  • Attachments

Namespace BluebirdPS.APIV2.TwitterTweet.Metrics

  • Public
  • NonPublic
  • Organic
  • Promoted

Namespace BluebirdPS.APIV2.TwitterTweet.Context

  • ContextAnnotation
  • Domain
  • Entity

Namespace BluebirdPS.APIV2.TwitterUser

  • User : TwitterObject

Namespace BluebirdPS.APIV2.TwitterUser.Metrics

  • Public

Add Commands for API v2 Endpoints

Add command for the Twitter API v2 endpoints.

CommandName ApiEndpoint
Add-TwitterFriend POST /2/users/:id/following
Get-Tweet GET /2/tweets/:id, GET /2/tweets, GET /2/tweets/search/recent
Get-TweetLikes GET /2/tweets/:id/liking_users
Get-TwitterBlockedUser GET /2/users/:id/blocking
Get-TwitterFollowers GET /2/users/:id/followers
Get-TwitterFriends GET /2/users/:id/following
Get-TwitterTimeline GET /2/users/:id/tweets, GET /2/users/:id/mentions
Get-TwitterUser GET /2/users/by, GET /2/users/by/username/:username, GET /2/users, GET /2/users/:id
Remove-TwitterFriend DELETE /2/users/:source_user_id/following/:target_user_id
Search-Tweet GET /2/tweets/search/recent
Set-TweetLike POST /2/users/:id/likes, DELETE /2/users/:id/likes/:tweet_id
Set-TweetReply PUT /2/tweets/:id/hidden
Set-TwitterBlockedUser POST /2/users/:id/blocking, DELETE /2/users/:source_user_id/blocking/:target_user_id

Build script does not work on MacOS or Raspbian

The expanded build scripts do not run correctly on MacOS or Raspbian.

Update build/requirements.psd1

    'PowerShellBuild' = @{
        RequiredVersion = '0.5.0-beta1'
        AllowPrerelease = $true
    }

Update psakeBuild.ps1

  • Remove $PSBPreference.Build.OutDir and use default OutDir
  • Remove duplicate $PSBPreference.Build.CopyDirectories

Create function to verify Twitter credentials

Create Test-TwitterAuthentication to verify Twitter credentials using the endpoint account/verify_credentials.json.

Use this new function in Set-TwitterAuthentication prior to exporting the credentials.

Remove Endpoints JSON

Command to API endpoint is now handled by parsing the command's help.

Use the command Get-TwitterApiEndpoint to show the commands and their endpoints.

New-TwitterSearchString - Create new function

Twitter Search Strings can be somewhat difficult, especially for newcomers to the module.

Create a New-TwitterSearchString that will assist the user in creating a valid search string that can be pipelined into Search-Tweet.

New-TwitterSearchString -From thedavecarroll -ExactPhrase 'homemade pizza' -Any 'these words' -NotAny 'bad malign' | Search-Tweet -ResultType Popular

[BUG] Get-TwitterDM is not allowed

Describe the bug
Running Get-TwitterDM produces an exception:

Line |
1063 |          Invoke-TwitterCursorRequest -OAuthParameters $OAuthParameters|          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | This application is not allowed to access or delete your direct messages.get-t

To Reproduce
Install module v0.1.1
Configure with secrets and export resources
Run Get-TwitterDM
I get the same error if I try to use Count.

Expected behavior
I should get 30 most DMs per the help.

PowerShell Environment (please complete the following information):

  • OS: Microsoft Windows 10.0.19042
  • Edition Core
  • Version 7.1.0

Additional context

Exception             : 
    Type       : Microsoft.PowerShell.Commands.HttpResponseException
    Response   : StatusCode: 403, ReasonPhrase: 'Forbidden', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
                 {
                 Cache-Control: no-store, must-revalidate, no-cache, pre-check=0, post-check=0
                 Date: Tue, 24 Nov 2020 14:31:13 GMT
                 Pragma: no-cache
                 Server: tsa_b
                 Set-Cookie: personalization_id="v1_I75MF2AboHJIvuDKAS0UHg=="; Max-Age=63072000; Expires=Thu, 24 Nov 2022 14:31:13 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None
                 Set-Cookie: lang=en; Path=/
                 Set-Cookie: guest_id=v1%3A160622827308660937; Max-Age=63072000; Expires=Thu, 24 Nov 2022 14:31:13 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None
                 status: 403 Forbidden
                 Strict-Transport-Security: max-age=631138519
                 x-connection-hash: 3444663e8eaa0856782c4517920a5764
                 X-Content-Type-Options: nosniff
                 X-Frame-Options: SAMEORIGIN
                 x-rate-limit-limit: 15
                 x-rate-limit-remaining: 13
                 x-rate-limit-reset: 1606229146
                 x-response-time: 17
                 x-transaction: 00fbefa400b9179c
                 x-twitter-response-tags: BouncerCompliant
                 X-XSS-Protection: 0
                 Content-Disposition: attachment; filename=json.json
                 Content-Length: 110
                 Content-Type: application/json; charset=utf-8
                 Expires: Tue, 31 Mar 1981 05:00:00 GMT
                 Last-Modified: Tue, 24 Nov 2020 14:31:13 GMT
                 }
    TargetSite : 
        Name          : ThrowTerminatingError
        DeclaringType : System.Management.Automation.MshCommandRuntime, System.Management.Automation, Version=7.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
        MemberType    : Method
        Module        : System.Management.Automation.dll
    StackTrace : 
   at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)
    Message    : This application is not allowed to access or delete your direct messages.
    Source     : System.Management.Automation
    HResult    : -2146233088
TargetObject          : https://api.twitter.com/1.1/direct_messages/events/list.json
CategoryInfo          : PermissionDenied: (https://api.twitter…es/events/list.json:String) [Invoke-TwitterCursorRequest], HttpResponseException
FullyQualifiedErrorId : Get-TwitterDM,Invoke-TwitterCursorRequest
InvocationInfo        : 
    MyCommand        : Invoke-TwitterCursorRequest
    ScriptLineNumber : 1063
    OffsetInLine     : 9
    HistoryId        : 257
    ScriptName       : C:\Users\Jeff\Documents\PowerShell\Modules\bluebirdps\0.1.1\BluebirdPS.psm1
    Line             : Invoke-TwitterCursorRequest -OAuthParameters $OAuthParameters -ReturnValue events
                       
    PositionMessage  : At C:\Users\Jeff\Documents\PowerShell\Modules\bluebirdps\0.1.1\BluebirdPS.psm1:1063 char:9
                       +         Invoke-TwitterCursorRequest -OAuthParameters $OAuthParameters …
                       +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    PSScriptRoot     : C:\Users\Jeff\Documents\PowerShell\Modules\bluebirdps\0.1.1
    PSCommandPath    : C:\Users\Jeff\Documents\PowerShell\Modules\bluebirdps\0.1.1\BluebirdPS.psm1
    InvocationName   : Invoke-TwitterCursorRequest
    CommandOrigin    : Internal
ScriptStackTrace      : at Invoke-TwitterCursorRequest, C:\Users\Jeff\Documents\PowerShell\Modules\bluebirdps\0.1.1\BluebirdPS.psm1: line 418
                        at Get-TwitterDM, C:\Users\Jeff\Documents\PowerShell\Modules\bluebirdps\0.1.1\BluebirdPS.psm1: line 1063
                        at <ScriptBlock>, <No file>: line 1

[New Feature] All commands using parameter sets needs default parameter set in cmdletbinding

Is your feature request related to a problem? Please describe.
Get-TwitterUser has 2 parameter sets. You should define a default.

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
I would make the Screenname the default and positional. A user is most likely to run:

Get-TwitterUser jeffhicks

Additional context
Add any other context or screenshots about the feature request here.

Suppress Duplicate ChangeLog Entries

The command Get-ChangeLogUpdate in \build\BuildFunctions.psm1 can include duplicate entries in the output if there are multiple commits for the same issue. Suppress them.

Create Get-TwitterDM

Create function Get-TwitterDM to use the following endpoints:

  • direct_messages/events/show.json
  • direct_messages/events/list.json

The list endpoint will use Invoke-TwitterCursorRequest which will require special handling since this endpoint does not implement cursoring as other endpoints do.

Move docs site to new domain

Move the docs site from bluebirdps.anovelidea.org to docs.bluebirdps.dev.

The work has been done on readthedocs.org.

Unfortunately, I did not use versioning for the external help url and when the docs are updated, any previous version would go to the latest version. This will break previous version online documentation where the command names are different, and the help will not be accurate.

This will be used to tack all of the documentation updates.

Convert-TweetDate

I'm sure you'll eventually have the commands write clean, structured objects to the pipeline. I'm using some adhoc tooling for the time being. Here's a function you can use that should convert the created_at datetime string, into a [datetime] object.

# Convert a value like "Tue Nov 24 15:15:19 +0000 2020" to Tuesday, November 24, 2020 10:15:19 AM which is local time
Function Convert-TweetDate {
    [cmdletbinding()]
    [outputtype([System.DateTime])]
    Param(
        [Parameter(Mandatory,Position=0,ValueFromPipelineByPropertyName)]
        [alias("Created_At")]
        [string]$Timestamp
    )
    Begin {}
    Process {
        Write-Verbose "Converting $timestamp"
        $dt = $timestamp.split()
        $dtstr  = "{0} {1} {2} {3} {4}" -f $dt[2],$dt[1],$dt[5],$dt[3],$dt[4]
        [datetime]::Parse($dtstr).toLocalTime()
    }
    end {}
}

I can then use it in a script like this:

#requires -version 7.1
#requires -module BluebirdPS

#get my recent Twitter mentions

. C:\scripts\Convert-TweetDate.ps1

Search-Tweet to:JeffHicks | Select-Object @{Name="Date";Expression={Convert-TweetDate $_.created_at}},
@{Name="Tweet";Expression={$_.text -replace "@JeffHicks",""}},@{name="from";Expression={$_.user.name}}

I'm assuming command output will eventually write properly formatted and typed data to the pipeline.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.