Skip to content

Commit 640c5ae

Browse files
Marc DonaldMarcDonald
authored andcommitted
Fix bug where config wouldn't have types & Add npm install to build script
Also added CONTRIBUTORS.md
1 parent da182f8 commit 640c5ae

12 files changed

Lines changed: 9124 additions & 1741 deletions

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ spotify-auth-store.json
33
build/
44
node_modules/
55
.idea/
6-
.dist/
6+
dist/

CONTRIBUTORS.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Contributors
2+
3+
- [IvanGodinez21](https://github.com/IvanGodinez21)
4+
5+
- Converted config loading to use environment variables (#9)
6+
7+
- [Trithir](https://github.com/Trithir)
8+
9+
- Fixed bug where songs couldn't be added to public playlists (#2 #3)
10+
11+
- [Colorful98](https://github.com/Colorful98)
12+
13+
- Created the script to generate platform binaries (#10)

README.md

Lines changed: 60 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,50 +9,58 @@ your queue. The Spotify link must be at the start of the message in order to be
99
✔️ Message that WOULD be picked up:
1010

1111
```
12-
https://open.spotify.com/track/4uLU6hMCjMI75M1A2tKUQC?si=x-_FFgqBRB20mzW_lM7kDQ pls play this, it's a bop
12+
!prefix https://open.spotify.com/track/4uLU6hMCjMI75M1A2tKUQC?si=x-_FFgqBRB20mzW_lM7kDQ pls play this, it's a bop
1313
```
1414

1515
❌ Message that WOULD NOT be picked up:
1616

1717
```
18-
this is a bop can you please play this https://open.spotify.com/track/4uLU6hMCjMI75M1A2tKUQC?si=x-_FFgqBRB20mzW_lM7kDQ
18+
!prefix this is a bop can you please play this https://open.spotify.com/track/4uLU6hMCjMI75M1A2tKUQC?si=x-_FFgqBRB20mzW_lM7kDQ
1919
```
2020

2121
## Prerequisites
2222

23-
- Some basic programming knowledge (running terminal commands and editing JSON
23+
- Some basic programming knowledge (running terminal commands and editing `.env`
2424
files)
25-
- Node (developed and tested on 14.6.0 - your mileage may vary on other versions)
26-
- Yarn or NPM
25+
- [Node](https://nodejs.org/en/) (developed and tested on 14.6.0 - your mileage may vary on other versions)
2726
- A Spotify account
2827

2928
## Setup
3029

31-
- Go to the [Spotify developer dashboard](https://developer.spotify.com/dashboard/)
32-
and create a new application. The app can have whatever name and description you want
33-
- Once the app is created, click on Edit Settings and add a redirect URL of
34-
`http://localhost:8000/spotifyAuth` (NB: the port will be whatever you have
35-
set as the `AUTH_SERVER_PORT` in the `./.env` file, by default it is 8000)
36-
- Create a `./.env` file based on `./.env.template` file and fill
37-
in the fields
38-
- The playlist ID can be found by right clicking on the playlist ->
39-
clicking Share -> Copy Spotify URI and then copying the ID after `spotify:playlist:`
40-
eg. `spotify:playlist:{THIS_STRING_IS_THE_ID}`)
41-
- The Spotify client ID and secret are obtained from the application you
42-
created in the Spotify developer dashboard
43-
- If you wish to have chat feedback, set `CHAT_FEEDBACK` to true then generate a
44-
[Twitch Chat OAuth Token](https://twitchapps.com/tmi/) and set it as the `TWITCH_TOKEN` field in
45-
the `config.json` file. Also set the `BOT_USERNAME` field to the name of the account you wish to
46-
use (must be the same account you generate the OAuth token for)
47-
- Run `./build.sh` This will compile from source using `npm` and then build OS-native binaries using `pkg`
48-
- Run the freshly compiled binary for your OS in `./dist`.
49-
- Open the authorization link and give the app the required permissions
50-
- If you have `ADD_TO_QUEUE` toggled on, ensure you have the Spotify client open and that it is active (i.e. is playing a song)
51-
- Type a Spotify link in the chat (ensuring the link is the first piece of text in the message)
52-
and make sure it shows up in your desired playlist (Spotify links should start
53-
with `https://open.spotify.com/track/`)
54-
- If there's a problem with Spotify authorization at any point, try deleting the
55-
`spotify-auth-store.json` file and starting the app again
30+
1. Go to the [Spotify developer dashboard](https://developer.spotify.com/dashboard/)
31+
and create a new application. The app can have whatever name and description you want
32+
2. Once the app is created, click on Edit Settings and add a redirect URL of
33+
`http://localhost:8000/spotifyAuth` (NB: the port will be whatever you have
34+
set as the `AUTH_SERVER_PORT` in the `./.env` file, by default it is 8000)
35+
3. Create a `./.env` file based on `./.env.template` file and fill
36+
in the fields
37+
38+
- The playlist ID can be found by right clicking on the playlist ->
39+
clicking Share -> Copy Spotify URI and then copying the ID after `spotify:playlist:`
40+
eg. `spotify:playlist:{THIS_STRING_IS_THE_ID}`)
41+
- The Spotify client ID and secret are obtained from the application you
42+
created in the Spotify developer dashboard
43+
- If you wish to have chat feedback, set `CHAT_FEEDBACK` to true then generate a
44+
[Twitch Chat OAuth Token](https://twitchapps.com/tmi/) and set it as the `TWITCH_TOKEN` field in
45+
the `.env` file. Also set the `BOT_USERNAME` field to the name of the account you wish to
46+
use (must be the same account you generate the OAuth token for)
47+
48+
4. Run `bash ./build.sh`. This will automatically compile from source using `npm` and then build OS-native binaries using `pkg`
49+
5. Run the freshly compiled binary for your OS in `./dist`.
50+
6. Open the authorization link and give the app the required permissions
51+
7. If you have `ADD_TO_QUEUE` toggled on, ensure you have the Spotify client open and that it is active (i.e. is playing a song)
52+
8. Type a Spotify link in the chat (ensuring the link is the first piece of text in the message)
53+
and make sure it shows up in your desired playlist (Spotify links should start
54+
with `https://open.spotify.com/track/`)
55+
9. If there's a problem with Spotify authorization at any point, try deleting the
56+
`spotify-auth-store.json` file and starting the app again
57+
58+
### Note
59+
60+
If you would prefer to launch the bot without generating a binary file you can replace steps 4 and 5 the following
61+
62+
- Run `npm install` or `yarn`
63+
- Run `npm start` or `yarn start`
5664

5765
## Open Source Libraries Used
5866

@@ -97,3 +105,25 @@ MIT License
97105
Used for strong typings
98106

99107
Apache 2.0 License
108+
109+
### [dotenv](https://github.com/motdotla/dotenv)
110+
111+
Used to load environment variables
112+
113+
BSD 2-Clause "Simplified" License
114+
115+
### [env-smart](https://github.com/jessety/env-smart)
116+
117+
Used to set types for environment variables
118+
119+
MIT License
120+
121+
### [pkg](https://github.com/vercel/pkg)
122+
123+
Used to create platform binaries
124+
125+
MIT License
126+
127+
## Contributors
128+
129+
Checkout the [Contributors file](./CONTRIBUTORS.md) to see everyone who has helped out with the bot

build.sh

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,44 @@
33
#description :This script compiles twitch-spotify-request-bot
44
#description2 :by @MarcDonald and builds OS-native binaries.
55
#author :@Colorful
6-
#version :1.2-beta
6+
#version :1.0
77
#usage :bash build.sh
8-
#changelog :changed target node version to node14
98
#==============================================================================
109

1110
ENV=./.env
1211

1312
echo "Checking if .env file exists...";
14-
sleep 2
13+
sleep 2
14+
15+
echo "Initializing npm...";
16+
npm install
1517

1618
if [ -f "$ENV" ]; then
1719

18-
clear >$(tty)
20+
clear >$(tty)
1921
echo "Compiling source to JS...";
20-
npm run build
22+
npm run build
2123

22-
else
23-
clear >$(tty)
24-
echo "Please create a .env file based on .env.template to continue...";
25-
sleep 2
26-
exit
24+
else
25+
clear >$(tty)
26+
echo "Please create a .env file based on .env.template to continue...";
27+
sleep 2
28+
exit
2729

2830
fi
2931

3032
clear >$(tty)
31-
echo "Building OS-native binaries from JS...";
32-
pkg ./build/index.js --targets node14-win-x64,node14-macos-x64,node14-linux-x64 --out-path ./dist/
33+
echo "Building OS-native binaries from JS...";
34+
pkg ./build/index.js --targets node14-win-x64,node14-macos-x64,node14-linux-x64 --out-path ./dist/
3335

3436
clear >$(tty)
35-
echo "Cleaning up...";
36-
mv ./dist/index-linux ./dist/twitch-spotify-bot-linux
37-
mv ./dist/index-win.exe ./dist/twitch-spotify-bot-win.exe
38-
mv ./dist/index-macos ./dist/twitch-spotify-bot-macos
39-
sleep 2
37+
echo "Cleaning up...";
38+
mv ./dist/index-linux ./dist/twitch-spotify-bot-linux
39+
mv ./dist/index-win.exe ./dist/twitch-spotify-bot-win.exe
40+
mv ./dist/index-macos ./dist/twitch-spotify-bot-macos
41+
sleep 2
4042

4143
clear >$(tty)
42-
echo "Thank you for using my little script //Colorful";
43-
sleep 2
44-
exit
44+
echo "Thank you for using my little script //Colorful";
45+
sleep 2
46+
exit

0 commit comments

Comments
 (0)