Skip to content

Commit

Permalink
General bugfixes (#1789)
Browse files Browse the repository at this point in the history
* quotation marks are important

Why we don't encounter this issue before is miracle.

* Yet another rewrite stuff

* In case some unlikely situations happen

* This spliting method make more sense

close #1790
  • Loading branch information
TheerapakG authored and Jayden Bailey committed Dec 6, 2018
1 parent be78ae8 commit b1715f6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
8 changes: 4 additions & 4 deletions musicbot/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,14 @@ def run_checks(self):

if self.bound_channels:
try:
self.bound_channels = set(x for x in self.bound_channels.split() if x)
self.bound_channels = set(x for x in self.bound_channels.replace(',', ' ').split() if x)
except:
log.warning("BindToChannels data is invalid, will not bind to any channels")
self.bound_channels = set()

if self.autojoin_channels:
try:
self.autojoin_channels = set(x for x in self.autojoin_channels.split() if x)
self.autojoin_channels = set(x for x in self.autojoin_channels.replace(',', ' ').split() if x)
except:
log.warning("AutojoinChannels data is invalid, will not autojoin any channels")
self.autojoin_channels = set()
Expand All @@ -184,9 +184,9 @@ def run_checks(self):

self.delete_invoking = self.delete_invoking and self.delete_messages

self.bound_channels = set(int(item.replace(',', ' ').strip()) for item in self.bound_channels)
self.bound_channels = set(int(item) for item in self.bound_channels)

self.autojoin_channels = set(int(item.replace(',', ' ').strip()) for item in self.autojoin_channels)
self.autojoin_channels = set(int(item) for item in self.autojoin_channels)

ap_path, ap_name = os.path.split(self.auto_playlist_file)
apn_name, apn_ext = os.path.splitext(ap_name)
Expand Down
15 changes: 11 additions & 4 deletions musicbot/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,17 @@ def _deserialize(cls, data, playlist=None):

# TODO: Better [name] fallbacks
if 'channel' in data['meta']:
meta['channel'] = playlist.bot.get_channel(data['meta']['channel']['id'])

if 'author' in data['meta']:
meta['author'] = meta['channel'].guild.get_member(data['meta']['author']['id'])
# int() it because persistent queue from pre-rewrite days saved ids as strings
meta['channel'] = playlist.bot.get_channel(int(data['meta']['channel']['id']))
if not meta['channel']:
log.warning('Cannot find channel in an entry loaded from persistent queue. Chennel id: {}'.format(data['meta']['channel']['id']))
meta.pop('channel')
elif 'author' in data['meta']:
# int() it because persistent queue from pre-rewrite days saved ids as strings
meta['author'] = meta['channel'].guild.get_member(int(data['meta']['author']['id']))
if not meta['author']:
log.warning('Cannot find author in an entry loaded from persistent queue. Author id: {}'.format(data['meta']['author']['id']))
meta.pop('author')

entry = cls(playlist, url, title, duration, expected_filename, **meta)
entry.filename = filename
Expand Down
4 changes: 2 additions & 2 deletions update.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ 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 -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))
raise OSError("Could not update dependencies. You will need to run '\"{0}\" -m pip install -U -r requirements.txt' yourself.".format(sys.executable))

def finalize():
try:
Expand Down

0 comments on commit b1715f6

Please sign in to comment.