Giter Site home page Giter Site logo

twitch-chat-plays-bot's Introduction

Twitch Chat Plays Bot

Stand With Ukraine

A Python script for Twitch Chat interaction with almost any game.

I have only tested this on Windows.

Prerequisites:


The Setup:

Line 5 - Replace 'PATH' with AHK .exe path location.

Example: 'C:\Program Files\AutoHotkey\AutoHotKey.exe'
    ahk = AHK(executable_path='PATH')

Line 10 - Add the oauth code that was generated from https://twitchapps.com/tmi/ here (include "oauth:" that is apart of the generated code).

DO NOT SHARE THIS KEY!
    PASS = "OAUTH_CODE"

Line 11 - Name the bot

    BOT = "BOT_NAME"

Line 12 - Add the name of the Twitch channel you want to monitor.

    CHANNEL = "CHANNEL_NAME"

Line 13 - Add your Twitch account name.

    OWNER = "ACCOUNT_NAME"

Tweaking:

Game controls are handled by condition checks(if chat sends "up", AHK will read "up" and pass the command to the game).

You may need to go into game settings to reconfigure keymap for each game.
See below example(s):
    # For an "UP" Press:
    if "up" == message.lower():
        ahk.key_press('up')
        message = ""
alternatively, add and remove conditions as you seem fit.
    # For a "DOWN" Press:
    if "down" == message.lower():
        ahk.key_press('down')
        message = ""

Run the Script:

Navigate to the project directory using CMD or Terminal and run the command:

    py twitchchatplays.py
Successful output example:
    :tmi.twitch.tv 001 :Welcome, GLHF!
    :tmi.twitch.tv 002 :Your host is tmi.twitch.tv
    :tmi.twitch.tv 003 :This server is rather new
    :tmi.twitch.tv 004 :-
    :tmi.twitch.tv 005 :-
    :tmi.twitch.tv 006 :You are in a maze of twisty passages, all alike.
    :tmi.twitch.tv 007 :>
    
    :tmi.twitch.tv 001 :Welcome, GLHF!
    :tmi.twitch.tv 002 :Your host is tmi.twitch.tv
    :tmi.twitch.tv 003 :This server is rather new
    :tmi.twitch.tv 004 :-
    :tmi.twitch.tv 005 :-
    :tmi.twitch.tv 006 :You are in a maze of twisty passages, all alike.
    :tmi.twitch.tv 007 :>
    :name![email protected] JOIN #name
    :name.tmi.twitch.tv 008 name = #name :name
    :name.tmi.twitch.tv 009 name #name :End of /NAMES list
    
    :name![email protected] JOIN #name
    :name.tmi.twitch.tv 001 name = #name :name
    :name.tmi.twitch.tv 002 name #name :End of /NAMES list
    BOT has joined name's Channel!
    tmi.twitch.tv CAP * ACK  : twitch.tv/tags
    -- Twitch chat messages will show up here. --
* Testing will be unresponsive from host machine running the script.
You will need to test from another device, or get a friend to login to Twitch and test inputs that way.

twitch-chat-plays-bot's People

Contributors

shirkx avatar

Watchers

 avatar

Forkers

nidark

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.