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:
parent
4d6c4dc7b5
commit
94dcff606f
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue