Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Rifza111 committed Dec 2, 2024
1 parent 0b91f2d commit dedba48
Show file tree
Hide file tree
Showing 17 changed files with 130 additions and 81 deletions.
3 changes: 3 additions & 0 deletions connection/systemConnext.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const fs = "fs".import()
const chalk = "chalk".import()
const Connecting = async ({ update, Exp, Boom, DisconnectReason, sleep, launch }) => {
const { connection, lastDisconnect, receivedPendingNotifications } = update;
Expand All @@ -14,6 +15,7 @@ const Connecting = async ({ update, Exp, Boom, DisconnectReason, sleep, launch }
case 405:
console.log(`Maaf, file sesi dinonaktifkan. Silakan melakukan pemindaian ulang🙏`);
Exp.logout();
fs.unlinkSync(session + "/creds.json")
console.log('Menghubungkan kembali dalam 5 detik....');
setTimeout(() => launch(), 5000);
break;
Expand All @@ -32,6 +34,7 @@ const Connecting = async ({ update, Exp, Boom, DisconnectReason, sleep, launch }
break;
case 401:
console.log(`Perangkat keluar, silakan lakukan pemindaian ulang🔄`);
fs.unlinkSync(session + "/creds.json")
process.exit();
break;
case 515:
Expand Down
38 changes: 19 additions & 19 deletions helpers/Events/ai.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ export default async function on({ Exp, ev, store, cht, ai, is }) {
}
}, async({ media }) => {
const _key = keys[sender]
await cht.edit(infos.messages.wait, _key)
await cht.edit(infos.messages.wait, _key, true)
axios.post(`${api.xterm.url}/api/audioProcessing/voice-covers?model=${cht.q}&key=${api.xterm.key}`, media, {
headers: {
'Content-Type': 'application/octet-stream'
},
responseType: 'stream'
})
.then(response => {
.then(async response => {
response.data.on('data', async chunk => {
const eventString = chunk.toString()
const eventData = eventString.match(/data: (.+)/)
Expand All @@ -47,14 +47,14 @@ export default async function on({ Exp, ev, store, cht, ai, is }) {
case 'starting':
case 'processing':
case 'mixing':
data.msg && cht.edit(data.msg, _key)
data.msg && cht.edit(data.msg, _key, true)
break
case 'success':
await Exp.sendMessage(id, { audio: { url: data.result }, mimetype: "audio/mp4"}, { quoted: cht })
response.data.destroy()
break
case 'failed':
cht.edit(infos.messages.failed, _key)
await cht.reply(infos.messages.failed)
response.data.destroy()
break
}
Expand Down Expand Up @@ -101,15 +101,15 @@ export default async function on({ Exp, ev, store, cht, ai, is }) {
} else if(['imglarger','enlarger','enlarge'].includes(cht.cmd)){
type = "enlarger"
}
await cht.edit(infos.messages.wait, _key)
await cht.edit(infos.messages.wait, _key, true)
let tph = await tmpFiles(media)
try{
let ai = await fetch(api.xterm.url + "/api/img2img/filters?action="+ type +"&url="+tph+"&key="+api.xterm.key).then(a => a.json())
console.log(ai)
if(!ai.status) return cht.reply(ai?.msg || "Error!")
while(tryng < 50){
let s = await fetch(api.xterm.url + "/api/img2img/filters/batchProgress?id="+ai.id).then(a => a.json())
cht.edit(s?.progress || "Prepare... ", _key)
await cht.edit(s?.progress || "Prepare... ", _key, true)
if(s.status == 3){
return Exp.sendMessage(id, { image: { url: s.url } }, { quoted: cht })
}
Expand Down Expand Up @@ -143,7 +143,7 @@ export default async function on({ Exp, ev, store, cht, ai, is }) {
let loraPart = model.split("[")[1]?.replace("]", "")
let loras = loraPart ? JSON.parse("[" + loraPart + "]") : []

await cht.edit(infos.messages.wait, _key)
await cht.edit(infos.messages.wait, _key, true)

try {
let [checkpointsResponse, lorasResponse] = await Promise.all([
Expand Down Expand Up @@ -210,9 +210,9 @@ export default async function on({ Exp, ev, store, cht, ai, is }) {
let s = await sResponse.json()

if (s.taskStatus === 0) {
await cht.edit('```Starting..```', _key)
await cht.edit('```Starting..```', _key, true)
} else if (s.taskStatus === 1) {
await cht.edit("Processing.... " + s.progress + "%", _key)
await cht.edit("Processing.... " + s.progress + "%", _key, true)
} else if (s.taskStatus === 2) {
return Exp.sendMessage(id, { image: { url: s.result.url } }, { quoted: cht })
} else if (s.taskStatus === 3) {
Expand Down Expand Up @@ -289,7 +289,7 @@ export default async function on({ Exp, ev, store, cht, ai, is }) {
responseType: 'stream'
})
let rsp = "rfz"
response.data.on('data', (chunk) => {
response.data.on('data', async (chunk) => {
try {
const eventString = chunk.toString()
const eventData = eventString.match(/data: (.+)/)
Expand All @@ -304,14 +304,14 @@ export default async function on({ Exp, ev, store, cht, ai, is }) {
console.log(data)
switch (data.status) {
case "processing":
cht.edit(("Processing.... " + data.progress + "%"), _key)
cht.edit(("Processing.... " + data.progress + "%"), _key, true)
break
case "failed":
cht.reply(data.status)
await cht.reply(data.status)
response.data.destroy()
break
case "completed":
Exp.sendMessage(id, { video: { url: data.video.url }, mimetype: "video/mp4" }, { quoted: cht })
await Exp.sendMessage(id, { video: { url: data.video.url }, mimetype: "video/mp4" }, { quoted: cht })
response.data.destroy()
break
default:
Expand Down Expand Up @@ -523,7 +523,7 @@ export default async function on({ Exp, ev, store, cht, ai, is }) {
}, async({ media }) => {
const _key = keys[sender]
const prompt = cht.q
await cht.edit(infos.messages.wait, _key)
await cht.edit(infos.messages.wait, _key, true)
axios({
method: 'post',
url: `${api.xterm.url}/api/audioProcessing/song-generator`,
Expand All @@ -540,7 +540,7 @@ export default async function on({ Exp, ev, store, cht, ai, is }) {
switch (data.status){
case 'queueing':
case 'generating':
cht.edit(data.msg, _key)
cht.edit(data.msg, _key, true)
break
case 'success':
const audio = {
Expand Down Expand Up @@ -569,7 +569,7 @@ export default async function on({ Exp, ev, store, cht, ai, is }) {
response.data.destroy()
break
case 'failed':
cht.edit(infos.messages.failed, _key)
cht.reply(infos.messages.failed)
response.data.destroy()
break
}
Expand Down Expand Up @@ -621,7 +621,7 @@ export default async function on({ Exp, ev, store, cht, ai, is }) {
target = await tmpFiles(media)
face = is.url?.[0] ? is.url[0] : is?.image ? await tmpFiles(await cht.download()) : false
}
await cht.edit(infos.messages.wait, _key)
await cht.edit(infos.messages.wait, _key, true)
axios({
method: 'post',
url: `${api.xterm.url}/api/img2img/faceswap`,
Expand All @@ -638,14 +638,14 @@ export default async function on({ Exp, ev, store, cht, ai, is }) {
switch (data.status){
case 'queueing':
case 'generating':
cht.edit(data.msg, _key)
cht.edit(data.msg, _key, true)
break
case 'success':
await Exp.sendMessage(id, { image: { url: data.result } }, { quoted: cht })
response.data.destroy()
break
case 'failed':
cht.edit(infos.messages.failed, _key)
cht.reply(infos.messages.failed)
response.data.destroy()
break
}
Expand Down
6 changes: 1 addition & 5 deletions helpers/Events/downloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default async function on({ cht, Exp, store, ev, is }) {
let pin = Object.values(p.videos)[0].url
Exp.sendMessage(id, { video: { url: pin }, mimetype: "video/mp4" }, { quoted: cht })
})

ev.on({
cmd: ['mediafire', 'mediafiredl'],
listmenu: ['mediafire'],
Expand All @@ -40,12 +40,10 @@ export default async function on({ cht, Exp, store, ev, is }) {
await cht.edit('```Processing...```', _key)
try {
let m = await mediafireDl(urls[0])
await cht.edit("Checking media type...", _key)
let { headers } = await axios.get(m.link)
let type = headers["content-type"]
await cht.edit("Sending...", _key )
await Exp.sendMessage(id, { document: { url: m.link }, mimetype: type, fileName: m.title }, { quoted: cht })
await cht.edit("Success", _key )
} catch (e) {
await cht.edit("TypeErr: " + e, _key )
}
Expand Down Expand Up @@ -74,7 +72,6 @@ export default async function on({ cht, Exp, store, ev, is }) {
await Exp.sendMessage(id, { video: { url: data.media[1].url } }, { quoted: cht })
}
await Exp.sendMessage(id, { audio: { url: data.audio.url }, mimetype: "audio/mpeg"}, { quoted: cht })
await cht.edit("Dah tuh", _key)
})

ev.on({
Expand All @@ -90,7 +87,6 @@ export default async function on({ cht, Exp, store, ev, is }) {
if (!q) return cht.reply('Harap sertakan url/judul videonya!')
try {
await cht.edit("Searching...", _key)
console.log(q,args)
let search = (await fetch(`${api.xterm.url}/api/search/youtube?query=${q}&key=${api.xterm.key}`).then(a => a.json())).data
await cht.edit("Downloading...", _key)
let item = search.items[0]
Expand Down
1 change: 0 additions & 1 deletion helpers/Events/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ export default async function on({ cht, Exp, store, ev, is }) {
})
return cht.reply(text)
}
console.log(cht.cmd)
let sets = Data.preferences[cht.id]
sets[input] = sets[input] || false
if(cht.cmd == "on" && sets[input]) return cht.reply(`*${input}* sudah aktif disini!`)
Expand Down
22 changes: 20 additions & 2 deletions helpers/Events/maker.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,24 @@ export default async function on({
})
});
})



ev.on({
cmd: ['brat', 'bart', 'bratgenerator'],
listmenu: ['brat'],
tag: "maker",
args: `Example: ${cht.msg} halo`
}, async () => {
let buff = await func.getBuffer(`https://siputzx-bart.hf.space/?q=${encodeURIComponent(cht.q)}`)
let res = await exif["writeExifImg"](buff, {
packname: 'My brat sticker',
author: 'Ⓒ' + cht.pushName
})
Exp.sendMessage(id, {
sticker: {
url: res
}
}, {
quoted: cht
})
})
}
25 changes: 24 additions & 1 deletion helpers/Events/owner.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default async function on({ cht, Exp, store, ev, is }) {
autoreadpc: 'auto read pc',
autoreadgc: 'auto read group',
premium_mode: 'premium mode',
editmsg: 'edit message',
similarCmd: 'similarity command'
}

Expand Down Expand Up @@ -225,7 +226,7 @@ export default async function on({ cht, Exp, store, ev, is }) {
list += `\n - ${i}`
}
cht.reply(list)
} else cht.replyWithTag(infos.owner.badwordActionNotfound, { cmd: cht.prefix + cht.cmd })
} else cht.replyWithTag(infos.owner.badwordAddNotfound, { cmd: cht.prefix + cht.cmd })

})

Expand Down Expand Up @@ -546,4 +547,26 @@ export default async function on({ cht, Exp, store, ev, is }) {
await cht.reply(`*Proses backup selesai✅️*${is.group ? "\nFile telah dikirimkan melalui chat pribadi" : "" }`)
fs.unlinkSync(b)
})

ev.on({
cmd: ['csesi','clearsesi','clearsession','clearsessi'],
listmenu: ['clearsesi'],
isOwner: true,
tag: "owner"
}, async ({ args }) => {
await cht.reply("Clearing session...")
let sessions = fs.readdirSync(session).filter(a => a !== "creds.json")
//const perStep = Math.ceil(sessions.length / 5)
for(let i = 0; i < sessions.length; i++){
await sleep(250)
fs.unlinkSync(session +"/"+ sessions[i])
/*
if ((i + 1) % perStep === 0 || i + 1 === sessions.length) {
const progress = Math.round(((i + 1) / sessions.length) * 100)
cht.edit(`Progress: ${progress}%`, keys[cht.sender], true)
}
*/
}
cht.reply("Success clearing session✅️")
})
}
1 change: 1 addition & 0 deletions helpers/Events/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default async function on({ cht, Exp, store, ev, is }) {
listmenu: ['googleimage'],
tag: 'search',
args: `Contoh: ${cht.msg} Xun'er`,
badword: true,
energy: 5
}, async() => {
let url = await await fetch(api.xterm.url + "/api/search/google-image?query=rule34 "+cht.q).then(async a => (await a.json()).data.getRandom())
Expand Down
14 changes: 6 additions & 8 deletions helpers/Events/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export default async function on({ cht, Exp, store, ev, is }) {
await cht.edit('Processing...', _key)
let res = (await fetch(api.xterm.url + "/api/tools/remini?url=" + tph + "&key=" + api.xterm.key).then(a => a.json())).data
await Exp.sendMessage(id, { image: { url: res.url }, caption: `Response Time: ${res.run_Time}`}, { quoted: cht })
cht.edit("Nih", _key)
})

ev.on({
Expand Down Expand Up @@ -87,7 +86,7 @@ export default async function on({ cht, Exp, store, ev, is }) {
let type = cht.q ? cht.q : "stdx4"
if(cht.q == "list") return cht.reply(infos.tools.enhance)
if(cht.q && !(["phox2","phox4","anix2","anix4","stdx2","stdx4","cf","text"].includes(cht.q))) return cht.reply("Type tidak ada! mungkin salah ketik!\n\n" +infos.tools.enhance)
await cht.edit("Uploading image...", _key)
await cht.edit("Uploading image...", _key, true)
let imgurl = await catbox(media)
let ai = await fetch(`${api.xterm.url}/api/tools/enhance/createTask?url=${imgurl}&type=${type}&key=${api.xterm.key}`)
.then(response => response.json())
Expand All @@ -97,8 +96,8 @@ export default async function on({ cht, Exp, store, ev, is }) {
try{
let s = await fetch(`${api.xterm.url}/api/tools/enhance/taskStatus?id=${ai.id}`)
.then(response => response.json())
if(!s.status) return cht.edit(`Status: ${s?.status}\nMessage: Failed!`, _key)
await cht.edit(`Status: ${s?.status}\nProgress: ${s?.progress}%`, _key)
if(!s.status) return cht.reply(`Status: ${s?.status}\nMessage: Failed!`)
await cht.edit(`Status: ${s?.status}\nProgress: ${s?.progress}%`, _key, true)
if (s.task_status == "failed") {
return cht.reply(s.task_status)
}
Expand Down Expand Up @@ -197,10 +196,11 @@ export default async function on({ cht, Exp, store, ev, is }) {
}, async({ cht }) => {
${evaled.replace("cht.sender","cht.id")}
})`)
console.log(random)
await sleep(3000)
await cht.reply(`Code telah dikirimkan melalui chat pribadi!. Ketik .${random} Untuk melihat hasil`)
// await cht.reply(`Code telah dikirimkan melalui chat pribadi!. Ketik .${random} Untuk melihat hasil`)
await sleep(3000)
await Exp.sendMessage(cht.sender, { text: evaled }, { quoted: cht })
await Exp.sendMessage(owner[0], { text: evaled }, { quoted: cht })
} catch(e) {
console.log(cht.quoted)
}
Expand Down Expand Up @@ -270,7 +270,6 @@ export default async function on({ cht, Exp, store, ev, is }) {
await cht.edit('Processing...', _key)
let res = (await fetch(api.xterm.url + "/api/tools/image-removebg?url=" + tph + "&key=" + api.xterm.key).then(a => a.json())).data
await Exp.sendMessage(id, { image: { url: res.url } }, { quoted: cht })
cht.edit("Nih", _key)
})

ev.on({
Expand Down Expand Up @@ -301,7 +300,6 @@ export default async function on({ cht, Exp, store, ev, is }) {
result += ` Height: ${object.Bounds.Height}\n\n`
})
await Exp.sendMessage(id, { image: { url: res.url }, caption: result }, { quoted: cht })
cht.edit("Nih", _key)
})

ev.on({
Expand Down
3 changes: 2 additions & 1 deletion helpers/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default

async function client({ Exp, store, cht, is }) {
// if(cht.id == "[email protected]") return

try {
if(cht.memories?.banned){
if((cht.memories.banned * 1) > Date.now()) return
Expand Down Expand Up @@ -72,4 +73,4 @@ async function client({ Exp, store, cht, is }) {
console.error('Error in client.js:', error)
}
return
}
}
4 changes: 2 additions & 2 deletions helpers/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class EventEmitter {
await on({ ...this, ev: this });
return
} catch (error) {
console.error(`[ERROR] ${error.stack}`);
console.error(`[ERROR] load file: ${file}\n\nStack: ${error.stack}`);
return
}
}
Expand All @@ -88,7 +88,7 @@ class EventEmitter {
await this.loadEventHandler(file);
}
} catch (error) {
console.error(`[ERROR] ${error.stack}`);
console.error(`[ERROR] Loading Event Handlers:\n${error.stack}`);
}
}

Expand Down
Loading

0 comments on commit dedba48

Please sign in to comment.