forked from TediCross/TediCross
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
49 lines (38 loc) · 1.31 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"use strict";
/**************************
* Import important stuff *
**************************/
// General stuff
const path = require("path");
const Application = require("./lib/Application");
const MessageMap = require("./lib/MessageMap");
const DiscordUserMap = require("./lib/discord2telegram/DiscordUserMap");
// Telegram stuff
const { BotAPI, InputFile } = require("teleapiwrapper");
const telegramSetup = require("./lib/telegram2discord/setup");
// Discord stuff
const Discord = require("discord.js");
const discordSetup = require("./lib/discord2telegram/setup");
/*************
* TediCross *
*************/
// Wrap everything in a try/catch to get a timestamp if a crash occurs
try {
// Create/Load the discord user map
const dcUsers = new DiscordUserMap(path.join(__dirname, "data", "discord_users.json"));
// Create a message ID map
const messageMap = new MessageMap();
// Create a Telegram bot
const tgBot = new BotAPI(Application.settings.telegram.auth.token);
// Create a Discord bot
const dcBot = new Discord.Client();
/*********************
* Set up the bridge *
*********************/
discordSetup(dcBot, tgBot, dcUsers, messageMap);
telegramSetup(tgBot, dcBot, dcUsers, messageMap);
} catch (err) {
// Log the timestamp and re-throw the error
Application.logger.error(err);
throw err;
}