Last active
April 4, 2021 02:20
-
-
Save anthonybaldwin/1ade79b8b8fd45a96f5c9fe4fc263240 to your computer and use it in GitHub Desktop.
IFTTT Filter for Discord Twitter Webhook
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
const t12To24 = function(time: any) { //time=12:30PM | |
time = time.replace(/[AP]/, " $&"); //time=12:30 PM | |
let [t, p] = time.split(' '); //t=12:30, p=PM | |
let [h, m] = t.split(':'); //h=12, m=30 | |
if (h === '12') {h = '00';} //h=00 | |
if (p === 'PM') {h = parseInt(h, 10) + 12;} //h=12 | |
return `${h}:${m}`; //12:30 | |
} | |
let date = Trigger.CreatedAt; //date="April 20, 2021 at 04:20PM" | |
let [d, t] = date.split(" at "); //d="April 20, 2021", t=04:20PM | |
t = t12To24(t); //t=16:20 | |
const url = Trigger.LinkToTweet.replace(/^http:\/\//i, 'https://'); | |
const body = { | |
username: "@" + Trigger.UserName, | |
avatar_url: Trigger.UserImageUrl, | |
content: "tweeted on " + d + " at "+ t +" PST: " + url | |
}; | |
// Filter | |
/*if (Trigger.Text.indexOf('word') > 0) { | |
MakerWebhooks.makeWebRequest.skip('Skipped because...'); | |
}*/ | |
MakerWebhooks.makeWebRequest.setBody(JSON.stringify(body)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment