Part of https://www.notion.so/Option-to-post-paid-for-memes-to-twitter-x-18ca6b22d4728051804ef4f55065d5ba Co-authored-by: AdityaSalunkhe21 <adityasalunkhe2204@gmail.com> Co-authored-by: Adw8 <adwaitgharpure@gmail.com> Co-authored-by: IshaVenikar <ishavenikar7@gmail.com> Reviewed-on: deep-stack/sol-mem-gen#12 Co-authored-by: adwait <adwait@noreply.git.vdb.to> Co-committed-by: adwait <adwait@noreply.git.vdb.to>
20 lines
817 B
TypeScript
20 lines
817 B
TypeScript
export const generateTweetText = (transactionSignature: string, handle: string | undefined) => {
|
|
return `Check out this meme that I generated! \n TX Hash: '${transactionSignature}' \n @${handle} \n`;
|
|
};
|
|
|
|
export const extractData = (tweet: string | object) => {
|
|
const tweetText = typeof tweet === 'string' ? tweet : JSON.stringify(tweet);
|
|
|
|
const decodedTweet = tweetText.replace(/'/g, "'").replace(/"/g, '"');
|
|
|
|
const urlMatch = decodedTweet.match(/<a href="(https:\/\/t.co\/[^"]+)">/);
|
|
const txSignatureMatch = decodedTweet.match(/TX Hash: '([^']+)'/);
|
|
const handleMatch = decodedTweet.match(/@([A-Za-z0-9_]+)/);
|
|
|
|
return {
|
|
memeUrl: urlMatch ? urlMatch[1] : null,
|
|
txSignature: txSignatureMatch ? txSignatureMatch[1].trim() : null,
|
|
handle: handleMatch ? handleMatch[1] : null,
|
|
};
|
|
};
|