def get_access(target, userlist, line): try: access = int(line[5]) if my_access(target, userlist) == 1000: if access <= 1000: update_access(line[4], access, target, userlist) else: config.confproto.notice(target, "Access must be greater than 1000.") else: config.confproto.notice( target, "Access modification can only be done via root (1000 access) users." ) except ValueError: config.confproto.notice(target, "Access level must be an integer.") return except IndexError: try: if my_access(target, userlist) > 0: show_access(line[4], target) except IndexError: if my_access(target, userlist) > 0: config.confproto.notice( target, "Account %s has access %s." % (get_acc( target, userlist), access_level(target, userlist)))
def add_exempt(target, userlist, line): if access_level(target, userlist) >= get_modify_exempt(): # Check to see if there is an IP address try: theip = line[5] except IndexError: config.confproto.notice( target, "You must provide an IP address to exempt") return # Try to find the time try: newdigit = int(line[6][:-1]) except ValueError: try: if int(line[6]) == 0: newdigit = line[6] else: config.confproto.notice(target, "Invalid time format") return except ValueError: config.confproto.notice(target, "Invalid time format") return # Check for a reason try: newstring = " ".join([line[n] for n in range(7, len(line))]) except IndexError: newstring = "No reason specified" perma = False if line[6][-1] == "s": newtime = newdigit elif line[6][-1] == "m": newtime = newdigit * 60 elif line[6][-1] == "h": newtime = newdigit * 3600 elif line[6][-1] == "d": newtime = newdigit * 86400 elif line[6][-1] == "w": newtime = newdigit * 604800 elif line[6][-1] == "M": newtime = newdigit * 2628000 elif line[6][-1] == "y": newtime = newdigit * 31536000 elif line[6] == "0": newtime = 0 perma = True else: config.confproto.notice(target, "Invalid time format") return account = get_acc(target, userlist) epoch = int(time.time()) expire = epoch + newtime addexempt(target, account, str(theip), epoch, expire, perma, newstring, newtime) else: config.confproto.notice(target, "You lack access to this command.")
def restart(target, userlist, line): try: account = get_acc(target, userlist) newstring = " ".join([line[n] for n in range(4, len(line))]) if access_level(target, userlist) >= get_die(): config.confproto.restart(account, newstring) else: config.confproto.notice(target, "You lack access to this command") except IndexError: config.confproto.notice(target, "Insufficient paramaters for RESTART")
def del_exempt(target, userlist, line): if access_level(target, userlist) >= get_modify_exempt(): try: theip = line[5] account = get_acc(target, userlist) if isIP(theip) or isIPv6(theip): delexempt(target, account, theip) else: config.confproto.notice(target, "You must provide a valid IP address") except IndexError: config.confproto.notice(target, "You must provide a valid IP address") else: config.confproto.notice(target, "You lack access to this command.")
def authme(target, userlist, line): if is_authed(target, userlist): if claim_root(): ourcookie = claim_root() try: theircookie = int(line[4]) except ValueError: config.confproto.notice(target, "Incorrect authcookie") return except IndexError: config.confproto.notice( target, "You must supply a cookie to identify with") return if ourcookie == theircookie: account = get_acc(target, userlist) give_root(account, target) else: config.confproto.notice(target, "Incorrect authcookie") else: config.confproto.notice(target, "The authcookie has already been claimed") else: config.confproto.notice(target, "You must be authenticated with NickServ")