Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
rifnd committed Nov 20, 2024
1 parent dc7942b commit 9eac245
Show file tree
Hide file tree
Showing 19 changed files with 417 additions and 228 deletions.
68 changes: 18 additions & 50 deletions handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ module.exports = {
if (!['unbanned.js'].includes(name.split('/').pop()) && groupSet && groupSet.isBanned) return // Except conn
if (!['unbanned.js'].includes(name.split('/').pop()) && users && users.banned) return
}
/** command disabled */
if (setting.error.includes(command)) return m.reply(Func.texted('bold', `🚩 Command _${usedPrefix + command}_ disabled.`))
/** plugin disabled */
if (plugin.disabled || setting.pluginDisable.includes(name.split('/').pop())) return

if (m.isBaileys || m.chat.endsWith('broadcast') || /edit/.test(m.mtype)) continue
if (setting.self && !isOwner && !m.fromMe) continue
Expand All @@ -241,18 +245,7 @@ module.exports = {
continue
}
if (plugin.premium && !isPrems) { // Premium
const soad = [{
name: 'quick_reply',
buttonParamsJson: JSON.stringify({
display_text: 'Contact Owner',
id: `${usedPrefix}owner`
})
}]
conn.sendIAMessage(m.chat, soad, m, {
content: global.status.premium,
footer: global.footer,
})
//m.reply(global.status.premium)
m.reply(global.status.premium)
continue
}
if (plugin.group && !m.isGroup) { // Group Only
Expand All @@ -275,12 +268,12 @@ module.exports = {
}
if (plugin.game && setting.game == false) {
// game mode
m.reply(status.game)
m.reply(global.status.game)
continue
}
if (plugin.rpg && setting.rpg == false) {
// RPG mode
m.reply(status.rpg)
m.reply(global.status.rpg)
continue
}

Expand All @@ -289,19 +282,8 @@ module.exports = {
if (xp > 200) m.reply('Ngecit -_-') // Hehehe
else m.exp += xp
if (!isPrems && plugin.limit && users.limit < plugin.limit * 1) {
const soad = [{
name: 'quick_reply',
buttonParamsJson: JSON.stringify({
display_text: 'Buy',
id: `${usedPrefix}buy 1`
})
}]
conn.sendIAMessage(m.chat, soad, m, {
content: `Your limit is exhausted, please purchase via *${usedPrefix}buy*`,
footer: global.footer,
})
//conn.reply(m.chat, `Your limit is exhausted, please purchase via *${usedPrefix}buy*`, m)
continue // Limit habis
conn.reply(m.chat, `Your limit is exhausted, please purchase via *${usedPrefix}buy*`, m)
continue
}
if (plugin.level > users.level) {
conn.reply(m.chat, `level ${plugin.level} is required to use conn command. Your level ${users.level}`, m)
Expand Down Expand Up @@ -367,34 +349,20 @@ module.exports = {
let user, stats = db.data.stats
if (m) {
if (m.sender && (user = db.data.users[m.sender])) {
user.exp += m.exp
user.exp += m.exp;
user.limit -= m.limit * 1
}

let stat
let now = +new Date()
if (m.plugin) {
let now = + new Date
if (m.plugin in stats) {
stat = stats[m.plugin]
if (!isNumber(stat.total)) stat.total = 1
if (!isNumber(stat.success)) stat.success = m.error != null ? 0 : 1
if (!isNumber(stat.last)) stat.last = now
if (!isNumber(stat.lastSuccess)) stat.lastSuccess = m.error != null ? 0 : now
} else stat = stats[m.plugin] = {
total: 1,
success: m.error != null ? 0 : 1,
last: now,
lastSuccess: m.error != null ? 0 : now
}
stat.total += 1
stat.last = now
if (m.error == null) {
stat.success += 1
stat.lastSuccess = now
}
let pluginName = m.plugin.split('/').pop().replace('.js', '')
let stat = stats[pluginName] || { hitstat: 0, today: 0, lasthit: 0, sender: m.sender, lastDate: '' }
stat.hitstat += 1
stat.today += 1
stat.lasthit = now
stat.lastDate = new Date(now).toDateString()
stats[pluginName] = stat
}
}

try {
Print(m, conn)
} catch (e) {
Expand Down
4 changes: 4 additions & 0 deletions lib/system/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,8 @@ module.exports = (m, env) => {
if (!('noprefix' in setting)) setting.noprefix = false
if (!('onlyprefix' in setting)) setting.onlyprefix = '.'
if (!('hidden' in setting)) setting.hidden = []
if (!('error' in setting)) setting.error = []
if (!('pluginDisable' in setting)) setting.pluginDisable = []
if (!isNumber(setting.lastReset)) setting.lastReset = new Date * 1
if (!('sk_pack' in setting)) setting.sk_pack = 'Sticker by'
if (!('sk_author' in setting)) setting.sk_author = '© moon-bot'
Expand All @@ -639,6 +641,8 @@ module.exports = (m, env) => {
noprefix: false,
onlyprefix: '.',
hidden: [],
error: [],
pluginDisable: [],
lastReset: new Date * 1,
sk_pack: 'Sticker by',
sk_author: '© moon-bot',
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@
"dependencies": {
"@moonr/func": "^0.3.1",
"@whiskeysockets/baileys": "^6.7.9",
"@xncn/instagramdownloaderpro": "^0.0.7",
"awesome-phonenumber": "^5.6.0",
"bytes": "^3.1.2",
"cfonts": "^2.10.1",
"jimp": "^0.16.13",
"json-stable-stringify": "^1.0.2",
"node-cron": "^3.0.0",
"yt-search": "^2.10.4"
}
Expand Down
18 changes: 18 additions & 0 deletions plugins/admin/totag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
help: ['totag'],
use: 'reply chat',
tags: ['admin'],
command: /^(totag)$/i,
run: async (m, {
conn,
text,
participants,
Func
}) => {
let users = participants.map(u => u.id).filter(v => v !== conn.user.jid)
if (!m.quoted) return conn.reply(m.chat, Func.texted('bold', '🚩 Reply chat'), m)
conn.sendMessage(m.chat, { forward: m.quoted.fakeObj, mentions: users })
},
group: true,
admin: true
}
57 changes: 57 additions & 0 deletions plugins/converter/smeta.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
module.exports = {
help: ['smeta'],
use: 'query / reply media',
tags: ['converter'],
command: /^(smeta|stikermeta|stickermeta)$/i,
run: async (m, {
conn,
usedPrefix,
command,
text,
Func
}) => {
try {
if (!m.quoted) return conn.reply(m.chat, Func.texted('bold', `🚩 Reply sticker.`), m)
var stiker = false
let [packname, ...author] = text.split`|`
author = (author || []).join`|`
let q = m.quoted ? m.quoted : m
let mime = (q.msg || q).mimetype || ''
if (!/webp/.test(mime)) return conn.reply(m.chat, Func.texted('bold', `🚩 Reply to the sticker you want to make into a meta sticker.`), m)
let img = await q.download()
if (!img) return conn.reply(m.chat, global.status.wrong, m)
stiker = await addExif(img, packname || global.db.data.setting.sk_pack, author || global.db.data.setting.sk_author)
} catch (e) {
console.error(e)
if (Buffer.isBuffer(e)) stiker = e
} finally {
if (stiker) conn.sendMessage(m.chat, {
sticker: stiker
}, {
quoted: m
})
else return conn.reply(m.chat, Func.texted('bold', `🚩 Conversion failed.`), m)
}
},
limit: true
}

const { Image } = require('node-webpmux')
async function addExif(buffer, packname, author, categories = [''], extra = {}) {
const img = new Image()
const json = {
'sticker-pack-id': packname || 'Sticker By',
'sticker-pack-name': author || 'moon-bot',
'sticker-pack-publisher': global.creator || '@naando.io',
'emojis': categories,
'is-avatar-sticker': 1,
...extra
}
let exifAttr = Buffer.from([0x49, 0x49, 0x2A, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x41, 0x57, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00])
let jsonBuffer = Buffer.from(JSON.stringify(json), 'utf8')
let exif = Buffer.concat([exifAttr, jsonBuffer])
exif.writeUIntLE(jsonBuffer.length, 14, 4)
await img.load(buffer)
img.exif = exif
return await img.save(null)
}
2 changes: 1 addition & 1 deletion plugins/downloader/apk.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion plugins/downloader/apkmod.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion plugins/internet/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = {
})
if (!json.status) return m.reply(Func.jsonFormat(json))
if (json.data.length == 0) return m.reply(Func.texted('bold', '🚩 Package not found.'))
let teks = ` *N P M J S*\n\n`
let teks = ` *N P M J S*\n\n`
json.data.map((v, i) => {
teks += '*' + (i + 1) + '. ' + v.package.name + '*\n'
teks += ' ◦ *Version* : ' + v.package.version + '\n'
Expand Down
2 changes: 1 addition & 1 deletion plugins/internet/wallpaper.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = {
if (!json.status) return m.reply(Func.jsonFormat(json))
for (let i = 0; i < 3; i++) {
let ran = Math.floor(json.data.length * Math.random())
let cap = ` *W A L L P A P E R*\n\n`
let cap = ` *W A L L P A P E R*\n\n`
cap += ` ∘ *Size* : ` + json.data[ran].size + `\n`
cap += ` ∘ *Dimension* : ` + json.data[ran].size + `\n`
cap += ` ∘ *Keyword* : ` + json.data[ran].keywords + `\n\n`
Expand Down
Loading

0 comments on commit 9eac245

Please sign in to comment.