Action

post with #WWDC

Posted by FlohGro, Last update almost 2 years ago - Unlisted

Uses the Draftodon post with hashtag action to post a draft with #WWDC hashtag

Steps

  • defineTemplateTag

    name
    hashtags-to-append
    template
    WWDC
  • defineTemplateTag

    name
    post-visibility
    template
    public
  • includeAction

    name
    Draftodon
  • script

    let visibility = draft.processTemplate("[[post-visibility]]")
    let hashtagsToAppend = draft.processTemplate("[[hashtags-to-append]]")
    
    
    let currentText = editor.getText().trim()
    
    if (currentText.length == 0) {
        context.cancel("draft is empty")
        app.displayWarningMessage("draft is empty")
    } else {
        // parse predefined hashtags
    
        let hashtags = hashtagsToAppend.split("\n")
        hashtags = hashtags.filter(hashtag => {
            if (hashtag.trim().length > 0) {
                return hashtag
            }
        })
        let hashtagsStrs = []
        for (let hashtag of hashtags) {
            if (!hashtag.startsWith("#")) {
                hashtag = "#" + hashtag
            }
            hashtagsStrs.push(hashtag)
        }
        if(hashtagsStrs.length == 0){
        	app.displayWarningMessage("no hashtags configured")
        	context.cancel("no hashtags configured")
        } else {
        	let finalText = currentText.trim() + "\n\n" + hashtagsStrs.join(" ")
    	    editor.setText(finalText)
        	Draftodon_publishDraftAsSinglePost(visibility)
        }
    }

Options

  • After Success Archive
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.