Skip to content

Commit

Permalink
v3.2.0
Browse files Browse the repository at this point in the history
Adds @clairebot pls ban <any text you want>
  • Loading branch information
Sidpatchy committed Apr 9, 2024
1 parent b9ab933 commit a744e0a
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jar {
}

group 'com.sidpatchy'
version '3.1.2'
version '3.2.0'

sourceCompatibility = 17
targetCompatibility = 17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static EmbedBuilder getInfo(User author) {
.addField("Add Me to a Server", "Adding me to a server is simple, all you have to do is click [here](https://invite.clairebot.net)", true)
.addField("GitHub", "ClaireBot is open source, that means you can view all of its code! Check out its [GitHub!](https://github.com/Sidpatchy/ClaireBot)", true)
.addField("Server Count", "I have enlightened **" + Main.getApi().getServers().size() + "** servers.", true)
.addField("Version", "I am running ClaireBot **v3.1.2**, released on **2024-04-02**", true)
.addField("Version", "I am running ClaireBot **v3.2.0**, released on **2024-04-08**", true)
.addField("Uptime", "Started on <t:" + Main.getStartMillis() / 1000 + ">" + "\n*" + timeSinceStart + "*", true);
}
}
22 changes: 22 additions & 0 deletions src/main/java/com/sidpatchy/clairebot/Listener/MessageCreate.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.javacord.api.entity.message.MessageBuilder;
import org.javacord.api.entity.message.mention.AllowedMentionsBuilder;
import org.javacord.api.entity.server.Server;
import org.javacord.api.entity.user.User;
import org.javacord.api.event.message.MessageCreateEvent;
import org.javacord.api.listener.message.MessageCreateListener;

Expand Down Expand Up @@ -53,6 +54,27 @@ public void onMessageCreate(MessageCreateEvent event) {
}
}

// pls ban
List<String> plsBanResponses = Main.getPlsBanResponses();
String escapedBotId = Pattern.quote("<@" + Main.getApi().getClientId() + ">");

for (String trigger : Main.getPlsBanTriggers()) {
String regex = "(?i)" + escapedBotId + "\\s*" + Pattern.quote(trigger) + ".*";
if (messageContent.toUpperCase().matches(regex)) {
Random random = new Random();
int rand = random.nextInt(plsBanResponses.size());

// Message.reply() doesn't allow disabling mentions.
new MessageBuilder()
.setContent(Main.getPlsBanResponses().get(rand))
.setAllowedMentions(new AllowedMentionsBuilder().build())
.replyTo(message)
.send(message.getChannel());

break;
}
}

// Grant between 0 and 8 points
if (server != null) {
Integer currentPoints = LevelingTools.getUserPoints(messageAuthor.getIdAsString(), "global");
Expand Down
20 changes: 18 additions & 2 deletions src/main/java/com/sidpatchy/clairebot/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* @since April 2020
* @version 3.1.2
* @version 3.2.0
* @author Sidpatchy
*/
public class Main {
Expand Down Expand Up @@ -69,6 +69,8 @@ public class Main {
private static List<Object> eightBallRigged;
private static List<Object> claireBotOnTopResponses;
private static List<Object> onTopTriggers;
private static List<Object> plsBanResponses;
private static List<Object> plsBanTriggers;

// Commands
private static final Logger logger = LogManager.getLogger(Main.class);
Expand Down Expand Up @@ -117,7 +119,7 @@ public static void main(String[] args) throws InvalidConfigurationException {
Clockwork.initClockwork();

// Set the bot's activity
api.updateActivity("ClaireBot v3.1.2", video_url);
api.updateActivity("ClaireBot v3.2.0", video_url);

// Register slash commands
registerSlashCommands();
Expand Down Expand Up @@ -187,6 +189,8 @@ public static void extractParametersFromConfig(boolean updateOutdatedConfigs) {
eightBallRigged = config.getList("8bRiggedResponses");
claireBotOnTopResponses = config.getList("ClaireBotOnTopResponses");
onTopTriggers = config.getList("OnTopTriggers");
plsBanResponses = config.getList("PlsBanResponses");
plsBanTriggers = config.getList("PlsBanTriggers");
}
catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -296,6 +300,18 @@ public static List<String> getClaireBotOnTopResponses() {
.collect(Collectors.toList());
}

public static List<String> getPlsBanTriggers() {
return plsBanTriggers.stream()
.map(Object::toString)
.collect(Collectors.toList());
}

public static List<String> getPlsBanResponses() {
return plsBanResponses.stream()
.map(Object::toString)
.collect(Collectors.toList());
}

public static String getConfigFile() { return configFile; }

public static String getCommandsFile() { return "config/" + commandsFile; }
Expand Down
23 changes: 22 additions & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ----------------------------------------------
# | ClaireBot v3.0 |
# | ClaireBot v3.2.0 |
# | Config file |
# ----------------------------------------------

Expand Down Expand Up @@ -116,6 +116,7 @@ zerfas_emote_id: 822591272295596032
- "*With ClaireBot, there's no question!*"
- "*All signs point to ClaireBot being on top!*"

# Things ClaireBot should respond with when triggered by one of the OnTopTriggers
ClaireBotOnTopResponses:
- "*You know it!*"
- "*I am... inevitable. -ClaireBot*"
Expand Down Expand Up @@ -166,6 +167,26 @@ OnTopTriggers:
- "Thank you based god"
- "Based god"

# Triggers for the pls ban feature. Ex. @clairebot pls ban the zucc
PlsBanTriggers:
- "pls ban"
- "please ban"
- "ban"

# Responses to the PlsBanTriggers
PlsBanResponses:
- "i gotchu fam"
- "No problem!"
- "Done. Happy to help :)"
- "Consider it done."
- "It's done. RIP BOZO"
- "*L + Ratio -ClaireBot*"
- "I'll tell them to kick rocks, I guess ¯\\_(ツ)_/¯"
- "Sand has been shipped to their location. Gift note: \"Pound sand\""
- "Cry harder."
- "K"
- "Good riddance"

# -------------------- MISC --------------------
# This section contains values that don't fit in the main categories

Expand Down

1 comment on commit a744e0a

@Sidpatchy
Copy link
Owner Author

Choose a reason for hiding this comment

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

Apparently there is a GitHub user named clairebot. Sorry, didn't mean to mention you.

Please sign in to comment.