Coder Social home page Coder Social logo

twitch-spambot's Introduction

twitch-spambot

CI

Coverage - statements Coverage - branches Coverage - functions Coverage - lines

Releases downloads GitHub release (latest SemVer) GitHub Release Date License GitHub open issues GitHub closed issues

An automated twitch spammer

Idea

The idea of this small project is to process the messages from given channel and simply spam whichever phrase is currently the most popular.

We can achieve this by constantly monitoring the chat with IRC from Twitch's Node.js library tmi.js.

We also fetch sub emotes from that channel to reject messages containing them, if we're not subbed.

How to run the program

Node.js is required, the program works under Windows, Ubuntu and macOS, with Node v14, v15 and the new v16 release.

.env file is required to provide data for the api and the config. Create an .env file consiting of values as shown below:

TWITCH_USERNAME=YourUsername
TWITCH_PASSWORD=oauth:YourOAuthCodeGoesHere

CLIENT_ID=YourClientId
CLIENT_SECRET=YourClientSecret
CLIENT_TOKEN=YourClientToken

Twitch password OAuth token (TWITCH_PASSWORD) can be retrieved from here.

Client variables require you to register your own application. After you're done, copy the Client ID given to the application as well as the Client Secret. Then you can retrieve your client token (CLIENT_TOKEN) via Twitch CLI.

Release version

If you're running a release downloaded from the releases page:

yarn --production

yarn start CHANNEL_NAME
# or
yarn start CHANNEL_NAME 3000 30000 5

Master version

Otherwise if you're running the current master build:

yarn

and then:

  • if you want to edit the code and made your own changes, run the TypeScript version
yarn dev CHANNEL_NAME
# or
yarn dev CHANNEL_NAME 3000 30000 5
  • if you want to compile the TypeScript to pure JavaScript
yarn tsc # to make a build directory

yarn start:dev CHANNEL_NAME
# or
yarn start:dev CHANNEL_NAME 3000 30000 5

The program has 4 available arguments:

  • channelName (required) - channel to which we connect to
  • readInterval: default = 5000 ms - the amount of time during which we gather channel messages and try to find the most popular spam
  • sleepInterval: default = 30000 ms - duration of sleep after sending the message to the channel
  • messageScore: default = 5 - score required for the most popular message to be sent (every message read within readInterval can contribute from 0 to 1 to the score and in case messages are the same, 2 will be added instead)
  • mentionResponse: when provided, results in an auto response (response takes randomly from 2 to 4s) to the person who mentioned your nickname in their message

The arguments are passed as:

yarn start CHANNEL_NAME READ_INTERVAL SLEEP_INTERVAL MESSAGE_SCORE MENTION_RESPONSE

If you wish to omit a particular argument (except the channelName), just pass a JavaScript falsy value, or an argument that is not a number, for example:

yarn start CHANNEL_NAME - - 6 -

which will result in running the script with default values for readInterval, sleepInterval and mentionResponse, but will change the default value of messageScore from 5 to 6.

You can also just run:

yarn start CHANNEL_NAME

to run the program with the default arguments. Adjust the arguments to match the desired channel's chat speed and activity.

You can also run multiple instances of the script at once by joining yarn start CHANNEL_NAME commands with & like:

yarn start CHANNEL_NAME & yarn start CHANNEL_NAME2 & yarn start CHANNEL_NAME3

Additional ignored words

You can add additional words to ignore (they will count towards message score, but will not be sent if they end up with the highest score). I found that feature useful since you might want to censor some words yourself.

My example cases were:

  • a streamer got banned, but people could still use his emotes, while they could not be fetched from the api
  • a 3rd party chat app (such as Chatterino for example), allows to easily whisper people without using the @ character before their username, which is hard to filter out - constantly keeping the user list cached would take a lot of resources and requests in bigger chats, so you might want to ignore usernames that are often whispered to avoid unintentional pings

To use this feature edit the json file called ignoredWords.json in the src/utils directory of the project, with structure as shown below:

{
  "ignoredWords": ["forsen1", "forsen2", "forsen3"] // 3 example words to ignore
}

with an array of ignored words of your choice.

Whitelist sub emotes

If you're subscired to a streamer and want to user their emotes with this bot, add their channel ID to whitelistEmotes.json file in the src/utils directory.

Since it would be troublesome for many people to create their own credentials for Twitch API requests you have to add the ID instead of the channel to simplify the process.

At the moment being one example website that allows finding channel IDs by providing usernames can be found here. After getting the channel ID paste it in as:

{
  "channels": ["62300805"] // Example channel ID for NymN's channel
}

Otherwise just leave the channels entry as an empty array.

Known problems

  1. yarn.ps1 cannot be loaded because running scripts is disabled on this system

Error on Windows that doesn't allow the user to install the libraries with yarn:

Open up Windows PowerShell and in the terminal type:

Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted

After that, yarn should properly install dependencies.

Contributing

Please review the contributing guidelines. We reserve the right to refuse a Pull Request if it does not meet the requirements.

twitch-spambot's People

Contributors

frozentear7 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  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

twitch-spambot's Issues

Says I need a valid .env config

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:
2. Run script '...'
3. See error

Expected behavior
I expected for it to work
Screenshot (11)

(i also made a .env file)

Duplicating Messages

  • Connected to irc-ws.chat.twitch.tv:443
  • Starting the spambot
    [21:41:53, #xqcow, score: 157.99]: OMEGALUL
    [21:42:52, #xqcow, score: 73.71]: ??????????
    [21:42:52, #xqcow, score: 73.71]: ??????????
    [21:42:52, #xqcow, score: 73.71]: ??????????
    Received notice: msg_ratelimit
    Your message was not sent because you are sending messages too quickly.
    Stream ended, stopping the spam

Exit status 13

Good Day,

i tried to run it but i got a weird Error

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Users\\XXxX\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'start',
1 verbose cli   'XXxX'
1 verbose cli ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle [email protected]~prestart: [email protected]
6 info lifecycle [email protected]~start: [email protected]
7 verbose lifecycle [email protected]~start: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~start: PATH: C:\Users\XXxX\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\XXxX\Desktop\twitch-spambot-master\node_modules\.bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\AdoptOpenJDK\jdk-13.0.2.8-hotspot\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\dotnet\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Topaz Labs LLC\Topaz Video Enhance AI;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\nodejs\;C:\Users\XXxX\AppData\Local\Microsoft\WindowsApps;C:\Users\XXxX\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\XXxX\AppData\Local\Programs\Fiddler;C:\Users\XXxX\AppData\Local\Microsoft\WindowsApps;C:\Users\XXxX\AppData\Roaming\npm
9 verbose lifecycle [email protected]~start: CWD: C:\Users\XXxX\Desktop\twitch-spambot-master
10 silly lifecycle [email protected]~start: Args: [
10 silly lifecycle   '/d /s /c',
10 silly lifecycle   'node --es-module-specifier-resolution=node index.js "XXxX"'
10 silly lifecycle ]
11 silly lifecycle [email protected]~start: Returned: code: 13  signal: null
12 info lifecycle [email protected]~start: Failed to exec start script
13 verbose stack Error: [email protected] start: `node --es-module-specifier-resolution=node index.js "XXxX"`
13 verbose stack Exit status 13
13 verbose stack     at EventEmitter.<anonymous> (C:\Users\XXxX\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:315:20)
13 verbose stack     at ChildProcess.<anonymous> (C:\Users\XXxX\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:315:20)
13 verbose stack     at maybeClose (internal/child_process.js:1048:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid [email protected]
15 verbose cwd C:\Users\XXxX\Desktop\twitch-spambot-master
16 verbose Windows_NT 10.0.19042
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\XXxX\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "start" "XXxX"
18 verbose node v14.15.4
19 verbose npm  v6.14.11
20 error code ELIFECYCLE
21 error errno 13
22 error [email protected] start: `node --es-module-specifier-resolution=node index.js "XXxX"`
22 error Exit status 13
23 error Failed at the [email protected] start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 13, true ]

i updated npm and node but nothing changes, can you help me with this?

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.