def onInsertBan(cn, args): '''@description Intert ban for ip address @usage <ip> <seconds> (reason)''' p = player(cn) args = args.split(' ') if len(args) < 2: raise UsageError('ip length (reason)') else: ip = ipStringToLong(args[0]) length = int(args[1]) try: reason = args[2] except IndexError: reason = 'Unspecified reason' expiration = time.time() + length newban = Ban(ip, expiration, reason, 'Unnamed', 0, 'Unnamed', time.time()) session.add(newban) session.commit() p.message(info('Inserted ban for %s for %i seconds for %s.' % (ipLongToString(ip), length, reason)))
def onInsertBan(cn, args): '''@description Intert ban for ip address @usage <ip> <seconds> (reason)''' p = player(cn) args = args.split(' ') if len(args) < 2: raise UsageError('ip length (reason)') else: ip = ipStringToLong(args[0]) length = int(args[1]) try: reason = args[2] except IndexError: reason = 'Unspecified reason' expiration = time.time() + length newban = Ban(ip, expiration, reason, 'Unnamed', 0, 'Unnamed', time.time()) session.add(newban) session.commit() p.message( info('Inserted ban for %s for %i seconds for %s.' % (ipLongToString(ip), length, reason)))
def playerByIpString(ip): '''Return Player instance with matching string ip''' return playerByIpLong(ipStringToLong(ip))