Skip to content

Commit

Permalink
Reminderrrrr
Browse files Browse the repository at this point in the history
  • Loading branch information
SlavyanDesu committed Dec 30, 2020
1 parent 63ccd48 commit 7fafffa
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 13 deletions.
1 change: 1 addition & 0 deletions database/reminder.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
13 changes: 12 additions & 1 deletion lib/fun.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@ const weton = (tgl, bln, thn) => new Promise((resolve, reject) => {
.catch((err) => reject(err))
})

/**
* Get TikTok asupan videos. h3h3
*/
const asupan = () => new Promise((resolve, reject) => {
console.log('Fetching video...')
fetchText('http://sansekai.my.id/sansekai.txt')
.then((result) => resolve(result))
.catch((err) => reject(err))
})

module.exports = {
howgay,
calender,
Expand All @@ -140,5 +150,6 @@ module.exports = {
distance,
truth,
dare,
weton
weton,
asupan
}
77 changes: 69 additions & 8 deletions message/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ const axios = require('axios')
const tts = require('node-gtts')
const bent = require('bent')
const ms = require('parse-ms')
const toMs = require('ms')
const canvas = require('canvacord')
const mathjs = require('mathjs')
const saus = sagiri(config.nao, { results: 5 })
const emojiUnicode = require('emoji-unicode')
const fetch = require('node-fetch')
const moment = require('moment-timezone')
moment.tz.setDefault('Asia/Jakarta').locale('id')
/********** END OF MODULES **********/
Expand All @@ -56,6 +56,7 @@ const _level = JSON.parse(fs.readFileSync('./database/level.json'))
const _limit = JSON.parse(fs.readFileSync('./database/limit.json'))
const _afk = JSON.parse(fs.readFileSync('./database/afk.json'))
const _autostiker = JSON.parse(fs.readFileSync('./database/autostiker.json'))
const _reminder = JSON.parse(fs.readFileSync('./database/reminder.json'))
/********** END OF DATABASES **********/

/********** MESSAGE HANDLER **********/
Expand Down Expand Up @@ -306,6 +307,46 @@ module.exports = msgHandler = async (bocchi = new Client(), message) => {
})
return position
}

const addReminder = (userId, message, time) => {
const obj = { id: userId, msg: message, time: Date.now() + toMs(time) }
_reminder.push(obj)
fs.writeFileSync('./database/reminder.json', JSON.stringify(_reminder))
}

const getReminderTime = (userId) => {
let position = false
Object.keys(_reminder).forEach((i) => {
if(_reminder[i].id === userId) {
position = i
}
})
if (position !== false) {
return _reminder[position].time
}
}

const getReminderMsg = (userId) => {
let position = false
Object.keys(_reminder).forEach((i) => {
if (_reminder[i].id === userId) {
position = i
}
})
if (position !== false) {
return _reminder[position].msg
}
}

const getReminderPosition = (userId) => {
let position = false
Object.keys(_reminder).forEach((i) => {
if (_reminder[i].id === userId) {
position = i
}
})
return position
}
/********** END OF FUNCTION **********/

/********** VALIDATOR **********/
Expand Down Expand Up @@ -443,7 +484,6 @@ module.exports = msgHandler = async (bocchi = new Client(), message) => {
var pepe = ppLink
}
const requiredXp = 5000 * (Math.pow(2, userLevel) - 1)
const userIds = sender.id.substring(9, 13)
const randomHexs = `#${(Math.random() * 0xFFFFFF << 0).toString(16).padStart(6, '0')}`
const randomHex = `#${(Math.random() * 0xFFFFFF << 0).toString(16).padStart(6, '0')}`
const rank = new canvas.Rank()
Expand All @@ -454,7 +494,7 @@ module.exports = msgHandler = async (bocchi = new Client(), message) => {
.setRequiredXP(requiredXp)
.setProgressBar([randomHexs, randomHex], 'GRADIENT')
.setUsername(pushname)
.setDiscriminator(userIds)
.setDiscriminator('#0001', '#2c2f33')
rank.build()
.then(async (buffer) => {
canvas.write(buffer, `${pushname}_card.png`)
Expand Down Expand Up @@ -1064,6 +1104,23 @@ module.exports = msgHandler = async (bocchi = new Client(), message) => {
console.log('Success sending Al-Kitab!')
})
break
case 'reminder': // by Slavyan
if (!isRegistered) return await bocchi.reply(from, ind.notRegistered(), id)
if (!q.includes('|')) return await bocchi.reply(from, ind.wrongFormat(), id)
const timeRemind = q.substring(0, q.indexOf('|') - 1)
const messRemind = q.substring(q.lastIndexOf('|') + 2)
const parsedTime = ms(toMs(timeRemind))
addReminder(sender.id, messRemind, timeRemind)
await bocchi.sendTextWithMentions(from, `*「 REMINDER 」*\n\nReminder diaktifkan! :3\n\n➸ *Pesan*: ${messRemind}\n➸ *Durasi*: ${parsedTime.hours} jam ${parsedTime.minutes} menit ${parsedTime.seconds} detik\n➸ *Untuk*: @${sender.id.replace('@c.us', '')}`, id)
const intervRemind = setInterval(async () => {
if (Date.now() > getReminderTime(sender.id)) {
await bocchi.sendTextWithMentions(from, `⏰ *「 REMINDER 」* ⏰\n\nAkhirnya tepat waktu~ @${sender.id.replace('@c.us', '')}\n\n➸ *Pesan*: ${getReminderMsg(sender.id)}`)
_reminder.splice(getReminderPosition(sender.id), 1)
fs.writeFileSync('./database/reminder.json', JSON.stringify(_reminder))
clearInterval(intervRemind)
}
}, 1000)
break

// Bot
case 'menu':
Expand Down Expand Up @@ -1245,9 +1302,8 @@ module.exports = msgHandler = async (bocchi = new Client(), message) => {
break
case 'wait':
if (!isRegistered) return await bocchi.reply(from, ind.notRegistered(), id)
if (isMedia && type === 'image' || isQuotedImage) {
if (isMedia && isImage || isQuotedImage) {
await bocchi.reply(from, ind.wait(), id)
console.log('Searching for anime source...')
const encryptMedia = isQuotedImage ? quotedMsg : message
const _mimetype = isQuotedImage ? quotedMsg.mimetype : mimetype
const mediaData = await decryptMedia(encryptMedia, uaOverride)
Expand Down Expand Up @@ -1375,12 +1431,17 @@ module.exports = msgHandler = async (bocchi = new Client(), message) => {
// Fun
case 'asupan':
if (!isRegistered) return await bocchi.reply(from, ind.notRegistered(), id)
fetch('http://sansekai.my.id/sansekai.txt')
.then((res) => res.text())
await bocchi.reply(from, ind.wait(), id)
fun.asupan()
.then(async (body) => {
const asupan = body.split('\n')
const asupanx = asupan[Math.floor(Math.random() * asupan.length)]
await bocchi.sendFileFromUrl(from, `http://sansekai.my.id/ptl_repost/${asupanx}`, '', 'Follow IG: https://www.instagram.com/ptl_repost untuk mendapatkan asupan lebih banyak.', id)
await bocchi.sendFileFromUrl(from, `http://sansekai.my.id/ptl_repost/${asupanx}`, 'asupan.mp4', 'Follow IG: https://www.instagram.com/ptl_repost untuk mendapatkan asupan lebih banyak.', id)
console.log('Success sending video!')
})
.catch(async (err) => {
console.error(err)
await bocchi.reply(from, `Error!\n${err}`, id)
})
break
case 'profile':
Expand Down
16 changes: 15 additions & 1 deletion message/text/lang/ind.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ exports.ytFound = (res) => {
}

exports.notRegistered = () => {
return `Kamu belum terdaftar di database!\n\nSilakan register dengan format:\n*${prefix}register* nama | umur`
return `Kamu belum terdaftar di database!\n\nSilakan register dengan format:\n*${prefix}register* nama | umur\n\nNote:\nHarap save nomor ku agar bisa mendapatkan serial!!`
}

exports.registered = (name, age, userId, time, serial) => {
Expand Down Expand Up @@ -526,6 +526,15 @@ Cari film.
Aliases: -
Usage: *${prefix}movie* judul
28. *${prefix}reminder*
Pengingat.
*s* - detik
*m* - menit
*h* - jam
*d* - hari
Aliases: -
Usage: *${prefix}reminder* 10s | pesan_pengingat
_Index of [3]_
`
}
Expand Down Expand Up @@ -720,6 +729,11 @@ Kiss someone ( ͡° ͜ʖ ͡°).
Aliases: -
Usage: Kirim gambar dengan caption *${prefix}kiss* atau reply gambar dengan *${prefix}kiss*.
17. *${prefix}asupan*
Asupan video cewek-cewek.
Aliases: -
Usage: *${prefix}asupan*
_Index of [6]_
`
}
Expand Down
20 changes: 17 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"fs-extra": "^9.0.1",
"mathjs": "^8.1.0",
"moment-timezone": "^0.5.31",
"ms": "^2.1.3",
"needle": "^2.5.2",
"nekos.life": "^2.0.7",
"nhentai-api": "^3.0.2",
Expand Down

0 comments on commit 7fafffa

Please sign in to comment.