modulecore.py

changeset 121
ac07779f788d
parent 118
dbf49689af0d
child 124
7b2cd8b1ba86
equal deleted inserted replaced
120:9880bb697149 121:ac07779f788d
160 160
161 try: 161 try:
162 func (**commandObject) 162 func (**commandObject)
163 except Confirmxeption as e: 163 except Confirmxeption as e:
164 if time.time() - g_lastConfirm < 15 and g_confirmCommand != None: 164 if time.time() - g_lastConfirm < 15 and g_confirmCommand != None:
165 command_error ('another confirm is underway') 165 command_error ('''another confirm is underway''')
166 166
167 g_lastConfirm = time.time() 167 g_lastConfirm = time.time()
168 response_function (str (e) + ' (.yes/.no)') 168 response_function (str (e) + ' (.yes/.no)')
169 commandObject['confirmed'] = e.id 169 commandObject['confirmed'] = e.id
170 g_confirmCommand = commandObject 170 g_confirmCommand = commandObject
171 except Exception as e:
172 command_error (str (e))
171 173
172 # 174 #
173 # call_command (bot, message, cmdname, **kvargs) 175 # call_command (bot, message, cmdname, **kvargs)
174 # 176 #
175 # Calls a cobalt command 177 # Calls a cobalt command
320 if arg[-3:] == '...': 322 if arg[-3:] == '...':
321 gotvariadic = True 323 gotvariadic = True
322 arg = arg[0:-3] 324 arg = arg[0:-3]
323 325
324 if gotoptional == False: 326 if gotoptional == False:
325 regex += '\s+' 327 regex += r'\s+'
326 else: 328 else:
327 regex += '\s*' 329 regex += r'\s*'
328 330
329 if gotliteral: 331 if gotliteral:
330 regex += arg 332 regex += arg
331 elif gotoptional: 333 elif gotoptional:
332 if gotvariadic: 334 if gotvariadic:
339 else: 341 else:
340 regex += r'([^ ]+)' 342 regex += r'([^ ]+)'
341 #fi 343 #fi
342 #done 344 #done
343 345
346 if not gotvariadic:
347 regex += r'\s*'
348
344 return '^[^ ]+%s$' % regex 349 return '^[^ ]+%s$' % regex
345 #enddef 350 #enddef

mercurial