Skip to content

Commit

Permalink
fixed a major bug that prevents playing from urls
Browse files Browse the repository at this point in the history
  • Loading branch information
Tzesh committed Oct 12, 2023
1 parent 30df512 commit da6902d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ dependencies {

compileJava.options.encoding = 'UTF-8'
mainClassName = 'com.tzesh.tzebot.Main'
version '4.0'
version '4.01'
6 changes: 6 additions & 0 deletions src/main/java/com/tzesh/tzebot/commands/music/Play.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import static com.tzesh.tzebot.core.LanguageManager.getMessage;
import static com.tzesh.tzebot.core.music.constants.MusicCommonConstants.DEFAULT_VOLUME;
import static com.tzesh.tzebot.utils.InputControlHelper.isUrl;
import static com.tzesh.tzebot.utils.InputControlHelper.isYouTubeUrl;

/**
* A class to manage the play command
Expand All @@ -33,6 +34,11 @@ protected void initializePreRequisites() {
addPreRequisite(isSelfMemberHasPermission, "join.cannotjoin.setTitle", "join.cannotjoin.setDescription");
if (!isSelfMemberHasPermission) return;

boolean isYouTubeUrl = isYouTubeUrl(rawMessage);
if (isYouTubeUrl) {
this.searchResult = rawMessage;
return;
}
this.searchResult = youTube.searchAudio(rawMessage);
boolean isFound = isUrl(rawMessage) || searchResult != null;
addPreRequisite(isFound, "play.noresults.setTitle", "play.noresults.setDescription");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
*/
public class CommonConstants {
public static String DEFAULT_PREFIX = ".";
public static Double CURRENT_VERSION = 4.0;
public static Double CURRENT_VERSION = 4.01;
public static int SAVE_INTERVAL = 30;
}
5 changes: 5 additions & 0 deletions src/main/java/com/tzesh/tzebot/utils/InputControlHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,9 @@ public static boolean isUrl(String input) {
return false;
}
}

public static boolean isYouTubeUrl(String input) {
if (!isUrl(input)) return false;
return input.contains("youtube.com") || input.contains("youtu.be");
}
}

0 comments on commit da6902d

Please sign in to comment.