Skip to content

Commit

Permalink
better volume messages when you're already at max or min
Browse files Browse the repository at this point in the history
resolves #26
  • Loading branch information
Hyphen-ated committed Feb 19, 2015
1 parent c16884a commit ee0b894
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/main/java/hyphenated/djbot/DjService.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,12 @@ public void irc_volume(String sender, String newVolStr) {
return;
}

int oldVolume = volume;
int newVolume;
if("up".equalsIgnoreCase(newVolStr)) {
newVolume = volume + 10;
newVolume = oldVolume + 10;
} else if ("down".equalsIgnoreCase(newVolStr)) {
newVolume = volume - 10;
newVolume = oldVolume - 10;
} else {
try {
newVolume = Integer.parseInt(newVolStr);
Expand All @@ -227,12 +228,20 @@ public void irc_volume(String sender, String newVolStr) {

if (newVolume < 1) {
newVolume = 1;
if(oldVolume == newVolume) {
irc.message(sender + ": volume is already at 1, the minimum");
return;
}
} else if (newVolume > 100) {
newVolume = 100;
if(oldVolume == newVolume) {
irc.message(sender + ": volume is already at 100, the maximum");
return;
}
}
irc.message(sender + ": volume changed from " + volume + " to " + newVolume);
volume = newVolume;

irc.message(sender + ": volume changed from " + oldVolume + " to " + newVolume);
volume = newVolume;
}

public void irc_songs(String sender) {
Expand Down

0 comments on commit ee0b894

Please sign in to comment.