File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { none , Option , Optional } from '../types/option' ;
2- import { TRSS , parseString } from '../parser/parse' ;
2+ import { parseString , TRSS } from '../parser/parse' ;
3+
34export async function isFeedValid ( feedStr : string ) : Promise < Option < TRSS > > {
45 try {
56 const feed = await parseString ( feedStr ) ;
@@ -15,7 +16,10 @@ export async function findFeed(
1516) : Promise < string [ ] > {
1617 const reqURL = new URL ( reqUrl ) ;
1718 const linksTag = html . match ( / < l i n k [ ^ > ] + r e l = " a l t e r n a t e " [ ^ > ] + \/ ? > / g) ;
18- const urls = linksTag
19+ if ( ! linksTag ) {
20+ return [ ] ;
21+ }
22+ return linksTag
1923 . filter ( ( t ) => t . match ( / r s s | a t o m / ) && t . includes ( 'href' ) )
2024 . map ( ( linkTag ) => {
2125 const url = linkTag . match ( / h r e f = " ( .+ ?) " / ) [ 1 ] ;
@@ -26,5 +30,4 @@ export async function findFeed(
2630 return reqURL . toString ( ) ;
2731 }
2832 } ) ;
29- return urls ;
3033}
Original file line number Diff line number Diff line change @@ -19,9 +19,7 @@ import { isNone } from '../types/option';
1919async function handlerSendError ( e : any , userId : number ) : Promise < boolean > {
2020 // bot was blocked or chat is deleted
2121 logger . error ( e ) ;
22- const re = new RegExp (
23- 'chat not found|bot was blocked by the user|bot was kicked'
24- ) ;
22+ const re = / c h a t n o t f o u n d | b o t w a s b l o c k e d b y t h e u s e r | b o t w a s k i c k e d | u s e r i s d e a c t i v a t e d / ;
2523 if ( config . delete_on_err_send && re . test ( e . description ) ) {
2624 logger . error ( `delete all subscribes for user ${ userId } ` ) ;
2725 deleteSubscribersByUserId ( userId ) ;
You can’t perform that action at this time.
0 commit comments