79 lines
2.4 KiB
JavaScript
79 lines
2.4 KiB
JavaScript
require('dotenv').config();
|
|
|
|
const logger = require('perfect-logger');
|
|
|
|
const token = process.env.BOT_TOKEN;
|
|
const name = process.env.BOT_NAME;
|
|
|
|
// Configure Settings
|
|
logger.initialize(name + "_bot", {
|
|
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
|
|
});
|
|
|
|
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_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')
|
|
|
|
|
|
let commands = require('./data/group/commands')
|
|
let navigation = require('./data/group/FAQ')
|
|
let chat = require('./data/group/chat')
|
|
let jointArray = navigation.concat(chat)
|
|
|
|
|
|
const bot = new TelegramBot(token, { polling: true });
|
|
|
|
bot.on('new_chat_members', (msg) => {
|
|
bot_welcome.welcomeMessage(bot, msg, logger)
|
|
});
|
|
|
|
bot.on('message', (msg) => {
|
|
bot_subStatus.setSubStatus(bot, msg, logger)
|
|
|
|
if (msg.text && msg.text.toString().includes("/sub_status")) {
|
|
questions.subStatus(bot, msg, logger)
|
|
}
|
|
|
|
if (msg.text && msg.text.toString().includes("/football_today")) {
|
|
requests.football_today(bot, msg, logger)
|
|
}
|
|
|
|
if (msg.text && msg.text.toString().includes("/joke")) {
|
|
requests.joke(bot, msg, logger)
|
|
}
|
|
|
|
if (msg.text && msg.text.toString() === "- What app should I use?") {
|
|
bot_faq_whatAppToUse.main(bot, msg, logger)
|
|
}
|
|
bot_faq_whatAppToUse.appSwitch(bot, msg, logger)
|
|
|
|
if (msg.text && msg.text.toString() === "- Subscription Options") {
|
|
bot_faq_subscription.pricesImageList(bot, msg, logger)
|
|
}
|
|
|
|
for (const x of jointArray) {
|
|
if (msg.text && msg.text.toString() === x.NAME) {
|
|
common.chat(bot, msg, x.NAME)
|
|
}
|
|
}
|
|
|
|
for (const x of commands) {
|
|
if (msg.text && msg.text.toString().includes(x.NAME)) {
|
|
common.commands(bot, msg, x.NAME)
|
|
}
|
|
}
|
|
|
|
if (msg.text && msg.text.toString().toLowerCase().includes("set sub")) {
|
|
bot_subStatus.setSubStatus(bot, msg, logger)
|
|
}
|
|
|
|
}) |