forked from juzheng/sdu-course-bot
		
	refactor:使用telegram通知
This commit is contained in:
		| @@ -36,17 +36,17 @@ axiosRetry(sduAxios, { | ||||
|  | ||||
| export async function logAndNotifyUser(text: string) { | ||||
|     console.log(text) | ||||
|     await axios.post('https://qmsg.zendee.cn/send/' + appConfig.qmsgKey, qs.stringify({ | ||||
|         msg: text | ||||
|     }), { | ||||
|         headers: { | ||||
|             'Content-Type': 'application/x-www-form-urlencoded' | ||||
|         } | ||||
|     }) | ||||
|     // await axios.post('https://' + appConfig.tgApiDomain + '/bot' + appConfig.tgApiKey + '/sendMessage', qs.stringify({ | ||||
|     //     chat_id: appConfig.tgChatId, | ||||
|     //     text: text | ||||
|     // })) | ||||
|     // await axios.post('https://qmsg.zendee.cn/send/' + appConfig.qmsgKey, qs.stringify({ | ||||
|     //     msg: text | ||||
|     // }), { | ||||
|     //     headers: { | ||||
|     //         'Content-Type': 'application/x-www-form-urlencoded' | ||||
|     //     } | ||||
|     // }) | ||||
|     await axios.post('https://' + appConfig.tgApiDomain + '/bot' + appConfig.tgApiKey + '/sendMessage', qs.stringify({ | ||||
|         chat_id: appConfig.tgChatId, | ||||
|         text: text | ||||
|     })) | ||||
| } | ||||
|  | ||||
| export function sleep(ms: number) { | ||||
|   | ||||
							
								
								
									
										22
									
								
								src/test.ts
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								src/test.ts
									
									
									
									
									
								
							| @@ -1,5 +1,5 @@ | ||||
| import {appConfig} from "./config" | ||||
| import {sduAxios} from "./includes" | ||||
| import {logAndNotifyUser, sduAxios} from "./includes" | ||||
| import {reqBody} from "./poll" | ||||
| import * as fs from "fs" | ||||
| import {IJsonCourse} from "./types" | ||||
| @@ -19,15 +19,17 @@ async function test() { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|  | ||||
|     let resp = await sduAxios.post('/jsxsd/xsxkkc/xsxkGgxxkxk?kcxx=&skls=&skxq=&skjc=&sfym=false&sfct=false&szjylb=&sfxx=true&skfs=&xqid=', reqBody) | ||||
|     fs.writeFileSync('arr.json', JSON.stringify(resp.data.aaData, null, 2)) | ||||
|     let courseList: IJsonCourse[] = resp.data.aaData | ||||
|     courseList = courseList.filter(single => single.kcmc.includes('稷下创新') | ||||
|         && single.xf >= 2) | ||||
|     for (let course of courseList) { | ||||
|         console.log(course.kcmc + ' ' + course.kch + ' ' + course.kxh + ' ' + course.syrs + ' ' + course.xf) | ||||
|     } | ||||
|     // sduAxios.defaults.headers['Cookie'] = 'bzb_jsxsd=91B210AA0E876E6C973D8CD52DBB9A5C; bzb_njw=705AF60821F8C9A23CB373F2A0369B85; SERVERID=121' | ||||
|     // let resp = await sduAxios.post('/jsxsd/xsxkkc/xsxkGgxxkxk?kcxx=&skls=&skxq=&skjc=&sfym=false&sfct=false&szjylb=&sfxx=true&skfs=&xqid=', reqBody) | ||||
|     // console.log(resp.data) | ||||
|     // fs.writeFileSync('arr.json', JSON.stringify(resp.data.aaData, null, 2)) | ||||
|     // let courseList: IJsonCourse[] = resp.data.aaData | ||||
|     // courseList = courseList.filter(single => single.kcmc.includes('稷下创新') | ||||
|     //     && single.xf >= 2) | ||||
|     // for (let course of courseList) { | ||||
|     //     console.log(course.kcmc + ' ' + course.kch + ' ' + course.kxh + ' ' + course.syrs + ' ' + course.xf) | ||||
|     // } | ||||
|     logAndNotifyUser('log test') | ||||
| } | ||||
|  | ||||
| test() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user