aboutsummaryrefslogtreecommitdiff
path: root/src/features/guild
diff options
context:
space:
mode:
authorSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2022-09-17 19:39:05 +0800
committerSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2022-09-17 19:39:05 +0800
commit431e4fc9d1657a50ebc34b8ac24f9bfaea06417f (patch)
tree5987bb14f38d2999c682970429f34b41eb3e5826 /src/features/guild
parente73f2efdf0f50aa775c540317394d46428e9704f (diff)
downloadSoopyV2-431e4fc9d1657a50ebc34b8ac24f9bfaea06417f.tar.gz
SoopyV2-431e4fc9d1657a50ebc34b8ac24f9bfaea06417f.tar.bz2
SoopyV2-431e4fc9d1657a50ebc34b8ac24f9bfaea06417f.zip
Initial move to babel + change fetch to use async/await
Diffstat (limited to 'src/features/guild')
-rw-r--r--src/features/guild/index.js70
-rw-r--r--src/features/guild/metadata.json8
2 files changed, 78 insertions, 0 deletions
diff --git a/src/features/guild/index.js b/src/features/guild/index.js
new file mode 100644
index 0000000..27b143b
--- /dev/null
+++ b/src/features/guild/index.js
@@ -0,0 +1,70 @@
+/// <reference types="../../../../CTAutocomplete" />
+/// <reference lib="es2015" />
+import Feature from "../../featureClass/class";
+import { toMessageWithLinks } from "../../utils/utils";
+import { fetch } from "../../utils/networkUtils";
+import ToggleSetting from "../settings/settingThings/toggle";
+import TextSetting from "../settings/settingThings/textSetting";
+
+class Guild extends Feature {
+ constructor() {
+ super()
+ }
+
+ onEnable() {
+
+ this.bridgeBots = new Set()
+ fetch("http://soopy.dev/api/soopyv2/gbots.json").json().then(bots => {
+ bots.forEach(b => this.bridgeBots.add(b))
+ })
+
+ this.shortenPrefix = new ToggleSetting("Shorten guild message prefix", "from Guild > to G > ", false, "shorten_prefix", this)
+ this.guildBot = new TextSetting("Bridge bot ign", "", "", "guild_bot_ign", this, "", false)
+
+ //&r&2Guild > &6[MVP&0++&6] zZzSNOW &e[STAFF]&f: &r@niftynathan7, niftynathan7's weight: 20 087 (#1 198) (Skill: 8 771, Slayer: 1 263, Dungeons: 10 053) ,.,,,..,.,,.,,,....,,,,,,,,,..,,,,,..,,,..,,,.,,.,,.,..,,....,,....,,..,.&r
+ //&r&2Guild > &6[MVP&4++&6] Soopyboo32 &e[STAFF]&f: &rasd&r
+ //&r&2Guild > &6[MVP&1++&6] niftynathan7 &e[E]&f: &r@Soopyboo32, Soopyboo32's networth: $8 424 131 866 (#2 592) ,..,...,....,.,,,....,,,...,,,,,,,..,,.,,..,,.,.,,,.........,.....,,,,.....,..,,...,.,.,...,.,&r
+ let ev = this.registerChat('&r&2Guild > ${player}&f: &r${msg}&r', (player, msg, event) => {
+ if (msg.includes("[ITEM:")) return
+ if (player.includes(":")) return; //stop people sending weard messages to troll using this
+
+ //player = &6[MVP&0++&6] zZzSNOW &e[STAFF]
+ let [_, rank, ign, grank] = player.match(/(&7|&[0-9a-fmnl]\[\w+(?:&[0-9a-fmnl]\+*&[0-9a-fmnl])?\] )(\w+)( &[0-9a-fmnl]\[\w+\])?/)
+
+ cancel(event)
+
+ let message = ""
+ if (this.bridgeBots.has(ign) || ign.toLowerCase() === this.guildBot.getValue().toLowerCase()) {
+ let [name, other] = msg.split(/ ?[\>\:\»] /g)
+
+ if (other) {
+ message = `&2B${this.shortenPrefix.getValue() ? "" : "ridge"} > &b${name.split(" replying to ").reverse().join(" &7⤷&b ").trim()}&f: ${msg.replace(name, "").replace(/^ ?[\>\:\»] /, "").trim()}`
+ } else {
+ if (msg.includes("---------------------------------------------") || msg.includes("You have 60 seconds to accept. Click here to join!")) {
+ return //bridge bot bug
+ }
+ message = `&2B${this.shortenPrefix.getValue() ? "" : "ridge"} > &7⤷&f ${msg.trim()}`
+ }
+ } else {
+ if (msg.match(/^@\w+, [\w\W]+[,.]+$/)) {
+ let [_, name2, reply] = msg.match(/^@(\w+?), ([\w\W]+?)[,.]+$/)
+ message = `&2B${this.shortenPrefix.getValue() ? "" : "ridge"} > &b${name2} &7⤷&f ${reply.trim()}`
+ } else {
+ message = `&2G${this.shortenPrefix.getValue() ? "" : "uild"} > ${rank}${ign}${grank || ""}&f: ${msg}`
+ }
+ }
+
+
+ toMessageWithLinks(message).chat()
+ })
+ ev.trigger.triggerIfCanceled(false)
+ }
+
+ onDisable() {
+
+ }
+}
+
+module.exports = {
+ class: new Guild()
+} \ No newline at end of file
diff --git a/src/features/guild/metadata.json b/src/features/guild/metadata.json
new file mode 100644
index 0000000..babd19d
--- /dev/null
+++ b/src/features/guild/metadata.json
@@ -0,0 +1,8 @@
+{
+ "name": "Guild features",
+ "description": "Features nice for guilds, eg bridge formatting",
+ "isHidden": false,
+ "isTogglable": true,
+ "defaultEnabled": false,
+ "sortA": 1
+} \ No newline at end of file