Discord Integration Forge

Discord Integration Forge

666k Downloads

[Suggestion] Filter out broadcast messages

LemADEC opened this issue · 14 comments

commented

What you want to be added?
On a public server, it's common to have periodic announcement broadcast in player chat: saving the world, backup running, vote for us, don't cheat, etc. This messages have little to no value in Discord.
In fact, the other discord bridge plugins/mods I've seen in the past just ignore broadcast messages or disable transferring them by default. I've found no similar option in DCIntegration, so please add one :).

commented

I thought ServerChatEvent.getPlayer() was null for broadcast, hence easy to detect, or did I miss something?

The code I use for sending /say messages gets called in the command event, if it is an /say command it sends the arguments as the server or the player who sent it

commented

Any reasons to use the command event instead of ServerChat one?

commented

At least when I tested /say and /me did not send an chat event (1.12).
Tought 1.15 did not change that

commented

the "[server]" prefix don't show in discord, so I could filter out those with your proposed change.
It still feel incomplete in my opinion. I thought ServerChatEvent.getPlayer() was null for broadcast, hence easy to detect, or did I miss something?

commented

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days

commented

for the record, this issue is still live as of 1.3.2-1.15.

commented

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days

commented

What mod are you using for this?

commented

I'm currently using MagiBridge (spongeforge) and DiscordSRV (spigot).

commented

I mean for the broadcast messages. Magi Bridge and discord srv are both discord integrations.
I need to know theese messages are being sent so I can add an way to filter them out

commented

Sponge broadcasts are done through Sponge.getServer().getBroadcastChannel().send(msg);
Console broadcasts are done with a simple command /say <msg>
Chat format and translation can largely be modified, so if you rely on the message content, we'll need a configuration for this.

For the record, Bungee broadcast aren't reported by this mod. Those are done with a simple console command /alert <msg> command. I guess the proxy directly sends the message to the client, invisibly from the server.

commented

Can you try if this version works? (jar is zipped because you can't upload jar files here, just inzip indo the mods folder)

dcintegration-1.2.7-1.15.zip

This is the default configuration entry:

#When an /say command's message starts with this prefix it will not be sent to discord
sayCommandIgnoredPrefix = "§c§o§9§k§r"

So you need to add §c§o§9§k§r before the broadcast message you want to hide from discord. Since theese are formatting codes and the last one is §r (reset) noone ingame sees them

commented

Actually, I was incorrect, the broadcast from console doing /say <msg> can't be changed from "[server] ". Could we use a regex expression instead or a list of prefixes?

commented

So you get [server] somemessage in discord or only ingame? If you don't see that [server] in discord you can still try it with this version