mirror of
https://github.com/cnaude/PurpleIRC-spigot.git
synced 2024-11-29 05:26:19 +01:00
Add %ATTACHMENTURLS% for Discord to IRC bridge messages.
This commit is contained in:
parent
683c2efe40
commit
f4e2857631
14
pom.xml
14
pom.xml
@ -6,7 +6,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<!-- Bukkit API Version, change if out dated -->
|
<!-- Bukkit API Version, change if out dated -->
|
||||||
<bukkit.version>1.18</bukkit.version>
|
<bukkit.version>1.20-R0.1-SNAPSHOT</bukkit.version>
|
||||||
<build.number>SNAPSHOT</build.number>
|
<build.number>SNAPSHOT</build.number>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
@ -450,14 +450,14 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.guava</groupId>
|
<groupId>com.google.guava</groupId>
|
||||||
<artifactId>guava</artifactId>
|
<artifactId>guava</artifactId>
|
||||||
<version>31.0.1-jre</version>
|
<version>32.1.2-jre</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Testing only -->
|
<!-- Testing only -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.13.1</version>
|
<version>4.13.2</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
@ -491,17 +491,17 @@
|
|||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.9.0-SNAPSHOT</version>
|
<version>3.11.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>11</source>
|
<source>17</source>
|
||||||
<target>11</target>
|
<target>17</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
<version>3.3.0-SNAPSHOT</version>
|
<version>3.5.0</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
|
@ -22,6 +22,9 @@ import github.scarsz.discordsrv.DiscordSRV;
|
|||||||
import github.scarsz.discordsrv.api.ListenerPriority;
|
import github.scarsz.discordsrv.api.ListenerPriority;
|
||||||
import github.scarsz.discordsrv.api.Subscribe;
|
import github.scarsz.discordsrv.api.Subscribe;
|
||||||
import github.scarsz.discordsrv.api.events.DiscordGuildMessageReceivedEvent;
|
import github.scarsz.discordsrv.api.events.DiscordGuildMessageReceivedEvent;
|
||||||
|
import github.scarsz.discordsrv.dependencies.jda.api.entities.Message.Attachment;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -58,7 +61,8 @@ public class DiscordListener {
|
|||||||
event.getMember().getEffectiveName(),
|
event.getMember().getEffectiveName(),
|
||||||
event.getMember().getColor(),
|
event.getMember().getColor(),
|
||||||
event.getChannel().getName(),
|
event.getChannel().getName(),
|
||||||
event.getMessage().getContentDisplay());
|
event.getMessage().getContentDisplay(),
|
||||||
|
event.getMessage().getAttachments());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,7 @@ import com.massivecraft.factions.entity.Faction;
|
|||||||
import com.massivecraft.factions.entity.MPlayer;
|
import com.massivecraft.factions.entity.MPlayer;
|
||||||
import com.nyancraft.reportrts.data.Ticket;
|
import com.nyancraft.reportrts.data.Ticket;
|
||||||
import com.titankingdoms.dev.titanchat.core.participant.Participant;
|
import com.titankingdoms.dev.titanchat.core.participant.Participant;
|
||||||
|
import github.scarsz.discordsrv.dependencies.jda.api.entities.Message.Attachment;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -66,7 +67,6 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
|
|||||||
import me.botsko.prism.actionlibs.QueryParameters;
|
import me.botsko.prism.actionlibs.QueryParameters;
|
||||||
import me.botsko.prism.events.BlockStateChange;
|
import me.botsko.prism.events.BlockStateChange;
|
||||||
import org.bukkit.Achievement;
|
import org.bukkit.Achievement;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -1513,16 +1513,29 @@ public final class PurpleBot {
|
|||||||
* @param color
|
* @param color
|
||||||
* @param effectiveName
|
* @param effectiveName
|
||||||
* @param message
|
* @param message
|
||||||
|
* @param attachments
|
||||||
*/
|
*/
|
||||||
public void discordChat(String username, String nickname, String effectiveName, Color color, String discordChannel, String message) {
|
public void discordChat(
|
||||||
|
String username,
|
||||||
|
String nickname,
|
||||||
|
String effectiveName,
|
||||||
|
Color color,
|
||||||
|
String discordChannel,
|
||||||
|
String message,
|
||||||
|
List<Attachment> attachments) {
|
||||||
if (!this.isConnected()) {
|
if (!this.isConnected()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
List<String> aList = new ArrayList<>();
|
||||||
|
for (Attachment a : attachments) {
|
||||||
|
aList.add(a.getUrl());
|
||||||
|
}
|
||||||
|
String attUrls = String.join(", ", aList);
|
||||||
for (String channelName : botChannels) {
|
for (String channelName : botChannels) {
|
||||||
if (isMessageEnabled(channelName, TemplateName.DISCORD_CHAT) || isMessageEnabled(channelName, "discord-" + discordChannel + "-chat")) {
|
if (isMessageEnabled(channelName, TemplateName.DISCORD_CHAT) || isMessageEnabled(channelName, "discord-" + discordChannel + "-chat")) {
|
||||||
String template = plugin.getMessageTemplate(botNick, channelName, TemplateName.DISCORD_CHAT);
|
String template = plugin.getMessageTemplate(botNick, channelName, TemplateName.DISCORD_CHAT);
|
||||||
asyncIRCMessage(channelName, plugin.tokenizer
|
asyncIRCMessage(channelName, plugin.tokenizer
|
||||||
.discordChatToIRCTokenizer(template, username, nickname, effectiveName, color, discordChannel, message)
|
.discordChatToIRCTokenizer(template, username, nickname, effectiveName, color, discordChannel, message, attUrls)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,12 +23,9 @@ import com.cnaude.purpleirc.TemplateName;
|
|||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.nyancraft.reportrts.data.Ticket;
|
import com.nyancraft.reportrts.data.Ticket;
|
||||||
import com.palmergames.bukkit.TownyChat.channels.Channel;
|
import com.palmergames.bukkit.TownyChat.channels.Channel;
|
||||||
import github.scarsz.discordsrv.DiscordSRV;
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -36,7 +33,6 @@ import org.bukkit.block.Block;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.pircbotx.User;
|
import org.pircbotx.User;
|
||||||
import github.scarsz.discordsrv.objects.MessageFormat;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main class containing all message template token expanding methods
|
* Main class containing all message template token expanding methods
|
||||||
@ -493,11 +489,20 @@ public class ChatTokenizer {
|
|||||||
* @param color
|
* @param color
|
||||||
* @param discordChannel
|
* @param discordChannel
|
||||||
* @param template
|
* @param template
|
||||||
*
|
|
||||||
* @param message
|
* @param message
|
||||||
|
* @param attUrls
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String discordChatToIRCTokenizer(String template, String username, String nickname, String effectiveName, Color color, String discordChannel, String message) {
|
public String discordChatToIRCTokenizer(
|
||||||
|
String template,
|
||||||
|
String username,
|
||||||
|
String nickname,
|
||||||
|
String effectiveName,
|
||||||
|
Color color,
|
||||||
|
String discordChannel,
|
||||||
|
String message,
|
||||||
|
String attUrls
|
||||||
|
) {
|
||||||
// String hex = color != null ? Integer.toHexString(color.getRGB()).toUpperCase() : "99AAB5";
|
// String hex = color != null ? Integer.toHexString(color.getRGB()).toUpperCase() : "99AAB5";
|
||||||
// if (hex.length() == 8) {
|
// if (hex.length() == 8) {
|
||||||
// hex = hex.substring(2);
|
// hex = hex.substring(2);
|
||||||
@ -517,6 +522,7 @@ public class ChatTokenizer {
|
|||||||
.replace("%CHANNEL%", discordChannel)
|
.replace("%CHANNEL%", discordChannel)
|
||||||
.replace("%MESSAGE%", plugin.colorConverter.gameColorsToIrc(message))
|
.replace("%MESSAGE%", plugin.colorConverter.gameColorsToIrc(message))
|
||||||
.replace("%RAWMESSAGE%", ChatColor.stripColor(message))
|
.replace("%RAWMESSAGE%", ChatColor.stripColor(message))
|
||||||
|
.replace("%ATTACHMENTURLS%", attUrls)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,8 @@ chat-ping-fix: false
|
|||||||
# %TOWNYCHANNELTAG% - Towny channel tag name
|
# %TOWNYCHANNELTAG% - Towny channel tag name
|
||||||
# %TOWNYMSGCOLOR% - Towny message color
|
# %TOWNYMSGCOLOR% - Towny message color
|
||||||
# %JOBS% - Player jobs
|
# %JOBS% - Player jobs
|
||||||
# %JOBSSHORT% - Player jobs shortened
|
# %JOBSSHORT% - Player jobs
|
||||||
|
# %ATTACHMENTURLS% - Discord attachment URLs
|
||||||
# Prism custom tokens:
|
# Prism custom tokens:
|
||||||
# prism-rollback:
|
# prism-rollback:
|
||||||
# %COMMAND%
|
# %COMMAND%
|
||||||
@ -153,7 +154,7 @@ message-format:
|
|||||||
# AdminPrivateChat message from IRC to game
|
# AdminPrivateChat message from IRC to game
|
||||||
irc-a-chat: '[AdminChat] [&4IRC&r] %MESSAGE%'
|
irc-a-chat: '[AdminChat] [&4IRC&r] %MESSAGE%'
|
||||||
# Messages from Discord (Valid tokens: %NAME%, %NICKNAME%, %EFFNAME%, %COLOR%, %CHANNEL%, %MESSAGE%, %RAWMESSAGE%)
|
# Messages from Discord (Valid tokens: %NAME%, %NICKNAME%, %EFFNAME%, %COLOR%, %CHANNEL%, %MESSAGE%, %RAWMESSAGE%)
|
||||||
discord-chat: '[Discord]<%NAME%> %MESSAGE%'
|
discord-chat: '[Discord]<%NAME%> %MESSAGE% %ATTACHMENTURLS%'
|
||||||
# Messages from IRC to Discord
|
# Messages from IRC to Discord
|
||||||
irc-discord-chat: '[IRC]<%NAME%> %MESSAGE%'
|
irc-discord-chat: '[IRC]<%NAME%> %MESSAGE%'
|
||||||
# Actions from IRC to Discord
|
# Actions from IRC to Discord
|
||||||
|
Loading…
Reference in New Issue
Block a user