Skip to content

Commit

Permalink
Update V4
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramlan404 committed Feb 27, 2022
1 parent b01f8bd commit 3f221a8
Show file tree
Hide file tree
Showing 53 changed files with 1,328 additions and 0 deletions.
15 changes: 15 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"ownerNumber": "[email protected]",
"botName": "Baby Bot",
"ownerName": "Ramlan ID",
"footer": "*2022 © BABYBOT*",
"apikey": "BELI ATUH",
"pathThumb": "./media/logo.jpg",
"sessionName": "ramlanid",
"limitCount": 30,
"gamewaktu": 60,
"gcount": {
"prem": 50,
"user": 20
}
}
1 change: 1 addition & 0 deletions database/antibitly.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions database/antilink.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions database/antitele.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions database/antiwame.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions database/antiyt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions database/balance.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions database/ban.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions database/glimit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions database/left.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions database/limit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions database/list-message.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions database/mute.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions database/premium.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions database/respon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions database/set_left.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions database/set_welcome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions database/sewa.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions database/user.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions database/welcome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
80 changes: 80 additions & 0 deletions lib/antispam.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
const toMs = require('ms')

// Message filter
const usedCommandRecently = new Set()

/**
* Check is number filtered.
* @param {String} from
* @returns {Boolean}
*/
const isFiltered = (from) => {
return !!usedCommandRecently.has(from)
}

/**
* Add number to filter.
* @param {String} from
*/
const addFilter = (from) => {
usedCommandRecently.add(from)
setTimeout(() => {
return usedCommandRecently.delete(from)
}, 5000) // 5 seconds delay, I don't recommend below that.
}

const addSpam = (sender, _db) => {
let position = false
Object.keys(_db).forEach((i) => {
if (_db[i].id === sender) {
position = i
}
})
if (position !== false) {
_db[position].spam += 1
} else {
const bulin = ({
id: sender,
spam: 1,
expired: Date.now() + toMs('10m')
})
_db.push(bulin)
}
}

const ResetSpam = (_dir) => {
setInterval(() => {
let position = null
Object.keys(_dir).forEach((i) => {
if (Date.now() >= _dir[i].expired) {
position = i
}
})
if (position !== null) {
console.log(`Spam expired: ${_dir[position].id}`)
_dir.splice(position, 1)
}
}, 1000)
}
const isSpam = (sender, _db) => {
let found = false
for (let i of _db) {
if (i.id === sender) {
let spam = i.spam
if (spam >= 5) {
found = true
return true
} else {
found = true
return false
}
}
}
}
module.exports = {
isFiltered,
addFilter,
addSpam,
ResetSpam,
isSpam
}
91 changes: 91 additions & 0 deletions lib/banned.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
const fs = require('fs')
const toMs = require('ms')

/**
* Add user to bannedList database
* @param {String} userId
* @param {String} expired
* @param {Object} _data
*/
const addBanned = (userId, expired, _data) => {
let success = false
if (expired === undefined) {
expired = 'PERMANENT'
} else {
expired = expired
}

let expired_at = 'PERMANENT'

if (expired === 'PERMANENT') {
expired_at = 'PERMANENT'
} else {
expired_at = Date.now() + toMs(expired)
}

const obj = {
id: userId,
expired: expired_at
}

_data.push(obj)
fs.writeFileSync('./database/ban.json', JSON.stringify(_data, null, 3))
}
/**
* Unbanned someone.
* @param {String} userId
* @param {Object} _dir
* @returns {Number}
*/
const unBanned = (userId, _data) => {
let position = null
Object.keys(_data).forEach((i) => {
if (_data[i].id === userId) {
position = i
}
})
if (position !== null) {
_data.splice(position, 1)
fs.writeFileSync('./database/ban.json', JSON.stringify(_data, null, 3))
}
return true
}
const BannedExpired = (_dir) => {
setInterval(() => {
let position = null
Object.keys(_dir).forEach((i) => {
if (_dir[i].expired === 'PERMANENT') {
position = null
} else if (Date.now() >= _dir[i].expired) {
position = i
}
})
if (position !== null) {
console.log(`Banned expired: ${_dir[position].id}`)
_dir.splice(position, 1)
fs.writeFileSync('./database/ban.json', JSON.stringify(_dir, null, 3))
}
}, 1000)
}
/**
* Check user is premium.
* @param {String} userId
* @param {Object} _dir
* @returns {Boolean}
*/
const cekBannedUser = (userId, _dir) => {
let status = false
Object.keys(_dir).forEach((i) => {
if (_dir[i].id === userId) {
status = true
}
})
return status
}

module.exports = {
addBanned,
unBanned,
BannedExpired,
cekBannedUser
}
19 changes: 19 additions & 0 deletions lib/color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const chalk = require('chalk')

const color = (text, color) => {
return !color ? chalk.green(text) : chalk.keyword(color)(text)
}

const bgcolor = (text, bgcolor) => {
return !bgcolor ? chalk.green(text) : chalk.bgKeyword(bgcolor)(text)
}

const babyLog = (text, color) => {
return !color ? chalk.yellow('[BABY] ') + chalk.green(text) : chalk.yellow('[BABY] ') + chalk.keyword(color)(text)
}

module.exports = {
color,
bgcolor,
babyLog
}
57 changes: 57 additions & 0 deletions lib/exif.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* Originally created by cwke
* Reuploaded by Waxaranai
* Recoded by SlavyanDesu
*
* GitHub is an open-source community, so why are you so triggered when someone shared some simple code?
*/

const fs = require('fs')
const packID = 'com.snowcorp.stickerly.android.stickercontentprovider b5e7275f-f1de-4137-961f-57becfad34f2'
const playstore = 'https://play.google.com/store/apps/details?id=com.pubg.newstate&hl=in&gl=US'
const itunes = 'https://apps.apple.com/us/app/pubg-mobile-3rd-anniversary/id1330123889'

/**
* @class Exif
*/
module.exports = class Exif {
/**
* Create an EXIF file.
* @param {String} packname
* @param {String} authorname
* @param {String} [filename=data]
*/
create(packname, authorname, filename) {
if (!filename) filename = 'data'
const json = {
'sticker-pack-id': packID,
'sticker-pack-name': packname,
'sticker-pack-publisher': authorname,
'android-app-store-link': playstore,
'ios-app-store-link': itunes
}
let len = JSON.stringify(json).length
const f = Buffer.from([0x49, 0x49, 0x2A, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x41, 0x57, 0x07, 0x00])
const code = [0x00, 0x00, 0x16, 0x00, 0x00, 0x00]
if (len > 256) {
len = len - 256
code.unshift(0x01)
} else {
code.unshift(0x00)
}
const fff = Buffer.from(code)
const ffff = Buffer.from(JSON.stringify(json))
if (len < 16) {
len = len.toString(16)
len = '0' + len
} else {
len = len.toString(16)
}
const ff = Buffer.from(len, 'hex')
const buffer = Buffer.concat([f, ff, fff, ffff])
fs.writeFile(`./sticker/${filename}.exif`, buffer, (err) => {
if (err) return console.error(err)
console.log('Success!')
})
}
}
Loading

0 comments on commit 3f221a8

Please sign in to comment.