Wblist - 黑白名单
wblist 模块提供了黑白名单管理功能,包含 blacklist 和 whitelist 两个命名空间,分别用于管理服务器的黑名单和白名单 。
版本要求
Wblist API 在 SDK v0.3.2 中引入。需要 EasyBot 2.1.0-dev.6 或更高版本。
Blacklist - 黑名单
blacklist 命名空间提供了黑名单的查询、添加和移除功能。
API 参考
declare namespace blacklist {
function InBlackList(accountId: string): boolean;
function RemoveBlackList(userId: string, opAccount: string, opName: string, opGroupId: string): Promise;
function AddBlackList(userId: string, opAccount: string, opName: string, opGroupId: string, banReason: string): Promise;
}
InBlackList()
功能描述:检查指定账号是否在黑名单中。
语法:
blacklist.InBlackList(accountId: string): boolean
参数:
accountId:要检查的账号 ID
返回值:true 在黑名单中,false 不在
使用示例:
if (blacklist.InBlackList("123456789")) {
logger.info("该账号已被封禁");
}
AddBlackList()
功能描述:将账号添加到黑名单。
语法:
blacklist.AddBlackList(userId: string, opAccount: string, opName: string, opGroupId: string, banReason: string): Promise
参数:
userId:被封禁的账号 IDopAccount:操作者账号 IDopName:操作者名称opGroupId:所属群号banReason:封禁原因
使用示例:
await blacklist.AddBlackList(
"123456789", // 被封禁账号
"admin_001", // 操作者ID
"管理员", // 操作者名称
"987654321", // 群号
"发布违规内容" // 原因
);
logger.info("已添加到黑名单");
RemoveBlackList()
功能描述:将账号从黑名单中移除。
语法:
blacklist.RemoveBlackList(userId: string, opAccount: string, opName: string, opGroupId: string): Promise
参数:
userId:要解封的账号 IDopAccount:操作者账号 IDopName:操作者名称opGroupId:所属群号
使用示例:
await blacklist.RemoveBlackList(
"123456789",
"admin_001",
"管理员",
"987654321"
);
logger.info("已从黑名单移除");