File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,6 +22,24 @@ function resolveCodeTtlSec(nowSec: number): number {
2222 return 30 - ( nowSec % 30 ) || 30 ;
2323}
2424
25+ function confirmationInlineKeyboard ( kind : 'trade' | 'login' , cacheId : number ) {
26+ if ( kind === 'trade' ) {
27+ return [
28+ [
29+ { text : 'Подтвердить' , callbackData : `sgl:a:${ cacheId } ` } ,
30+ { text : 'Отклонить' , callbackData : `sgl:r:${ cacheId } ` }
31+ ]
32+ ] ;
33+ }
34+
35+ return [
36+ [
37+ { text : 'Впустить' , callbackData : `sgl:a:${ cacheId } ` } ,
38+ { text : 'Не впускать' , callbackData : `sgl:r:${ cacheId } ` }
39+ ]
40+ ] ;
41+ }
42+
2543function formatLoginAlertMessage ( params : {
2644 alias : string ;
2745 steamid : string ;
@@ -248,14 +266,9 @@ async function runCycle(app: FastifyInstance): Promise<void> {
248266 await sendTelegramMessage (
249267 account . telegram_user_id ,
250268 `New ${ kind } confirmation for ${ account . alias } : ${ confirmation . headline } ` ,
251- kind === 'login'
269+ kind === 'trade' || kind === ' login'
252270 ? {
253- inlineKeyboard : [
254- [
255- { text : 'Впустить' , callbackData : `sgl:a:${ Number ( inserted . insertId ) } ` } ,
256- { text : 'Не впускать' , callbackData : `sgl:r:${ Number ( inserted . insertId ) } ` }
257- ]
258- ]
271+ inlineKeyboard : confirmationInlineKeyboard ( kind , Number ( inserted . insertId ) )
259272 }
260273 : undefined
261274 ) ;
Original file line number Diff line number Diff line change @@ -172,19 +172,31 @@ function isSteamSessionExpiredError(error: unknown): boolean {
172172}
173173
174174function normalizeLegacyKind ( rawItem : any ) : 'trade' | 'login' | 'other' {
175+ const clue = `${ rawItem ?. type_name ?? '' } ${ rawItem ?. headline ?? '' } ` . toLowerCase ( ) ;
175176 const rawType = Number ( rawItem ?. type ?? 0 ) ;
176177 if ( rawType === 2 ) {
177178 return 'trade' ;
178179 }
179180 if ( rawType === 3 ) {
180- return 'login' ;
181+ if ( clue . includes ( 'sign in' ) || clue . includes ( 'signin' ) || clue . includes ( 'login' ) ) {
182+ return 'login' ;
183+ }
184+ return 'trade' ;
181185 }
182186
183- const clue = `${ rawItem ?. type_name ?? '' } ${ rawItem ?. headline ?? '' } ` . toLowerCase ( ) ;
184187 if ( clue . includes ( 'sign in' ) || clue . includes ( 'signin' ) || clue . includes ( 'login' ) ) {
185188 return 'login' ;
186189 }
187190
191+ if (
192+ clue . includes ( 'selling for' ) ||
193+ clue . includes ( 'listed for' ) ||
194+ clue . includes ( 'trade' ) ||
195+ clue . includes ( 'market' )
196+ ) {
197+ return 'trade' ;
198+ }
199+
188200 return 'other' ;
189201}
190202
You can’t perform that action at this time.
0 commit comments