function formatDate(date: Date, sep: string): string { const yyyy = date.getFullYear(); const mm = ("00" + (date.getMonth() + 1)).slice(-2); const dd = ("00" + date.getDate()).slice(-2); return `${yyyy}${sep}${mm}${sep}${dd}`; } const fetch_retry = async (url: string, n: number): Promise => { try { return await fetch(url); } catch (err) { if (n === 1) { throw err; } return await fetch_retry(url, n - 1); } }; const sub1 = async ( index: number, quiet: boolean ): Promise<{ date: string; res: RegExpExecArray[] }> => { const date = new Date(Date.now()); date.setDate(date.getDate() + index); const datetext = formatDate(date, "/"); const pglisttempreq = await fetch_retry( `https://scrapbox.io/api/pages/villagepump/${encodeURIComponent( datetext )}/text`, 15 ); if (!quiet) { console.log(datetext); } const pglisttemptxt = await pglisttempreq.text(); if (pglisttempreq.status == 200) { const ma = pglisttemptxt.matchAll(/\[([^\[\]]*)\.icon\*?[0-9]*\]/g); return { date: datetext, res: Array.from(ma) }; } else { console.error(datetext, "not found"); return { date: datetext, res: [] }; } }; const userlist: readonly string[] = [ "1O2RT", "4513echo", "45Nuyagawa", "Aritaka", "AttoCat", "AzukiCandy", "Buntin", "C.C.Lemon", "Cafe", "ChatGPT", "Gen", "Gorira Tatsu", "Gorira_Tatsu", "Hal_O‘Knoll", "Hinami173", "Hiro Aki", "Hope Rike (Rikehope)", "Hyou", "Idobatanishi", "InkoHX", "Kenshiro", "Kent", "Lovun1", "MS", "Mijinko_SD", "Minemu", "Miyabi", "MugiSus", "Naa_tsure", "Naoki Shima", "OKITO", "REN", "RR", "RRM", "Rand", "Rein", "Renick", "Riley", "Rokumon", "Sazaragi", "Summer498", "Taisei117", "TakamiChie", "TomiXRM", "Waranziya", "Yakuruton", "aaaaninja", "akku", "amemy", "anonymous", "applessk", "applism118", "asaka_s", "auto_chan", "avashe", "axpensive", "bara0", "bettttou", "biwa", "blu3mo", "bsahd", "cFQ2f7LRuLYP", "cak", "claude", "cman", "comgy", "conpota", "coolwind0202", "dai", "daiiz", "daikai", "dn0t_", "dnin", "dokudami", "erniogi", "frain", "fumito", "ggkkiwat", "hanamichi", "hata6502", "hatori", "healthy-sato", "hide", "hiragi", "hiroki", "hiroshi", "hnymht", "hoko", "hoshio", "ik", "ikoanymg", "imo", "inajob", "inori", "inoue2002", "io_saito", "iro", "iroami", "jgs", "june29", "juneboku", "k11115555", "k47de", "kaito5373", "kakakaya", "kamesuke42", "kamo", "kan", "kana", "kani100g", "kaorukit", "kaya", "kbyshwtn", "keiichi.yokoyama", "kendea", "kentnkmr", "kidooom", "kiichi", "kikuchis", "kimihito", "kiyo", "kofu", "koyoshi", "kts", "ktsuyu2525", "kumatako", "kuroma6666", "kutsumofu", "kuucyn", "kuuote", "kyamad9", "kzmi", "lsajfk", "mactkg", "maichan", "makoton", "maobushi", "marimocchi", "masa6272", "masumi", "matobaa", "md", "meganii", "memoru", "mgn901", "miminashi", "minetaro12", "misonln41", "miura", "miyamonz", "mizdra", "mizz", "mktoho", "mm", "mo mo", "mocchi", "moeki", "momeemt", "mos", "mrsekut", "mtane0412", "mthr", "mushy", "nakamuramk", "nalayama089", "nariakiiwatani", "natsukium", "nejimaki", "newwingbird", "nhayato", "nishio", "nomadoor", "nrRoute", "odiak", "okadada", "okito", "onokatio", "onomotoharu", "opd93zk", "opz", "per_terra", "pogin503", "pogin909", "pongpewpong", "popsilon", "project okd", "qo", "rashita", "reira", "rickshinmi", "rmaruon", "rtree", "ryunosuke", "sakiyama", "satokoki", "seibe", "sekiyasu", "sellsshimizu", "sh1ma", "shiganana", "shio", "shotato", "shoya140", "sizumita", "sjntn", "sk6cleine", "ssig33", "sta", "star_field", "suchi", "suika", "sume", "suto3", "swawa_yu", "taigasaito", "taikisato", "takano32", "takaoka", "takker", "takkii", "tatta", "tellu", "tetsuya-k", "teyoda7", "thinceller", "tkgshn", "tom", "toribird", "torish14", "tosho", "tosiiu", "tsuzumik", "uchan", "udonn", "uni_kalifa", "uribo", "utanaka", "uvoa", "wakaran", "waterking", "wi3per", "windymelt", "wing", "wogikaze", "worktips3838", "xyx", "y", "yamanoku", "yanma", "yasushi_sapporo", "ygsts", "ykic", "yosider", "yugo", "yuiseki", "yuki_minoh", "yupbox", "yuta0801", "yuta0801.old", "yuta25", "yutaro", "yuyuko", "zk_phi", "あしやまひろこ", "あとにいく", "あなるけつお", "うやまる", "えむおー", "ししかわ", "しめさば80", "つばくろ", "はるひ", "ひい らぎ", "イタロー", "クオリアさん", "ロボカス", "久住哲", "基素", "山本健太", "悲しみの41番", "情報うさぎ", "日付入れ太郎", "滝沢悠太", "玄武", "綾坂こと", "菅原宏治", "蒼", "隼のぉ豆頁", "青野ブン", "鶏七味", "龍太郎鈴木", "masui", ]; export default async function getdiaryaulist(quiet: boolean) { const promises: Promise<{ date: string; res: RegExpExecArray[] }>[] = []; for (let index = -30; index < 0; index++) { promises.push(sub1(index, quiet)); } const res = await Promise.all(promises); const ress: string[] = []; res.forEach((r) => { const res2: string[] = []; r.res.forEach((e) => { res2.push(e[1]); }); const sete = Array.from(new Set(res2)); const sete2: string[] = []; sete.forEach((e) => { if (userlist.includes(e)) { sete2.push(e); } }); ress.push(`${r.date} [${sete2.join(".icon][")}.icon]`); }); return ress.join("\n"); } import { Command } from "https://deno.land/x/cliffy@v1.0.0-rc.4/command/mod.ts"; const { options } = await new Command() .name("日記からアクティブユーザーを生成する") .version("0.1") .description("日記からアクティブユーザーを生成する by bsahd") .option("-q, --quiet", "disable output.") .option("-o=, --output=", "output file name", { required: true, conflicts: ["console"], }) .option("-c, --console", "output to console", { required: true, conflicts: ["output"], }) .parse(Deno.args); if (options.console) { const a = await getdiaryaulist(Boolean(options.quiet)); if (!options.quiet) { console.log(""); console.log(""); console.log("===================="); console.log("below is output"); console.log("===================="); console.log(""); console.log(""); } console.log(a); } else { if (options.output) { await Deno.writeTextFile( options.output, await getdiaryaulist(Boolean(options.quiet)) ); console.log(`output is in ${options.output}`); } else { console.log("Error:options.output not found") } }