Last active
August 31, 2023 07:05
-
-
Save ayumin/cf94ea3e195114a388b739d71ead5cb4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function autoreply() { | |
const threads = GmailApp.search('from:[email protected] is:unread さとうさおり後援会に新しいメンバーが加わりました',0,1); | |
const send_subject_template = "さ党 - %knickname% さん 入党ありがとうございます"; | |
const send_body_template = "%knickname% さん\n \ | |
\n \ | |
さ党(さとうさおり後援会)への入党ありがとうございます\n \ | |
\n \ | |
さ党公式LINEオープンチャット参加のお誘い\n \ | |
さ党公式LINEオープンチャットオープンチャットでは、さ党さおり本人を含むたくさんのメンバーがおしゃべりしています。\n \ | |
党員限定のゲリラライブ配信のお知らせなどもこちらでアナウンスしますので、ぜひこれを気に参加をご検討ください。\n \ | |
ttps://line.me/ti/g2/OTCc-COwC4-aIY5i86MAStgejmPsz1S5v-vofQ \n \ | |
パスワード: besuzvxw \n \ | |
\n \ | |
公式X(旧Twitter)アカウント\n \ | |
さ党の公式X(旧Twitter)アカウントを開設しました。\n \ | |
さとうさおりの政治活動や、政治団体さ党に関するお問合せはこちらのアカウントのDMでも受け付けています。\n \ | |
X(旧Twitter)をお使いの方は、ぜひこちらのアカウントをフォローしてください。\n \ | |
ttps://x.com/satosaori_sato \n \ | |
\n \ | |
=====\n \ | |
さ党の運営に関するお問い合わせは、こちらのフォームからお願いします。\n \ | |
ttps://satosaori.doorkeeper.jp/contact/new \n \ | |
"; | |
const send_option = { name: 'さ党(さとうさおり後援会)', noReply: true }; | |
threads.forEach(thread => { | |
const messages = thread.getMessages(); | |
messages.forEach(message => { | |
// Capture knickname from plain body. | |
let body = message.getPlainBody().replace(/\n/g,""); | |
let lines = body.split('\r'); | |
let knickname = lines[6]; | |
let email = message.getReplyTo(); | |
let register_date = message.getDate(); | |
// Inject knickname to subject and body | |
let send_subject = send_subject_template.replace(/%knickname%/, knickname); | |
let send_body = send_body_template.replace(/%knickname%/, knickname); | |
GmailApp.sendEmail(email,send_subject,send_body,send_option); | |
message.markRead(); | |
}) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment