Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' of https://github.com/mmattbtw/tajjbot
Browse files Browse the repository at this point in the history
  • Loading branch information
mmattbtw committed Jul 19, 2021
2 parents e7b4554 + 96ff065 commit d8d6787
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
1. [Bot Token](https://twitchapps.com/tmi/)
2. [Twitch Application](https://dev.twitch.tv/console/apps/create)
* Create a `Chat Bot` application
* the OAuth redirect URL can just be 'http://localhost'
* the OAuth redirect URL can just be `http://localhost`
3. [Spotify Application](https://developer.spotify.com/dashboard/applications)
* Set the Website and Redirect URLs to `http://localhost:8080`

Expand Down
24 changes: 15 additions & 9 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@
client_id=os.environ.get("spotify_client_id"),
client_secret=os.environ.get("spotify_secret"),
redirect_uri="http://localhost:8080",
scope=["user-modify-playback-state", "user-read-currently-playing", "user-read-playback-state"],
scope=[
"user-modify-playback-state",
"user-read-currently-playing",
"user-read-playback-state",
],
)
)

Expand All @@ -47,7 +51,7 @@ def __init__(self):
self.version = "1.2.3"

async def event_ready(self):
print("\n" * 100)
print("\n" * 100)
print(f"TwitchTunes ({self.version}) Ready, logged in as: {self.nick}")
print(
"Ignore the 'AttributeError: 'NoneType' object has no attribute '_ws'' error, this is an issue with the library."
Expand All @@ -63,18 +67,20 @@ async def ping_command(self, ctx):
@commands.command(name="np", aliases=["nowplaying", "song"])
async def np_command(self, ctx):
data = sp.currently_playing()
song_artists = data['item']["artists"]
song_artists_names = [artist['name'] for artist in song_artists]
song_artists = data["item"]["artists"]
song_artists_names = [artist["name"] for artist in song_artists]

min_through = int(data["progress_ms"]/(1000*60)%60)
sec_through = int(data["progress_ms"]/(1000)%60)
min_through = int(data["progress_ms"] / (1000 * 60) % 60)
sec_through = int(data["progress_ms"] / (1000) % 60)
time_through = f"{min_through} mins, {sec_through} secs"

min_total = int(data["item"]["duration_ms"]/(1000*60)%60)
sec_total = int(data["item"]["duration_ms"]/(1000)%60)
min_total = int(data["item"]["duration_ms"] / (1000 * 60) % 60)
sec_total = int(data["item"]["duration_ms"] / (1000) % 60)
time_total = f"{min_total} mins, {sec_total} secs"

await ctx.send(f"🎶Now Playing - {data['item']['name']} by {', '.join(song_artists_names)} | Link: {data['item']['external_urls']['spotify']} | {time_through} - {time_total}")
await ctx.send(
f"🎶Now Playing - {data['item']['name']} by {', '.join(song_artists_names)} | Link: {data['item']['external_urls']['spotify']} | {time_through} - {time_total}"
)

@commands.command(name="songrequest", aliases=["sr", "addsong"])
async def songrequest_command(self, ctx, *, song: str):
Expand Down
32 changes: 24 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,37 @@
)
print("\n=-=-=-=-=-=-=-=-=-=")
print("\nSecond, let's setup the Twitch Client ID")
client_id = input("You can get this by going to https://dev.twitch.tv/console/apps/create, signing in, creating a 'Chat Bot' application (the OAuth redirect URLs can just be 'http://localhost')\nNow just copy and paste the Client ID into here.\nType the Client ID, then press `ENTER`. (You can change this later) ")
client_id = input(
"You can get this by going to https://dev.twitch.tv/console/apps/create, signing in, creating a 'Chat Bot' application (the OAuth redirect URLs can just be 'http://localhost')\nNow just copy and paste the Client ID into here.\nType the Client ID, then press `ENTER`. (You can change this later) "
)
print("\n=-=-=-=-=-=-=-=-=-=")
print("\nThird, lets setup the Spotify Client ID")
spotify_client_id = input("You can get this by going to https://developer.spotify.com/dashboard/applications, signing in, then creating an application.\nJust paste in the Client ID into here now.\nType Spotify's Client ID, then press `ENTER`. (You can change this later)")
spotify_client_id = input(
"You can get this by going to https://developer.spotify.com/dashboard/applications, signing in, then creating an application.\nJust paste in the Client ID into here now.\nType Spotify's Client ID, then press `ENTER`. (You can change this later)"
)
print("\n=-=-=-=-=-=-=-=-=-=")
print("\nFourth, let's setup the Spotify Client Secret")
spotify_secret = input("You can get this by going to that application page, then clicking the 'SHOW CLIENT SECRET' button.\nNow just paste the Client Secret here.\nType Spotify Client Secret, then press `ENTER`. (You can change this later) ")
spotify_secret = input(
"You can get this by going to that application page, then clicking the 'SHOW CLIENT SECRET' button.\nNow just paste the Client Secret here.\nType Spotify Client Secret, then press `ENTER`. (You can change this later) "
)
print("\n=-=-=-=-=-=-=-=-=-=")
print("\nFifth, let's setup the Spotify Website/Redirect URI")
input("All you have to do, is hit the settings button, then in BOTH the Website field, AND the Redirect URIs field, but 'http://localhost:8080'\nPress `ENTER` once you have completed this step.")
input(
"All you have to do, is hit the settings button, then in BOTH the Website field, AND the Redirect URIs field, but 'http://localhost:8080'\nPress `ENTER` once you have completed this step."
)
print("\n=-=-=-=-=-=-=-=-=-=")
print("\nSixth, what's your Twitch Bot's name?")
bot_name = input("Type your Bot's name, then press `ENTER`. (You can change this later) ")
bot_name = input(
"Type your Bot's name, then press `ENTER`. (You can change this later) "
)
print("\n=-=-=-=-=-=-=-=-=-=")
print("\nSeventh, what will your prefix be? (example: !, ?, $)")
prefix = input("Type your prefix, then press `ENTER`. (You can change this later) ")
print("\n=-=-=-=-=-=-=-=-=-=")
print("\nEighth, what's your Twitch Channel's name?")
channel = input("Type your Channel's name, then press `ENTER`. (You can change this later) ")
channel = input(
"Type your Channel's name, then press `ENTER`. (You can change this later) "
)
print("\n=-=-=-=-=-=-=-=-=-=")
print("\n" * 10)

Expand All @@ -60,6 +72,10 @@
)

with open("config.json", "a") as config_file:
config_file.write(json.dumps({"nickname": bot_name, "prefix": prefix, "channels": [channel]}))
config_file.write(
json.dumps({"nickname": bot_name, "prefix": prefix, "channels": [channel]})
)

input("All done!, enjoy using your Song Request Bot!\nAll you have to do now, is run the `bot.py` file!")
input(
"All done!, enjoy using your Song Request Bot!\nAll you have to do now, is run the `bot.py` file!"
)

0 comments on commit d8d6787

Please sign in to comment.