Skip to content

Instantly share code, notes, and snippets.

@hyuki
Last active April 10, 2023 00:49
Show Gist options
  • Select an option

  • Save hyuki/a80b09e1f256dac3d8f9f8fad8e15856 to your computer and use it in GitHub Desktop.

Select an option

Save hyuki/a80b09e1f256dac3d8f9f8fad8e15856 to your computer and use it in GitHub Desktop.
IFTTT ProでTwitterのツイートを日ごとにEvernoteにまとめるアプレットの構成図

IFTTT ProでTwitterのツイートを日ごとにEvernoteにまとめるアプレットの構成図(結城メルマガVol.576

アプレット全体の構成

image

TwitterのTrigger

Twitter

フィルタの構成

// TypeScript v2.92

function padLeft(str: string, targetLength: number, padChar: string): string {
    const padding = targetLength - str.length;

    if (padding <= 0) {
        return str;
    }

    return repeatString(padChar, padding) + str;
}

function repeatString(str: string, count: number): string {
    let repeated = '';
    for (let i = 0; i < count; i++) {
        repeated += str;
    }
    return repeated;
}

function formatDate(input: string): string {
    const months = {
        January: '01',
        February: '02',
        March: '03',
        April: '04',
        May: '05',
        June: '06',
        July: '07',
        August: '08',
        September: '09',
        October: '10',
        November: '11',
        December: '12',
    };

    const datePattern = /(\w+)\s(\d+),\s(\d{4})/;
    const match = input.match(datePattern);

    if (match) {
        const month = months[match[1] as keyof typeof months];
        const day = padLeft(match[2], 2, '0');
        const year = match[3];

        return `${year}-${month}-${day}`;
    }

    throw new Error('Invalid date format');
}

const tweet_date = formatDate(Twitter.newTweetByYou.CreatedAt);
const note_title = `My Tweet ${tweet_date}`;

Evernote.appendToNote.setTitle(note_title);

Evernoteのアクション

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment