Skip to content

Commit

Permalink
app: convert js to ts (lnp2pBot#477)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mersho authored Mar 1, 2024
1 parent 54be2d9 commit 678be5b
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions app.js → app.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
require('dotenv').config();
const { SocksProxyAgent } = require('socks-proxy-agent');
const { start } = require('./bot');
const { connect: mongoConnect } = require('./db_connect');
import "dotenv/config";
import { SocksProxyAgent } from "socks-proxy-agent";
import { MainContext, start } from "./bot/start";
import { connect as mongoConnect } from './db_connect'
const { resubscribeInvoices } = require('./ln');
const { logger } = require('./logger');
import { logger } from "./logger";
import { Telegraf } from "telegraf";
const { delay } = require('./util');

(async () => {
Expand All @@ -23,7 +24,7 @@ const { delay } = require('./util');
mongoose.connection
.once('open', async () => {
logger.info('Connected to Mongo instance.');
let options = { handlerTimeout: 60000 };
let options: Partial<Telegraf.Options<MainContext>> = { handlerTimeout: 60000 };
if (process.env.SOCKS_PROXY_HOST) {
const agent = new SocksProxyAgent(process.env.SOCKS_PROXY_HOST);
options = {
Expand All @@ -32,10 +33,10 @@ const { delay } = require('./util');
},
};
}
const bot = start(process.env.BOT_TOKEN, options);
const bot = start(String(process.env.BOT_TOKEN), options);
// Wait 1 seconds before try to resubscribe hold invoices
await delay(1000);
await resubscribeInvoices(bot);
})
.on('error', error => logger.error(`Error connecting to Mongo: ${error}`));
.on('error', (error: Error) => logger.error(`Error connecting to Mongo: ${error}`));
})();

0 comments on commit 678be5b

Please sign in to comment.