initial rework and cleanup
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 19s
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 19s
This commit is contained in:
parent
342c063011
commit
a662c68ecf
12
app.js
12
app.js
@ -48,17 +48,19 @@ const TelegramBot = require('node-telegram-bot-api');
|
||||
const common = require('./data/bot/lib/common')
|
||||
const questions = require('./data/bot/lib/questions')
|
||||
const requests = require('./data/bot/lib/requests')
|
||||
const bot_welcome = require('./data/bot/functions/welcomeMesage')
|
||||
const bot_welcome = require('./data/bot/functions/welcomeMessage')
|
||||
const bot_faq_whatAppToUse = require('./data/bot/functions/faq/whatAppToUse')
|
||||
const bot_faq_subscription = require('./data/bot/functions/faq/subscriptions')
|
||||
const bot_subStatus = require('./data/bot/functions/requests/updateSubStatus')
|
||||
const shortcuts = require('./data/bot/lib/shorcuts')
|
||||
|
||||
|
||||
let commands = require('./data/group/commands')
|
||||
let navigation = require('./data/group/FAQ')
|
||||
let chat = require('./data/group/chat')
|
||||
let jointArray = navigation.concat(chat)
|
||||
// Load group data using utils
|
||||
const utils = require('./data/bot/lib/utils');
|
||||
let commands = utils.loadCommands();
|
||||
let navigation = utils.loadFAQ();
|
||||
let chat = utils.loadChat();
|
||||
let jointArray = navigation.concat(chat);
|
||||
|
||||
|
||||
const bot = new TelegramBot(token, { polling: true });
|
||||
|
@ -1,5 +1,5 @@
|
||||
const fs = require('fs')
|
||||
const subs = JSON.parse(fs.readFileSync('./data/group/subs.json', 'utf8'))
|
||||
const utils = require('../../lib/utils');
|
||||
const subs = utils.loadSubs();
|
||||
|
||||
module.exports = {
|
||||
prices: (bot, msg, logger) => {
|
||||
|
@ -1,5 +1,5 @@
|
||||
const fs = require('fs')
|
||||
const subs = JSON.parse(fs.readFileSync('./data/group/subs.json', 'utf8'))
|
||||
const utils = require('../../lib/utils');
|
||||
const subs = utils.loadSubs();
|
||||
|
||||
var subArray = []
|
||||
subs.forEach(element => {
|
||||
|
@ -1,11 +1,11 @@
|
||||
const fs = require('fs')
|
||||
const utils = require('../../lib/utils');
|
||||
const admins = JSON.parse(process.env.ADMIN_ID)
|
||||
const questions = require('../../lib/questions')
|
||||
|
||||
|
||||
module.exports = {
|
||||
setSubStatus: (bot, msg, logger, name) => {
|
||||
let subs = JSON.parse(fs.readFileSync('./data/group/subs.json', 'utf8'))
|
||||
let subs = utils.loadSubs();
|
||||
if (admins.indexOf(msg.from.id) > -1) {
|
||||
sub = msg.text.match(/(?<=set sub )(.*)(?= to (up|down))/g)[0]
|
||||
status = msg.text.match(/\w+(?=( \w+){0}$)/g)[0]
|
||||
|
@ -1,10 +1,10 @@
|
||||
const decache = require('decache');
|
||||
const utils = require('./utils');
|
||||
|
||||
module.exports = {
|
||||
commands: async (bot, msg, input, logger) => {
|
||||
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " did - " + input);
|
||||
const userMention = "<a href=\"tg:\/\/user?id=" + msg.from.id + "\">@" + msg.from.first_name + "<\/a> "
|
||||
let commands = require('../../group/commands')
|
||||
let commands = utils.loadCommands();
|
||||
for (const x of commands) {
|
||||
if (x.NAME === input) {
|
||||
let n = x.NAME
|
||||
@ -13,17 +13,16 @@ module.exports = {
|
||||
let a = userMention.concat(m)
|
||||
await bot.sendMessage(msg.chat.id, a, { parse_mode: "HTML" })
|
||||
}
|
||||
decache('../../group/commands');
|
||||
commands = require('../../group/commands')
|
||||
commands = utils.loadCommands();
|
||||
}
|
||||
}
|
||||
},
|
||||
chat: async (bot, msg, input, logger) => {
|
||||
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " asked - " + input);
|
||||
const userMention = "<a href=\"tg:\/\/user?id=" + msg.from.id + "\">@" + msg.from.first_name + "<\/a> "
|
||||
let commands = require('../../group/commands')
|
||||
let navigation = require('../../group/FAQ')
|
||||
let chat = require('../../group/chat')
|
||||
let commands = utils.loadCommands();
|
||||
let navigation = utils.loadFAQ();
|
||||
let chat = utils.loadChat();
|
||||
let jointArray = commands.concat(navigation, chat)
|
||||
|
||||
for (const x of jointArray) {
|
||||
@ -41,10 +40,8 @@ module.exports = {
|
||||
disable_web_page_preview: true
|
||||
})
|
||||
}
|
||||
decache('../../group/commands');
|
||||
decache('../../group/chat');
|
||||
commands = require('../../group/commands')
|
||||
commands = require('../../group/FAQ')
|
||||
commands = utils.loadCommands();
|
||||
navigation = utils.loadFAQ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
const fs = require('fs')
|
||||
const utils = require('./utils');
|
||||
const Nato = require('nato');
|
||||
|
||||
module.exports = {
|
||||
whatSubShouldIBuy: (bot, msg, logger) => {
|
||||
let subs = JSON.parse(fs.readFileSync('./data/group/subs.json', 'utf8'))
|
||||
let subs = utils.loadSubs();
|
||||
|
||||
const whatSubShouldIBuy = "what sub should i buy"
|
||||
|
||||
@ -14,7 +14,7 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
subStatus: async (bot, msg, logger, notify = false, chatId = null) => {
|
||||
let subs = JSON.parse(fs.readFileSync('./data/group/subs.json', 'utf8'))
|
||||
let subs = utils.loadSubs();
|
||||
|
||||
let string = ""
|
||||
const subStatus = "sub status";
|
||||
|
@ -44,28 +44,6 @@ module.exports = {
|
||||
},
|
||||
|
||||
|
||||
joke: (bot, msg, logger, name) => {
|
||||
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " asked for a joke");
|
||||
|
||||
var options = {
|
||||
method: 'GET',
|
||||
url: 'https://joke3.p.rapidapi.com/v1/joke',
|
||||
// qs: { tz: 'Europe/London', leagues: '8', include: 'localTeam,visitorTeam' },
|
||||
headers: {
|
||||
'x-rapidapi-host': 'joke3.p.rapidapi.com',
|
||||
'x-rapidapi-key': process.env.RAPIDAPI_API_KEY,
|
||||
useQueryString: true
|
||||
},
|
||||
};
|
||||
|
||||
request(options, function (error, response, body) {
|
||||
if (error) throw new Error(error);
|
||||
let jsonBody = JSON.parse(body)
|
||||
bot.sendMessage(msg.chat.id, jsonBody.content)
|
||||
}
|
||||
)
|
||||
},
|
||||
|
||||
// get_all_pages: async () => {
|
||||
// full_list = []
|
||||
// pages = [1,2,3,4,5]
|
||||
|
@ -5,48 +5,105 @@ throttledRequest.configure({ requests: 8, milliseconds: 60000 }); //send 1 reque
|
||||
cachedRequest = require('cached-request')(throttledRequest);
|
||||
cachedRequest.setCacheDirectory("./cache");
|
||||
var emoji = require('node-emoji')
|
||||
const shortcutUtils = require('./shortcutUtils');
|
||||
|
||||
module.exports = {
|
||||
maintenance: async (bot, msg, logger) => {
|
||||
bot.sendMessage(msg.chat.id, `Updates ${emoji.get('one')}${emoji.get('seven')} has everything you need to keep your device performing and provides help if you're having issues (green poster)\n\n${emoji.get('arrow_right')}<a href='https://t.me/c/1473840950/310'>PRESS HERE</a>${emoji.get('arrow_left')} to go directly to post in updates page`, { parse_mode: 'HTML', disable_web_page_preview: true })
|
||||
shortcutUtils.sendShortcutMessage(bot, msg, logger,
|
||||
`Updates ${emoji.get('one')}${emoji.get('seven')}`,
|
||||
"has everything you need to keep your device performing and provides help if you're having issues (green poster)",
|
||||
"to go directly to post in updates page",
|
||||
'https://t.me/c/1473840950/310')
|
||||
},
|
||||
unlinked_code: async (bot, msg, logger) => {
|
||||
bot.sendMessage(msg.chat.id, `Updates ${emoji.get('one')}${emoji.get('four')}has our main unlinked code for all of our Bob15TV apps\n\n ${emoji.get('arrow_right')}<a href='https://t.me/c/1473840950/305'>PRESS HERE</a>${emoji.get('arrow_left')} to go directly to post in updates page`, { parse_mode: 'HTML', disable_web_page_preview: true })
|
||||
shortcutUtils.sendShortcutMessage(bot, msg, logger,
|
||||
`Updates ${emoji.get('one')}${emoji.get('four')}`,
|
||||
"has our main unlinked code for all of our Bob15TV apps",
|
||||
"to go directly to post in updates page",
|
||||
'https://t.me/c/1473840950/305')
|
||||
},
|
||||
vpn: async (bot, msg, logger) => {
|
||||
bot.sendMessage(msg.chat.id, `Updates ${emoji.get('seven')} has everything you need to know on our Bob15TV VPN apps and also our apps that have built in VPN\n\n ${emoji.get('arrow_right')}<a href='https://t.me/c/1473840950/257'>PRESS HERE</a>${emoji.get('arrow_left')} to go directly to post in updates page`, { parse_mode: 'HTML', disable_web_page_preview: true })
|
||||
shortcutUtils.sendShortcutMessage(bot, msg, logger,
|
||||
`Updates ${emoji.get('seven')}`,
|
||||
"has everything you need to know on our Bob15TV VPN apps and also our apps that have built in VPN",
|
||||
"to go directly to post in updates page",
|
||||
'https://t.me/c/1473840950/257')
|
||||
},
|
||||
installing_unlinked: async (bot, msg, logger) => {
|
||||
bot.sendMessage(msg.chat.id, `Updates ${emoji.get('one')}${emoji.get('two')} shows you a step by step on how to add unlinked onto your devices\n\n ${emoji.get('arrow_right')}<a href='https://t.me/c/1473840950/300'>PRESS HERE</a>${emoji.get('arrow_left')} to go directly to post in updates page`, { parse_mode: 'HTML', disable_web_page_preview: true })
|
||||
shortcutUtils.sendShortcutMessage(bot, msg, logger,
|
||||
`Updates ${emoji.get('one')}${emoji.get('two')}`,
|
||||
"shows you a step by step on how to add unlinked onto your devices",
|
||||
"to go directly to post in updates page",
|
||||
'https://t.me/c/1473840950/300')
|
||||
},
|
||||
app_videos: async (bot, msg, logger) => {
|
||||
bot.sendMessage(msg.chat.id, `Updates ${emoji.get('five')} is our app help room where we have step by step help videos for all of our room players.\n\n ${emoji.get('arrow_right')}<a href='https://t.me/+dvfsvjs1uVlmYWFk'>PRESS HERE</a>${emoji.get('arrow_left')} to go directly there`, { parse_mode: 'HTML', disable_web_page_preview: true })
|
||||
shortcutUtils.sendShortcutMessage(bot, msg, logger,
|
||||
`Updates ${emoji.get('five')}`,
|
||||
"is our app help room where we have step by step help videos for all of our room players.",
|
||||
"to go directly there",
|
||||
'https://t.me/+dvfsvjs1uVlmYWFk')
|
||||
},
|
||||
webplayer: async (bot, msg, logger) => {
|
||||
bot.sendMessage(msg.chat.id, `Updates ${emoji.get('six')} has details of our Webplayer so that you can watch our subs on your PC/laptop\n\n ${emoji.get('arrow_right')}<a href='https://t.me/c/1473840950/250'>PRESS HERE</a>${emoji.get('arrow_left')} to go directly to post in updates page`, { parse_mode: 'HTML', disable_web_page_preview: true })
|
||||
shortcutUtils.sendShortcutMessage(bot, msg, logger,
|
||||
`Updates ${emoji.get('six')}`,
|
||||
"has details of our Webplayer so that you can watch our subs on your PC/laptop",
|
||||
"to go directly to post in updates page",
|
||||
'https://t.me/c/1473840950/250')
|
||||
},
|
||||
what_player_to_use: async (bot, msg, logger) => {
|
||||
bot.sendMessage(msg.chat.id, `Updates ${emoji.get('eight')} is our poster showing you at a glance what apps you can have your Bob15TV sub/subs playing on.\n\n ${emoji.get('arrow_right')}<a href='https://t.me/c/1473840950/271'>PRESS HERE</a>${emoji.get('arrow_left')} to go directly to post in updates page`, { parse_mode: 'HTML', disable_web_page_preview: true })
|
||||
shortcutUtils.sendShortcutMessage(bot, msg, logger,
|
||||
`Updates ${emoji.get('eight')}`,
|
||||
"is our poster showing you at a glance what apps you can have your Bob15TV sub/subs playing on.",
|
||||
"to go directly to post in updates page",
|
||||
'https://t.me/c/1473840950/271')
|
||||
},
|
||||
plex: async (bot, msg, logger) => {
|
||||
bot.sendMessage(msg.chat.id, `Updates ${emoji.get('two')}${emoji.get('four')} shows you how to add Plex to your device and everything else for best results.\n\n ${emoji.get('arrow_right')}<a href='https://t.me/c/1473840950/341'>PRESS HERE</a>${emoji.get('arrow_left')} to go directly to post in updates page`, { parse_mode: 'HTML', disable_web_page_preview: true })
|
||||
shortcutUtils.sendShortcutMessage(bot, msg, logger,
|
||||
`Updates ${emoji.get('two')}${emoji.get('four')}`,
|
||||
"shows you how to add Plex to your device and everything else for best results.",
|
||||
"to go directly to post in updates page",
|
||||
'https://t.me/c/1473840950/341')
|
||||
},
|
||||
ios: async (bot, msg, logger) => {
|
||||
bot.sendMessage(msg.chat.id, `Updates ${emoji.get('one')}${emoji.get('nine')} shows you how to add all Bob15TV room subs onto your iPhone, iPad or directly onto your Apple TV.\n\n${emoji.get('arrow_right')}<a href='https://t.me/c/1473840950/315'>PRESS HERE</a>${emoji.get('arrow_left')} to go directly to post in updates page`, { parse_mode: 'HTML', disable_web_page_preview: true })
|
||||
shortcutUtils.sendShortcutMessage(bot, msg, logger,
|
||||
`Updates ${emoji.get('one')}${emoji.get('nine')}`,
|
||||
"shows you how to add all Bob15TV room subs onto your iPhone, iPad or directly onto your Apple TV.",
|
||||
"to go directly to post in updates page",
|
||||
'https://t.me/c/1473840950/315')
|
||||
},
|
||||
android: async (bot, msg, logger) => {
|
||||
bot.sendMessage(msg.chat.id, `Updates ${emoji.get('two')}${emoji.get('zero')} shows you how to add all Bob15TV room subs onto your android phone or tablet.\n\n ${emoji.get('arrow_right')}<a href='https://t.me/c/1473840950/319'>PRESS HERE</a>${emoji.get('arrow_left')} to go directly to post in updates page`, { parse_mode: 'HTML', disable_web_page_preview: true })
|
||||
shortcutUtils.sendShortcutMessage(bot, msg, logger,
|
||||
`Updates ${emoji.get('two')}${emoji.get('zero')}`,
|
||||
"shows you how to add all Bob15TV room subs onto your android phone or tablet.",
|
||||
"to go directly to post in updates page",
|
||||
'https://t.me/c/1473840950/319')
|
||||
},
|
||||
vodReq: async (bot, msg, logger) => {
|
||||
bot.sendMessage(msg.chat.id, `Updates ${emoji.get('two')}${emoji.get('three')} shows you how to request VOD on your sub.\n\n ${emoji.get('arrow_right')}<a href='https://t.me/c/1473840950/333'>PRESS HERE</a>${emoji.get('arrow_left')} to go directly to post in updates page`, { parse_mode: 'HTML', disable_web_page_preview: true })
|
||||
shortcutUtils.sendShortcutMessage(bot, msg, logger,
|
||||
`Updates ${emoji.get('two')}${emoji.get('three')}`,
|
||||
"shows you how to request VOD on your sub.",
|
||||
"to go directly to post in updates page",
|
||||
'https://t.me/c/1473840950/333')
|
||||
},
|
||||
firesticks: async (bot, msg, logger) => {
|
||||
bot.sendMessage(msg.chat.id, `Updates ${emoji.get('two')}${emoji.get('five')} shows you help in maintaining and getting the best performance from your firestick.\n\n${emoji.get('arrow_right')}<a href='https://t.me/c/1473840950/344'>PRESS HERE</a>${emoji.get('arrow_left')} to go directly to post in updates page`, { parse_mode: 'HTML', disable_web_page_preview: true })
|
||||
shortcutUtils.sendShortcutMessage(bot, msg, logger,
|
||||
`Updates ${emoji.get('two')}${emoji.get('five')}`,
|
||||
"shows you help in maintaining and getting the best performance from your firestick.",
|
||||
"to go directly to post in updates page",
|
||||
'https://t.me/c/1473840950/344')
|
||||
},
|
||||
sports: async (bot, msg, logger) => {
|
||||
bot.sendMessage(msg.chat.id, `Updates ${emoji.get('one')}${emoji.get('six')} has our very own telegram sports listing channels and available websites for you to use to find the channels your favourite sport is streaming on. Please join them.\n\n${emoji.get('arrow_right')}<a href='https://t.me/c/1473840950/308'>PRESS HERE</a>${emoji.get('arrow_left')} to go directly to post in updates page.`, { parse_mode: 'HTML', disable_web_page_preview: true })
|
||||
shortcutUtils.sendShortcutMessage(bot, msg, logger,
|
||||
`Updates ${emoji.get('one')}${emoji.get('six')}`,
|
||||
"has our very own telegram sports listing channels and available websites for you to use to find the channels your favourite sport is streaming on. Please join them.",
|
||||
"to go directly to post in updates page.",
|
||||
'https://t.me/c/1473840950/308')
|
||||
},
|
||||
bob15: async (bot, msg, logger) => {
|
||||
bot.sendMessage(msg.chat.id, `Updates ${emoji.get('three')}${emoji.get('zero')} shows you a step by step on how to add our Bob15 apk onto your devices. This apk includes our huge collection of apps both for our room subs and miscellaneous extra apps.\n\n${emoji.get('arrow_right')}<a href='https://t.me/c/1473840950/356'>PRESS HERE</a>${emoji.get('arrow_left')} to go directly to post in updates page.`, { parse_mode: 'HTML', disable_web_page_preview: true })
|
||||
shortcutUtils.sendShortcutMessage(bot, msg, logger,
|
||||
`Updates ${emoji.get('three')}${emoji.get('zero')}`,
|
||||
"shows you a step by step on how to add our Bob15 apk onto your devices. This apk includes our huge collection of apps both for our room subs and miscellaneous extra apps.",
|
||||
"to go directly to post in updates page.",
|
||||
'https://t.me/c/1473840950/356')
|
||||
}
|
||||
}
|
5
data/bot/lib/shortcutUtils.js
Normal file
5
data/bot/lib/shortcutUtils.js
Normal file
@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
sendShortcutMessage: async (bot, msg, logger, title, description, postNumber, link) => {
|
||||
bot.sendMessage(msg.chat.id, `${title} ${description}\n\n ${emoji.get('arrow_right')}<a href='${link}'>PRESS HERE</a>${emoji.get('arrow_left')} ${postNumber}`, { parse_mode: 'HTML', disable_web_page_preview: true })
|
||||
}
|
||||
};
|
23
data/bot/lib/utils.js
Normal file
23
data/bot/lib/utils.js
Normal file
@ -0,0 +1,23 @@
|
||||
const fs = require('fs');
|
||||
const decache = require('decache');
|
||||
|
||||
module.exports = {
|
||||
loadSubs: () => {
|
||||
return JSON.parse(fs.readFileSync('./data/group/subs.json', 'utf8'));
|
||||
},
|
||||
|
||||
loadCommands: () => {
|
||||
decache('../../group/commands');
|
||||
return require('../../group/commands');
|
||||
},
|
||||
|
||||
loadFAQ: () => {
|
||||
decache('../../group/FAQ');
|
||||
return require('../../group/FAQ');
|
||||
},
|
||||
|
||||
loadChat: () => {
|
||||
decache('../../group/chat');
|
||||
return require('../../group/chat');
|
||||
}
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user