mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-07 23:05:04 +02:00
Use NSFW Site List in Phone and Portal
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const { stripIndents } = require('common-tags');
|
||||
const moment = require('moment');
|
||||
require('moment-duration-format');
|
||||
const { shorten, stripInvites, preventURLEmbeds, verify } = require('../../util/Util');
|
||||
const { shorten, stripInvites, preventURLEmbeds, stripNSFWURLs, verify } = require('../../util/Util');
|
||||
|
||||
module.exports = class PhoneCall {
|
||||
constructor(client, startUser, origin, recipient, adminCall) {
|
||||
@@ -146,17 +146,19 @@ module.exports = class PhoneCall {
|
||||
setTimeout(() => this.ratelimitMeters.set(msg.author.id, 0), 5000);
|
||||
}
|
||||
}
|
||||
const attachments = hasImage ? msg.attachments.map(a => this.cleanContent(a.url)).join('\n') : null;
|
||||
const attachments = hasImage ? msg.attachments.map(a => this.cleanContent(a.url, channel.nsfw)).join('\n') : null;
|
||||
if (!hasText && hasImage) return channel.send(`☎️ **${msg.author.tag}:**\n${attachments}`);
|
||||
if (!hasText && hasEmbed) return channel.send(`☎️ **${msg.author.tag}** sent an embed.`);
|
||||
const content = msg.content.length > 1000 ? `${shorten(msg.content, 500)} (Message too long)` : msg.content;
|
||||
return channel.send(`☎️ **${msg.author.tag}:** ${this.cleanContent(content)}\n${attachments || ''}`.trim());
|
||||
return channel.send(
|
||||
`☎️ **${msg.author.tag}:** ${this.cleanContent(content, channel.nsfw)}\n${attachments || ''}`.trim()
|
||||
);
|
||||
}
|
||||
|
||||
sendVoicemail(channel, msg) {
|
||||
return channel.send(stripIndents`
|
||||
☎️ New Voicemail from **${this.originDM ? `${this.startUser.tag}'s DMs` : this.origin.guild.name}:**
|
||||
**${msg.author.tag}:** ${this.cleanContent(msg.content)}
|
||||
**${msg.author.tag}:** ${this.cleanContent(msg.content, channel.nsfw)}
|
||||
`);
|
||||
}
|
||||
|
||||
@@ -170,8 +172,9 @@ module.exports = class PhoneCall {
|
||||
return moment.duration(Date.now() - this.timeStarted).format('hh[h]mm[m]ss[s]');
|
||||
}
|
||||
|
||||
cleanContent(str) {
|
||||
cleanContent(str, nsfw) {
|
||||
str = stripInvites(str);
|
||||
if (!nsfw && this.client.adultSiteList) str = stripNSFWURLs(str, this.client.adultSiteList);
|
||||
str = preventURLEmbeds(str);
|
||||
return str;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user