Git Product home page Git Product logo

twitch-bot's Introduction

Welcome to twitch-bot

License: MIT Twitter: athanoquest

Twitch Chat bot with custom commands, TTS, sounds, rewards, API integrations and more!

Welcome to our Twitch Bot!

This bot is intended for self-hosting streamers. Its adaptation for other channels is not covered in this project.

For Twitch API help, visit https://dev.twitch.tv/docs/.

This bot assumes users have programming experience. Please keep in mind that this project may not meet the needs of all users, but it does offer the ability to create a customized Twitch Bot.

We used Twitch's example at https://dev.twitch.tv/docs/irc/example-bot as a starting point. Thanks, Twitch!

Features

  • Twitch chat overlay
    • Supports Twitch emotes and badges, 7TV emotes, BTTV emotes and modifiers, and FFZ emotes and modifiers
    • Customisable formatting, colours, and animations
  • Custom commands
  • Text-to-speech with custom voices from streamelements and TikTok
  • Sound effects
  • Spotify integration with song requests
  • Spotify song overlay
  • Twitch rewards integration
  • Interval commands (e.g. periodic messages)
  • Twitch task overlay
  • Discord webhook integration for announcing stream start
  • Probably more!

Setup

View SETUP instructions

Configuration

View CONFIGURATION instructions

Start the bot

Client for Chat, Tasks and Spotify overlays:

cd client
npm start

Server:

cd server
npm start

Troubleshooting

Primarily, watch the console output for errors to troubleshoot issues.

For tokens that are saved in tokens.json (Twitch and Spotify), if you change your scope and there are already access_token and refresh_token present in the file, you should remove these token values. Once you have your new access code the program will retrieve a new access_token and refresh_token.

Contributing

Contributions, issues and feature requests are welcome!
Feel free to check the issues page.

License

This project is MIT licensed.

twitch-bot's People

Contributors

6lr61 avatar delvoid avatar dependabot[bot] avatar mjfwebb avatar renovate[bot] avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

twitch-bot's Issues

Add !filter command

change the filter of your camera based on this command for a certain time. add a big cooldown to it
!filter [name: string]
!filterlist - sends the list of available filters

!song command

Probably want to make it work with lastfm, or Spotify directly

!roll command

Roll a die basically. Should accept parameters min max with default of min = 1 and max = 6

!randomissue command

Should return a random issue's title from GitHub

Example:

!randomissue
Here's a random issue: ${issueTitle}

Type Challenge: Event type based on Subscription "type" property

In this example taken from Twitch docs, we see a channel.subscription.end event. The subscription object contains the type property "channel.subscription.end":

{
    "subscription": {
        "id": "f1c2a387-161a-49f9-a165-0f21d7a4e1c4",
        "type": "channel.subscription.end",
        "version": "1",
        "status": "enabled",
        "cost": 0,
        "condition": {
           "broadcaster_user_id": "1337"
        },
         "transport": {
            "method": "webhook",
            "callback": "https://example.com/webhooks/callback"
        },
        "created_at": "2019-11-16T10:11:12.634234626Z"
    },
    "event": {
        "user_id": "1234",
        "user_login": "cool_user",
        "user_name": "Cool_User",
        "broadcaster_user_id": "1337",
        "broadcaster_user_login": "cooler_user",
        "broadcaster_user_name": "Cooler_User",
        "tier": "1000",
        "is_gift": false
    }
}

We should be able to therefore infer that the event object is of a certain structure. How do we do this in Typescript?

We don't want to use the as keyword in Typescript for this!

Reference: https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types

!followage command

With no param: Informs the user how long it has been since they followed the stream

Example:

!followage
It has been 27 days, 2 hours, 8 seconds since you started following

With param (username): Informs how long it has been since the provided user followed the stream

Example:

!followage John
It has been 18 days, 18 hours, 9 seconds since John started following

Synchronous promise wrapper

For example, it is used twice in this same callback to avoid issues with async/await

callback: (connection) => {
new Promise<void>(() => {
void (async () => {
const lutfiskId = await getUserIdByName('lutf1sk');
if (lutfiskId !== '') {
sendChatMessage(connection, 'Get banned fool');
setTimeout(() => {
new Promise<void>(() => {
void (async () => {
await unbanUser(lutfiskId);
})();
}).catch((e) => console.log(e));
}, 10000);
await banUser(lutfiskId);
}
})();
}).catch((e) => console.log(e));
},

Moderation API endpoints

Twitch will be deprecating many chat commands through IRC.

https://discuss.dev.twitch.tv/t/deprecation-of-chat-commands-through-irc/40486

Only the /ban and /unban currently, by the lutf1sk chat command:

command: ['lutf1sk', 'lutfisk'],
id: 'lutf1sk',
mustBeUser: 'lutf1sk',
hidden: true,
callback: (connection) => {
sendChatMessage(connection, 'Get banned fool');
setTimeout(() => {
sendChatMessage(connection, '/unban lutf1sk');
}, 10000);
sendChatMessage(connection, '/ban lutf1sk');
},
cooldown: 30 * MINUTE_MS,
},

Welcome message (opt-in)

With https://dev.twitch.tv/docs/irc/capabilities/ the membership capability, we can receive messages when a user enters or leaves the chat channel, so we could send them a welcome message.

Personally, I think I would prefer this to be opt-in only from a user's perspective because it's quite anti-lurk.

Combined with this is a need to keep a memory of user choices, so some sort of database is required.

Depends on #24

Add !issues command

List the current todo issues from the GitHub API

Potentially with a search string

Add !uptime command

Examples:

When the stream is online:

!uptime
The stream has been live for 1 hour, 5 minutes, 20 seconds

When the stream is offline:

!uptime
The stream is offline

Improve parseParameters

} else {
command.botCommand = commandParts.slice(0, paramsIdx);
command.botCommandParams = commandParts.slice(paramsIdx).trim();
// TODO: remove extra spaces in parameters string
}

Currently, it doesn't really handle multiple parameters in a nice way. It could be nicer to return this as an array of strings, or even as a separate property in addition to the existing botCommandParams.

Potential proposal:

Return both botCommandParams and a new botCommandParamsList which is pre-split by space.

Add credits screen

Should be a separate webpage /credits where it shows all active chatters, new followers, new subscribers, and raiding channels

Sound queue

There is a queue for commands, but not for sounds. Currently, that means if two separate sound commands are used then the last one will play, even if the former was in the process of being played.

!command command

Shows details about a command:

  • Who can use it
  • What cooldown it has
  • Aliases
  • What it does
  • What arguments it takes

Add playing sounds to database commands

Currently we can't play sounds from commands that are made with the !addcommand command. If this is added then a lot of the custom commands saved to the repo could be removed.

Make Discord optional in code

Currently, the Discord webhook is required in code by default and requires a manual change to remove it.

Let's just make this optional from the beginning.

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.