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 more options for how the bot send now playing messages #1898

Merged
merged 4 commits into from May 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 17 additions & 9 deletions config/example_options.ini
Expand Up @@ -66,17 +66,25 @@ AllowUnboundServers = no
# enabled, this option will take priority.
AutojoinChannels =

# Determine which channels the bot is going to output now playing messages to. If this is
# not specified for a server, the bot will output now playing message for manually added
# entry in the channel that users used the command to add that entry. The bot will also
# try to guess where the now playing messages for automatically added entries should go
# if this is not specified for a server, which might not possible in some cases. Specifying
# more than one channel for a server forces the bot to pick only one channel from the list
# to send messages to
# Send direct messages for now playing messages instead of sending them into the guild. They are
# sent to the user who added the media being played. Now playing messages for automatic entries
# are unaffected and follows NowPlayingChannels config. The bot will not delete direct messages.
DMNowPlaying = no

# Disable now playing messages for entries automatically added by the bot, via the autoplaylist.
DisableNowPlayingAutomatic = no

# For now playing messages that are unaffected by DMNowPlaying and DisableNowPlayingAutomatic,
# determine which channels the bot is going to output now playing messages to. If this is not
# specified for a server, now playing message for manually added entries will be sent in the same
# channel that users used the command to add that entry, and now playing messages for automatically
# added entries will be sent to the same channel that the last now playing message was sent to if
# this is not specified for a server if possible. Specifying more than one channel for a server
# forces the bot to pick only one channel from the list to send messages to.
NowPlayingChannels =

# The bot try to delete (or edit) previously sent now playing messages by default. If you
# don't want the bot to delete them (for keeping log of what have been played), turn this
# The bot would try to delete (or edit) previously sent now playing messages by default. If you
# don't want the bot to delete them (for keeping a log of what has been played), turn this
# option off.
DeleteNowPlaying = yes

Expand Down
7 changes: 7 additions & 0 deletions musicbot/bot.py
Expand Up @@ -487,6 +487,13 @@ async def on_player_play(self, player, entry):
entry.title, player.voice_client.channel.name)

if newmsg:
if self.config.dm_nowplaying and author:
await self.safe_send_message(author, newmsg)
return

if self.config.no_nowplaying_auto and not author:
return

guild = player.voice_client.guild
last_np_msg = self.server_specific_data[guild]['last_np_msg']

Expand Down
4 changes: 4 additions & 0 deletions musicbot/config.py
Expand Up @@ -47,6 +47,8 @@ def __init__(self, config_file):
self.bound_channels = config.get('Chat', 'BindToChannels', fallback=ConfigDefaults.bound_channels)
self.unbound_servers = config.getboolean('Chat', 'AllowUnboundServers', fallback=ConfigDefaults.unbound_servers)
self.autojoin_channels = config.get('Chat', 'AutojoinChannels', fallback=ConfigDefaults.autojoin_channels)
self.dm_nowplaying = config.getboolean('Chat', 'DMNowPlaying', fallback=ConfigDefaults.dm_nowplaying)
self.no_nowplaying_auto = config.getboolean('Chat', 'DisableNowPlayingAutomatic', fallback=ConfigDefaults.no_nowplaying_auto)
self.nowplaying_channels = config.get('Chat', 'NowPlayingChannels', fallback=ConfigDefaults.nowplaying_channels)
self.delete_nowplaying = config.getboolean('Chat', 'DeleteNowPlaying', fallback=ConfigDefaults.delete_nowplaying)

Expand Down Expand Up @@ -324,6 +326,8 @@ class ConfigDefaults:
bound_channels = set()
unbound_servers = False
autojoin_channels = set()
dm_nowplaying = False
no_nowplaying_auto = False
nowplaying_channels = set()
delete_nowplaying = True

Expand Down