@2003scape/rsc-censor 中文文档教程

发布于 5年前 浏览 23 项目主页 更新于 3年前

rsc-censor

runescape 经典聊天审查器和缓存修改。 这个审查员是 半智能,可以检测相似的符号和间距。

install

$ npm install @2003scape/rsc-censor # -g for CLI program

cli usage

rsc-censor <command>

Commands:
  rsc-censor censor <archive> <message>     censor message using filters in
                                            archive
  rsc-censor dump-json <archive>            dump JSON files of each censor
                                            section
  rsc-censor pack-json <archive> <files..>  encode and compress JSON files into
                                            filter archive

Options:
  --help     Show help                                                 [boolean]
  --version  Show version number                                       [boolean]
$ rsc-censor censor filter2.jag "you suck"

example

const Censor = require('./src');
const fs = require('fs');

const censor = new Censor();
censor.loadArchive(fs.readFileSync('./filter2.jag'));

console.log(censor.censorMessage('hey you suck! visit dogs.com'))
// hey you ****! visit ********

censor.badWords = censor.badWords.filter(({ word }) => !/suc/i.test(word));
censor.populateBuffers();

console.log(censor.censorMessage('hey you suck! visit dogs.com'))
// hey you suck! visit ********

fs.writeFileSync('./filter3.jag', censor.toArchive());

api

censor = new Censor()

创建一个新的检查器实例。

censor.badWords

一系列的亵渎。

[
    {
        word: 'breast',
        // this allows "abreast" and "breastplate", but not "breast"
        ignore: [
            {
                prefix: 'a',
                postfix: null
            },
            {
                prefix: null,
                postfix: 'p'
            }
        ]
    }
]

censor.hosts

网站列表主机名

[
    {
        word: 'aol',
        // allows for "gaols" but not "go aol"
        ignore: [
            {
                prefix: 'g',
                postfix: 's'
            }
            // ...
        ]
    }
]

censor.tlds

TLD 数组。

[
    {
        word: 'com',
        type: 3
    }
]

censor.fragments

单词片段数组。 这些似乎是用来修复检查器的 贪婪和 星号字符太多。

censor.loadArchive(buffer)

加载过滤器 jag 存档缓冲区。

censor.populateBuffers()

将对内部属性的更改应用到过滤器实例。

censor.censorMessage(message)

返回经过审查的字符串。

censor.toArchive()

返回过滤器 jag 存档。

license

版权所有 2019 2003Scape Team

本程序是免费软件:您可以重新分发它和/或修改它 GNU Affero 通用公共许可证的条款由 自由软件基金会,许可证的第 3 版,或(由您选择) 任何更高版本。

分发该程序是希望它有用,但没有任何 保修单; 甚至没有适销性或适用性的默示保证 特殊用途。 有关详细信息,请参阅 GNU Affero 通用公共许可证。

您应该已经收到 GNU Affero 通用公共许可证的副本 有了这个程序。 如果没有,请参阅 http://www.gnu.org/licenses/。

rsc-censor

runescape classic chat censor and cache modification. this censor is semi-intelligent and can detect similar looking symbols and spacing.

install

$ npm install @2003scape/rsc-censor # -g for CLI program

cli usage

rsc-censor <command>

Commands:
  rsc-censor censor <archive> <message>     censor message using filters in
                                            archive
  rsc-censor dump-json <archive>            dump JSON files of each censor
                                            section
  rsc-censor pack-json <archive> <files..>  encode and compress JSON files into
                                            filter archive

Options:
  --help     Show help                                                 [boolean]
  --version  Show version number                                       [boolean]
$ rsc-censor censor filter2.jag "you suck"

example

const Censor = require('./src');
const fs = require('fs');

const censor = new Censor();
censor.loadArchive(fs.readFileSync('./filter2.jag'));

console.log(censor.censorMessage('hey you suck! visit dogs.com'))
// hey you ****! visit ********

censor.badWords = censor.badWords.filter(({ word }) => !/suc/i.test(word));
censor.populateBuffers();

console.log(censor.censorMessage('hey you suck! visit dogs.com'))
// hey you suck! visit ********

fs.writeFileSync('./filter3.jag', censor.toArchive());

api

censor = new Censor()

create a new censor instance.

censor.badWords

array of profanities.

[
    {
        word: 'breast',
        // this allows "abreast" and "breastplate", but not "breast"
        ignore: [
            {
                prefix: 'a',
                postfix: null
            },
            {
                prefix: null,
                postfix: 'p'
            }
        ]
    }
]

censor.hosts

array of webiste hostnames.

[
    {
        word: 'aol',
        // allows for "gaols" but not "go aol"
        ignore: [
            {
                prefix: 'g',
                postfix: 's'
            }
            // ...
        ]
    }
]

censor.tlds

array of TLDs.

[
    {
        word: 'com',
        type: 3
    }
]

censor.fragments

array of word fragments. these seem to be used to fix the censor when it's greedy and asterisks too many characters.

censor.loadArchive(buffer)

load a filter jag archive buffer.

censor.populateBuffers()

apply changes to internal properties to the filter instance.

censor.censorMessage(message)

return a censored string.

censor.toArchive()

return a filter jag archive.

license

Copyright 2019 2003Scape Team

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see http://www.gnu.org/licenses/.

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文