-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
303 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"version":2,"languages":{"nodejs-npm":{"specfileHash":"86ec984341153df1db081c21ceb4d1f4","lockfileHash":"e8325405eaf65ff7657db50a6d790d07"}}} | ||
{"version":2,"languages":{"nodejs-npm":{"specfileHash":"850f2380345327571d06057ea5dbbc49","lockfileHash":"e8325405eaf65ff7657db50a6d790d07"}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
[{"key":"datr","value":"yyZCZfAoCWWe-b8hsGEKMHVb","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T11:46:02.066Z","lastAccessed":"2024-01-22T11:46:07.232Z"},{"key":"sb","value":"yyZCZUc_mSDokjud8RpVB1Sa","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T11:46:02.461Z","lastAccessed":"2024-01-22T11:46:07.232Z"},{"key":"vpd","value":"v1%3B830x424x2.294114351272583","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T11:46:02.592Z","lastAccessed":"2024-01-22T11:46:07.232Z"},{"key":"fr","value":"00TLeUURqctZjAWTx.AWUYXkn6ibfG8bmGfEgJUxYGCiQ.BlQibL.L7.AAA.0.0.BlmiMf.AWU5Vv8qfrE","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T11:46:02.619Z","lastAccessed":"2024-01-22T11:46:07.232Z"},{"key":"c_user","value":"61552579757417","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T11:46:02.621Z","lastAccessed":"2024-01-22T11:46:07.232Z"},{"key":"xs","value":"24%3ACNNTDukyHDpqtg%3A2%3A1704600351%3A-1%3A10199","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T11:46:02.624Z","lastAccessed":"2024-01-22T11:46:07.232Z"},{"key":"fbl_ci","value":"848594360078994","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T11:46:02.627Z","lastAccessed":"2024-01-22T11:46:07.232Z"},{"key":"locale","value":"en_US","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T11:46:02.631Z","lastAccessed":"2024-01-22T11:46:07.232Z"},{"key":"fbl_st","value":"101621049%3BT%3A28430599","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T11:46:02.634Z","lastAccessed":"2024-01-22T11:46:07.232Z"},{"key":"fbl_cs","value":"AhB5itBnFUWY08aGuIf5C59OGHhQN3JVdkgzRFVzaGhDcnhMbkMrNjdSMw","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T11:46:02.799Z","lastAccessed":"2024-01-22T11:46:07.232Z"},{"key":"wl_cbv","value":"v2%3Bclient_version%3A2396%3Btimestamp%3A1705835972","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T11:46:02.967Z","lastAccessed":"2024-01-22T11:46:07.232Z"},{"key":"m_page_voice","value":"61552579757417","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T11:46:02.968Z","lastAccessed":"2024-01-22T11:46:07.232Z"},{"key":"datr","value":"yyZCZfAoCWWe-b8hsGEKMHVb","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T11:46:02.066Z","lastAccessed":"2024-01-22T11:46:07.232Z"},{"key":"sb","value":"yyZCZUc_mSDokjud8RpVB1Sa","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T11:46:02.461Z","lastAccessed":"2024-01-22T11:46:07.232Z"},{"key":"vpd","value":"v1%3B830x424x2.294114351272583","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T11:46:02.592Z","lastAccessed":"2024-01-22T11:46:07.232Z"},{"key":"fr","value":"00TLeUURqctZjAWTx.AWUYXkn6ibfG8bmGfEgJUxYGCiQ.BlQibL.L7.AAA.0.0.BlmiMf.AWU5Vv8qfrE","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T11:46:02.619Z","lastAccessed":"2024-01-22T11:46:07.232Z"},{"key":"c_user","value":"61552579757417","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T11:46:02.621Z","lastAccessed":"2024-01-22T11:46:07.232Z"},{"key":"xs","value":"24%3ACNNTDukyHDpqtg%3A2%3A1704600351%3A-1%3A10199","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T11:46:02.624Z","lastAccessed":"2024-01-22T11:46:07.232Z"},{"key":"fbl_ci","value":"848594360078994","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T11:46:02.627Z","lastAccessed":"2024-01-22T11:46:07.232Z"},{"key":"locale","value":"en_US","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T11:46:02.631Z","lastAccessed":"2024-01-22T11:46:07.232Z"},{"key":"fbl_st","value":"101621049%3BT%3A28430599","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T11:46:02.634Z","lastAccessed":"2024-01-22T11:46:07.232Z"},{"key":"fbl_cs","value":"AhB5itBnFUWY08aGuIf5C59OGHhQN3JVdkgzRFVzaGhDcnhMbkMrNjdSMw","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T11:46:02.799Z","lastAccessed":"2024-01-22T11:46:07.232Z"},{"key":"wl_cbv","value":"v2%3Bclient_version%3A2396%3Btimestamp%3A1705835972","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T11:46:02.967Z","lastAccessed":"2024-01-22T11:46:07.232Z"},{"key":"m_page_voice","value":"61552579757417","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T11:46:02.968Z","lastAccessed":"2024-01-22T11:46:07.232Z"},{"key":"m_page_voice","value":"61552579757417","domain":"messenger.com","path":"/","hostOnly":false,"creation":"2024-01-22T11:46:03.025Z","lastAccessed":"2024-01-22T11:46:07.252Z"}] | ||
[{"key":"datr","value":"yyZCZfAoCWWe-b8hsGEKMHVb","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T12:38:00.856Z","lastAccessed":"2024-01-22T12:38:04.278Z"},{"key":"sb","value":"yyZCZUc_mSDokjud8RpVB1Sa","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T12:38:01.042Z","lastAccessed":"2024-01-22T12:38:04.278Z"},{"key":"vpd","value":"v1%3B830x424x2.294114351272583","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T12:38:01.063Z","lastAccessed":"2024-01-22T12:38:04.278Z"},{"key":"fr","value":"00TLeUURqctZjAWTx.AWUYXkn6ibfG8bmGfEgJUxYGCiQ.BlQibL.L7.AAA.0.0.BlmiMf.AWU5Vv8qfrE","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T12:38:01.066Z","lastAccessed":"2024-01-22T12:38:04.278Z"},{"key":"c_user","value":"61552579757417","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T12:38:01.068Z","lastAccessed":"2024-01-22T12:38:04.278Z"},{"key":"xs","value":"24%3ACNNTDukyHDpqtg%3A2%3A1704600351%3A-1%3A10199","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T12:38:01.071Z","lastAccessed":"2024-01-22T12:38:04.278Z"},{"key":"fbl_ci","value":"848594360078994","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T12:38:01.073Z","lastAccessed":"2024-01-22T12:38:04.278Z"},{"key":"locale","value":"en_US","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T12:38:01.143Z","lastAccessed":"2024-01-22T12:38:04.278Z"},{"key":"fbl_st","value":"101621049%3BT%3A28430599","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T12:38:01.145Z","lastAccessed":"2024-01-22T12:38:04.278Z"},{"key":"fbl_cs","value":"AhB5itBnFUWY08aGuIf5C59OGHhQN3JVdkgzRFVzaGhDcnhMbkMrNjdSMw","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T12:38:01.148Z","lastAccessed":"2024-01-22T12:38:04.278Z"},{"key":"wl_cbv","value":"v2%3Bclient_version%3A2396%3Btimestamp%3A1705835972","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T12:38:01.151Z","lastAccessed":"2024-01-22T12:38:04.278Z"},{"key":"m_page_voice","value":"61552579757417","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T12:38:01.154Z","lastAccessed":"2024-01-22T12:38:04.278Z"},{"key":"datr","value":"yyZCZfAoCWWe-b8hsGEKMHVb","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T12:38:00.856Z","lastAccessed":"2024-01-22T12:38:04.278Z"},{"key":"sb","value":"yyZCZUc_mSDokjud8RpVB1Sa","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T12:38:01.042Z","lastAccessed":"2024-01-22T12:38:04.278Z"},{"key":"vpd","value":"v1%3B830x424x2.294114351272583","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T12:38:01.063Z","lastAccessed":"2024-01-22T12:38:04.278Z"},{"key":"fr","value":"00TLeUURqctZjAWTx.AWUYXkn6ibfG8bmGfEgJUxYGCiQ.BlQibL.L7.AAA.0.0.BlmiMf.AWU5Vv8qfrE","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T12:38:01.066Z","lastAccessed":"2024-01-22T12:38:04.278Z"},{"key":"c_user","value":"61552579757417","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T12:38:01.068Z","lastAccessed":"2024-01-22T12:38:04.278Z"},{"key":"xs","value":"24%3ACNNTDukyHDpqtg%3A2%3A1704600351%3A-1%3A10199","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T12:38:01.071Z","lastAccessed":"2024-01-22T12:38:04.278Z"},{"key":"fbl_ci","value":"848594360078994","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T12:38:01.073Z","lastAccessed":"2024-01-22T12:38:04.278Z"},{"key":"locale","value":"en_US","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T12:38:01.143Z","lastAccessed":"2024-01-22T12:38:04.278Z"},{"key":"fbl_st","value":"101621049%3BT%3A28430599","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T12:38:01.145Z","lastAccessed":"2024-01-22T12:38:04.278Z"},{"key":"fbl_cs","value":"AhB5itBnFUWY08aGuIf5C59OGHhQN3JVdkgzRFVzaGhDcnhMbkMrNjdSMw","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T12:38:01.148Z","lastAccessed":"2024-01-22T12:38:04.278Z"},{"key":"wl_cbv","value":"v2%3Bclient_version%3A2396%3Btimestamp%3A1705835972","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T12:38:01.151Z","lastAccessed":"2024-01-22T12:38:04.278Z"},{"key":"m_page_voice","value":"61552579757417","domain":"facebook.com","path":"/","hostOnly":false,"creation":"2024-01-22T12:38:01.154Z","lastAccessed":"2024-01-22T12:38:04.278Z"},{"key":"m_page_voice","value":"61552579757417","domain":"messenger.com","path":"/","hostOnly":false,"creation":"2024-01-22T12:38:01.292Z","lastAccessed":"2024-01-22T12:38:04.279Z"}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
const { execSync } = require('child_process'); | ||
const axios = require('axios'); | ||
const fs = require('fs'); | ||
|
||
async function checkForUpdates() { | ||
try { | ||
// Fetch latest release information from GitHub | ||
const { data: releases } = await axios.get('https://api.github.com/repos/ruingl/Yue/releases'); | ||
|
||
// Extract the latest release tag | ||
const latestRelease = releases[0]; | ||
const latestVersion = latestRelease.tag_name; | ||
|
||
// Read the current version from version.json | ||
const currentVersion = JSON.parse(fs.readFileSync('version.json', 'utf8')).version; | ||
|
||
// Compare versions | ||
if (compareVersions(latestVersion, currentVersion) > 0) { | ||
// Log the update | ||
console.log(`Update available: v${currentVersion} -> v${latestVersion}`); | ||
|
||
// Perform the update logic (git pull) | ||
execSync('git pull origin ' + latestVersion, { stdio: 'inherit' }); | ||
|
||
console.log('Update complete.'); | ||
} else { | ||
console.log('No updates available.'); | ||
} | ||
} catch (error) { | ||
console.error('Error checking for updates:', error); | ||
} | ||
} | ||
|
||
// Helper function to compare version strings | ||
function compareVersions(a, b) { | ||
const partsA = a.split('.').map(Number); | ||
const partsB = b.split('.').map(Number); | ||
|
||
for (let i = 0; i < Math.max(partsA.length, partsB.length); i++) { | ||
const partA = partsA[i] || 0; | ||
const partB = partsB[i] || 0; | ||
|
||
if (partA !== partB) { | ||
return partA - partB; | ||
} | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
// Call the function to check for updates | ||
checkForUpdates(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"version": "1.0.2" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const login = require("fca-unofficial"); | ||
const axios = require("axios"); | ||
const express = require("express"); | ||
const chalk = require("chalk"); | ||
const gradient = require("gradient-string"); | ||
|
||
const app = express(); | ||
const commandPath = path.join(__dirname, "scripts", "commands"); | ||
const PREFIX = ":" | ||
const PORT = process.env.PORT || 3000; | ||
|
||
const commands = {}; | ||
|
||
// Load the version from version.json | ||
const versionPath = path.join(__dirname, "version.json"); | ||
let version = loadVersion(); | ||
|
||
function loadConfig() { | ||
try { | ||
return JSON.parse(fs.readFileSync(configPath, "utf8")); | ||
} catch (error) { | ||
console.error("Error loading config:", error); | ||
return null; | ||
} | ||
} | ||
|
||
function loadAppState() { | ||
try { | ||
const appStatePath = path.join(__dirname, "appstate.json"); | ||
return JSON.parse(fs.readFileSync(appStatePath, "utf8")); | ||
} catch (error) { | ||
console.error("Error loading app state:", error); | ||
return null; | ||
} | ||
} | ||
|
||
function saveConfig() { | ||
fs.writeFileSync(configPath, JSON.stringify(config, null, 2)); | ||
} | ||
|
||
function loadVersion() { | ||
try { | ||
return JSON.parse(fs.readFileSync(versionPath, "utf8")).version; | ||
} catch (error) { | ||
console.error("Error loading version:", error); | ||
return null; | ||
} | ||
} | ||
|
||
function saveVersion() { | ||
fs.writeFileSync(versionPath, JSON.stringify({ version }, null, 2)); | ||
} | ||
|
||
function loadCommands() { | ||
const commandFiles = fs | ||
.readdirSync(commandPath) | ||
.filter((file) => file.endsWith(".js")); | ||
|
||
commandFiles.forEach((file) => { | ||
const startTime = new Date(); | ||
const commandName = path.basename(file, ".js"); | ||
commands[commandName] = require(path.join(commandPath, file)); | ||
const endTime = new Date(); | ||
|
||
// Loading commands logger | ||
const duration = endTime - startTime; | ||
const loadingLog = gradient.rainbow(`Loaded ${commandName}.js (${duration}ms)`); | ||
console.log(loadingLog); | ||
}); | ||
} | ||
|
||
function initializeBot() { | ||
login({ appState: loadAppState() }, (err, api) => { | ||
if (err) return console.error(err); | ||
|
||
// Get the app state and write it to 'appstate.json' | ||
fs.writeFileSync('appstate.json', JSON.stringify(api.getAppState())); | ||
|
||
api.listen((err, event) => { | ||
if (err) { | ||
console.error("Error occurred while processing event:", err); | ||
return; | ||
} | ||
|
||
// Liane: new functions added | ||
const react = (emoji) => { | ||
api.setMessageReaction(emoji, event.messageID, () => {}, true); | ||
}; | ||
|
||
const reply = (msg) => { | ||
api.sendMessage(msg, event.threadID, event.messageID); | ||
}; | ||
|
||
const add = (uid) => { | ||
api.addUserToGroup(uid, event.threadID); | ||
}; | ||
|
||
const kick = (uid) => { | ||
api.removeUserFromGroup(uid, event.threadID); | ||
}; | ||
|
||
const send = (msg) => { | ||
api.sendMessage(msg, event.threadID); | ||
}; | ||
|
||
const box = { | ||
react: react, | ||
reply: reply, | ||
add: add, | ||
kick: kick, | ||
send: send, | ||
}; | ||
|
||
try { | ||
if (event.body && event.body.toLowerCase() === "prefix") { | ||
api.sendMessage( | ||
`My prefix is: \`${PREFIX}\``, | ||
event.threadID, | ||
event.messageID, | ||
); | ||
} else if (event.body && event.body.toLowerCase().startsWith(PREFIX)) { | ||
const [command, ...args] = event.body | ||
.slice(PREFIX.length) | ||
.trim() | ||
.split(" "); | ||
|
||
if (commands[command]) { | ||
commands[command].run({ api, event, args, box }); | ||
} else { | ||
api.sendMessage("Invalid command.", event.threadID, event.messageID); | ||
} | ||
} | ||
} catch (error) { | ||
console.error("Error occurred while executing command:", error); | ||
// Handle the error or log it to your preferred logging service | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
function updateCheck() { | ||
axios.get("https://api.github.com/repos/ruingl/Yue/releases/latest") | ||
.then((response) => { | ||
const latestVersion = response.data.tag_name; | ||
if (latestVersion && latestVersion !== version) { | ||
console.log(gradient.retro(`⟩ New version found! Update to ${latestVersion} using npm run update`)); | ||
} | ||
}) | ||
.catch((error) => { | ||
console.error("Error checking for updates:", error); | ||
}); | ||
} | ||
|
||
app.get("/", (req, res) => { | ||
res.send("Website in construction 🏗️"); | ||
}); | ||
|
||
app.listen(PORT, async () => { | ||
console.log(gradient.retro(`⟩ yuev1 - (${version}) 🙀`)); | ||
|
||
// Additional logging for 'by ruingl' | ||
console.log(gradient.retro("⟩ by ruingl ♥️")); | ||
|
||
// Check for updates | ||
await updateCheck(); | ||
|
||
// ... (rest of your logging) | ||
console.log(""); | ||
|
||
// Log the loaded commands | ||
console.log(gradient.rainbow("Loaded Commands:")); | ||
loadCommands(); | ||
|
||
// Additional console.log(""); for separation | ||
console.log(""); | ||
|
||
// Initialize the bot | ||
initializeBot(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters