fca-riya-bot
Version:
Facebook-chat-api made by Smart Shankar
67 lines (64 loc) • 2.58 kB
JavaScript
;
/* eslint-disable linebreak-style */
const chalk = require('chalk');
var isHexcolor = require('is-hexcolor');
var getText = function(/** @type {string[]} */ ...Data) {
var Main = (Data.splice(0,1)).toString();
for (let i = 0; i < Data.length; i++) Main = Main.replace(RegExp(`%${i + 1}`, 'g'), Data[i]);
return Main;
};
/**
* @param {any} obj
*/
function getType(obj) {
return Object.prototype.toString.call(obj).slice(8, -1);
}
module.exports = {
Normal: function(/** @type {string} */ Str, /** @type {() => any} */ Data ,/** @type {() => void} */ Callback) {
if (isHexcolor(global.Fca.Require.Shankar.MainColor) != true) {
this.Warning(getText(global.Fca.Require.Language.Index.InvaildMainColor,global.Fca.Require.Shankar.MainColor),process.exit(0));
}
else console.log(chalk.hex(global.Fca.Require.Shankar.MainColor).bold(`${global.Fca.Require.Shankar.MainName || '[ FCA-HZI ]'} > `) + Str);
if (getType(Data) == 'Function' || getType(Data) == 'AsyncFunction') {
return Data();
}
if (Data) {
return Data;
}
if (getType(Callback) == 'Function' || getType(Callback) == 'AsyncFunction') {
Callback();
}
else return Callback;
},
Warning: function(/** @type {unknown} */ str, /** @type {() => void} */ callback) {
console.log(chalk.magenta.bold('[ FCA-WARNING ] > ') + chalk.yellow(str));
if (getType(callback) == 'Function' || getType(callback) == 'AsyncFunction') {
callback();
}
else return callback;
},
Error: function(/** @type {unknown} */ str, /** @type {() => void} */ callback) {
if (!str) {
console.log(chalk.magenta.bold('[ FCA-ERROR ] > ') + chalk.red("Already Faulty, Please Contact: Facebook.com/Lazic.Kanzu"));
}
console.log(chalk.magenta.bold('[ FCA-ERROR ] > ') + chalk.red(str));
if (getType(callback) == 'Function' || getType(callback) == 'AsyncFunction') {
callback();
}
else return callback;
},
Success: function(/** @type {unknown} */ str, /** @type {() => void} */ callback) {
console.log(chalk.hex('#9900FF').bold(`${global.Fca.Require.Shankar.MainName || '[ FCA-HZI ]'} > `) + chalk.green(str));
if (getType(callback) == 'Function' || getType(callback) == 'AsyncFunction') {
callback();
}
else return callback;
},
Info: function(/** @type {unknown} */ str, /** @type {() => void} */ callback) {
console.log(chalk.hex('#9900FF').bold(`${global.Fca.Require.Shankar.MainName || '[ FCA-HZI ]'} > `) + chalk.blue(str));
if (getType(callback) == 'Function' || getType(callback) == 'AsyncFunction') {
callback();
}
else return callback;
}
};