Skip to content

Instantly share code, notes, and snippets.

@RoachLin
Created May 22, 2024 14:57
Show Gist options
  • Select an option

  • Save RoachLin/ee4ebb104ca6d934117e66b07a103133 to your computer and use it in GitHub Desktop.

Select an option

Save RoachLin/ee4ebb104ca6d934117e66b07a103133 to your computer and use it in GitHub Desktop.
showroom开播提醒bot v3版本
// 教程:https://www.bilibili.com/read/cv27985834/
var i;
var j;
var respond;
var json;
var send;
var date;
var year;
var offset;
const roomIDList = new Array();
/* -------------------- =LOVE -------------------- */
roomIDList.push("107419"); // 大谷 映美里(=LOVE)
roomIDList.push("107470"); // 大場 花菜(=LOVE)
roomIDList.push("106820"); // 音嶋 莉沙(=LOVE)
roomIDList.push("106267"); // 齋藤 樹愛羅(=LOVE)
roomIDList.push("106268"); // 佐々木 舞香(=LOVE)
roomIDList.push("106270"); // 髙松 瞳(=LOVE)
roomIDList.push("107457"); // 瀧脇 笙古(=LOVE)
roomIDList.push("106016"); // 野口 衣織(=LOVE)
roomIDList.push("106264"); // 諸橋 沙夏(=LOVE)
roomIDList.push("105923"); // 山本 杏奈(=LOVE)
/* -------------------- ≠ME -------------------- */
roomIDList.push("230189"); // 尾木 波菜(≠ME)
roomIDList.push("230161"); // 落合 希来里(≠ME)
roomIDList.push("230160"); // 蟹沢 萌子(≠ME)
roomIDList.push("228540"); // 河口 夏音(≠ME)
roomIDList.push("230185"); // 川中子 奈月心(≠ME)
roomIDList.push("230164"); // 櫻井 もも(≠ME)
roomIDList.push("230175"); // 菅波 美玲(≠ME)
roomIDList.push("230181"); // 鈴木 瞳美(≠ME)
roomIDList.push("230174"); // 谷崎 早耶(≠ME)
roomIDList.push("230219"); // 冨田 菜々風(≠ME)
roomIDList.push("230208"); // 永田 詩央里(≠ME)
roomIDList.push("230171"); // 本田 珠由記(≠ME)
/* -------------------- ≒JOY -------------------- */
roomIDList.push("387113"); // 逢田 珠里依(≒JOY)
roomIDList.push("387127"); // 天野 香乃愛(≒JOY)
roomIDList.push("387845"); // 市原 愛弓(≒JOY)
roomIDList.push("387812"); // 江角 怜音(≒JOY)
roomIDList.push("387179"); // 大信田 美月(≒JOY)
roomIDList.push("387187"); // 大西 葵(≒JOY)
roomIDList.push("150710"); // 小澤 愛実(≒JOY)
roomIDList.push("387836"); // 髙橋 舞(≒JOY)
roomIDList.push("387164"); // 藤沢 莉子(≒JOY)
roomIDList.push("387863"); // 村山 結香(≒JOY)
roomIDList.push("387209"); // 山田 杏佳(≒JOY)
roomIDList.push("387814"); // 山野 愛月(≒JOY)
/* -------------------- 官方直播间 -------------------- */
roomIDList.push("139470"); // =LOVE 山本杏奈の「教えて、花便り」
roomIDList.push("272301"); // のいみーのいみ。
roomIDList.push("402345"); // 火曜はじょ〜いドン!
/* -------------------- 指P -------------------- */
roomIDList.push("61774"); // 指原 莉乃
const roomIDListLength = roomIDList.length;
const liveStatusList = new Array(roomIDListLength);
for (i = 0; i < roomIDListLength; ++i) {
liveStatusList[i] = 1; // 1:未开播,2:已开播
}
const liveEndTimeList = new Array(roomIDListLength);
for (i = 0; i < roomIDListLength; ++i) {
liveEndTimeList[i] = 0;
}
const birthdayMonthList = new Array();
const birthdayDayList = new Array();
/* -------------------- =LOVE -------------------- */
birthdayMonthList.push(3); // 大谷 映美里(=LOVE)
birthdayDayList.push(15); // 大谷 映美里(=LOVE)
birthdayMonthList.push(2); // 大場 花菜(=LOVE)
birthdayDayList.push(4); // 大場 花菜(=LOVE)
birthdayMonthList.push(8); // 音嶋 莉沙(=LOVE)
birthdayDayList.push(11); // 音嶋 莉沙(=LOVE)
birthdayMonthList.push(11); // 齋藤 樹愛羅(=LOVE)
birthdayDayList.push(26); // 齋藤 樹愛羅(=LOVE)
birthdayMonthList.push(1); // 佐々木 舞香(=LOVE)
birthdayDayList.push(21); // 佐々木 舞香(=LOVE)
birthdayMonthList.push(1); // 髙松 瞳(=LOVE)
birthdayDayList.push(19); // 髙松 瞳(=LOVE)
birthdayMonthList.push(7); // 瀧脇 笙古(=LOVE)
birthdayDayList.push(9); // 瀧脇 笙古(=LOVE)
birthdayMonthList.push(4); // 野口 衣織(=LOVE)
birthdayDayList.push(26); // 野口 衣織(=LOVE)
birthdayMonthList.push(8); // 諸橋 沙夏(=LOVE)
birthdayDayList.push(3); // 諸橋 沙夏(=LOVE)
birthdayMonthList.push(11); // 山本 杏奈(=LOVE)
birthdayDayList.push(30); // 山本 杏奈(=LOVE)
/* -------------------- ≠ME -------------------- */
birthdayMonthList.push(5); // 尾木 波菜(≠ME)
birthdayDayList.push(8); // 尾木 波菜(≠ME)
birthdayMonthList.push(5); // 落合 希来里(≠ME)
birthdayDayList.push(22); // 落合 希来里(≠ME)
birthdayMonthList.push(10); // 蟹沢 萌子(≠ME)
birthdayDayList.push(25); // 蟹沢 萌子(≠ME)
birthdayMonthList.push(7); // 河口 夏音(≠ME)
birthdayDayList.push(29); // 河口 夏音(≠ME)
birthdayMonthList.push(9); // 川中子 奈月心(≠ME)
birthdayDayList.push(26); // 川中子 奈月心(≠ME)
birthdayMonthList.push(4); // 櫻井 もも(≠ME)
birthdayDayList.push(13); // 櫻井 もも(≠ME)
birthdayMonthList.push(2); // 菅波 美玲(≠ME)
birthdayDayList.push(5); // 菅波 美玲(≠ME)
birthdayMonthList.push(4); // 鈴木 瞳美(≠ME)
birthdayDayList.push(13); // 鈴木 瞳美(≠ME)
birthdayMonthList.push(10); // 谷崎 早耶(≠ME)
birthdayDayList.push(7); // 谷崎 早耶(≠ME)
birthdayMonthList.push(7); // 冨田 菜々風(≠ME)
birthdayDayList.push(17); // 冨田 菜々風(≠ME)
birthdayMonthList.push(4); // 永田 詩央里(≠ME)
birthdayDayList.push(2); // 永田 詩央里(≠ME)
birthdayMonthList.push(2); // 本田 珠由記(≠ME)
birthdayDayList.push(27); // 本田 珠由記(≠ME)
/* -------------------- ≒JOY -------------------- */
birthdayMonthList.push(9); // 逢田 珠里依(≒JOY)
birthdayDayList.push(13); // 逢田 珠里依(≒JOY)
birthdayMonthList.push(1); // 天野 香乃愛(≒JOY)
birthdayDayList.push(21); // 天野 香乃愛(≒JOY)
birthdayMonthList.push(8); // 市原 愛弓(≒JOY)
birthdayDayList.push(21); // 市原 愛弓(≒JOY)
birthdayMonthList.push(4); // 江角 怜音(≒JOY)
birthdayDayList.push(26); // 江角 怜音(≒JOY)
birthdayMonthList.push(9); // 大信田 美月(≒JOY)
birthdayDayList.push(27); // 大信田 美月(≒JOY)
birthdayMonthList.push(8); // 大西 葵(≒JOY)
birthdayDayList.push(6); // 大西 葵(≒JOY)
birthdayMonthList.push(4); // 小澤 愛実(≒JOY)
birthdayDayList.push(9); // 小澤 愛実(≒JOY)
birthdayMonthList.push(2); // 髙橋 舞(≒JOY)
birthdayDayList.push(22); // 髙橋 舞(≒JOY)
birthdayMonthList.push(1); // 藤沢 莉子(≒JOY)
birthdayDayList.push(16); // 藤沢 莉子(≒JOY)
birthdayMonthList.push(2); // 村山 結香(≒JOY)
birthdayDayList.push(15); // 村山 結香(≒JOY)
birthdayMonthList.push(2); // 山田 杏佳(≒JOY)
birthdayDayList.push(2); // 山田 杏佳(≒JOY)
birthdayMonthList.push(10); // 山野 愛月(≒JOY)
birthdayDayList.push(21); // 山野 愛月(≒JOY)
/* -------------------- 指P -------------------- */
birthdayMonthList.push(11); // 指原 莉乃
birthdayDayList.push(21); // 指原 莉乃
const birthdayMonthListLength = birthdayMonthList.length;
const birthdayStatusList = new Array(birthdayMonthListLength);
for (i = 0; i < birthdayMonthListLength; ++i) {
birthdayStatusList[i] = 2023;
}
const memberList = new Array();
/* -------------------- =LOVE -------------------- */
memberList.push("大谷 映美里(=LOVE)");
memberList.push("大場 花菜(=LOVE)");
memberList.push("音嶋 莉沙(=LOVE)");
memberList.push("齋藤 樹愛羅(=LOVE)");
memberList.push("佐々木 舞香(=LOVE)");
memberList.push("髙松 瞳(=LOVE)");
memberList.push("瀧脇 笙古(=LOVE)");
memberList.push("野口 衣織(=LOVE)");
memberList.push("諸橋 沙夏(=LOVE)");
memberList.push("山本 杏奈(=LOVE)");
/* -------------------- ≠ME -------------------- */
memberList.push("尾木 波菜(≠ME)");
memberList.push("落合 希来里(≠ME)");
memberList.push("蟹沢 萌子(≠ME)");
memberList.push("河口 夏音(≠ME)");
memberList.push("川中子 奈月心(≠ME)");
memberList.push("櫻井 もも(≠ME)");
memberList.push("菅波 美玲(≠ME)");
memberList.push("鈴木 瞳美(≠ME)");
memberList.push("谷崎 早耶(≠ME)");
memberList.push("冨田 菜々風(≠ME)");
memberList.push("永田 詩央里(≠ME)");
memberList.push("本田 珠由記(≠ME)");
/* -------------------- ≒JOY -------------------- */
memberList.push("逢田 珠里依(≒JOY)");
memberList.push("天野 香乃愛(≒JOY)");
memberList.push("市原 愛弓(≒JOY)");
memberList.push("江角 怜音(≒JOY)");
memberList.push("大信田 美月(≒JOY)");
memberList.push("大西 葵(≒JOY)");
memberList.push("小澤 愛実(≒JOY)");
memberList.push("髙橋 舞(≒JOY)");
memberList.push("藤沢 莉子(≒JOY)");
memberList.push("村山 結香(≒JOY)");
memberList.push("山田 杏佳(≒JOY)");
memberList.push("山野 愛月(≒JOY)");
/* -------------------- 指P -------------------- */
memberList.push("指原 莉乃");
console.show();
loop1: while (true) {
send = "";
for (i = 0; i < roomIDListLength; ++i) {
// 如果网络不稳定、断网,这里就会报错,只能直接退出循环
try {
respond = http.get(
"https://www.showroom-live.com/api/live/live_info?room_id=" +
roomIDList[i]
);
} catch (error) {
console.error(error);
sleep(30 * 1000);
continue loop1;
}
if (respond.statusCode != 200) {
// 访问被拒绝,可能是短时间内访问太多次了,同样只能退出循环
console.error(respond.statusCode);
sleep(30 * 1000);
continue loop1;
} else {
// 此处可能出现connection reset错误,原因不明,同样只能退出循环
try {
json = respond.body.json();
} catch (error) {
console.error(error);
sleep(30 * 1000);
continue loop1;
}
if (liveStatusList[i] == 1 && json.live_status == 2) {
if (Date.now() - liveEndTimeList[i] > 5 * 60 * 1000) {
send = send + json.room_name + "\n" + "▶️ 直播中!" + "\n" + "\n";
liveStatusList[i] = json.live_status;
console.log(json.room_name, "已开播");
} else {
liveStatusList[i] = json.live_status;
console.log(json.room_name, "疑似断线重连");
}
} else if (liveStatusList[i] == 2 && json.live_status == 1) {
liveStatusList[i] = json.live_status;
liveEndTimeList[i] = Date.now();
console.log(json.room_name, "已下播");
} else if (liveStatusList[i] == 2 && json.live_status == 2) {
console.log(json.room_name, "✓");
} else if (liveStatusList[i] == 1 && json.live_status == 1) {
console.log(json.room_name);
}
if (i == roomIDListLength - 1) {
date = new Date();
year = date.getFullYear();
for (j = 0; j < birthdayMonthListLength; ++j) {
if (year > birthdayStatusList[j]) {
date = new Date(
year,
birthdayMonthList[j] - 1,
birthdayDayList[j],
0,
0,
0,
0
);
offset = Date.now() - (date.getTime() - 1 * 60 * 60 * 1000);
if (offset >= 0 && offset < 24 * 60 * 60 * 1000) {
send =
send +
memberList[j] +
"\n" +
"🎂 生日快乐!" +
"\n" +
year.toString() +
"." +
(date.getMonth() + 1).toString() +
"." +
date.getDate().toString() +
"\n" +
"\n";
birthdayStatusList[j] = year;
console.log(memberList[j], "生日快乐!");
}
}
}
}
}
sleep(100); // 每次查询之间象征性休眠一会儿
}
if (send == "") {
click(520, 80); // 如果待发送内容为空,也点击一下屏幕,防止手机熄屏
} else {
date = new Date();
send += date.toTimeString().replace("GMT+0800 (GMT+08:00)", "");
setText(send);
sleep(100); // 休眠一会儿,防止发送键点太快了,也防止QQ检测
while (!click("发送"));
}
date = new Date();
console.log(date.toTimeString().replace("GMT+0800 (GMT+08:00)", ""));
sleep(30 * 1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment