Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- case "sing":
- if (!BotUtils.checkMinrank(cmd, uid)) {
- return;
- }
- final String search = Utils.get("http://search.azlyrics.com/search.php?q=" + msg.replace(' ', '+'));
- final String song1 = Utils.getBetween(search, "<td class=\"text-left visitedlyr\">", " by ");
- if (!song1.substring(0, 2).equals("1.")) {
- XatUtils.respond("The song \"" + msg + "\" was not found.", type, uid);
- return;
- }
- final String song2 = Utils.getBetween(song1, "<a href=\"", "\" target=\"_blank");
- final String lyrics[] = Utils.getBetween(Utils.get(song2),
- "<!-- Usage of azlyrics.com content by any third-party lyrics provider is prohibited by our licensing agreement. Sorry about that. -->",
- "</div>").split("<br>");
- Thread song = new Thread(() -> {
- String lastLyric = "";
- for (String lyric : lyrics) {
- lyric = lyric.trim();
- try {
- System.out.println(PacketHandler.PACKET);
- if (PacketHandler.PACKET.containsKey("t")
- && (PacketHandler.PACKET.get("t").toLowerCase().indexOf("stop thread") != -1)) {
- XatUtils.respond("I have stopped singing", type, uid0);
- Thread.currentThread().interrupt();
- return;
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- if (Thread.interrupted())
- return;
- if (lyric.equals(lastLyric)) {
- lastLyric = lyric;
- lyric += " ";
- }
- if (lyric.equals("")) {
- continue;
- }
- try {
- XatUtils.sendMessage(lyric);
- lastLyric = lyric;
- Thread.sleep(1000);
- } catch (final Exception e1) {
- return;
- }
- }
- try {
- XatUtils.respond("That was: \"" + Utils.getBetween(Utils.get(song2), "song: \"", "\",") + "\" by \""
- + Utils.getBetween(Utils.get(song2), "artist: \"", "\",") + "\"", type, uid0);
- } catch (Exception e) {
- e.printStackTrace();
- }
- });
- song.start();
- break;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement