diff options
author | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-07-14 12:31:37 +0800 |
---|---|---|
committer | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-07-14 12:31:37 +0800 |
commit | 598dadc9efadf69401f08d27e5b0ff1b36a0f2bc (patch) | |
tree | 97a66f46b0d19ed98f7493e32703d81d85cbc8b3 /features/globalSettings | |
parent | 99dbeef6058f8e30e763fd1b05470a36defa3d46 (diff) | |
download | SoopyV2-598dadc9efadf69401f08d27e5b0ff1b36a0f2bc.tar.gz SoopyV2-598dadc9efadf69401f08d27e5b0ff1b36a0f2bc.tar.bz2 SoopyV2-598dadc9efadf69401f08d27e5b0ff1b36a0f2bc.zip |
+ ingame twitch bot commands
Diffstat (limited to 'features/globalSettings')
-rw-r--r-- | features/globalSettings/index.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/features/globalSettings/index.js b/features/globalSettings/index.js index c317eb4..4848a56 100644 --- a/features/globalSettings/index.js +++ b/features/globalSettings/index.js @@ -47,6 +47,7 @@ class GlobalSettings extends Feature { this.reportErrorsSetting = new ToggleSetting("Send module errors to soopy server", "This will allow me to more effectivly fix them", false, "privacy_send_errors", this) this.hideFallingBlocks = new ToggleSetting("Hide falling blocks", "NOTE: this may cause more lag because of render entity event", false, "hide_falling_sand", this) + this.twitchCommands = new ToggleSetting("Ingame twitch bot commands", "Allows u to use twitch bot commands ingame (eg -sa)", true, "twitch_commands_ingame", this) this.privacySettings = [this.reportErrorsSetting] @@ -136,6 +137,26 @@ class GlobalSettings extends Feature { cancel(e) } }) + + this.registerEvent("messageSent", (message, event) => { + if (!this.twitchCommands.getValue()) return + + if (message.startsWith("-")) { + cancel(event) + fetch("http://soopymc.my.to/api/soopyv2/botcommand?m=" + encodeURIComponent(message.replace("-", "")) + "&u=" + Player.getName()).text(text => { + ChatLib.chat(this.FeatureManager.messagePrefix + "&7" + message) + let sendMessage = text + sendMessage = sendMessage.split(" ").map(a => { + if (a.match(/(?:(?:https?|ftp|file):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$])/igm)) { + return new TextComponent("&f&n" + a + ' ').setHover("show_text", "Click to open " + a).setClick("open_url", a) + } else { + return new TextComponent("&f" + a + ' ') + } + }) + sendMessage.reduce((c, curr) => c.addTextComponent(curr), new Message().addTextComponent(new TextComponent(this.FeatureManager.messagePrefix))).chat() + }) + } + }) } // renderWebpage() { |