Merge branch 'massive-refactor' of Karl/BBLBTV_bot into master
This commit is contained in:
commit
9e1a756d20
262
app.js
262
app.js
@ -2,16 +2,28 @@ require('dotenv').config();
|
|||||||
|
|
||||||
var request = require("request");
|
var request = require("request");
|
||||||
var throttledRequest = require('throttled-request')(request);
|
var throttledRequest = require('throttled-request')(request);
|
||||||
throttledRequest.configure({requests: 8, milliseconds: 60000}); //send 1 request per second
|
throttledRequest.configure({ requests: 8, milliseconds: 60000 }); //send 1 request per second
|
||||||
cachedRequest = require('cached-request')(throttledRequest);
|
cachedRequest = require('cached-request')(throttledRequest);
|
||||||
cachedRequest.setCacheDirectory("./cache");
|
cachedRequest.setCacheDirectory("./cache");
|
||||||
|
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
const logger = require('perfect-logger');
|
const logger = require('perfect-logger');
|
||||||
const TelegramBot = require('node-telegram-bot-api');
|
const TelegramBot = require('node-telegram-bot-api');
|
||||||
|
|
||||||
|
const bot_chat = require('./data/bot/chat')
|
||||||
|
const bot_welcome = require('./data/bot/welcomeMesage')
|
||||||
|
const bot_questions = require('./data/bot/questions')
|
||||||
|
const bot_football = require('./data/bot/requests/football')
|
||||||
|
const bot_joke = require('./data/bot/requests/joke')
|
||||||
|
const bot_faq_subscription = require('./data/bot/faq/subscriptions')
|
||||||
|
const bot_subStatus = require('./data/bot/requests/updateSubStatus')
|
||||||
|
|
||||||
const token = process.env.BOT_TOKEN;
|
const token = process.env.BOT_TOKEN;
|
||||||
const name = process.env.BOT_NAME;
|
const name = process.env.BOT_NAME;
|
||||||
const channel = process.env.CHANNEL
|
const channel = process.env.CHANNEL
|
||||||
|
const admins = JSON.parse(process.env.ADMIN_ID)
|
||||||
|
let comp_users = []
|
||||||
|
|
||||||
// Configure Settings
|
// Configure Settings
|
||||||
logger.initialize(name + "_bot", {
|
logger.initialize(name + "_bot", {
|
||||||
@ -27,153 +39,37 @@ const bot = new TelegramBot(token, {
|
|||||||
|
|
||||||
// Wlecome Message
|
// Wlecome Message
|
||||||
bot.on('new_chat_members', (msg) => {
|
bot.on('new_chat_members', (msg) => {
|
||||||
const newUserMention = "<a href=\"tg:\/\/user?id=" + msg.new_chat_member.id + "\">@" + msg.new_chat_member.first_name + "<\/a>"
|
bot_welcome.welcomeMessage(bot, msg, logger)
|
||||||
bot.sendMessage(msg.chat.id, "Hello " + newUserMention + ", Welcome to " + channel + ". \n\nPlease PM me @" + process.env.BOT_USERNAME + " to find out all needed information about our service before asking an admin or posting in here.\n\nIf you do ask questions, and its obvious you have not spoken to me, you will be booted from the room. This is IPTV, admins don't have time for hand holding.!!!", { parse_mode: "HTML" });
|
|
||||||
logger.info("ID - " + msg.new_chat_member.id + " First Name - " + msg.new_chat_member.first_name + " joined the group");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
bot.on('message', (msg) => {
|
bot.on('message', (msg) => {
|
||||||
|
|
||||||
// Listen call for "help"
|
// Listen call for "help"
|
||||||
const help = "help";
|
bot_chat.help(bot, msg, logger)
|
||||||
if (msg.text && msg.text.toString().toLowerCase().includes(help)) {
|
// listen for "filelinked code"
|
||||||
const userMention = "<a href=\"tg:\/\/user?id=" + msg.from.id + "\">@" + msg.from.first_name + "<\/a>"
|
bot_chat.filelinked_help(bot, msg, logger)
|
||||||
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked for help");
|
// listen for "bye"
|
||||||
bot.sendMessage(msg.chat.id, "Hello " + userMention + " please PM me @" + process.env.BOT_USERNAME + " and i'll try to help.", { parse_mode: "HTML" });
|
bot_chat.bye(bot, msg, logger)
|
||||||
}
|
// listen for "thank you BOT"
|
||||||
|
bot_chat.thankYou(bot, msg, logger, name)
|
||||||
|
// listen for "i love you BOT"
|
||||||
|
bot_chat.iLoveYou(bot, msg, logger, name)
|
||||||
|
// listen for "deal"
|
||||||
|
bot_chat.loveADeal(bot, msg, logger)
|
||||||
|
// listen for "football today"
|
||||||
|
bot_football.gamesToday(bot, msg, logger)
|
||||||
|
// listen for "BOT tell me a joke"
|
||||||
|
bot_joke.tellMe(bot, msg, logger, name)
|
||||||
|
// listen for "you there BOT"
|
||||||
|
bot_chat.youThere(bot, msg, logger, name)
|
||||||
|
// listen for "fuck off BOT"
|
||||||
|
bot_chat.fOff(bot, msg, logger, name)
|
||||||
|
// listen for "what sub should i buy?"
|
||||||
|
bot_questions.whatSubShouldIBuy(bot, msg, logger)
|
||||||
|
bot_questions.subStatus(bot, msg, logger)
|
||||||
|
bot_subStatus.setSubStatus(bot, msg, logger)
|
||||||
|
|
||||||
const help_filelinked = "filelinked code";
|
// FAQ susbcription prices
|
||||||
if (msg.text && msg.text.toString().toLowerCase().includes(help_filelinked)) {
|
bot_faq_subscription.prices(bot, msg, logger)
|
||||||
const userMention = "<a href=\"tg:\/\/user?id=" + msg.from.id + "\">@" + msg.from.first_name + "<\/a>"
|
|
||||||
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked for fileLinked code");
|
|
||||||
bot.sendMessage(msg.chat.id, "Hello " + userMention + " please PM me @" + process.env.BOT_USERNAME + " and i'll give you the code", { parse_mode: "HTML" });
|
|
||||||
}
|
|
||||||
|
|
||||||
const bye = "bye";
|
|
||||||
if (msg.text && msg.text.toString().toLowerCase().includes(bye)) {
|
|
||||||
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Said bye");
|
|
||||||
bot.sendMessage(msg.chat.id, "Bye " + msg.from.first_name + ", Hope to see you again.");
|
|
||||||
}
|
|
||||||
|
|
||||||
const love = "i love you ";
|
|
||||||
const lovePlus = love + name.toLowerCase()
|
|
||||||
if (msg.text && msg.text.toString().toLowerCase().includes(lovePlus)) {
|
|
||||||
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Said they loved me");
|
|
||||||
bot.sendMessage(msg.chat.id, "I love you too " + msg.from.first_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
const thankYou = "thank you " + name.toLowerCase();
|
|
||||||
if (msg.text && msg.text.toString().toLowerCase().includes(thankYou)) {
|
|
||||||
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Said thank you");
|
|
||||||
bot.sendMessage(msg.chat.id, "You're welcome " + msg.from.first_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
const footballToday = "football today";
|
|
||||||
if (msg.text && msg.text.toString().toLowerCase().includes(footballToday)) {
|
|
||||||
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " asked for football today");
|
|
||||||
|
|
||||||
var options = {
|
|
||||||
method: 'GET',
|
|
||||||
url: 'https://football-pro.p.rapidapi.com/api/v2.0/livescores',
|
|
||||||
qs: { tz: 'Europe/London', leagues: '8', include: 'localTeam,visitorTeam' },
|
|
||||||
headers: {
|
|
||||||
'x-rapidapi-host': 'football-pro.p.rapidapi.com',
|
|
||||||
'x-rapidapi-key': process.env.RAPIDAPI_API_KEY,
|
|
||||||
useQueryString: true
|
|
||||||
},
|
|
||||||
ttl: 18000000 //5 hours
|
|
||||||
};
|
|
||||||
|
|
||||||
cachedRequest(options, function (error, response, body) {
|
|
||||||
// console.log(response)
|
|
||||||
if (error) throw new Error(error);
|
|
||||||
|
|
||||||
// console.log(body);
|
|
||||||
let jsonBody = JSON.parse(body)
|
|
||||||
if (jsonBody.data.length > 0) {
|
|
||||||
bot.sendMessage(msg.chat.id, 'Yes there is!').then(() => {
|
|
||||||
return jsonBody.data.forEach(function (entry) {
|
|
||||||
var homeTeam = entry.localTeam.data.name
|
|
||||||
var awayTeam = entry.visitorTeam.data.name
|
|
||||||
var startTime = entry.time.starting_at.time
|
|
||||||
// console.log(entry);
|
|
||||||
bot.sendMessage(msg.chat.id, homeTeam + " VS " + awayTeam + " @ " + startTime)
|
|
||||||
});
|
|
||||||
}).then(() => {
|
|
||||||
return bot.sendMessage(msg.chat.id, 'To see what channels the football is streaming on please join @footballontv')
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
bot.sendMessage(msg.chat.id, 'Sadly there is no football today :(')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const joke = name.toLowerCase() + " tell me a joke";
|
|
||||||
if (msg.text && msg.text.toString().toLowerCase().includes(joke)) {
|
|
||||||
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
|
|
||||||
},
|
|
||||||
// ttl: 18000 //5 hours
|
|
||||||
};
|
|
||||||
|
|
||||||
request(options, function (error, response, body) {
|
|
||||||
// console.log(response)
|
|
||||||
|
|
||||||
if (error) throw new Error(error);
|
|
||||||
let jsonBody = JSON.parse(body)
|
|
||||||
bot.sendMessage(msg.chat.id, jsonBody.content)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const youThere = "you there " + name.toLowerCase() + "?";
|
|
||||||
if (msg.text && msg.text.toString().toLowerCase().includes(youThere)) {
|
|
||||||
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " asked if im there");
|
|
||||||
bot.sendMessage(msg.chat.id, "Always...");
|
|
||||||
}
|
|
||||||
|
|
||||||
const fuuk = "fuck off ";
|
|
||||||
const fuuckPlus = fuuk + name.toLowerCase()
|
|
||||||
if (msg.text && msg.text.toString().toLowerCase().includes(fuuckPlus)) {
|
|
||||||
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " told me to fuck off");
|
|
||||||
bot.sendMessage(msg.chat.id, "Fuck off yourself " + msg.from.first_name + "!");
|
|
||||||
}
|
|
||||||
|
|
||||||
const whatSubShouldIBuy = "what sub should i buy?"
|
|
||||||
const subs = ["VIP!", "Premium Plus!", "Old Premium!", "Gold!", "Bronze!", "New Premium!", "KDB!", "Technoid!", "Bluemoon!", "SOL!", "Gambler!", "All of em!"]
|
|
||||||
if (msg.text && msg.text.toString().toLowerCase().includes(whatSubShouldIBuy)) {
|
|
||||||
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked what sub to buy");
|
|
||||||
const randomSub = subs[Math.floor(Math.random() * subs.length)];
|
|
||||||
bot.sendMessage(msg.chat.id, randomSub);
|
|
||||||
}
|
|
||||||
|
|
||||||
const deal = "deal";
|
|
||||||
const me = 434187971
|
|
||||||
const sarah = 868225940
|
|
||||||
const MANC = 470861863
|
|
||||||
if (msg.text && msg.text.toString().toLowerCase().match(/\bdeal\b/)) {
|
|
||||||
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Said we got a deal!");
|
|
||||||
bot.sendMessage(msg.chat.id, "I LOVE it when " + msg.from.first_name + ", does a deal :)");
|
|
||||||
}
|
|
||||||
|
|
||||||
const subPrice = "- subscription prices";
|
|
||||||
if (msg.text && msg.text.toString().toLowerCase() === subPrice) {
|
|
||||||
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Got subscription Prices");
|
|
||||||
bot.sendMessage(msg.chat.id, "PREMIUM PLUS ----£30\nVIP-----------------------£25\nOLD PREMIUM -----£17\nBLUEMOON ---------£15\nKDB --------------------£14\nGOLD ------------------£13\nTECHNOID -----------£13\nBRONZE --------------£10\nSOL ---------------------£10")
|
|
||||||
.then(() => {
|
|
||||||
return bot.sendMessage(msg.chat.id, "All of these prices are for 12 Month subscription subs").then(() => {
|
|
||||||
return bot.sendMessage(msg.chat.id, "Keep an eye out though because we offer special deals on different subs from time to time.")
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const howToSignUp = "- how to get a subscription?";
|
const howToSignUp = "- how to get a subscription?";
|
||||||
if (msg.text && msg.text.toString().toLowerCase() === howToSignUp) {
|
if (msg.text && msg.text.toString().toLowerCase() === howToSignUp) {
|
||||||
@ -230,10 +126,9 @@ bot.on('message', (msg) => {
|
|||||||
const installoOnAndroid = "- install filelinked on android";
|
const installoOnAndroid = "- install filelinked on android";
|
||||||
if (msg.text && msg.text.toString().toLowerCase() === installoOnAndroid) {
|
if (msg.text && msg.text.toString().toLowerCase() === installoOnAndroid) {
|
||||||
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Found out how to install on Android");
|
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Found out how to install on Android");
|
||||||
bot.sendMessage(msg.chat.id, "First thing you need to do is go to browser on your Android TV box and enter www.filelinked.com")
|
bot.sendMessage(msg.chat.id, "First thing you need to do is go to browser on your Android TV box and enter http://get.filelinked.com")
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return bot.sendMessage(msg.chat.id, "From this browser page, download FileLinked.").then(() => {
|
return bot.sendMessage(msg.chat.id, "Once the apk has downloaded you can close the browser and go to your apps.").then(() => {
|
||||||
return bot.sendMessage(msg.chat.id, "Once you have pressed download then you can close the browser and go to your apps.").then(() => {
|
|
||||||
return bot.sendMessage(msg.chat.id, "Then open file manager or file browser. In here go to downloads, filemanager, press install.").then(() => {
|
return bot.sendMessage(msg.chat.id, "Then open file manager or file browser. In here go to downloads, filemanager, press install.").then(() => {
|
||||||
return bot.sendMessage(msg.chat.id, "Then go back to your apps section on the box and find filelinked app.").then(() => {
|
return bot.sendMessage(msg.chat.id, "Then go back to your apps section on the box and find filelinked app.").then(() => {
|
||||||
return bot.sendMessage(msg.chat.id, "Open the app and enter the code.")
|
return bot.sendMessage(msg.chat.id, "Open the app and enter the code.")
|
||||||
@ -241,7 +136,6 @@ bot.on('message', (msg) => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const SurfShark = "- vpn (surfshark)";
|
const SurfShark = "- vpn (surfshark)";
|
||||||
@ -308,7 +202,79 @@ bot.on('message', (msg) => {
|
|||||||
const howToResetCache = "- how do i clear cache?";
|
const howToResetCache = "- how do i clear cache?";
|
||||||
if (msg.text && msg.text.toString().toLowerCase() === howToResetCache) {
|
if (msg.text && msg.text.toString().toLowerCase() === howToResetCache) {
|
||||||
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked how to clear cache");
|
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked how to clear cache");
|
||||||
bot.sendMessage(msg.chat.id, "Cache files are main source of errors and problems in functioning of Apps, by clearing cache may solve most of the problems associated with Apps. To clear cache, go to Settings > Application > Manage apps > Select \"All\" tabs, select the app which was producing error and then tap Clear cache.");
|
bot.sendMessage(msg.chat.id, process.env.ADMIN_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
const whoAdmin = "who is an admin";
|
||||||
|
if (msg.text && msg.text.toString().toLowerCase() === whoAdmin) {
|
||||||
|
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked who is an admin");
|
||||||
|
admins.forEach(element =>
|
||||||
|
bot.sendMessage(msg.chat.id, element)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const startCompCalled = "start comp called";
|
||||||
|
if (msg.text && msg.text.toString().toLowerCase().includes(startCompCalled)) {
|
||||||
|
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked who is an admin");
|
||||||
|
test = msg.text.match(/\b(\w+)$/gm);
|
||||||
|
fs.writeFileSync('./data/' + test + '.json', '[]')
|
||||||
|
bot.sendMessage(msg.chat.id, 'Comp created')
|
||||||
|
}
|
||||||
|
|
||||||
|
const stopCompCalled = "stop comp called";
|
||||||
|
if (msg.text && msg.text.toString().toLowerCase().includes(stopCompCalled)) {
|
||||||
|
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked who is an admin");
|
||||||
|
test = msg.text.match(/\b(\w+)$/gm);
|
||||||
|
fs.unlinkSync('./data/' + test + '.json', '[]')
|
||||||
|
bot.sendMessage(msg.chat.id, 'Comp removed')
|
||||||
|
}
|
||||||
|
|
||||||
|
const comp = "entered the comp";
|
||||||
|
if (msg.text && msg.text.toString().toLowerCase().includes(comp)) {
|
||||||
|
if (admins.indexOf(msg.from.id) > -1) {
|
||||||
|
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked who is an admin");
|
||||||
|
user = msg.text.match(/^([\w\-]+)/gm)[0];
|
||||||
|
let comp_name = msg.text.match(/\b(\w+)$/gm)[0];
|
||||||
|
|
||||||
|
comp_users = JSON.parse(fs.readFileSync('./data/' + comp_name + '.json', 'utf8'))
|
||||||
|
|
||||||
|
let new_comp_users = comp_users.concat(user)
|
||||||
|
|
||||||
|
fs.writeFileSync('./data/' + comp_name + '.json', JSON.stringify(new_comp_users))
|
||||||
|
|
||||||
|
bot.sendMessage(msg.chat.id, user + " has been added to the competition")
|
||||||
|
} else {
|
||||||
|
console.log('not found')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const enteredTheComp = "how many in comp";
|
||||||
|
if (msg.text && msg.text.toString().toLowerCase().includes(enteredTheComp)) {
|
||||||
|
if (admins.indexOf(msg.from.id) > -1) {
|
||||||
|
let comp_name = msg.text.match(/\b(\w+)$/gm)[0];
|
||||||
|
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked who is an admin");
|
||||||
|
var comp_entered = JSON.parse(fs.readFileSync('./data/' + comp_name + '.json', 'utf8'))
|
||||||
|
bot.sendMessage(msg.chat.id, "There are " + comp_entered.length + " people in the comp")
|
||||||
|
} else {
|
||||||
|
console.log('not found')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const whoWon = "who won comp";
|
||||||
|
if (msg.text && msg.text.toString().toLowerCase().includes(whoWon)) {
|
||||||
|
if (admins.indexOf(msg.from.id) > -1) {
|
||||||
|
let comp_name = msg.text.match(/\b(\w+)$/gm)[0];
|
||||||
|
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked who is an admin");
|
||||||
|
var comp_entered = JSON.parse(fs.readFileSync('./data/' + comp_name + '.json', 'utf8'))
|
||||||
|
|
||||||
|
var winner = comp_entered[Math.floor(Math.random() * comp_entered.length)];
|
||||||
|
|
||||||
|
bot.sendMessage(msg.chat.id, "There winner is .....").then(() => {
|
||||||
|
return bot.sendMessage(msg.chat.id, winner)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
console.log('not found')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const whatAppShouldIUse = "- what app should i use?";
|
const whatAppShouldIUse = "- what app should i use?";
|
||||||
|
63
data/bot/chat.js
Normal file
63
data/bot/chat.js
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
module.exports = {
|
||||||
|
help: (bot, msg, logger) => {
|
||||||
|
const help = "help";
|
||||||
|
if (msg.text && msg.text.toString().toLowerCase().includes(help)) {
|
||||||
|
const userMention = "<a href=\"tg:\/\/user?id=" + msg.from.id + "\">@" + msg.from.first_name + "<\/a>"
|
||||||
|
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked for help");
|
||||||
|
bot.sendMessage(msg.chat.id, "Hello " + userMention + " please PM me @" + process.env.BOT_USERNAME + " and i'll try to help.", { parse_mode: "HTML" });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
filelinked_help: (bot, msg, logger) => {
|
||||||
|
const help_filelinked = "filelinked code";
|
||||||
|
if (msg.text && msg.text.toString().toLowerCase().includes(help_filelinked)) {
|
||||||
|
const userMention = "<a href=\"tg:\/\/user?id=" + msg.from.id + "\">@" + msg.from.first_name + "<\/a>"
|
||||||
|
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked for fileLinked code");
|
||||||
|
bot.sendMessage(msg.chat.id, "Hello " + userMention + " please PM me @" + process.env.BOT_USERNAME + " and i'll give you the code", { parse_mode: "HTML" });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
bye: (bot, msg, logger) => {
|
||||||
|
const bye = "bye";
|
||||||
|
if (msg.text && msg.text.toString().toLowerCase().includes(bye)) {
|
||||||
|
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Said bye");
|
||||||
|
bot.sendMessage(msg.chat.id, "Bye " + msg.from.first_name + ", Hope to see you again.");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
iLoveYou: (bot, msg, logger, name) => {
|
||||||
|
const love = "i love you ";
|
||||||
|
const lovePlus = love + name.toLowerCase()
|
||||||
|
if (msg.text && msg.text.toString().toLowerCase().includes(lovePlus)) {
|
||||||
|
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Said they loved me");
|
||||||
|
bot.sendMessage(msg.chat.id, "I love you too " + msg.from.first_name);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
thankYou: (bot, msg, logger, name) => {
|
||||||
|
const thankYou = "thank you " + name.toLowerCase();
|
||||||
|
if (msg.text && msg.text.toString().toLowerCase().includes(thankYou)) {
|
||||||
|
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Said thank you");
|
||||||
|
bot.sendMessage(msg.chat.id, "You're welcome " + msg.from.first_name);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
youThere: (bot, msg, logger, name) => {
|
||||||
|
const youThere = "you there " + name.toLowerCase() + "?";
|
||||||
|
if (msg.text && msg.text.toString().toLowerCase().includes(youThere)) {
|
||||||
|
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " asked if im there");
|
||||||
|
bot.sendMessage(msg.chat.id, "Always...");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fOff: (bot, msg, logger, name) => {
|
||||||
|
const fuuk = "fuck off ";
|
||||||
|
const fuuckPlus = fuuk + name.toLowerCase()
|
||||||
|
if (msg.text && msg.text.toString().toLowerCase().includes(fuuckPlus)) {
|
||||||
|
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " told me to fuck off");
|
||||||
|
bot.sendMessage(msg.chat.id, "Fuck off yourself " + msg.from.first_name + "!");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
loveADeal: (bot, msg, logger) => {
|
||||||
|
const deal = "deal";
|
||||||
|
if (msg.text && msg.text.toString().toLowerCase().match(/\bdeal\b/)) {
|
||||||
|
if (msg)
|
||||||
|
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Said we got a deal!");
|
||||||
|
bot.sendMessage(msg.chat.id, "I LOVE it when " + msg.from.first_name + ", does a deal :)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
28
data/bot/faq/subscriptions.js
Normal file
28
data/bot/faq/subscriptions.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
const fs = require('fs')
|
||||||
|
const subs = JSON.parse(fs.readFileSync('./data/group/subs.json', 'utf8'))
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
prices: (bot, msg, logger) => {
|
||||||
|
const subPrice = "- subscription prices";
|
||||||
|
if (msg.text && msg.text.toString().toLowerCase() === subPrice) {
|
||||||
|
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Got subscription Prices");
|
||||||
|
bot.sendMessage(msg.chat.id,
|
||||||
|
`-
|
||||||
|
${subs[0].SUB} ----£${subs[0].COST}\n
|
||||||
|
${subs[1].SUB} -----------------------£${subs[1].COST}\n
|
||||||
|
${subs[2].SUB} -----£${subs[2].COST}\n
|
||||||
|
${subs[3].SUB} ---------£${subs[3].COST}\n
|
||||||
|
${subs[4].SUB} --------------------£${subs[4].COST}\n
|
||||||
|
${subs[5].SUB} ------------------£${subs[5].COST}\n
|
||||||
|
${subs[6].SUB} -----------£${subs[6].COST}\n
|
||||||
|
${subs[7].SUB} --------------£${subs[7].COST}\n
|
||||||
|
${subs[8].SUB} ---------------------£${subs[8].COST}
|
||||||
|
`)
|
||||||
|
.then(() => {
|
||||||
|
return bot.sendMessage(msg.chat.id, "All of these prices are for 12 Month subscription subs").then(() => {
|
||||||
|
return bot.sendMessage(msg.chat.id, "Keep an eye out though because we offer special deals on different subs from time to time.")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
38
data/bot/questions.js
Normal file
38
data/bot/questions.js
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
const fs = require('fs')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
whatSubShouldIBuy: (bot, msg, logger) => {
|
||||||
|
let subs = JSON.parse(fs.readFileSync('./data/group/subs.json', 'utf8'))
|
||||||
|
|
||||||
|
const whatSubShouldIBuy = "what sub should i buy"
|
||||||
|
|
||||||
|
if (msg.text && msg.text.toString().toLowerCase().includes(whatSubShouldIBuy)) {
|
||||||
|
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked what sub to buy");
|
||||||
|
const randomSub = subs[Math.floor(Math.random() * subs.length)];
|
||||||
|
bot.sendMessage(msg.chat.id, randomSub.SUB + "!");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
subStatus: (bot, msg, logger, name) => {
|
||||||
|
let subs = JSON.parse(fs.readFileSync('./data/group/subs.json', 'utf8'))
|
||||||
|
|
||||||
|
let string = ""
|
||||||
|
const subStatus = "sub status";
|
||||||
|
if (msg.text && msg.text.toString().toLowerCase().includes(subStatus)) {
|
||||||
|
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked how to get a subscription");
|
||||||
|
subs.forEach(element => {
|
||||||
|
if (element.STATUS != "X") {
|
||||||
|
if (element.STATUS === 1) {
|
||||||
|
element.STATUS = "Up"
|
||||||
|
} else {
|
||||||
|
element.STATUS = "Down"
|
||||||
|
}
|
||||||
|
let catString = element.SUB + " Is " + element.STATUS
|
||||||
|
// console.log(catString)
|
||||||
|
string += '\n' + catString;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// console.log(string)
|
||||||
|
bot.sendMessage(msg.chat.id, string, { parse_mode: "HTML" })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
47
data/bot/requests/football.js
Normal file
47
data/bot/requests/football.js
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
module.exports = {
|
||||||
|
gamesToday: (bot, msg, logger) => {
|
||||||
|
const footballToday = "football today";
|
||||||
|
if (msg.text && msg.text.toString().toLowerCase().includes(footballToday)) {
|
||||||
|
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " asked for football today");
|
||||||
|
|
||||||
|
var options = {
|
||||||
|
method: 'GET',
|
||||||
|
url: 'https://football-pro.p.rapidapi.com/api/v2.0/livescores',
|
||||||
|
qs: { tz: 'Europe/London', leagues: '8', include: 'localTeam,visitorTeam' },
|
||||||
|
headers: {
|
||||||
|
'x-rapidapi-host': 'football-pro.p.rapidapi.com',
|
||||||
|
'x-rapidapi-key': process.env.RAPIDAPI_API_KEY,
|
||||||
|
useQueryString: true
|
||||||
|
},
|
||||||
|
ttl: 18000000 //5 hours
|
||||||
|
};
|
||||||
|
|
||||||
|
cachedRequest(options, function (error, response, body) {
|
||||||
|
// console.log(response)
|
||||||
|
if (error) throw new Error(error);
|
||||||
|
|
||||||
|
// console.log(body);
|
||||||
|
let jsonBody = JSON.parse(body)
|
||||||
|
if (jsonBody.data.length > 0) {
|
||||||
|
bot.sendMessage(msg.chat.id, 'Yes there is!').then(() => {
|
||||||
|
return jsonBody.data.forEach(function (entry) {
|
||||||
|
var homeTeam = entry.localTeam.data.name
|
||||||
|
var awayTeam = entry.visitorTeam.data.name
|
||||||
|
var startTime = entry.time.starting_at.time
|
||||||
|
// console.log(entry);
|
||||||
|
bot.sendMessage(msg.chat.id, homeTeam + " VS " + awayTeam + " @ " + startTime)
|
||||||
|
});
|
||||||
|
}).then(() => {
|
||||||
|
return bot.sendMessage(msg.chat.id, 'To see what channels the football is streaming on please join @footballontv')
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
bot.sendMessage(msg.chat.id, 'Sadly there is no football today :(')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
30
data/bot/requests/joke.js
Normal file
30
data/bot/requests/joke.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
module.exports = {
|
||||||
|
tellMe: (bot, msg, logger, name) => {
|
||||||
|
const joke = name.toLowerCase() + " tell me a joke";
|
||||||
|
if (msg.text && msg.text.toString().toLowerCase().includes(joke)) {
|
||||||
|
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
|
||||||
|
},
|
||||||
|
// ttl: 18000 //5 hours
|
||||||
|
};
|
||||||
|
|
||||||
|
request(options, function (error, response, body) {
|
||||||
|
// console.log(response)
|
||||||
|
|
||||||
|
if (error) throw new Error(error);
|
||||||
|
let jsonBody = JSON.parse(body)
|
||||||
|
bot.sendMessage(msg.chat.id, jsonBody.content)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
26
data/bot/requests/updateSubStatus.js
Normal file
26
data/bot/requests/updateSubStatus.js
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
const fs = require('fs')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
setSubStatus: (bot, msg, logger, name) => {
|
||||||
|
let subs = JSON.parse(fs.readFileSync('./data/group/subs.json', 'utf8'))
|
||||||
|
const setSub = "set sub";
|
||||||
|
if (msg.text && msg.text.toString().toLowerCase().includes(setSub)) {
|
||||||
|
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked how to get a subscription");
|
||||||
|
sub = msg.text.match(/(?<=set sub )(.*)(?= to (up|down))/g)[0]
|
||||||
|
status = msg.text.match(/\w+(?=( \w+){0}$)/g)[0]
|
||||||
|
if (status === "up") {
|
||||||
|
status = 1
|
||||||
|
} else {
|
||||||
|
status = 0
|
||||||
|
}
|
||||||
|
subs.forEach(function (element, index) {
|
||||||
|
if (element.SUB.toLowerCase() === sub) {
|
||||||
|
subs[index].STATUS = status; //set the value
|
||||||
|
}
|
||||||
|
})
|
||||||
|
console.log(subs);
|
||||||
|
fs.writeFileSync('./data/group/subs.json', JSON.stringify(subs))
|
||||||
|
bot.sendMessage(msg.chat.id, sub + " sub updated")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
7
data/bot/welcomeMesage.js
Normal file
7
data/bot/welcomeMesage.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
module.exports = {
|
||||||
|
welcomeMessage: (bot, msg, logger) => {
|
||||||
|
const newUserMention = "<a href=\"tg:\/\/user?id=" + msg.new_chat_member.id + "\">@" + msg.new_chat_member.first_name + "<\/a>"
|
||||||
|
bot.sendMessage(msg.chat.id, "Hello " + newUserMention + ", Welcome to " + channel + ". \n\nPlease PM me @" + process.env.BOT_USERNAME + " to find out all needed information about our service before asking an admin or posting in here.\n\nIf you do ask questions, and its obvious you have not spoken to me, you will be booted from the room. This is IPTV, admins don't have time for hand holding.!!!", { parse_mode: "HTML" });
|
||||||
|
logger.info("ID - " + msg.new_chat_member.id + " First Name - " + msg.new_chat_member.first_name + " joined the group");
|
||||||
|
}
|
||||||
|
};
|
1
data/group/subs.json
Normal file
1
data/group/subs.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
[{"SUB":"Premium Plus","COST":30,"STATUS":1},{"SUB":"VIP","COST":25,"STATUS":1},{"SUB":"Old Premium","COST":17,"STATUS":1},{"SUB":"Bluemoon","COST":15,"STATUS":1},{"SUB":"KDB","COST":14,"STATUS":1},{"SUB":"Gold","COST":13,"STATUS":1},{"SUB":"Technoid","COST":13,"STATUS":1},{"SUB":"Bronze","COST":10,"STATUS":1},{"SUB":"SOL","COST":10,"STATUS":0},{"SUB":"New Premium (tvob)","COST":"X","STATUS":0},{"SUB":"Gambler","COST":"X","STATUS":1},{"SUB":"All of em","COST":"X","STATUS":"X"}]
|
@ -1,9 +0,0 @@
|
|||||||
let logger = require('perfect-logger');
|
|
||||||
|
|
||||||
// Configure Settings
|
|
||||||
logger.initialize('FrontEndDriver', {
|
|
||||||
logLevelFile: 0, // Log level for file
|
|
||||||
logLevelConsole: 0, // Log level for STDOUT/STDERR
|
|
||||||
logDirectory: 'logs/', // Log directory
|
|
||||||
customBannerHeaders: 'This is a custom banner' // Custom Log Banner
|
|
||||||
});
|
|
828
package-lock.json
generated
828
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -14,12 +14,18 @@
|
|||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"array-to-table": "^1.0.1",
|
||||||
"cached-request": "^2.0.1",
|
"cached-request": "^2.0.1",
|
||||||
"dotenv": "^8.2.0",
|
"dotenv": "^8.2.0",
|
||||||
|
"fs": "0.0.1-security",
|
||||||
|
"html-table-builder": "^1.0.1",
|
||||||
|
"node-html-to-image": "^2.1.1",
|
||||||
"node-telegram-bot-api": "^0.50.0",
|
"node-telegram-bot-api": "^0.50.0",
|
||||||
|
"obj-array-table": "^1.0.17",
|
||||||
"perfect-logger": "^2.0.1",
|
"perfect-logger": "^2.0.1",
|
||||||
"rapidapi-connect": "0.0.6",
|
|
||||||
"request": "^2.88.2",
|
"request": "^2.88.2",
|
||||||
|
"require-dir": "^1.2.0",
|
||||||
|
"table": "^5.4.6",
|
||||||
"throttled-request": "^0.1.1"
|
"throttled-request": "^0.1.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user