@@ -21,7 +21,6 @@ import { erc20Provider } from "../../providers/erc20Provider";
2121import packageJson from "../../../package.json" ;
2222import { AuctionDto } from "@/types/dtos/Auction.dto" ;
2323
24- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2524const noticeBotTelegram = async ( message : string ) => {
2625 try {
2726 const version = `\n_${ ENV } -v${ packageJson . version } _` ;
@@ -32,7 +31,7 @@ const noticeBotTelegram = async (message: string) => {
3231 parse_mode : "Markdown"
3332 } ) ;
3433 } catch ( error ) {
35- console . error ( "Error noticeBotDiscord " , error ) ;
34+ console . error ( "Error noticeBot " , error ) ;
3635 if ( ! API_TELEGRAM || ! CHATID_MOBOX ) {
3736 console . error ( "API_TELEGRAM or CHATID_MOBOX is not defined" ) ;
3837 }
@@ -54,13 +53,25 @@ const noticeBotDiscord = async (message: string) => {
5453 }
5554 ) ;
5655 } catch ( error ) {
57- console . error ( "Error noticeBotDiscord " , error ) ;
56+ console . error ( "Error noticeBot " , error ) ;
5857 if ( ! DISCORD_BOT_TOKEN || ! CHANNEL_ID_DISCORD ) {
5958 console . error ( "DISCORD_BOT_TOKEN or CHANNEL_ID_DISCORD is not defined" ) ;
6059 }
6160 }
6261} ;
6362
63+ const noticeBot = async ( message : string ) => {
64+ if ( ENV === Environment . TESTNET ) {
65+ console . log ( "Notice bot testnet" ) ;
66+ return ;
67+ }
68+ try {
69+ await noticeBotTelegram ( message ) ;
70+ } catch {
71+ await noticeBotDiscord ( message ) ;
72+ }
73+ } ;
74+
6475export const noticeProfitAuction = async (
6576 bidAuction : BidAuction ,
6677 auctionStatus : BidStatus ,
@@ -93,7 +104,7 @@ export const noticeProfitAuction = async (
93104 bidAuction . type === BidType . PRO ? `\nTokenId: ${ bidAuction . auctions [ 0 ] . tokenId } ` : "" ;
94105 const txInfo = txHash ? `\nTx info: [here](${ EXPLORER_URL } /tx/${ txHash } )` : "" ;
95106 const message = `${ status } ${ profit } ${ bidType } ${ totalPrice } ${ amounts } ${ amount } ${ ids } ${ tokenId } ${ txInfo } ` ;
96- await noticeBotDiscord ( message ) ;
107+ await noticeBot ( message ) ;
97108} ;
98109
99110export const noticeBotBid = async ( latestNotice : number ) : Promise < number > => {
@@ -115,7 +126,7 @@ export const noticeBotBid = async (latestNotice: number): Promise<number> => {
115126
116127 const message = `${ status } ${ mode } ${ contract } ` ;
117128 try {
118- await noticeBotDiscord ( message ) ;
129+ await noticeBot ( message ) ;
119130 // eslint-disable-next-line @typescript-eslint/no-unused-vars
120131 } catch ( error ) {
121132 return latestNotice ;
@@ -152,7 +163,7 @@ export const noticeBotFind = async (
152163 const feeChangeMess = `\nFee change: ${ shortenNumber ( Number ( feeChange ) , 18 , 4 ) } BNB` ;
153164 const message = `${ status } ${ floorPrices } ${ bnbNow } ${ budgetNormalMess } ${ feeBidderMess } ${ feeProMess } ${ feeChangeMess } ` ;
154165 try {
155- await noticeBotDiscord ( message ) ;
166+ await noticeBot ( message ) ;
156167 // eslint-disable-next-line @typescript-eslint/no-unused-vars
157168 } catch ( error ) {
158169 return latestNotice ;
@@ -207,7 +218,7 @@ export const noticeBotDetectProfit = async (bidAuctions: BidAuction[]) => {
207218 . join ( ", $" ) } `
208219 : "" ;
209220 const message = `${ status } ${ profits } ${ types } ${ amounts } ${ prices } ${ pricePredictions } ${ floorPrices } ` ;
210- await noticeBotDiscord ( message ) ;
221+ await noticeBot ( message ) ;
211222} ;
212223
213224export const noticeBotInsufficient = async ( bidAuctions : BidAuction [ ] ) => {
@@ -248,7 +259,7 @@ export const noticeBotInsufficient = async (bidAuctions: BidAuction[]) => {
248259 . map ( bidAuction => shortenNumber ( bidAuction . pricePrediction ?? 0 , 0 , 2 ) )
249260 . join ( ", $" ) } `;
250261 const message = `${ status } ${ profits } ${ types } ${ prices } ${ pricePredictions } ` ;
251- await noticeBotDiscord ( message ) ;
262+ await noticeBot ( message ) ;
252263} ;
253264
254265export const noticeErrorBid = async ( errBidAuction : BidAuction ) => {
@@ -260,7 +271,7 @@ export const noticeErrorBid = async (errBidAuction: BidAuction) => {
260271 Math . round ( Date . now ( ) / 1000 ) - ( errBidAuction . uptime ?? 0 + TIME_ENABLE_BID_AUCTION )
261272 } s`;
262273 const message = `${ status } ${ profit } ${ time } ${ nowTime } ${ overTime } ` ;
263- await noticeBotDiscord ( message ) ;
274+ await noticeBot ( message ) ;
264275} ;
265276
266277export const noticeBotCancel = async ( bidAuction : BidAuction ) => {
@@ -274,7 +285,7 @@ export const noticeBotCancel = async (bidAuction: BidAuction) => {
274285 ? `\nAuctor: ${ shortenAddress ( bidAuction . auctionGroup . auctor ?? "" ) } `
275286 : "" ;
276287 const message = `${ status } ${ profit } ${ auctor } ${ auctorGroup } ` ;
277- await noticeBotDiscord ( message ) ;
288+ await noticeBot ( message ) ;
278289} ;
279290
280291export const noticeBotChangeStatus = async ( ) => {
@@ -285,7 +296,7 @@ export const noticeBotChangeStatus = async () => {
285296 const status = "Change: 🔄" ;
286297 const message = `${ status } ` ;
287298 try {
288- await noticeBotDiscord ( message ) ;
299+ await noticeBot ( message ) ;
289300 } catch {
290301 return 0 ;
291302 }
@@ -310,5 +321,5 @@ export const noticeBotChangeAuction = async (
310321 3
311322 ) } `;
312323 const message = `${ status } ${ auctionInfo } ${ hash } ${ lv } ${ change } ` ;
313- await noticeBotDiscord ( message ) ;
324+ await noticeBot ( message ) ;
314325} ;
0 commit comments