Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Vibe Mode #42

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Add Vibe Mode #42

wants to merge 8 commits into from

Conversation

aadibajpai
Copy link
Member

Implements an automatic loop so you do not need to request lyrics again and again if the song changes, until you stop listening to music or use the $kill command.

This is similar to the way it works in the cli swaglyrics application.

@aadibajpai aadibajpai requested a review from flabbet July 26, 2020 02:19
@pep8speaks
Copy link

pep8speaks commented Jul 26, 2020

Hello @aadibajpai! Thanks for updating this PR.

Line 95:66: W291 trailing whitespace

Comment last updated at 2020-08-20 01:32:12 UTC

@aadibajpai aadibajpai marked this pull request as draft July 26, 2020 02:19
@codecov
Copy link

codecov bot commented Jul 26, 2020

Codecov Report

Merging #42 into master will decrease coverage by 1.59%.
The diff coverage is 14.51%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #42      +/-   ##
==========================================
- Coverage   28.70%   27.11%   -1.60%     
==========================================
  Files           9        9              
  Lines         310      354      +44     
==========================================
+ Hits           89       96       +7     
- Misses        221      258      +37     
Impacted Files Coverage Δ
SwagLyricsBot/lyrics.py 21.87% <0.00%> (ø)
SwagLyricsBot/general_commands.py 35.32% <14.75%> (-6.95%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9232d96...b39c037. Read the comment docs.

Copy link
Member

@flabbet flabbet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I know you said it's not going to work with more users, but this approach is a no-go. Using self statement makes it almost impossible to make it work for more users. Also, I don't like the idea of calling it vibe mode, Especially in code, what if someone will work on this except us? We would need to explain to him what it is, code should be self-explanatory, this is an unnecessary complication. This is all right to add this as command alias, but not as default one.

SwagLyricsBot/general_commands.py Outdated Show resolved Hide resolved
@aadibajpai
Copy link
Member Author

Well, I know you said it's not going to work with more users, but this approach is a no-go. Using self statement makes it almost impossible to make it work for more users.

fixed

@aadibajpai aadibajpai marked this pull request as ready for review July 29, 2020 22:24
@aadibajpai
Copy link
Member Author

@thealphadollar, this adds a looping feature to the bot, where you once call the commands and it will keep sending lyrics as activity changes until you stop listening or kill the loop with $kill. The logic is that the $vibe command adds your info to a shared variable and starts a loop if the loop isn't already running. And then the loop every 5s takes care of all the users in the shared variable and $kill removes your info from the shared variable.

There's a bunch of debug print statements there but I'll get rid of them.

@aadibajpai
Copy link
Member Author

@dolphingarlic @fadedcoder review again, thanks!

@aadibajpai aadibajpai requested a review from flabbet July 30, 2020 08:52
looks like there's a problem with the logging part, it doesn't integrate well with this. Once commented it works as intended.
SwagLyricsBot/general_commands.py Show resolved Hide resolved
SwagLyricsBot/general_commands.py Outdated Show resolved Hide resolved
SwagLyricsBot/general_commands.py Show resolved Hide resolved

@commands.command()
async def vibe(self, ctx):
prev = self.current.copy()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of copying the entire dict, you could just check whether the new dict has length equal to 1

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, check whether the user is already in self.current if you do this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alright

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, check whether the user is already in self.current if you do this

what do you mean by this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

look at the updated commit and see if that's ok?

SwagLyricsBot/general_commands.py Outdated Show resolved Hide resolved
await self.send_lyrics(channel, song, artists)
except LyricsError as e:
print('No activity detected, stopping loop.')
await channel.send("No activity detected, killing the vibe.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
await channel.send("No activity detected, killing the vibe.")
await channel.send("No activity detected. Killing the vibe.")

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not that bad is it?

self.vibe_mode.start()

@commands.command()
async def kill(self, ctx):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rename this to kill_vibe or something to prevent ambiguity

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ambiguity with what?

SwagLyricsBot/lyrics.py Show resolved Hide resolved
@flabbet
Copy link
Member

flabbet commented Aug 6, 2020

Make logs work (you can't call add_sub_log without first calling add_log) + clean up console output, and make sure it works independently for every user, also I think this option should be only called on direct messages

Copy link
Member

@flabbet flabbet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make changes based on the comment above

we don't need to store channel now since DMs only
@aadibajpai
Copy link
Member Author

aadibajpai commented Aug 9, 2020

Make logs work (you can't call add_sub_log without first calling add_log) + clean up console output, and make sure it works independently for every user, also I think this option should be only called on direct messages

check now, also how much console output would you like to keep so it's okay?

Copy link
Member

@flabbet flabbet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it's too much same information for one loop, get rid of it, it should print maybe ony a user name + song name.
And get rid of the slang. Use casual language, but not slang. It's not consistent for the rest of the bot and I will not merge it until you change it. I let you leave $vibe as a command string, but provide aliases like $loop, and describe it in $help
image

Oh and fix the conflict

@aadibajpai
Copy link
Member Author

Well, it's too much same information for one loop, get rid of it, it should print maybe ony a user name + song name.
And get rid of the slang. Use casual language, but not slang. It's not consistent for the rest of the bot and I will not merge it until you change it. I let you leave $vibe as a command string, but provide aliases like $loop, and describe it in $help
image

Oh and fix the conflict

the Spotify thing happens through the logging set up in the preexisting function, so I'm not modifying that. Rest everything has been addressed.

@flabbet
Copy link
Member

flabbet commented Aug 23, 2020

Fine, It can stay then

Copy link
Member

@flabbet flabbet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the user nickname in this line https://github.com/aadibajpai/SwagLyrics-discord-bot/blob/vibe/SwagLyricsBot/general_commands.py#L49. You should add the log to webhook that someone started vibe and ended it, so we can investigate it easier. Also include the number of people currently in vibe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants