Browse Source

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
changes/22/548522/1
Thierry Carrez 3 years ago
parent
commit
94dcff606f
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      ptgbot/bot.py

+ 2
- 2
ptgbot/bot.py 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()


Loading…
Cancel
Save