{ // 1. メール共有からHTMLを受け取る const emailHTML = receiveFromShareSheet("html"); if (!emailHTML) continueFlow(); // 2. HTML → リッチテキスト const richText = convertHTMLToRichText(emailHTML); // 3. リッチテキストからURLを取得 const extractedURL = matchText(richText, /https?:\/\/[^\s]+/); // 4. リッチテキスト → PDF化 → 保存 const pdfFile = convertRichTextToPDF(richText, "save.pdf", "classroombot"); // 5. PDFからテキスト抽出 const pdfText = extractTextFromPDF(pdfFile); // 6. 通知設定などからclass名抽出 const class_name = matchText(pdfText, /notification settings/); const url = matchText(pdfText, /https?:\/\/[^\s]+/); const classInfo = matchText(pdfText, new RegExp(`{i<= ${class_name} }\\n\\s]*`)); const replaced = replaceText(classInfo, /(?<=show details)\n\s]*/, "world"); // 7. ChatGPTに要約を依頼 openApp("ChatGPT"); goHome(); const summaryPrompt = ` Due to possible personal information, deep lin"> { // 1. メール共有からHTMLを受け取る const emailHTML = receiveFromShareSheet("html"); if (!emailHTML) continueFlow(); // 2. HTML → リッチテキスト const richText = convertHTMLToRichText(emailHTML); // 3. リッチテキストからURLを取得 const extractedURL = matchText(richText, /https?:\/\/[^\s]+/); // 4. リッチテキスト → PDF化 → 保存 const pdfFile = convertRichTextToPDF(richText, "save.pdf", "classroombot"); // 5. PDFからテキスト抽出 const pdfText = extractTextFromPDF(pdfFile); // 6. 通知設定などからclass名抽出 const class_name = matchText(pdfText, /notification settings/); const url = matchText(pdfText, /https?:\/\/[^\s]+/); const classInfo = matchText(pdfText, new RegExp(`{i<= ${class_name} }\\n\\s]*`)); const replaced = replaceText(classInfo, /(?<=show details)\n\s]*/, "world"); // 7. ChatGPTに要約を依頼 openApp("ChatGPT"); goHome(); const summaryPrompt = ` Due to possible personal information, deep lin"> { // 1. メール共有からHTMLを受け取る const emailHTML = receiveFromShareSheet("html"); if (!emailHTML) continueFlow(); // 2. HTML → リッチテキスト const richText = convertHTMLToRichText(emailHTML); // 3. リッチテキストからURLを取得 const extractedURL = matchText(richText, /https?:\/\/[^\s]+/); // 4. リッチテキスト → PDF化 → 保存 const pdfFile = convertRichTextToPDF(richText, "save.pdf", "classroombot"); // 5. PDFからテキスト抽出 const pdfText = extractTextFromPDF(pdfFile); // 6. 通知設定などからclass名抽出 const class_name = matchText(pdfText, /notification settings/); const url = matchText(pdfText, /https?:\/\/[^\s]+/); const classInfo = matchText(pdfText, new RegExp(`{i<= ${class_name} }\\n\\s]*`)); const replaced = replaceText(classInfo, /(?<=show details)\n\s]*/, "world"); // 7. ChatGPTに要約を依頼 openApp("ChatGPT"); goHome(); const summaryPrompt = ` Due to possible personal information, deep lin">
const CreatePDFShortcut = {
  title: "Bot",
  onRun: () => {
    // 1. メール共有からHTMLを受け取る
    const emailHTML = receiveFromShareSheet("html");

    if (!emailHTML) continueFlow();

    // 2. HTML → リッチテキスト
    const richText = convertHTMLToRichText(emailHTML);

    // 3. リッチテキストからURLを取得
    const extractedURL = matchText(richText, /https?:\\/\\/[^\\s]+/);

    // 4. リッチテキスト → PDF化 → 保存
    const pdfFile = convertRichTextToPDF(richText, "save.pdf", "classroombot");

    // 5. PDFからテキスト抽出
    const pdfText = extractTextFromPDF(pdfFile);

    // 6. 通知設定などからclass名抽出
    const class_name = matchText(pdfText, /notification settings/);
    const url = matchText(pdfText, /https?:\\/\\/[^\\s]+/);
    const classInfo = matchText(pdfText, new RegExp(`{i<= ${class_name} }\\\\n\\\\s]*`));
    const replaced = replaceText(classInfo, /(?<=show details)\\n\\s]*/, "world");

    // 7. ChatGPTに要約を依頼
    openApp("ChatGPT");
    goHome();

    const summaryPrompt = `
      Due to possible personal information, deep linking is prohibited.
      Please output results only. Summarize the following content concisely.
      Please output in plain text only, not using .md format, regarding the output results.
    `;

    const summaryFormat = `
      Summary: (in one sentence)
      Key points:
        - (bullet point 1)
        - (bullet point 2)
        - (bullet point 3)
      If content doesn't exist, say "Does not exist."
    `;

    const chatResponse = askChatGPT(summaryPrompt + summaryFormat);

    // 8. 結果送信
    const message = formatMessage(chatResponse);
    const destination = "line";
    sendMessage(message, destination);
  }
};