Giter VIP home page Giter VIP logo

obs-chatbot's Introduction

OBS Chat Bot

Stream via Open Broadcaster Software (OBS)?

Want to allow chat to ruin your stream or speed-run with memes, scene changes, and other integrations? Or, simply want to automate sequences of OBS, Twitch, and more actions at the press of a button in your stream deck?

You're in the right place! Connect Twitch Chat, OBS, your stream deck (and more) in one place!

(TODO: Add illustrations and/or pictures)

UNDER DEVELOPMENT

You can read the draft documentation in the wiki here, and can watch progress in the issues (I create issues to track my work).

If you are interested in early alpha/beta testing or want to contribute, please contact me and I can guide you (some Postman is required at this time).

Suggestions and feedback are welcome, especially in regards to what actions you want to see in the first release (planned are ObsSceneItemVisibility, SendMessage, and Wait at minimum).

You can contact me via contact (at) tinatiel.com, or via my profile here on GitHub.

obs-chatbot's People

Contributors

tinatiel avatar

Stargazers

Cecil Ureña avatar Jeffrey Schütt avatar  avatar

Watchers

James Cloos avatar  avatar

obs-chatbot's Issues

Wait action

An action that will wait a specified duration of time. Since seconds will matter then this should use something besides Thread.sleep.

RunnableAction and RunnableActionFactory

Instead of having (mutable) actions that may/may-not need to ever run (e.g., JPA entities combined with logic), we should separate it out so that we have a container instead.

Action:

  • has data on what it is (clientType, and other data; e.g. a SceneItemVisibilityAction has OBS client type, and has data on scene name, scene-item name, and that it should be shown (instead of hidden)
  • can be mutated / persisted to Hibernate etc. / is JPA entity

RunnableAction:

  • has a copy of the data in the action, except for clientType; instead of client type, has the actual instance of the Client it needs
  • has a copy of the CommandRequestContext; e.g. data about who is executing, arguments, etc.
  • is runnable; implements how it should use the client
  • Immutable; will be executed, must be thread-safe

We could then create a Factory that takes a (mutable) Action and CommandRequestContext and creates a runnable version for the specific request context.

  • It would create an immutable clone of the Action (as the Action provided may likely be mutable considering it will come from Hibernate / be JPA compliant)
  • It would have a dependency on ActionClientFactory so it can find the right client to inject given the Action's type.

ChatMessage parser

Chat message parser will take a given string and return a parse result containing a command name and list of args.

The parser can be configured to only parse the first char, or the entire message.

Feature: Automated Scene-Item creation/destruction

WHAT IF
Viewers could submit a command, and for each command OBS would show a scene or scene-item in response unique to each request?

E.g., maybe we have a "clap" command. Each viewer would send the !clap command and a gif (or realistically, a reference to an existing scene with sounds, maybe a text source, etc.) would be rendered at a random position and rotation on the current scene? And then after a specified amount of time, that resource would be cleaned up / deleted from the current scene?

Some caveats might be to specify a limit on how many objects to render (with a reasonable default), so the stream quality doesn't degrade due to too many things running at once.

This would be super neat!

Executor / Command Dispatcher Interface

Interface should allow for:

  • submitting requests
  • pausing
  • resuming

Implementation can accept any ExecutorService, but preferably a bounded ThreadPool with a high number of threads since the operations are I/O (not CPU) intensive.

Number of threads should be configurable by the streamer; they may choose to use a default but may lower or raise it depending on the performance of their PC (which would also be running OBS and whatever game they're streaming)

Command equality

Need to be able to check for command equality in order for cycle detection to work.

Command are unique by name

Action Enumerator / Action Factory

Takes a command object and gets a flattened list of actions, using the ActionSequencer to request the appropriate sequence.
It should only be getting the list of actions; it shouldn't be injecting execution context or making immutable clones
It must check for recursion / stack overflow; i.e. in the case where an action is to execute a command, and through the chain we end up back at the original command.

Concurrency / Multithreading

Feeling like I have a rough idea of how to configure a client. However, I feel like there's a gap in my understanding in how the client will be able to receive/broadcast messages currently.

So, let's take a break and dive into concurrency and multithreading -- then if necessary dive into scheduling/queueing in Spring / how to best architect this. Questions I have:

  • How will I queue message-send requests?
  • How will I handle responses from OBS? How will I know how to route those requests so they go back to the requester?
  • How will I respond to the client connecting/disconnecting? E.G., how could I make it possible to manually enable/disable the connection, or to automatically attempt a reconnect? Would it be through emitting an event and consuming it somewhere?

Add to research, make a Spring example of websocket client

We have a classic example, now we need to have a Spring example and explore how we can keep that configurable and clean.

One question I have is if the Spring example can be done in such a way that the client config can be done in a separate module and brought in as a project dependency. This seems to be the case with AnnotatedEndpointConnectionManager as described in https://spring.io/blog/2013/05/23/spring-framework-4-0-m1-websocket-support but that article is 7 years old.

Anyway, if that's possible then it should be feasible to offer a JSR-356 WS client for OBS that is thoroughly tested / testable as an alternative to the other Java client out there (that is coupled to using the Jetty client implementation specifically, and doesn't offer its main client class as an interface so folks can stub it in their projects/tests)

Startup Order and Failed Connection Handling

The program should be able to handle not being able to connect to OBS, Twitch, etc. and try again later. . . Or at the very least, not need to spin up all those services on startup until requested. (maybe we can add configuration for this, so some services always startup while others don't)

CommandExecutorService

CommandExecutorService is responsible for:

  • storing the Request timeout
  • storing the pause timeout
  • returning new instances of SequentialExecutor
  • running Requests (and since it should extend ExecutorService, it must validate the Runnable is a Request object, and cast it)

Simple Command Object

Mutable
has a name and list of actions
can be disabled

Will be used to generate a list of (mutable, Runnable) actions for executor

ActionServiceFactory & Action

Actions need to be able to get a current reference to the service they use (OBS, Twitch, etc).

This could be done by:

  • Action is injected with ActionServiceFactory (has a getService(ActionType type) method
  • Action internally has an ActionType (enum with values OBS, TWITCH_CHAT, etc)
  • Let's keep it simple for now but consider the possibility later of adding many OBS services or many TWITCH references; could be possible to reference the service by its id or name instead in the service lookup??

Externalized Twitch Client Config

  • message to send when joining chat (or not at all)
  • whether to parse all of message for ! trigger, or just the beginning
  • channel to join (streamer's channel)
  • who to join as
  • server, port, ssl
  • listener

Command Request and factory

A CommandRequest is a group of Actions that will be executed with a single-thread threadpool. It implements Runnable and will be submitted to an Executor (most likely a bounded thread pool with of moderate-to-large size)

Since we don't want to expect the client to have to provide the threadpool instance for each, then we should also provide a factory that will have a method to generate the request from a list of actions (and will inject the threadpool into the commandRequest).

Twitch client

Needs to connect to Twitch's chat API and listen for messages
Needs to be able to send messages to chat

OBS testing resources

When doing end-to-end testing with OBS, we'll need:

  • default scene collection, with the testing scenes, sources, etc.
  • plugins, such as obs-remote

Twitch Client authentication / credentials

For now creds are being passed as environment variables; this will eventually be stored in the DB as an encrypted string. This should be pulled from there instead.

ALSO, disable the logs that are printing out the raw IRC event stuff, as it includes the password being printed in plaintext to the logs.

CommandAction Action

Action should refer to a Command

Needs to be accounted for in the ActionEnumerator

Centralize exception handling

Pet the exceptions in a central place and give each a unique code so that these can be passed up to the UI when needed.

Integration Tests using Spring DI

Now that the project is Spring integrated, take some of the inpromptu sanity-checks in App.java and turn them into Integration tests

Twitch Client - Translate Twitch message into ActionContext

When a new message comes in:

  • It should be checked for a command trigger (!). This could be in the middle or beginning
  • It should be repackaged as an ActionContext containing:
    • command name
    • args
    • User info (username, etc.)
  • Should handle if a command doesn't exist for the specified name; whether to respond or not should be configurable (some streamers may want a helpful message, others may want nothing at all because this could be spammy in large streams)

CommandExecutionContext and equality

A CommandExecutionContext defines the key for Action execution within the keyed FIFO executor. It should include:

  • command id
  • user id
  • arguments (list of strings)

Replace null arg stuff with better options

I think there's libraries out there that will replace the manual stuff with better messaging? Take a look and see if it would be worth adding the dependency, versus doing what we've been doing and just throwing an IllegalArgumentException

Dispatch (for chat messages)

Dispatchers will handle incoming requests for commands. They can be from:

  • text chat
  • local client (invoking commands directly)

Their job is to build a Command Request and send it to the request bus.

Execute command with arguments

Should be able to execute a command with arguments, for example:

!cheer @person some message
!silence @person 15 min
!grant @person permission
!creategroup groupname @member1 @member2 @member3
!schedule commandname in 45 sec

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.