Git Product home page Git Product logo

twitchbotveeone's Introduction

Twitch Chatbot using Python Asyncio

The aim of this project is to provide an extendable, high performing and low impact chatbot for Twitch chat.

For more information on Twitch and chatbots running on it follow this link.

Architecture

Python's Asyncio library is useful especially in cases where much time is spent waiting on IO. In the case of a chatbot a lot of the time will be spent simply waiting on a socket to the Twitch server for data. In a similar way any integration triggered by the chatbot will likely also be waiting on some remote endpoint to provide feedback.

What this chatbot is not meant to do is any sort of CPU intensive work. This would include processing data such as large text, images or sound to name a few things that can consume many cycles. Worth also pointing out any handler that is meant to work with this Chatbot should not be using sleep (in a real use case) which will cause any task to potentially slow throughput. The bot simply acts as an intermediary between Twitch and various other services. Rather than work as a monolithic application we expect to be useful in a service based architecture where these services can do much of the heavy lifting, and be built to purpose.

All that out of the way now a quick overview of what we are working with. Asyncio contains the low level Transport and Protocol which are useful to abstract out Twitch's chatbot protocol. These constructs are in contrast to the high level Streams which facilitate a much simpler, direct way to do socket io when working with Asynchio. For our needs well want to use transports and protocols. These allow creating a high performing callback based implementation of this chatbot protocol. Underlying needs such as establishing socket connection to server, authenticating, channel and user info, and handling keep alive messages from the server can all be abstracted away. Any non-core events coming from the server (mainly text messages from chat users) will be parsed into lightweight objects that are passed along to an event bus. These objects will contain the basic metadata included in a payload from the chat server.

To pass information from the protocol layer to the event processing layer we use Asyncio Queues which allow for feeding the events out across any number of Asyncio Tasks. In this way we can also easily configure a pool of Tasks that will allow scaling our bot as required.

A todo in the future will be to add rate limiting into the design. This is a primary function and should live under the Asyncio Protocol we are building for twitch chat. The event processing layer should not need to be aware of any abuses at the chat level.

Applications

Simple:

  • Create and manage chat baubles such as polls, music/video playlist, product wishlists
  • Quick search/lookups for things like wikipedia, youtube and general web search

More complex:

  • Twitch <--> Discord bridging... post Twitch messages into discord, get info on Discord
  • Game api integration... Dota2 get player stats

Getting a Token

You can get a token using this URL after being logged into Twitch in your browser.

twitchbotveeone's People

Contributors

robottaway avatar

Watchers

 avatar Kostas Georgiou avatar  avatar

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.