Skip to content
This repository was archived by the owner on Oct 9, 2025. It is now read-only.

Commit c839aaa

Browse files
committed
feat: remove legacy profanity filter
1 parent f81c60c commit c839aaa

24 files changed

+78
-927
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
44
# patreon: # Replace with a single Patreon username
55
# open_collective: # Replace with a single Open Collective username
6-
ko_fi: dev737
6+
ko_fi: interchat
77
# tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
88
# community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
99
# liberapay: # Replace with a single Liberapay username

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ A powerful Discord bot for easy and real-time chatting hubs across multiple Disc
5151
3. Connect a channel to a hub containing many other discord servers using the `/hub join` command.
5252
4. Start chatting across servers!
5353

54-
For detailed instructions, check out our [Donate](https://ko-fi.com/dev737).
54+
For detailed instructions, check out our [Donate](https://ko-fi.com/interchat).
5555

5656
## 💻 Self-Hosting
5757

locales/en.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ connection:
109109
connected: Connected
110110
emColor: Embed Color
111111
compact: Compact Mode
112-
profanity: Profanity Filter
113112
footer: Use the button & dropdown below to manage your connection.
114113
selects:
115114
placeholder: '🛠️ Select an option to edit this connection'
@@ -119,7 +118,7 @@ connection:
119118
120119
Unpaused connection for {channel}! Messages from the hub will start coming into the channel and you can send messages to the hub again.
121120
tips: |
122-
**💡 Tip:** Use {pause_cmd} to pause the connection or {edit_cmd} to set embed colors, toggle profanity filter, and more.
121+
**💡 Tip:** Use {pause_cmd} to pause the connection or {edit_cmd} to set embed colors, invite to your server and more.
123122
paused:
124123
desc: |
125124
### {clock_emoji} Paused Connection
@@ -353,9 +352,6 @@ hub:
353352
modLogs:
354353
label: Mod Logs
355354
description: Log Moderation actions. (eg. blacklist, message deletes, etc.)
356-
profanity:
357-
label: Profanity Filter
358-
description: Log messages that are caught by the profanity filter.
359355
joinLeaves:
360356
label: Join/Leave
361357
description: Log when a server joins or leaves this hub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"prepare": "husky"
2020
},
2121
"sponsor": {
22-
"url": "https://ko-fi.com/dev737"
22+
"url": "https://ko-fi.com/interchat"
2323
},
2424
"type": "module",
2525
"dependencies": {

src/api/index.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@
1515
* along with InterChat. If not, see <https://www.gnu.org/licenses/>.
1616
*/
1717

18-
import { Hono } from 'hono';
1918
import { VoteManager } from '#src/managers/VoteManager.js';
2019
import Constants from '#src/utils/Constants.js';
20+
import { handleError } from '#src/utils/Utils.js';
2121
import Logger from '#utils/Logger.js';
2222
import { serve } from '@hono/node-server';
2323
import {
2424
Collection,
2525
WebhookClient,
2626
type WebhookMessageCreateOptions,
2727
} from 'discord.js';
28-
import { handleError } from '#src/utils/Utils.js';
28+
import { Hono } from 'hono';
2929

3030
export const webhookMap = new Collection<string, WebhookClient>();
3131

@@ -46,7 +46,6 @@ export const startApi = () => {
4646
data: WebhookMessageCreateOptions;
4747
}>();
4848

49-
const start = performance.now();
5049
let client = webhookMap.get(body.webhookUrl);
5150
if (!client) {
5251
client = new WebhookClient({ url: body.webhookUrl });
@@ -55,7 +54,6 @@ export const startApi = () => {
5554

5655
try {
5756
const res = await client.send(body.data);
58-
Logger.info(`Webhook message sent in ${performance.now() - start}ms`);
5957
return c.json({ data: res });
6058
}
6159
catch (err) {
@@ -64,7 +62,7 @@ export const startApi = () => {
6462
}
6563
});
6664

67-
app.all('*', (c) => c.text('404!', 404));
65+
app.all('*', (c) => c.redirect(Constants.Links.Website));
6866

6967
serve({ fetch: app.fetch, port: Number(process.env.PORT || 3000) });
7068
Logger.info(`API server started on port ${process.env.PORT || 3000}`);

src/commands/Main/connection/edit.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default class ConnectionEditSubcommand extends BaseCommand {
5151
super({
5252
name: 'edit',
5353
description:
54-
'📝 Set embed colors, profanity filter, compact mode and more!',
54+
'📝 Set embed colors, compact mode and more!',
5555
types: { slash: true, prefix: true },
5656
options: [
5757
{
@@ -238,13 +238,6 @@ export default class ConnectionEditSubcommand extends BaseCommand {
238238
await updateConnection({ channelId }, { compact: !connection.compact });
239239
break;
240240

241-
case 'profanity':
242-
await updateConnection(
243-
{ channelId },
244-
{ profFilter: !connection.profFilter },
245-
);
246-
break;
247-
248241
case 'invite': {
249242
const modal = new ModalBuilder()
250243
.setTitle('Add Invite Link')

src/commands/Main/editMsg.ts

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ import { CustomID } from '#utils/CustomID.js';
4747
import db from '#utils/Db.js';
4848
import { getAttachmentURL } from '#utils/ImageUtils.js';
4949
import { t } from '#utils/Locale.js';
50-
import { censor } from '#utils/ProfanityUtils.js';
5150
import { containsInviteLinks, fetchUserLocale, handleError, replaceLinks } from '#utils/Utils.js';
5251

5352
interface ImageUrls {
@@ -190,8 +189,8 @@ export default class EditMessage extends BaseCommand {
190189

191190
// Prepare the new message contents and embeds
192191
const imageURLs = await this.getImageURLs(target, mode, messageToEdit);
193-
const newContents = this.getCompactContents(messageToEdit, imageURLs);
194-
const newEmbeds = await this.buildEmbeds(target, mode, messageToEdit, {
192+
const newContent = this.getCompactContents(messageToEdit, imageURLs);
193+
const newEmbed = await this.buildEmbeds(target, mode, messageToEdit, {
195194
guildId: originalMsgData.guildId,
196195
user: interaction.user,
197196
imageURLs,
@@ -217,10 +216,10 @@ export default class EditMessage extends BaseCommand {
217216
let content: string | null = null;
218217
let embeds: EmbedBuilder[] = [];
219218
if (msg.mode === ConnectionMode.Embed) {
220-
embeds = connection.profFilter ? [newEmbeds.censored] : [newEmbeds.normal];
219+
embeds = [newEmbed];
221220
}
222221
else {
223-
content = connection.profFilter ? newContents.censored : newContents.normal;
222+
content = newContent;
224223
}
225224

226225
// Edit the message
@@ -317,13 +316,7 @@ export default class EditMessage extends BaseCommand {
317316
)
318317
.setFooter({ text: `Server: ${guild?.name}` });
319318
}
320-
321-
const censored = EmbedBuilder.from({
322-
...embed.data,
323-
description: censor(embedContent),
324-
});
325-
326-
return { normal: embed, censored };
319+
return embed;
327320
}
328321

329322
private sanitizeMessage(content: string, settings: SerializedHubSettings) {
@@ -339,6 +332,6 @@ export default class EditMessage extends BaseCommand {
339332
compactMsg = compactMsg.replace(imageUrls.oldURL, imageUrls.newURL);
340333
}
341334

342-
return { normal: compactMsg, censored: censor(compactMsg) };
335+
return compactMsg;
343336
}
344337
}

src/commands/Main/hub/config/logging.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -289,12 +289,6 @@ export default class HubConfigLoggingSubcommand extends BaseCommand {
289289
description: t('hub.manage.logs.modLogs.description', locale),
290290
emoji: '👮',
291291
},
292-
{
293-
label: t('hub.manage.logs.profanity.label', locale),
294-
value: 'profanity',
295-
description: t('hub.manage.logs.profanity.description', locale),
296-
emoji: '🤬',
297-
},
298292
{
299293
label: t('hub.manage.logs.networkAlerts.label', locale),
300294
value: 'networkAlerts',

src/managers/ConnectionManager.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ export default class ConnectionManager {
9494
});
9595
}
9696

97-
async setProfanityFilter(profFilter: boolean): Promise<void> {
98-
await this.updateConnectionIfExists({ profFilter });
99-
}
100-
10197
// Private helper methods
10298
private buildCacheKey(hubId: string): string {
10399
return `${RedisKeys.Hub}:${hubId}:connections`;

src/managers/InfractionManager.ts

Lines changed: 15 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,11 @@
1616
*/
1717

1818
import { isDate } from 'node:util/types';
19-
import type {
20-
Infraction,
21-
InfractionStatus,
22-
InfractionType,
23-
Prisma,
24-
} from '@prisma/client';
19+
import type { Infraction, InfractionStatus, InfractionType, Prisma } from '@prisma/client';
2520
import type { Client, Snowflake, User } from 'discord.js';
2621
import { HubService } from '#src/services/HubService.js';
2722
import db from '#src/utils/Db.js';
28-
import {
29-
logServerUnblacklist,
30-
logUserUnblacklist,
31-
} from '#src/utils/hub/logger/ModLogs.js';
23+
import { logServerUnblacklist, logUserUnblacklist } from '#src/utils/hub/logger/ModLogs.js';
3224
import type { ConvertDatesToString } from '#types/Utils.d.ts';
3325
import { CacheManager } from '#src/managers/CacheManager.js';
3426
import getRedis from '#src/utils/Redis.js';
@@ -92,11 +84,7 @@ export default class InfractionManager {
9284
filter: { type: InfractionType; hubId: string; status?: InfractionStatus },
9385
data: Prisma.InfractionUpdateInput,
9486
) {
95-
const infraction = await this.fetchInfraction(
96-
filter.type,
97-
filter.hubId,
98-
filter.status,
99-
);
87+
const infraction = await this.fetchInfraction(filter.type, filter.hubId, filter.status);
10088
if (!infraction) return null;
10189

10290
const updated = await db.infraction.update({
@@ -121,27 +109,20 @@ export default class InfractionManager {
121109
});
122110
}
123111

124-
public async getHubInfractions(
125-
hubId: string,
126-
opts?: { type?: InfractionType; count?: number },
127-
) {
112+
public async getHubInfractions(hubId: string, opts?: { type?: InfractionType; count?: number }) {
128113
let infractionsArr =
129-
(await this.cacheManager.get(
130-
`${this.targetId}:${hubId}`,
131-
async () => await this.queryEntityInfractions(hubId),
132-
)) ?? [];
114+
(await this.cacheManager.get(
115+
`${this.targetId}:${hubId}`,
116+
async () => await this.queryEntityInfractions(hubId),
117+
)) ?? [];
133118

134119
if (opts?.type) infractionsArr = infractionsArr.filter((i) => i.type === opts.type);
135120
if (opts?.count) infractionsArr = infractionsArr.slice(0, opts.count);
136121

137122
return this.updateInfractionDates(infractionsArr);
138123
}
139124

140-
public async fetchInfraction(
141-
type: InfractionType,
142-
hubId: string,
143-
status?: InfractionStatus,
144-
) {
125+
public async fetchInfraction(type: InfractionType, hubId: string, status?: InfractionStatus) {
145126
const infractions = await this.getHubInfractions(hubId, { type });
146127
const infraction = infractions.find(
147128
(i) => (status ? i.status === status : true) && i.type === type,
@@ -155,10 +136,7 @@ export default class InfractionManager {
155136
hubId: string,
156137
status: Exclude<InfractionStatus, 'ACTIVE'> = 'REVOKED',
157138
) {
158-
const revoked = await this.updateInfraction(
159-
{ type, hubId, status: 'ACTIVE' },
160-
{ status },
161-
);
139+
const revoked = await this.updateInfraction({ type, hubId, status: 'ACTIVE' }, { status });
162140
return revoked;
163141
}
164142

@@ -196,9 +174,9 @@ export default class InfractionManager {
196174
protected async cacheEntity(entity: Infraction) {
197175
const entitySnowflake = entity.userId ?? entity.serverId;
198176
const key = this.getKey(entitySnowflake as string, entity.hubId);
199-
const existing = (
200-
await this.getHubInfractions(entity.hubId, { type: entity.type })
201-
).filter((i) => i.id !== entity.id);
177+
const existing = (await this.getHubInfractions(entity.hubId, { type: entity.type })).filter(
178+
(i) => i.id !== entity.id,
179+
);
202180

203181
return this.cacheManager.set(key, [...existing, entity]);
204182
}
@@ -214,9 +192,7 @@ export default class InfractionManager {
214192
);
215193
}
216194

217-
protected updateInfractionDates(
218-
infractions: ConvertDatesToString<Infraction>[],
219-
) {
195+
protected updateInfractionDates(infractions: ConvertDatesToString<Infraction>[]) {
220196
if (infractions.length === 0) {
221197
return [];
222198
}
@@ -236,11 +212,7 @@ export default class InfractionManager {
236212
}
237213

238214
public filterValidInfractions(infractions: Infraction[]): Infraction[] {
239-
return (
240-
infractions.filter(
241-
({ expiresAt }) => !expiresAt || expiresAt > new Date(),
242-
) ?? []
243-
);
215+
return infractions.filter(({ expiresAt }) => !expiresAt || expiresAt > new Date()) ?? [];
244216
}
245217

246218
public isExpiredInfraction(infraction: Infraction | null) {

0 commit comments

Comments
 (0)