Prevent crash w/ slot codes with no hyphen at all

Using maxplit in the slot code splitting made it resistant to
more than one hyphen, but still failed in case there were no
hyphens at all.  Switch to .partition() to avoid all the
corner cases.

Change-Id: I763ff301b8e8b2af947d9c51a34259965dc95f9f
This commit is contained in:
Thierry Carrez 2018-02-28 10:14:05 +01:00
parent 4d6c4dc7b5
commit 94dcff606f
1 changed files with 2 additions and 2 deletions

View File

@ -153,7 +153,7 @@ class PTGBot(irc.bot.SingleServerIRCBot):
elif adverb == 'location':
self.data.add_location(track, params)
elif adverb == 'book':
room, timeslot = params.split('-', 1)
room, sep, timeslot = params.partition('-')
if self.data.is_slot_valid_and_empty(room, timeslot):
self.data.book(track, room, timeslot)
else:
@ -174,7 +174,7 @@ class PTGBot(irc.bot.SingleServerIRCBot):
self.data.reload()
elif command == 'unbook':
params = str.join(' ', words[1:])
room, timeslot = params.split('-', 1)
room, sep, timeslot = params.partition('-')
self.data.unbook(room, timeslot)
elif command == 'newday':
self.data.new_day_cleanup()