Giter Site home page Giter Site logo

twitch's Introduction

This is the repo for two twitch modules. Below is a quick overview. More documentation can be found by clicking on the module directories.

To see all of the commands available, install and run:

Get-Command -Module tvbot, tvclient

Installation instructions can be found at tvclient and tvbot.

tvclient

tvclient logo

tvclient is a PowerShell client for the twitch.tv API.

ย 

Basic usage

Set your variables

$splat = @{
    ClientId = "abcdefh01234567ijklmop"
    Token    = "01234567fghijklmnopqrs"
}

Set-TvConfig @splat

And run your commands

Get-TvSubscriber
Get-TvFollower -Since LastStream
Get-TvUser -UserName potatoqualitee

Read more at tvclient.

tvbot

tvbot logo

tvbot is a pi-friendly PowerShell bot for twitch.tv that works on the Windows, Linux, and mac OS.

ย 

Basic usage

Set your variables

$splat = @{
    BotClientId = "abcdefh01234567ijklmop"
    BotToken    = "01234567fghijklmnopqrs"
    BotChannel  = "potatoqualitee"
    BotOwner    = "potatoqualitee", "afriend"
}

Set-TvConfig @splat

And start your bot

Start-TvBot

Read more at tvbot.

twitch's People

Contributors

potatoqualitee avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

twitch's Issues

Make greeter

When subscriber talks for first time, say yay

sqlite chatter tracker?

Not sure if this is for numbers of names.

Could just be number of viewers/chatters. Total / Regulars.

Perhaps a 'hey, thanks for sticking around: (users present in chat since last check n-1 checks ago).... Happy to update this issue with what you were actually thinking

Just a thankyou

Hey Chrissie, just wanted to drop this message to say thank you for publishing this project, and module...saved my ass when I couldn't my own attempts at a bot to work. Great work

some code

Invoke-RestMethod -Uri "https://api.twitch.tv/kraken/user" -Headers @{
"Accept" = "application/vnd.twitchtv.v5+json"
"Client-ID" = "uo6dggojyb8d6soh92zknwmi5ej1q2"
"Authorization" = "OAuth $token"
} -Method Get

Connect to multiple channels

Is it possible to connect this bot to multiple channels?

The tmi.js library handles it in node, but I know very little about node as a language and would love to keep playing around in Powershell.

I tried adding the second channel to the BotChannel field but it seems to break everything. Love what you've created here though!

errors

VERBOSE: [01/05/2021 19:56:43] JOIN #pspibot
VERBOSE: [01/05/2021 19:56:43] Sleeping a moment to let the server catch up
Exception calling "Peek" with "0" argument(s): "Unable to read data from the transport connection: An established connection was aborted by the software in
your host machine."
At line:58 char:20
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : IOException

Exception calling "GetStream" with "0" argument(s): "The operation is not allowed on non-connected sockets."
At line:58 char:20
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : InvalidOperationException

Exception calling "GetStream" with "0" argument(s): "The operation is not allowed on non-connected sockets."
At line:58 char:20
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : InvalidOperationException

Exception calling "GetStream" with "0" argument(s): "The operation is not allowed on non-connected sockets."

tvclient - Project link for module is wrong

Seems the link used in the psd1 for the ProjectUri is not resolving to the folder in the project.

# The web address of this module's project or support homepage.
ProjectUri = "https://github.com/potatoqualitee/twitch/tvclient"

Instead of using trying to link to the folder which would require a URL like https://github.com/potatoqualitee/twitch/blob/main/tvclient you might link to the root project instead https://github.com/potatoqualitee/twitch (have seen other projects do this when they are storing the modules in the same repo).

maybe add extra sounds?

Add-Type -AssemblyName presentationCore
$mediaPlayer = New-Object system.windows.media.mediaplayer
$mediaPlayer.open('C:\sounds\bike.mp3')
$mediaPlayer.Play()

Polling

"every now and then list the users in the channel" and save to sqlite? join/part is far too unreliable

Code stash

function Set-TvConfig {
    <#
    .SYNOPSIS
        Connects to a Twitch

    .DESCRIPTION
        Connects to a Twitch

    .EXAMPLE
        PS C:\>

#>
    [CmdletBinding()]
    param
    (
        [Parameter(ValueFromPipelineByPropertyName)]
        [ValidateSet("ClientId","Token","BotClientId","BotToken")]
        [string]$Name,
        [Parameter(ValueFromPipelineByPropertyName)]
        [string]$Value
    )
    process {
        $config = Get-Content -Path $script:configfile | ConvertFrom-Json | ConvertTo-HashTable
        $config[$Name] = $Value

        $config | ConvertTo-Json | Set-Content -Path $script:configfile
    }
}

TvBot depends on functions from TvClient

Try to import TvBot before anything else; fails to find Get-TvConfigValue

Get-TvConfigValue: /home/marv/code/marv/twitch/tvbot/tvbot.psm1:29
Line |
  29 |  $dir = Split-Path -Path (Get-TvConfigValue -Name ConfigFile)
     |                           ~~~~~~~~~~~~~~~~~
     | The term 'Get-TvConfigValue' is not recognized as a name of a cmdlet, function, script file, or executable program. Check
     | the spelling of the name, or if a path was included, verify that the path is correct and try again.

Join-Path: /home/marv/code/marv/twitch/tvbot/tvbot.psm1:32
Line |
  32 |  $adminfile = Join-Path -Path $dir -ChildPath "admin-commands.json"
     |                               ~~~~
     | Cannot bind argument to parameter 'Path' because it is null.

Join-Path: /home/marv/code/marv/twitch/tvbot/tvbot.psm1:33
Line |
  33 |  $userfile = Join-Path -Path $dir -ChildPath "user-commands.json"
     |                              ~~~~
     | Cannot bind argument to parameter 'Path' because it is null.

Test-Path: /home/marv/code/marv/twitch/tvbot/tvbot.psm1:35
Line |
  35 |  if (-not (Test-Path -Path $adminfile)) {
     |            ~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Value cannot be null. (Parameter 'The provided Path argument was null or an empty collection.')

Set-Content: /home/marv/code/marv/twitch/tvbot/tvbot.psm1:38
Line |
  38 |      } | ConvertTo-Json | Set-Content -Path $adminfile -Encoding Unico โ€ฆ
     |                                             ~~~~~~~~~~
     | Cannot bind argument to parameter 'Path' because it is null.

Get-TvConfigValue: /home/marv/code/marv/twitch/tvbot/tvbot.psm1:41
Line |
  41 |  if (-not (Get-TvConfigValue -Name AdminCommandFile)) {
     |            ~~~~~~~~~~~~~~~~~
     | The term 'Get-TvConfigValue' is not recognized as a name of a cmdlet, function, script file, or executable program. Check
     | the spelling of the name, or if a path was included, verify that the path is correct and try again.

Not sure how you were planning to deal with this. I'm starting to test Linux support ;)

bad math

[12/27/2020 23:55:33] LIL LUL :| Some text
VERBOSE: EMOTE: 425618:4-6/555555563:8-9
VERBOSE: EMOTE ONLY: False
VERBOSE: 4-6/555555563 8-9
Cannot convert value "6/555555563" to type "System.Int32". Error: "Input string was not in a correct format."
At line:124 char:53

  • ... $remove = $message.Substring($first, $last - $first + 1)
  •              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidArgument: (:) [], RuntimeException
    • FullyQualifiedErrorId : InvalidCastFromStringToInteger

Reconnect

WARNING: PING :tmi.twitch.tv
VERBOSE: PONG
Cannot read stream: Exception calling "ReadLine" with "0" argument(s): "Unable to read data from the transport connection: An existing connection
was forcibly closed by the remote host."

PSMessageDetails :
Exception : System.Management.Automation.RuntimeException: Cannot read stream: Exception calling "ReadLine" with "0" argument(s): "Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host."
TargetObject : Cannot read stream: Exception calling "ReadLine" with "0" argument(s): "Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host."
CategoryInfo : OperationStopped: (Cannot read str...e remote host.":String) [], RuntimeException
FullyQualifiedErrorId : Cannot read stream: Exception calling "ReadLine" with "0" argument(s): "Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host."
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at Wait-TvResponse, : line 95
at Start-TvBot, : line 86
at , : line 1

close gracefully

maybe something along the lines of this

$null = $asyncwindow::ShowWindowAsync((Get-Process -PID $pid).MainWindowHandle, 0)

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.