1.0.8 • Published 3 years ago

jonin-services v1.0.8

Weekly downloads
33
License
Apache-2.0
Repository
github
Last release
3 years ago

Following Modules Used/Recoded

OldNew
decode-encode-binary❯❯binary
cleverbot-free❯❯chatbot
dotenv❯❯env
node-fetch❯❯fetch
moment-duration-format❯❯moment
node-osu❯❯osu
@2toad/profanity❯❯profanity
sloc-count❯❯sloc
weather-js❯❯weather
Other Modules
canvas 2.6.1
discord.js 12.5.1
elara-services 1.3.0
discord-music-player 6.4.1
moment 2.29.1
opusscript 0.0.7
mongodb 3.6.3

Usage

Install

npm install jonin-services

Modules

❯ Binary

Click here for more information

/**
 * Converts input text into binary or ascii depending on params.
 * 
 * @name binary
 */

let services = require("jonin-services")
let binary = new services().binary

console.log(binary.auto(`Hi`)) // Detect text and return opposite
// Console: 0100100001101001
console.log(binary.auto(`0100100001101001`))
// Console: Hi
console.log(binary.encode(`Hi`)) // Force encode
// Console: 0100100001101001
console.log(binary.decode(`0100100001101001`)) // Force decode
// Console: Hi

❯ Chatbot

Click here for more information

/**
 * Takes the history of the chat and the current message to make a proper response.
 * 
 * @name chatbot
 */

let services = require("jonin-services")
let chatbot = new services().chatbot

let noHistoryChat = await chatbot.get(`Hi`)
console.log(noHistoryChat) // Start a conversation/No history avaliable
// Console: Hello
let historyChat = await chatbot.get(`Hi`, [`Hello There!`, `What's up?`])
console.log(historyChat) // Request a message with history
// Console: How are you?

❯ Env

Click here for more information

/**
 * @file Access `.env` through process.
 * 
 * @name env
 * @see Object.mergify() Found in `services.js`
 * @usage  new <Services>().env.config()
 */

let services = require("jonin-services")

new services().env.config() // Run config

console.log(process.env.TOKEN) // Access env data
// Console: SUPER_SECRET_KEY

❯ Fetch

Click here for more information

/**
 * @file node-fetch module.
 * 
 * @name fetch
 * @usage new <Services>().fetch(string)
 */

let services = require("jonin-services")
let fetch = new services().fetch

let jsonFetch = await fetch(`https://jsonplaceholder.typicode.com/todos/1`) // Fetch site
console.log(await jsonFetch.json()) // Log JSON
// Console: { userId: 1, id: 1, title: 'delectus aut autem', completed: false }

❯ Moment

Click here for more information

/**
 * @file moment-duration-format module.
 * 
 * @name moment
 * @usage new <Services>().moment(module[MOMENT])
 */

let services = require("jonin-services")
let moment = require(`moment`) // https://www.npmjs.com/package/moment
new services().moment(moment)

// Moment duration format
console.log(moment.duration((new Date().getTime() + 500000000) - new Date().getTime()).format(`w [Weeks], d [Days], h [Hours], m [Minutes], s [Seconds]`))
// Console: 5 Days, 18 Hours, 53 Minutes, 20 Seconds

❯ Osu

Click here for more information

/**
 * @file osu! info module.
 * 
 * @name osu
 * @see Object.mergify() Found in `services.js`
 * @usage new <Services>(object[TOKEN]).osu.getUser(object[USER])
 */

let services = require("jonin-services")
let token = `` // ADD TOKEN HERE
let osu = new services({ osu: token }).osu

if (!token) return console.log(`\tOsu Service Issue: No token provided [Visit https://osu.ppy.sh/p/api/ to get a token]`) // If not token
let osuUser = await osu.getUser({ u: `fangary12` }) // Get osu! user information
console.log(`\tUser Fetch:`, `fangary12`, `=>`, JSON.stringify(osuUser))
// Console: User {...}

❯ Profanity

Click here for more information

/**
 * @file Clear out profanity from text.
 * 
 * @name profanity
 * @usage new <Services>().profanity.clean(string)
 */

let services = require("jonin-services")
let profanity = new services().profanity

console.log(profanity.clean(`So much damn code`)) // Clean up text
// Console: So much ***** code

❯ Sloc

Click here for more information

/**
 * @file File data and sloc getter.
 * 
 * @name sloc
 * @usage new <Services>().sloc.readFile(string)
 */

let services = require("jonin-services")
let { readFileSync } = require(`fs`)
let sloc = new services().sloc

console.log(JSON.stringify(sloc.readFile(readFileSync(`./example.js`, `utf8`)))) // Log file data
// Console: {"total":117,"source":95,"singleLineComments":0,"blockCommentLines":0,"blockComments":0,"empty":22}

❯ Weather

Click here for more information

/**
 * @file Current/Forcast weather fetcher.
 * 
 * @name weather
 * @see fetch.js Found in `./services/modules/fetch/fetch.js`
 * @usage new <Services>().weather.get(object)
 */

let services = require("jonin-services")
let weather = new services().weather

await weather.get({ degreeType: `F`, lang: `en-US`, search: `dallas, tx` }, (err, res) => {
    if (err) { }
    console.log(`\tWeather/Forecast:`, `\"Dallas, TX\"`, `=>`, JSON.stringify(res))
})
// Console: [{"location":{...},"forecast":[{...},{...},{...}]}]