Giter Site home page Giter Site logo

method-dev's Introduction

Twitch Chat Bot

This repository contains a Go application that serves as a chat bot for Twitch. It listens to the chat of a specific channel and responds to a specific command with a random Chuck Norris fact.

Installation

Before you start, please ensure you have Go installed on your computer. You can download and install Go from here.

Prerequisites

You should copy the placeholders in the credentials.json.example into credentials.json file with your actual Twitch username, OAuth token, and channel name. Here's an example of what it might look like:

{
    "username": "mytwitchusername",
    "oauth_token": "oauth:myoauthtoken",
    "channel_name": "mytwitchchannel"
}

The bot will use these credentials to connect to the Twitch api. Remember to never share this file, as it contains your sensitive data. It is ignored by git in the .gitignore file.

To build the project, navigate to root of the project and use the Go build command:

go build

This will create an executable file in the same directory.

Usage

Running

To start the bot, simply run the executable that you built in the installation step:

./dev

How it works

The bot uses the standard Go libraries to connect to the Twitch IRC server over SSL. It then joins the specified channel and listens for messages. If a message matches the !chucknorris command, the bot fetches a random fact from the Chuck Norris API and sends it to the channel.

The bot runs asynchronously, using goroutines to handle incoming messages and API responses. It also handles PING/PONG messages from the Twitch server to avoid disconnection. It is designed to comply with the Twitch API rate limits.

Testing

The bot has a suite of unit tests that can be run using the Go test command:

go test -v ./...

In order to run the conn_test.go file you will need to create a certificate and key file for the bot to use. You can do this by running the following command in teh conn directory:

openssl req -x509 -nodes -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365

License

MIT

method-dev's People

Contributors

jwilson780 avatar

Watchers

 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.