diff --git a/tipbot/modules/bookie.py b/tipbot/modules/bookie.py index f69a392..ca89c02 100644 --- a/tipbot/modules/bookie.py +++ b/tipbot/modules/bookie.py @@ -52,11 +52,6 @@ def Bookie(link,cmd): link.send('usage: !bookie [...]') return - active_books = GetActiveBooks() - if active_books and name in active_books.values(): - link.send('A book is already active with that name') - return - book_index=long(redis_get('bookie:last_book') or 0) book_index += 1 tname = "bookie:%d" % book_index @@ -83,10 +78,18 @@ def GetBookIndex(cmd,base_arg_count): if GetParam(cmd,base_arg_count+1): name = GetParam(cmd,1) - if not name in active_books.values(): - return None, 'Book %s not found' % name - book_index = long(active_books.keys()[active_books.values().index(name)]) - parm_offset = 1 + if name[0] == '#': + if not name[1:] in active_books.keys(): + return None, 'Book %s not found' % name + book_index = long(active_books.keys()[active_books.keys().index(name[1:])]) + parm_offset = 1 + else: + if not name in active_books.values(): + return None, 'Book %s not found' % name + if active_books.values().count(name) > 1: + return None, 'There are several books named %s, use its #N id instead' % name + book_index = long(active_books.keys()[active_books.values().index(name)]) + parm_offset = 1 else: if len(active_books) > 1: return None, 'There are several open books: %s' % ", ".join(active_books.values()) @@ -199,7 +202,7 @@ def Book(link,cmd): link.send('The book is empty') return - for book_index in active_books.keys(): + for book_index in sorted(active_books.keys()): book_index = long(book_index) tname='bookie:%s' % book_index try: @@ -405,7 +408,7 @@ RegisterCommand({ RegisterCommand({ 'module': __name__, 'name': 'cancel', - 'parms': '[]', + 'parms': '[ | #]', 'function': Cancel, 'admin': True, 'registered': True, @@ -421,7 +424,7 @@ RegisterCommand({ RegisterCommand({ 'module': __name__, 'name': 'close', - 'parms': '[]', + 'parms': '[ | #]', 'function': Close, 'admin': True, 'registered': True, @@ -430,7 +433,7 @@ RegisterCommand({ RegisterCommand({ 'module': __name__, 'name': 'schedule_close', - 'parms': '[] ', + 'parms': '[ | #] ', 'function': ScheduleClose, 'admin': True, 'registered': True, @@ -439,7 +442,7 @@ RegisterCommand({ RegisterCommand({ 'module': __name__, 'name': 'result', - 'parms': '[] ', + 'parms': '[ | #] ', 'function': Result, 'admin': True, 'registered': True, @@ -448,7 +451,7 @@ RegisterCommand({ RegisterCommand({ 'module': __name__, 'name': 'bet', - 'parms': '[] ', + 'parms': '[ | #] ', 'function': Bet, 'registered': True, 'help': "bet some %s on a particular outcome" % coinspecs.name