BBLBTV_Suzie/test.js

72 lines
2.1 KiB
JavaScript
Raw Normal View History

2020-06-29 21:32:14 +01:00
require('dotenv').config();
2020-06-29 22:43:41 +01:00
const logger = require('perfect-logger');
2020-06-29 21:32:14 +01:00
const token = process.env.BOT_TOKEN;
2020-06-29 22:43:41 +01:00
const name = process.env.BOT_NAME;
2020-06-29 21:32:14 +01:00
2020-06-29 22:43:41 +01:00
// Configure Settings
logger.initialize(name + "_bot", {
2020-06-30 13:34:58 +01:00
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
2020-06-29 22:43:41 +01:00
});
2020-06-29 21:32:14 +01:00
2020-06-29 22:43:41 +01:00
const TelegramBot = require('node-telegram-bot-api');
const common = require('./data/bot/lib/common')
const questions = require('./data/bot/lib/questions')
2020-06-30 10:09:22 +01:00
const requests = require('./data/bot/lib/requests')
2020-06-30 13:34:58 +01:00
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')
let commands = require('./data/group/commands')
let navigation = require('./data/group/FAQ')
let chat = require('./data/group/chat')
let jointArray = navigation.concat(chat)
2020-06-29 21:32:14 +01:00
2020-06-29 22:43:41 +01:00
const bot = new TelegramBot(token, { polling: true });
2020-06-29 21:32:14 +01:00
2020-06-30 13:34:58 +01:00
bot.on('new_chat_members', (msg) => {
bot_welcome.welcomeMessage(bot, msg, logger)
});
2020-06-29 21:32:14 +01:00
bot.on('message', (msg) => {
if (msg.text && msg.text.toString().includes("/sub_status")) {
2020-06-29 22:43:41 +01:00
questions.subStatus(bot, msg, logger)
2020-06-29 21:32:14 +01:00
}
2020-06-29 22:43:41 +01:00
if (msg.text && msg.text.toString().includes("/football_today")) {
2020-06-30 10:09:22 +01:00
requests.football_today(bot, msg, logger)
}
if (msg.text && msg.text.toString().includes("/joke")) {
requests.joke(bot, msg, logger)
}
2020-06-30 13:34:58 +01:00
if (msg.text && msg.text.toString() === "- What app should I use?") {
bot_faq_whatAppToUse.main(bot, msg, logger)
2020-06-30 10:41:39 +01:00
}
2020-06-30 13:34:58 +01:00
bot_faq_whatAppToUse.appSwitch(bot, msg, logger)
if (msg.text && msg.text.toString() === "- Subscription Prices") {
bot_faq_subscription.prices(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)
}
2020-06-30 10:09:22 +01:00
}
})