Skip to content

Commit

Permalink
app: convert js to ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Mersho committed Oct 25, 2023
1 parent 21d6da9 commit 162d400
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 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 mongoConnect = require('./db_connect');
import 'dotenv/config';
import { SocksProxyAgent } from "socks-proxy-agent";
import { MainContext, start } from "./bot/start";
import 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,11 @@ 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 162d400

Please sign in to comment.