update format message, update favion icon and title

This commit is contained in:
joseph le 2023-09-19 08:34:02 +07:00
parent 425ca91172
commit 382b74ad83
7 changed files with 158 additions and 62 deletions

View File

@ -0,0 +1,8 @@
adfasf
anfasll ak shflks as klhfalk la EHWIC- fsjl
123 PVDM3- hui 800G2-POE-2
sdhgksd sjk hk error
abc 123 fail
abc 123 fail
sdhgksd sjk hk error
123 PVDM3- hui 800G2-POE-2

View File

@ -0,0 +1,44 @@
const zulip = require("zulip-js");
export async function deleteMessagesZulip(streamName, topicName, numOfDay) {
const config = {
zuliprc: "./download",
zulipVersion: "v2",
};
const client = await zulip(config);
try {
const messages = await client.messages.retrieve({
anchor: "oldest",
num_before: 0,
num_after: 5000,
narrow: [
{ operator: "stream", operand: streamName },
{ operator: "topic", operand: topicName },
],
});
// console.log(messages.messages.map(u=>u.reactions))
const members = await client.users.retrieve();
// console.log(members.members)
for (const message of messages.messages) {
if (
message.reactions.filter(
(i) =>
i.emoji_name === "working_on_it" &&
members.members.filter((u) => u.user_id === i.user_id)[0]
.is_admin === true
).length === 0 &&
message.timestamp <
Math.floor((Date.now() - 60000 * 60 * 24 * numOfDay) / 1000)
) {
const res = await client.messages.deleteById({
message_id: message.id,
});
console.log(`Deleted message ID ${message.id}`);
// console.log(res)
}
}
} catch (error) {
console.error("Error:", error);
}
}

View File

@ -7,8 +7,6 @@ import KeyValue from "App/Models/KeyValue";
import Database from "@ioc:Adonis/Lucid/Database";
import { sendMessToZulip } from "./sendMessToZulip";
import { getListLineByItem } from "./getListLineByItem";
import { screenShot } from "./screenShot";
import { uploadFileToZulip } from "./uploadFileZulip";
// export default class loggerAPI {
export async function runtimeCheckLogs(folderPath) {
@ -45,9 +43,11 @@ export async function runtimeCheckLogs(folderPath) {
//import log new file
// console.log(filePath)
if (
//Sua \\ --> /
filePath?.split(".")[filePath.split(".").length - 1] === "log" &&
filePath.split("/")[filePath.split("/").length - 1]?.split("-")[0] ===
//localhost
// filePath.split("\\")[filePath.split("\\").length - 1]?.split("-")[0] ===
moment(Date.now()).format("YYYYMMDD").toString()
) {
console.log("New file added: ", filePath);
@ -55,6 +55,7 @@ export async function runtimeCheckLogs(folderPath) {
{ file_name: filePath.split("/")[filePath.split("/").length - 1] },
{ file_name: filePath.split("/")[filePath.split("/").length - 1] }
);
//localhost
// await LogDetectFile.firstOrCreate(
// { file_name: filePath.split("\\")[filePath.split("\\").length - 1] },
// { file_name: filePath.split("\\")[filePath.split("\\").length - 1] }
@ -191,15 +192,24 @@ export async function runtimeCheckLogs(folderPath) {
let item = listExtraItem.includes(log.detected_content)
? ":medal: **" + log.detected_content + "**"
: ":small_orange_diamond: " + log.detected_content;
log.line?.map((line)=>{
log.line?.map((line) => {
issueFound =
issueFound +
"\n" +
line +
"$" +
contentFile[line-1]?.replace(log.detected_content, "`" + log.detected_content + "`")
})
issueFound +
"\n`" +
line +
"` " +
contentFile[line - 1]?.replace(
log.detected_content,
"[" +
log.detected_content +
"](https://logs.danielvu.com/logs/" +
fileName +
"#" +
line +
")"
);
});
content =
content +
"|" +
@ -228,23 +238,24 @@ export async function runtimeCheckLogs(folderPath) {
content +
"\n\n" +
spoiler +
"\n\n*Issue found:*\n" + issueFound
"\n\n***Issue found:***\n" +
issueFound
// uriImage +
// ")\n"
);
sendMessToZulip(
"stream",
"AUS_VN_Test",
"Test Log Alerts",
"------------\n\n:warning: :warning: **" +
fileName +
"**\n\n" +
content +
"\n\n" +
spoiler +
"\n\n*Issue found:*\n" + issueFound
);
// sendMessToZulip(
// "stream",
// "AUS_VN_Test",
// "Test Log Alerts",
// "------------\n\n:warning: :warning: **" +
// fileName +
// "**\n\n" +
// content +
// "\n\n" +
// spoiler +
// "\n\n*Issue found:*\n" + issueFound
// );
// }, 10000);
// }, 3000);

View File

@ -6,6 +6,7 @@ export const screenShot = async (filename, time) => {
args: ["--no-sandbox"],
});
try {
// Open a new page
const page = await browser.newPage();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -24,7 +24,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>Log View</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>

View File

@ -26,48 +26,63 @@
// // Close the browser
// })();
const zulip = require("zulip-js");
// const zulip = require("zulip-js");
const config = {
zuliprc: "./zuliprc",
zulipVersion: "v2",
};
// const config = {
// zuliprc: "./download",
// zulipVersion: "v2",
// };
async function deleteMessages() {
const client = await zulip(config);
// async function deleteMessages() {
// const client = await zulip(config);
// Thay thế "stream-name", "topic-name", và các mốc thời gian cụ thể
const streamName = "Result test - auto.nswteam.net";
const topicName = "AU-dev";
const startTime = Date.parse("2023-09-11T00:00:00Z");
const endTime = Date.parse("2023-09-11T23:59:59Z");
// // Thay thế "stream-name", "topic-name", và các mốc thời gian cụ thể
// const streamName = "Result test - auto.nswteam.net";
// const topicName = "test";
try {
const messages = await client.messages.retrieve({
anchor: "oldest",
num_before: 0,
num_after: 3, // Điều chỉnh theo nhu cầu của bạn
narrow: [
{ operator: "stream", operand: streamName },
{ operator: "topic", operand: topicName },
// {
// operator: ,
// operand: `169457100,1694571399`,
// },
],
});
console.log(messages.messages.map(obj=>obj.reactions))
// for (const message of messages.messages) {
// const res = await client.messages.deleteById({ message_id: message.id });
// console.log(`Deleted message ID ${message.id}`);
// console.log(res)
// }
} catch (error) {
console.error("Error:", error);
}
}
// try {
// const messages = await client.messages.retrieve({
// anchor: "oldest",
// num_before: 0,
// num_after: 5000, // Điều chỉnh theo nhu cầu của bạn
// narrow: [
// { operator: "stream", operand: streamName },
// { operator: "topic", operand: topicName },
// // {
// // operator: ,
// // operand: `169457100,1694571399`,
// // },
// ],
// });
// // console.log(messages.messages.map(u=>u.reactions))
// const members = await client.users.retrieve();
// // console.log(members.members)
// console.log(messages.messages.length)
// // await client.messages.deleteById([159454, 159455]);
// for (const message of messages.messages) {
// console.log(message.id)
// if (
// message.reactions.filter(
// (i) =>
// i.emoji_name === "working_on_it" &&
// members.members.filter((u) => u.user_id === i.user_id)[0]
// .is_admin === true
// ).length === 0 &&
// message.timestamp < Math.floor((Date.now() - 60000*60*24*10) / 1000)
// ) {
// const res = await client.messages.deleteById({
// message_id: message.id,
// });
// console.log(`Deleted message ID ${message.id}`);
// console.log(res)
// }
// }
// } catch (error) {
// console.error("Error:", error);
// }
// }
deleteMessages();
// deleteMessages();
// const zulip = require("zulip-js");
// const fs = require("fs");
@ -145,3 +160,20 @@ deleteMessages();
// const filePath = 'screenshot.png'; // Replace with your file path
// uploadFileToZulip(filePath);
// const puppeteer = require("puppeteer");
// (async () => {
// const browser = await puppeteer.launch();
// // Store the endpoint to be able to reconnect to the browser.
// const browserWSEndpoint = browser.wsEndpoint("https://pptr.dev/api/puppeteer.browser");
// // Disconnect puppeteer from the browser.
// browser.disconnect();
// // Use the endpoint to reestablish a connection
// const browser2 = await puppeteer.connect({browserWSEndpoint});
// // Close the browser.
// await browser2.close();
// })();