def add_cmd_permission(self, cmd, mask, regexpify=True): """ Creates a regular expression from the mask and adds it to the list of allowed regexps for the cmd. mask is an IRC mask, and will be changed into a corresponding regular expression. """ mask = regexpify(mask) m = re.compile(mask) self.command_masks.setdefault(cmd, []).append(m)
def rm_cmd_permission(self, cmd, mask): """ Creates a regular expression from the mask, and removes the permission for that expression from cmd's list. mask is an IRC mask, and will be changed into a corresponding regular expression. """ mask = regexpify(mask) if cmd in self.command_masks: for index, regexp in enumerate(self.command_masks[cmd]): if regexp.pattern == mask: del self.command_masks[cmd][index] break