Coder Social home page Coder Social logo

mjfwebb / twitch-bot Goto Github PK

View Code? Open in Web Editor NEW
27.0 27.0 9.0 9.45 MB

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

License: MIT License

HTML 0.08% CSS 0.11% TypeScript 96.19% JavaScript 1.34% Less 2.27%
bot twitch twitch-bot

twitch-bot's Introduction

Hello!

  • ๐Ÿ”ญ Iโ€™m currently working at Neo4j on the GraphQL team
  • ๐Ÿ‘ฏ Iโ€™m looking to collaborate on GraphQL security analysis tools!

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  avatar

Watchers

 avatar  avatar  avatar

twitch-bot's Issues

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));
},

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

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.

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

!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

Add !issues command

List the current todo issues from the GitHub API

Potentially with a search string

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,
},

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.

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

!command command

Shows details about a command:

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

!song command

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

Add credits screen

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

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

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 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.

!randomissue command

Should return a random issue's title from GitHub

Example:

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

!roll command

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

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.