-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain-compiled.js.map
1 lines (1 loc) · 13.2 KB
/
main-compiled.js.map
1
{"version":3,"sources":["main.js"],"names":[],"mappings":";;;;;QAAgB,iBAAiB,GAAjB,iBAAiB;AAA1B,SAAS,iBAAiB,GAAG;AAClC,cAAY,CAAC;;AACb,MAAM,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAClD,MAAM,WAAW,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AACrD,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACrC,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;;AAEzB,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,CAAC;AACxE,MAAM,QAAQ,GAAG,4CAA4C,GAC3D,6BAA6B,GAC7B,kEAAkE,GAClE,oIAAoI,GACpI,0EAA0E,GAC1E,iKAAiK,GACjK,wFAAwF,GACxF,gGAAgG,GAChG,iDAAiD,CAAC;;AAEpD,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;AACjC,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;AAC7B,MAAM,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC;;AAEvC,MAAI,EAAE,GAAG,IAAI,eAAe,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAChD,aAAW,EAAE,CAAA;;AAEb,WAAS,WAAW,GAAG;AACrB,MAAE,CAAC,EAAE,CAAC,OAAO,EAAE,UAAC,GAAG,EAAK;AACtB,QAAE,GAAG,IAAI,eAAe,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAC5C,iBAAW,EAAE,CAAC;AACd,0BAAoB,EAAE,CAAC;AACvB,2BAAqB,EAAE,CAAC;KACzB,CAAC,CAAC;;AAEH,MAAE,CAAC,EAAE,CAAC,OAAO,E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AE;AACP,iBAAO;SACR,AAAC,IAAI,MAAM,EAAE;AACZ,gBAAM,CAAC,OAAO,CAAC,UAAC,OAAO,EAAK;AAC1B,eAAG,CAAC,WAAW,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,eAAe,GAAG,qBAAqB,CAAC,CAAC;WACjF,CAAC,CAAC;SACJ;OACF,CAAC,CAAC;KACJ,CAAC,CAAC;GACJ;CACF;;AAED,IAAM,QAAQ,GAAG,IAAI,iBAAiB,EAAE,CAAC","file":"main-compiled.js","sourcesContent":["export function TeamSpeakListener() {\r\n 'use strict';\r\n const TeamSpeakClient = require(\"node-teamspeak\");\r\n const TelegramBot = require('node-telegram-bot-api');\r\n const mongoose = require('mongoose');\r\n const fs = require('fs');\r\n\r\n const parsedJson = JSON.parse(fs.readFileSync('settings.json', 'utf8'));\r\n const helpText = \"The following commands are supported: \\n\\n\" +\r\n \"/help - Show this help.\\n\\n\" +\r\n \"/start - Initial command to start conversation with the bot.\\n\\n\" +\r\n \"/stop or /stahp - Omit this command and you'll never hear anything again from the bot. All your subscriptions will be deleted.\\n\\n\" +\r\n \"/subscribeall - Get notified if any user connects to the TS3 server.\\n\\n\" +\r\n \"/unsubscribeall - Don't get notified for every user that joins the server. If you subscribed to specific users, you'll keep getting notifications for them.\\n\\n\" +\r\n \"/subscribe [username] - Get notified if the specified [username] joins the server.\\n\\n\" +\r\n \"/unsubscribe [username] - Don't get notified if the specified [username} joins the server.\\n\\n\" +\r\n \"/subscriptions - Show all active subscriptions.\";\r\n\r\n const server = parsedJson.server;\r\n const port = parsedJson.port;\r\n const queryPort = parsedJson.queryPort;\r\n\r\n let cl = new TeamSpeakClient(server, queryPort);\r\n setHandlers()\r\n\r\n function setHandlers() {\r\n cl.on(\"error\", (err) => {\r\n cl = new TeamSpeakClient(server, queryPort);\r\n setHandlers();\r\n serverNotifyRegister();\r\n handleClientEnterView();\r\n });\r\n\r\n cl.on(\"close\", () => {\r\n cl = new TeamSpeakClient(server, queryPort);\r\n setHandlers();\r\n serverNotifyRegister();\r\n handleClientEnterView();\r\n });\r\n }\r\n const bot = new TelegramBot(parsedJson.botApiKey, {polling: true});\r\n\r\n const usersSchema = new mongoose.Schema(\r\n {\r\n \"tgUserId\": {type: String, index: true},\r\n \"notifyAll\": {type: Boolean, default: false},\r\n \"notifyOnDisconnect\": {type: Boolean, default: false},\r\n \"tsUserNames\": [String]\r\n }\r\n );\r\n const Users = mongoose.model('Users', usersSchema);\r\n mongoose.connect(parsedJson.mongooseConnection);\r\n const db = mongoose.connection;\r\n db.on('error', console.error.bind(console, 'connection error:'));\r\n\r\n db.once('open', () => {\r\n bot.onText(/\\/start/, (msg) => {\r\n Users.findOneAndUpdate({tgUserId: msg.from.id}, {tgUserId: msg.from.id}, {upsert: true}, (err, result) => {\r\n if (result) {\r\n bot.sendMessage(msg.from.id, helpText);\r\n }\r\n if (err) {\r\n bot.sendMessage(msg.from.id, 'Failed to register your Telegram account.');\r\n }\r\n });\r\n });\r\n\r\n bot.onText(/\\/stop|\\/stahp/, (msg) => {\r\n Users.remove({tgUserId: msg.from.id}, err => {\r\n if (!err) {\r\n bot.sendMessage(msg.from.id, 'You\\'ll never hear anything from me again.');\r\n }\r\n if (err) {\r\n bot.sendMessage(msg.from.id, 'Failed to persist in database');\r\n }\r\n });\r\n });\r\n\r\n bot.onText(/\\/help/, (msg) => {\r\n bot.sendMessage(msg.from.id, helpText);\r\n });\r\n\r\n bot.onText(/\\/subscribeall/, (msg) => {\r\n Users.findOneAndUpdate({tgUserId: msg.from.id}, {notifyAll: true}, (err, result) => {\r\n if (result) {\r\n bot.sendMessage(msg.from.id, 'You will receive a notification if any user joins the server.');\r\n }\r\n if (err) {\r\n bot.sendMessage(msg.from.id, 'Failed to subscribe.');\r\n }\r\n });\r\n });\r\n\r\n bot.onText(/\\/unsubscribeall/, (msg) => {\r\n Users.findOneAndUpdate({tgUserId: msg.from.id}, {notifyAll: false}, (err, result) => {\r\n if (result) {\r\n bot.sendMessage(msg.from.id, 'You will only receive notifications for users you specified.');\r\n }\r\n if (err) {\r\n bot.sendMessage(msg.from.id, 'Failed to subscribe.');\r\n }\r\n });\r\n });\r\n\r\n bot.onText(/\\/subscribe (.+)/, (msg, match) => {\r\n Users.findOneAndUpdate({tgUserId: msg.from.id}, {$addToSet: {tsUserNames: match[1]}}, (err, result) => {\r\n if(result) {\r\n bot.sendMessage(msg.from.id, 'You will receive a notification once ' + match[1] + ' joins the server.');\r\n }\r\n if (err) {\r\n bot.sendMessage(msg.from.id, 'Failed to subscribe.');\r\n }\r\n });\r\n });\r\n\r\n bot.onText(/\\/subscribe$/, (msg) => {\r\n bot.sendMessage(msg.from.id, 'Please enter a username for /subscribe.');\r\n });\r\n\r\n bot.onText(/\\/unsubscribe (.+)/, (msg, match) => {\r\n Users.findOneAndUpdate({tgUserId: msg.from.id}, {$pull: {tsUserNames: match[1]}}, (err, result) => {\r\n if(result) {\r\n bot.sendMessage(msg.from.id, 'You won\\'t receive a notification once ' + match[1] + ' joins the server.');\r\n }\r\n if (err) {\r\n bot.sendMessage(msg.from.id, 'Failed to unsubscribe.');\r\n }\r\n });\r\n });\r\n });\r\n\r\n bot.onText(/\\/unsubscribe$/, (msg) => {\r\n bot.sendMessage(msg.from.id, 'Please enter a username for /unsubscribe..');\r\n });\r\n\r\n bot.onText(/\\/subscriptions/, (msg) => {\r\n Users.findOne({tgUserId: msg.from.id}, (err, result) => {\r\n if(result) {\r\n let subscriptions = \"\";\r\n result.tsUserNames.forEach((element) => {\r\n subscriptions = subscriptions + element + \"\\n\";\r\n });\r\n if (result.notifyAll) {\r\n bot.sendMessage(msg.from.id, 'You subscribed to all users.');\r\n }\r\n else if (subscriptions) {\r\n bot.sendMessage(msg.from.id, 'You subscribed to: \\n' + subscriptions);\r\n } else {\r\n bot.sendMessage(msg.from.id, 'You don\\'t have any subscription.');\r\n }\r\n }\r\n if (err) {\r\n bot.sendMessage(msg.from.id, 'Request failed.');\r\n }\r\n });\r\n });\r\n\r\n\r\n serverNotifyRegister();\r\n handleClientEnterView();\r\n\r\n function serverNotifyRegister() {\r\n cl.send(\"use\", {port: port || 9987}, () => {\r\n cl.send(\"servernotifyregister\", {event: \"server\"}, () => {\r\n });\r\n });\r\n }\r\n\r\n function handleClientEnterView() {\r\n cl.on(\"cliententerview\", (resp) => {\r\n //noinspection JSUnresolvedVariable\r\n Users.find({$or: [{tsUserNames: resp.client_nickname}, {notifyAll: true}]}).exec((err, result) => {\r\n if (err) {\r\n return;\r\n } if (result) {\r\n result.forEach((element) => {\r\n bot.sendMessage(element.tgUserId, resp.client_nickname + \" joined the server.\");\r\n });\r\n }\r\n });\r\n });\r\n }\r\n}\r\n\r\nconst listener = new TeamSpeakListener();"]}