Use NSFW Site List in Phone and Portal

This commit is contained in:
Dragon Fire
2021-02-28 14:47:02 -05:00
parent ca5d3c02d3
commit 85d25cd2d7
7 changed files with 78 additions and 62 deletions
+10
View File
@@ -41,6 +41,7 @@ module.exports = class XiaoClient extends CommandoClient {
this.phone = new PhoneManager(this);
this.activities = activities;
this.leaveMessages = leaveMsgs;
this.adultSiteList = null;
}
async registerFontsIn(filepath) {
@@ -156,6 +157,15 @@ module.exports = class XiaoClient extends CommandoClient {
return buf;
}
async fetchAdultSiteList(force = false) {
if (!force && this.adultSiteList) return this.adultSiteList;
const { text } = await request.get('https://raw.githubusercontent.com/blocklistproject/Lists/master/porn.txt');
this.adultSiteList = text.split('\n')
.filter(site => site && !site.startsWith('#'))
.map(site => site.replace(/^(0.0.0.0 )/, '')); // eslint-disable-line no-control-regex
return this.adultSiteList;
}
fetchReportChannel() {
if (!REPORT_CHANNEL_ID) return null;
return this.channels.fetch(REPORT_CHANNEL_ID);