Compare commits
1 commit
Author | SHA1 | Date | |
---|---|---|---|
0320a6a30f |
1 changed files with 48 additions and 6 deletions
|
@ -1,9 +1,9 @@
|
||||||
/// @ 0.19.0
|
/// @ 0.19.0
|
||||||
### {
|
### {
|
||||||
name: "Headmate Hopper"
|
name: "Headmate Hopper"
|
||||||
version: "1.1.0"
|
version: "1.1.1"
|
||||||
author: "@bunnybeam@transfem.social"
|
author: "@bunnybeam@transfem.social, @Chloe@catwithaclari.net"
|
||||||
description: "Adds a tag containing the name of the selected headmate to the end of all new posts."
|
description: "Adds a tag containing the name of the selected headmate to the end of all new posts. Chnages the default like emoji depending on the headmate."
|
||||||
permissions: ["read:account", "write:account"]
|
permissions: ["read:account", "write:account"]
|
||||||
config: {
|
config: {
|
||||||
headmates: {
|
headmates: {
|
||||||
|
@ -12,6 +12,18 @@
|
||||||
description: "List of headmate names. Separate with commas."
|
description: "List of headmate names. Separate with commas."
|
||||||
default: "Headmate 1, Headmate 2"
|
default: "Headmate 1, Headmate 2"
|
||||||
}
|
}
|
||||||
|
default_likes: {
|
||||||
|
type: "string"
|
||||||
|
label: "Default Like Emoji list"
|
||||||
|
description: "Default like emoji for each headmate. Make sure they're in the same order as the headmates! There must be an emoji for every headmate."
|
||||||
|
default: ":neocat_heart:, :neofox_heart:"
|
||||||
|
}
|
||||||
|
default_like: {
|
||||||
|
type: "string"
|
||||||
|
label: "Default Like Emoji"
|
||||||
|
description: "Like emoji to defualt to when headmate is cleared."
|
||||||
|
default: "❤️"
|
||||||
|
}
|
||||||
change_name: {
|
change_name: {
|
||||||
type: "boolean"
|
type: "boolean"
|
||||||
label: "Change display name"
|
label: "Change display name"
|
||||||
|
@ -85,6 +97,16 @@
|
||||||
return new_list
|
return new_list
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@get_emoji_list() {
|
||||||
|
let raw_list = Plugin:config.default_likes.split(",")
|
||||||
|
let new_list = []
|
||||||
|
each let name, raw_list {
|
||||||
|
new_list.push(name.trim())
|
||||||
|
}
|
||||||
|
return new_list
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Check if `text` already contains the headmate tag
|
// Check if `text` already contains the headmate tag
|
||||||
@already_tagged(text) {
|
@already_tagged(text) {
|
||||||
return text.incl(make_tag_from_name(headmate_name))
|
return text.incl(make_tag_from_name(headmate_name))
|
||||||
|
@ -120,6 +142,21 @@
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Attempt to change defualt emoji. Returns true if successful, false if otherwise.
|
||||||
|
@change_like_emoji(emoji) {
|
||||||
|
// Attempt to change emoji
|
||||||
|
let write_res = Mk:api("i/registry/set", {key: "like", value: emoji, scope: ["client", "base"], domain: "System"})
|
||||||
|
if write_res != null {
|
||||||
|
var message = "An unknown error occurred when attempting to edit the default like emoji."
|
||||||
|
if write_res.info.code == "PERMISSION_DENIED" {
|
||||||
|
message = "The 'Edit account information' permission must be enabled in order to change your default like emoji."
|
||||||
|
}
|
||||||
|
Mk:dialog("Error setting default emoji", message, "error")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// Select a new headmate name
|
// Select a new headmate name
|
||||||
@select_headmate_name(name) {
|
@select_headmate_name(name) {
|
||||||
if Plugin:config.change_name {
|
if Plugin:config.change_name {
|
||||||
|
@ -178,16 +215,21 @@ Plugin:register_note_post_interruptor(@(note) {
|
||||||
})
|
})
|
||||||
|
|
||||||
// Register post form actions for each headmate
|
// Register post form actions for each headmate
|
||||||
each let name, get_headmate_list() {
|
for (let i, get_headmate_list().len) {
|
||||||
Plugin:register_post_form_action(`Switch to {name}`, @(note, rewrite) {
|
let name = get_headmate_list()[i]
|
||||||
|
let emoji = get_emoji_list()[i]
|
||||||
|
Plugin:register_post_form_action(`Switch to {name} {emoji}`, @(note, rewrite) {
|
||||||
select_headmate_name(name)
|
select_headmate_name(name)
|
||||||
|
change_like_emoji(emoji)
|
||||||
if Plugin:config.switch_notif {
|
if Plugin:config.switch_notif {
|
||||||
Mk:dialog("Switched headmate", `Switched headmate to "{name}".`, "success")
|
Mk:dialog("Switched headmate", `Switched headmate to "{name} with emoji {emoji}".`, "success")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
Plugin:register_post_form_action("Clear headmate", @(note, rewrite) {
|
Plugin:register_post_form_action("Clear headmate", @(note, rewrite) {
|
||||||
select_headmate_name("")
|
select_headmate_name("")
|
||||||
|
change_like_emoji(Plugin:config.default_like)
|
||||||
if Plugin:config.switch_notif {
|
if Plugin:config.switch_notif {
|
||||||
Mk:dialog("Switched headmate", "Cleared the current headmate.", "success")
|
Mk:dialog("Switched headmate", "Cleared the current headmate.", "success")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue