enhancement(lint): Fix lint errors for src/modules/seven39feed.ts

Co-authored-by: NeonGamerBot-QK <neon@saahild.com>
Signed-off-by: zeon-neon[bot] <136533918+zeon-neon[bot]@users.noreply.github.com>
This commit is contained in:
zeon-neon[bot] 2025-03-12 01:38:16 +00:00 committed by GitHub
parent 5428926d8d
commit c6c9318cbe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,118 +1,119 @@
import { Cron } from "croner";
import { ModifiedApp } from "./slackapp";
export interface SevenTimeline {
success: boolean;
posts: Post[];
hasMore: boolean;
totalCount: number;
}
export interface Post {
id: string;
content: string;
authorId: string;
createdAt: string;
updatedAt: string;
imageUrl?: string;
author: Author;
likes: Like[];
replies: (Reply | Replies2 | Replies3)[];
hasLiked: boolean;
likeCount: number;
}
export interface Replies3 {
id: string;
content: string;
postId: string;
authorId: string;
createdAt: string;
updatedAt: string;
author: Author;
likes: any[];
hasLiked: boolean;
likeCount: number;
}
export interface Replies2 {
id: string;
content: string;
postId: string;
authorId: string;
createdAt: string;
updatedAt: string;
author: Author;
likes: Like2[];
hasLiked: boolean;
likeCount: number;
}
export interface Reply {
id: string;
content: string;
postId: string;
authorId: string;
createdAt: string;
updatedAt: string;
author: Author;
likes: Like2[];
hasLiked: boolean;
likeCount: number;
}
export interface Like2 {
id: string;
postId?: any;
replyId: string;
userId: string;
createdAt: string;
}
export interface Like {
id: string;
postId: string;
replyId?: any;
userId: string;
createdAt: string;
}
export interface Author {
id: string;
username: string;
avatar: Avatar;
}
export interface Avatar {
bg: string;
animal: string;
}
export function setupSeverCron(app:ModifiedApp) {
new Cron('39-59 19-22 * * *', async () => {
const data = await fetch('https://www.seven39.com/timeline', {
method: 'POST',
headers: {
'accept': 'text/x-component',
'accept-language': 'en-US,en;q=0.9',
'content-type': 'text/plain;charset=UTF-8',
'next-action': '60f5fd81034ead85c201a71fc0b495af5b112e870f',
'next-router-state-tree': '%5B%22%22%2C%7B%22children%22%3A%5B%22timeline%22%2C%7B%22children%22%3A%5B%22__PAGE__%22%2C%7B%7D%2C%22%2Ftimeline%22%2C%22refresh%22%5D%7D%5D%7D%2Cnull%2Cnull%2Ctrue%5D'
},
body: '[]'
}).then(r=>r.text());
const dataa = JSON.parse(data.split('\n1:')[1]) as SevenTimeline
// writeFileSync('data.json', JSON.stringify(dataa, null, 2))
for(const post of dataa.posts) {
await new Promise(r=> setTimeout(r, 10))
if(app.dbs.seven39.get(post.id)) continue;
const str = `${post.content}${post.imageUrl ? "\n" + post.imageUrl : ""}\nLikes: ${post.likeCount} - Author: ${post.author.username} - ${post.replies.length} - Created at: ${post.createdAt}`
await app.client.chat.postMessage({
text: str,
channel: `C08H3KGF27Q`
})
// post.content)
// console.log(`Likes: ${post.likeCount} - Author: ${post.author.username} - ${post.replies.length}`)
app.dbs.seven39.set(post.id, true)
await new Promise(r=> setTimeout(r, 100))
}
});
}
success: boolean;
posts: Post[];
hasMore: boolean;
totalCount: number;
}
export interface Post {
id: string;
content: string;
authorId: string;
createdAt: string;
updatedAt: string;
imageUrl?: string;
author: Author;
likes: Like[];
replies: (Reply | Replies2 | Replies3)[];
hasLiked: boolean;
likeCount: number;
}
export interface Replies3 {
id: string;
content: string;
postId: string;
authorId: string;
createdAt: string;
updatedAt: string;
author: Author;
likes: any[];
hasLiked: boolean;
likeCount: number;
}
export interface Replies2 {
id: string;
content: string;
postId: string;
authorId: string;
createdAt: string;
updatedAt: string;
author: Author;
likes: Like2[];
hasLiked: boolean;
likeCount: number;
}
export interface Reply {
id: string;
content: string;
postId: string;
authorId: string;
createdAt: string;
updatedAt: string;
author: Author;
likes: Like2[];
hasLiked: boolean;
likeCount: number;
}
export interface Like2 {
id: string;
postId?: any;
replyId: string;
userId: string;
createdAt: string;
}
export interface Like {
id: string;
postId: string;
replyId?: any;
userId: string;
createdAt: string;
}
export interface Author {
id: string;
username: string;
avatar: Avatar;
}
export interface Avatar {
bg: string;
animal: string;
}
export function setupSeverCron(app: ModifiedApp) {
new Cron("39-59 19-22 * * *", async () => {
const data = await fetch("https://www.seven39.com/timeline", {
method: "POST",
headers: {
accept: "text/x-component",
"accept-language": "en-US,en;q=0.9",
"content-type": "text/plain;charset=UTF-8",
"next-action": "60f5fd81034ead85c201a71fc0b495af5b112e870f",
"next-router-state-tree":
"%5B%22%22%2C%7B%22children%22%3A%5B%22timeline%22%2C%7B%22children%22%3A%5B%22__PAGE__%22%2C%7B%7D%2C%22%2Ftimeline%22%2C%22refresh%22%5D%7D%5D%7D%2Cnull%2Cnull%2Ctrue%5D",
},
body: "[]",
}).then((r) => r.text());
const dataa = JSON.parse(data.split("\n1:")[1]) as SevenTimeline;
// writeFileSync('data.json', JSON.stringify(dataa, null, 2))
for (const post of dataa.posts) {
await new Promise((r) => setTimeout(r, 10));
if (app.dbs.seven39.get(post.id)) continue;
const str = `${post.content}${post.imageUrl ? "\n" + post.imageUrl : ""}\nLikes: ${post.likeCount} - Author: ${post.author.username} - ${post.replies.length} - Created at: ${post.createdAt}`;
await app.client.chat.postMessage({
text: str,
channel: `C08H3KGF27Q`,
});
// post.content)
// console.log(`Likes: ${post.likeCount} - Author: ${post.author.username} - ${post.replies.length}`)
app.dbs.seven39.set(post.id, true);
await new Promise((r) => setTimeout(r, 100));
}
});
}