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(//); 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, }; };