Last active
March 7, 2023 01:52
-
-
Save Akkiesoft/459be59bdc09f025fd52866e3a3f9039 to your computer and use it in GitHub Desktop.
mikutter pictcollectっぽいファイル名を出すMisskeyプラグイン(雑)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// @ 0.12.4 | |
### { | |
name: "pictcollectっぽいファイル名生成" | |
version: "0.0.1" | |
author: "Akkiesoft" | |
description: "pictcollectっぽいファイル名を生成する" | |
} | |
Plugin:register_note_action(`pictcollectっぽいファイル名生成` @(note) { | |
// for debug | |
// print(Json:stringify(note)) | |
var host = "" | |
var note_id = note.id | |
if (0 < note.files.len) { | |
if (note.uri == null) { | |
host = Mk:api("meta" {}).uri.split('//')[1] | |
} else { | |
// remote user | |
let note_url_splitted = note.uri.split('/') | |
note_id = note_url_splitted[note_url_splitted.len - 1] | |
host = note.user.host | |
} | |
let file_base = `{note.user.username}@{host}_{note_id}` | |
var out = "" | |
var count = 1 | |
each (let file, note.files) { | |
let url_dotted = file.url.split('.') | |
let ext = url_dotted[url_dotted.len - 1] | |
out = `{out}{file_base}_{count}.{ext} | |
` | |
count += 1 | |
} | |
Mk:dialog("" `{out}` "success") | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment