Skip to content
This repository has been archived by the owner on Aug 29, 2021. It is now read-only.

Commit

Permalink
Merge pull request #41 from Just-Some-Bots/review
Browse files Browse the repository at this point in the history
Review
  • Loading branch information
AutumnClove committed Jul 24, 2019
2 parents 120eb28 + af87d5e commit ddc1ccf
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
5 changes: 5 additions & 0 deletions config/example_options.ini
Expand Up @@ -44,6 +44,11 @@ OwnerID = auto
# are familiar with Python code.
DevIDs =

# This option determines if the bot should respond to other any other bots
# put bot ID's here seperated with spaces
# Any id you put here the bot WILL respond to.
BotExceptionIDs =

[Chat]
# Determines the prefix that must be used before commands in the Discord chat.
# e.g if you set this to *, the play command would be triggered using *play.
Expand Down
4 changes: 4 additions & 0 deletions musicbot/bot.py
Expand Up @@ -2636,6 +2636,10 @@ async def on_message(self, message):
log.warning("Ignoring command from myself ({})".format(message.content))
return

if message.author == message.author.bot and message.author.id not in self.config.bot_exception_ids:
log.warning("Ignoring command from other bot ({})".format(message.content))
return

if (not isinstance(message.channel, discord.abc.GuildChannel)) and (not isinstance(message.channel, discord.abc.PrivateChannel)):
return

Expand Down
9 changes: 9 additions & 0 deletions musicbot/config.py
Expand Up @@ -42,6 +42,7 @@ def __init__(self, config_file):

self.owner_id = config.get('Permissions', 'OwnerID', fallback=ConfigDefaults.owner_id)
self.dev_ids = config.get('Permissions', 'DevIDs', fallback=ConfigDefaults.dev_ids)
self.bot_exception_ids = config.get("Permissions", "BotExceptionIDs", fallback=ConfigDefaults.bot_exception_ids)

self.command_prefix = config.get('Chat', 'CommandPrefix', fallback=ConfigDefaults.command_prefix)
self.bound_channels = config.get('Chat', 'BindToChannels', fallback=ConfigDefaults.bound_channels)
Expand Down Expand Up @@ -169,6 +170,13 @@ def run_checks(self):
preface=self._confpreface
)

if self.bot_exception_ids:
try:
self.bot_exception_ids = set(int(x) for x in self.bot_exception_ids.replace(',', ' ').split())
except:
log.warning("BotExceptionIDs data is invalid, will ignore all bots")
self.bot_exception_ids = set()

if self.bound_channels:
try:
self.bound_channels = set(x for x in self.bound_channels.replace(',', ' ').split() if x)
Expand Down Expand Up @@ -318,6 +326,7 @@ class ConfigDefaults:

token = None
dev_ids = set()
bot_exception_ids = set()

spotify_clientid = None
spotify_clientsecret = None
Expand Down
5 changes: 4 additions & 1 deletion musicbot/player.py
Expand Up @@ -110,6 +110,9 @@ def read(self):
def get_progress(self):
return self.progress * 0.02

def cleanup(self):
self._source.cleanup()


class MusicPlayer(EventEmitter, Serializable):
def __init__(self, bot, voice_client, playlist):
Expand Down Expand Up @@ -223,7 +226,7 @@ def _playback_finished(self, error=None):
break
except PermissionError as e:
if e.winerror == 32: # File is in use
log.error('Can\'t delete file, it is currently in use: {0}').format(filename)
log.error('Can\'t delete file, it is currently in use: {0}'.format(filename))
except FileNotFoundError:
log.debug('Could not find delete {} as it was not found. Skipping.'.format(filename), exc_info=True)
break
Expand Down
2 changes: 1 addition & 1 deletion update.py
Expand Up @@ -14,7 +14,7 @@ def update_deps():
print("Attempting to update dependencies...")

try:
subprocess.check_call('"{}" -m pip install -U -r requirements.txt'.format(sys.executable), shell=True)
subprocess.check_call('"{}" -m pip install --no-warn-script-location --user -U -r requirements.txt'.format(sys.executable), shell=True)
except subprocess.CalledProcessError:
raise OSError("Could not update dependencies. You will need to run '\"{0}\" -m pip install -U -r requirements.txt' yourself.".format(sys.executable))

Expand Down

0 comments on commit ddc1ccf

Please sign in to comment.