Skip to content

Commit

Permalink
update v5
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramlan404 committed Apr 20, 2022
1 parent 3875e21 commit d3fa618
Show file tree
Hide file tree
Showing 21 changed files with 1,820 additions and 263 deletions.
6 changes: 3 additions & 3 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"ownerNumber": "62855xxx@s.whatsapp.net",
"botName": "Baby Bot",
"ownerNumber": "62855xxxx@s.whatsapp.net",
"botName": "BABYBOT V5",
"ownerName": "Ramlan ID",
"footer": "*2022 © BABYBOT*",
"apikey": "BELI ATUH",
"apikey": "APIKEY",
"pathThumb": "./media/logo.jpg",
"sessionName": "ramlanid",
"limitCount": 30,
Expand Down
1 change: 1 addition & 0 deletions database/afk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
2 changes: 1 addition & 1 deletion database/premium.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[]
[]
109 changes: 109 additions & 0 deletions lib/afk.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
const fs = require('fs')

/**
* Add AFK.
* @param {String} userId
* @param {String} time
* @param {String} reason
* @param {Object} _dir
*/
const addAfkUser = (userId, time, reason, _dir) => {
const obj = { id: userId, time: time, reason: reason }
_dir.push(obj)
fs.writeFileSync('./database/afk.json', JSON.stringify(_dir))
}

/**
* Check user AFK.
* @param {String} userId
* @param {Object} _dir
* @returns {Boolean}
*/
const checkAfkUser = (userId, _dir) => {
let status = false
Object.keys(_dir).forEach((i) => {
if (_dir[i].id === userId) {
status = true
}
})
return status
}

/**
* Get AFK reason.
* @param {String} userId
* @param {Object} _dir
* @returns {String}
*/
const getAfkReason = (userId, _dir) => {
let position = null
Object.keys(_dir).forEach((i) => {
if (_dir[i].id === userId) {
position = i
}
})
if (position !== null) {
return _dir[position].reason
}
}

/**
* Get AFK time.
* @param {String} userId
* @param {Object} _dir
* @returns {String}
*/
const getAfkTime = (userId, _dir) => {
let position = null
Object.keys(_dir).forEach((i) => {
if (_dir[i].id === userId) {
position = i
}
})
if (position !== null) {
return _dir[position].time
}
}

/**
* Get AFK ID.
* @param {String} userId
* @param {Object} _dir
* @returns {String}
*/
const getAfkId = (userId, _dir) => {
let position = null
Object.keys(_dir).forEach((i) => {
if (_dir[i].id === userId) {
position = i
}
})
if (position !== null) {
return _dir[position].id
}
}

/**
* Get AFK position.
* @param {String} userId
* @param {Object} _dir
* @returns {Number}
*/
const getAfkPosition = (userId, _dir) => {
let position = null
Object.keys(_dir).forEach((i) => {
if (_dir[i].id === userId) {
position = i
}
})
return position
}

module.exports = {
addAfkUser,
checkAfkUser,
getAfkReason,
getAfkTime,
getAfkId,
getAfkPosition
}
13 changes: 6 additions & 7 deletions lib/myfunc.js

Large diffs are not rendered by default.

Loading

0 comments on commit d3fa618

Please sign in to comment.