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

Config options to control the !!nowplaying refreshing #1266

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/main/java/com/jagrosh/jmusicbot/BotConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public class BotConfig
private Path path = null;
private String token, prefix, altprefix, helpWord, playlistsFolder,
successEmoji, warningEmoji, errorEmoji, loadingEmoji, searchingEmoji;
private boolean stayInChannel, songInGame, npImages, updatealerts, useEval, dbots;
private long owner, maxSeconds, aloneTimeUntilStop;
private boolean stayInChannel, songInGame, updateNP, npImages, updatealerts, useEval, dbots;
private long owner, updateNPTime, maxSeconds, aloneTimeUntilStop;
private OnlineStatus status;
private Activity game;
private Config aliases, transforms;
Expand Down Expand Up @@ -83,6 +83,8 @@ public void load()
status = OtherUtil.parseStatus(config.getString("status"));
stayInChannel = config.getBoolean("stayinchannel");
songInGame = config.getBoolean("songinstatus");
updateNP = config.getBoolean("updatenp");
updateNPTime = config.getLong("updatenptime");
npImages = config.getBoolean("npimages");
updatealerts = config.getBoolean("updatealerts");
useEval = config.getBoolean("eval");
Expand Down Expand Up @@ -306,6 +308,16 @@ public boolean useEval()
return useEval;
}

public boolean getUpdateNP()
{
return updateNP;
}

public long getUpdateNPTime()
{
return updateNPTime;
}

public boolean useNPImages()
{
return npImages;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ public NowplayingHandler(Bot bot)

public void init()
{
if(!bot.getConfig().useNPImages())
bot.getThreadpool().scheduleWithFixedDelay(() -> updateAll(), 0, 5, TimeUnit.SECONDS);
if(bot.getConfig().getUpdateNP() && !bot.getConfig().useNPImages())
bot.getThreadpool().scheduleWithFixedDelay(
() -> updateAll(),
0,
bot.getConfig().getUpdateNPTime(),
TimeUnit.SECONDS);
}

public void setLastNPMessage(Message m)
Expand Down
9 changes: 9 additions & 0 deletions src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ searching = "🔎"
help = help


// If you set this, the "nowplaying" command will refresh every n-seconds,
// specified in option "updatenptime" below.
updatenp = true


// This sets the amount of seconds of "nowplaying" refreshing interval.
updatenptime = 5


// If you set this, the "nowplaying" command will show youtube thumbnails
// Note: If you set this to true, the nowplaying boxes will NOT refresh
// This is because refreshing the boxes causes the image to be reloaded
Expand Down