Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Plugin] ReplyPingControl #1975

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
a7d9fdb
Added README.md
ant0n-0x0000 Nov 11, 2023
1c047ae
Update src/plugins/replyPingControl/index.ts
ant0n-0x0000 Nov 11, 2023
f71bcef
Update src/plugins/replyPingControl/index.ts
ant0n-0x0000 Nov 11, 2023
66b49a2
new getCurrentUserMention()
ant0n-0x0000 Nov 11, 2023
5026f3f
Update src/plugins/replyPingControl/index.ts
ant0n-0x0000 Nov 11, 2023
5d2cefb
Update src/plugins/replyPingControl/index.ts
ant0n-0x0000 Nov 11, 2023
b2ddee9
Update src/plugins/replyPingControl/index.ts
ant0n-0x0000 Nov 11, 2023
6694e3b
Update index.ts
ant0n-0x0000 Nov 11, 2023
cab9e55
Update src/plugins/replyPingControl/index.ts
ant0n-0x0000 Nov 12, 2023
c5fb9f8
Update src/plugins/replyPingControl/index.ts
ant0n-0x0000 Nov 12, 2023
fb6cdc0
No longer imports UserJSON
ant0n-0x0000 Nov 12, 2023
27660e1
:husk:
ant0n-0x0000 Nov 12, 2023
de38925
Update src/plugins/replyPingControl/index.ts
ant0n-0x0000 Nov 12, 2023
b789094
Merge branch 'main' into main
ant0n-0x0000 Nov 13, 2023
e5ffb34
Added a whitelist (always ping)
ant0n-0x0000 Nov 13, 2023
191bb3c
Removed pipebomb...
ant0n-0x0000 Nov 13, 2023
c65f3db
Updated README.md to include Whitelist
ant0n-0x0000 Nov 13, 2023
df0a29f
Added a caching for the whitelist
ant0n-0x0000 Nov 13, 2023
0e494fc
Updated validateWhitelist
ant0n-0x0000 Nov 13, 2023
400e970
:husk:
ant0n-0x0000 Nov 13, 2023
4ac6d97
Fixed validation fail if at least one ID was valid
ant0n-0x0000 Nov 13, 2023
b20501d
No longer creats two arrays onChange
ant0n-0x0000 Nov 13, 2023
ef4ab95
Added whitelist
ant0n-0x0000 Nov 13, 2023
5b2fe0a
Update src/plugins/replyPingControl/index.ts
ant0n-0x0000 Nov 17, 2023
a9a4d19
Removed redundant thing
ant0n-0x0000 Nov 17, 2023
4b02352
oops
ant0n-0x0000 Nov 17, 2023
3afece4
Removed swag from index.ts
ant0n-0x0000 Nov 17, 2023
338b969
removed the isValidUserId (oops)
ant0n-0x0000 Nov 17, 2023
90608ab
Merge branch 'main' into main
ant0n-0x0000 Nov 29, 2023
f4fca14
Merge branch 'main' into main
ant0n-0x0000 Dec 7, 2023
60f1416
Merge branch 'main' into main
ant0n-0x0000 Dec 22, 2023
97f7f97
Merge branch 'main' into main
Vendicated May 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/plugins/replyPingControl/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# ReplyPingControl

Overrides notification settings for received reply pings to either always notify, or never notify.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Overrides notification settings for received reply pings to either always notify, or never notify.
Overrides notification settings for replies to your messages to either always notify, or never notify, regardless of if the author enabled reply mention or not

or something like that


## Settings
- **Enabled**: You will always be notified when someone replies to your messages, regardless of if the sender has reply pings enabled.
- **Disabled (Default)**: You will not receive notification pings for replies, regardless of if the sender has reply pings enabled.

## License
This project is licensed under the GPL-3.0-or-later License - see file for details.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line is redundant and can be removed. was this maybe added due to being in a third party repo?

unless you deliberately want it here, then you can leave it, but i would suggest adding your name

58 changes: 58 additions & 0 deletions src/plugins/replyPingControl/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2023 Vendicated, MrDiamond, ant0n, and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/

import { definePluginSettings } from "@api/Settings";
import { Devs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types";
import { MessageStore, UserStore } from "@webpack/common";

ant0n-0x0000 marked this conversation as resolved.
Show resolved Hide resolved
export const settings = definePluginSettings({
alwaysPingOnReply: {
Copy link
Owner

@Vendicated Vendicated May 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it would be better to change this to a select between the following 3 options:

  • Always receive reply pings
  • [DEFAULT] Receive reply pings if author enables it (like default discord) or if they are whitelisted, but not if they are blacklisted
  • Never receive reply pings

this way people won't enable this plugin then cry that they never get notifications, and it also allows you to use the plugin to just enable reply pings for individual people who always turn it off without changing behaviour for other people's replies

type: OptionType.BOOLEAN,
description: "Always get pinged when someone replies to your messages",
default: false,
ant0n-0x0000 marked this conversation as resolved.
Show resolved Hide resolved
}
});

export default definePlugin({
name: "ReplyPingControl",
description: "Control whether to always or never get pinged on message replies",
authors: [Devs.ant0n, Devs.MrDiamond],
settings,

patches: [
{
find: "_channelMessages",
replacement: {
match: /receiveMessage\((\i)\)\{/,
replace: "$&$self.modifyMentions($1);"
}
}
],

modifyMentions(message: MessageJSON) {

Check failure on line 36 in src/plugins/replyPingControl/index.ts

View workflow job for this annotation

GitHub Actions / test

Cannot find name 'MessageJSON'.
const isReplyToCurrentUser = this.isReplyToCurrentUser(message);
if (settings.store.alwaysPingOnReply && isReplyToCurrentUser) {

ant0n-0x0000 marked this conversation as resolved.
Show resolved Hide resolved
if (!message.mentions.some(mention => mention.id === UserStore.getCurrentUser().id)) {
message.mentions.push(this.getCurrentUserMention());
}
} else if (!settings.store.alwaysPingOnReply && isReplyToCurrentUser) {

message.mentions = message.mentions.filter(mention => mention.id !== UserStore.getCurrentUser().id);
}
},

isReplyToCurrentUser(message: MessageJSON) {

Check failure on line 49 in src/plugins/replyPingControl/index.ts

View workflow job for this annotation

GitHub Actions / test

Cannot find name 'MessageJSON'.
if (!message.message_reference) return false;
const repliedMessage = MessageStore.getMessage(message.channel_id, message.message_reference.message_id);
return repliedMessage && repliedMessage.author.id === UserStore.getCurrentUser().id;
},

getCurrentUserMention() {
return UserStore.getCurrentUser() as unknown as UserJSON;

Check failure on line 56 in src/plugins/replyPingControl/index.ts

View workflow job for this annotation

GitHub Actions / test

Cannot find name 'UserJSON'.
}
});
4 changes: 4 additions & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({
name: "ant0n",
id: 145224646868860928n
},
MrDiamond: {
name: "MrDiamond",
id: 523338295644782592n
}
} satisfies Record<string, Dev>);

// iife so #__PURE__ works correctly
Expand Down
Loading