Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Commit

Permalink
Merge pull request #90 from mrepol742/master
Browse files Browse the repository at this point in the history
Initial PR
  • Loading branch information
mrepol742 authored Mar 10, 2024
2 parents 2e1af16 + cb6f551 commit 1d064f5
Show file tree
Hide file tree
Showing 18 changed files with 32 additions and 40 deletions.
49 changes: 21 additions & 28 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,18 @@ const normalize = /[\u0300-\u036f|\u00b4|\u0060|\u005e|\u007e]/g;
* CREATE SERVER
*/

/*
const LOG_PORT = 8081;
const WEB_PORT = 3000;
/*
http.createServer(getLogs()).listen(LOG_PORT, () => {
utils.logged("log_server_running http://0.0.0.0:" + LOG_PORT);
});
*/

http.createServer(getRoutes()).listen(WEB_PORT, () => {
utils.logged("log_server_running http://0.0.0.0:" + LOG_PORT);
});

/*
* LOAD WEB
*/
Expand Down Expand Up @@ -339,7 +343,6 @@ function redfox_fb(fca_state, login, cb) {
task(
function () {
fs.writeFileSync(__dirname + "/data/cookies/" + login + ".bin", getAppState(api), "utf8");
fb_stateD = utils.getCurrentTime();
utils.logged("cookie_state " + login + " synchronized");
},
Math.floor(1800000 * Math.random() + 1200000)
Expand Down Expand Up @@ -680,7 +683,7 @@ function redfox_fb(fca_state, login, cb) {

switch (event.type) {
case "message":
case "message_reply":
case "message_reply":
saveEvent(api, event);
ai(api, event);
break;
Expand Down Expand Up @@ -1645,7 +1648,6 @@ async function ai22(api, event, query, query2) {
if (Array.isArray(appsss)) {
let login = getUserIdFromAppState(appsss);
if (login) {
const login = appsss[item].value;
if (!settings[login]) {
settings[login] = settings.default;
}
Expand Down Expand Up @@ -1816,7 +1818,7 @@ async function ai22(api, event, query, query2) {
if (i == response.data.length) {
let ss2 = {
body: " ",
attachment: attach,
attachment: attch,
};
sendMessage(api, event, ss2);
unLink(filename);
Expand Down Expand Up @@ -1978,8 +1980,8 @@ async function ai(api, event) {
}

if (event.type == "message") {
let cmmdReply = ["balance --transfer", "add --instance", "unsend", "notify", "totext", "bgremove", "gphoto", "image --reverse", "run", "count", "count --vowels", "count --consonants", "wfind", "pin --add", "translate"];
if (cmmdReply.includes(query)) {
let cmmdReply = ["balance--transfer", "add--instance", "unsend", "notify", "totext", "bgremove", "gphoto", "image--reverse", "run", "count", "count--vowels", "count--consonants", "wfind", "pin--add", "translate"];
if (cmmdReply.includes(query) && testCommand(api, query2, query2.replace("--", " --"), event.senderID)) {
if (settings.shared["block_cmd"] && settings.shared["block_cmd"].includes(query)) {
return;
}
Expand Down Expand Up @@ -2026,7 +2028,7 @@ async function ai(api, event) {
} else {
let query = getDataFromQuery(data);
getResponseData("https://api.duckduckgo.com/?q=" + query + "&format=json&pretty=1").then((response) => {
if (response == null) return sendMessage(api, event, handleError({ stacktrace: err, cuid: api.getCurrentUserID(), e: event }));
if (response == null) return sendMessage(api, event, handleError({ stacktrace: response, cuid: api.getCurrentUserID(), e: event }));
if (response.Abstract == "") {
sendMessage(api, event, "No results found for `" + query + "`");
} else {
Expand Down Expand Up @@ -2471,7 +2473,7 @@ async function ai(api, event) {
} else if (testCommand(api, query, "left", event.senderID, "owner", true)) {
let login = api.getCurrentUserID();
api.removeUserFromGroup(login, event.threadID, (err) => {
for (let hreads in settingsThread) {
for (let threads in settingsThread) {
if (settingsThread[threads].lock && settingsThread[threads].lock == login) {
delete settingsThread[threads]["lock"];
}
Expand Down Expand Up @@ -3662,15 +3664,6 @@ async function ai(api, event) {
sendMessage(api, event, response.baybayin);
});
}
} else if (testCommand(api, query2, "doubleStruck", event.senderID)) {
if (isGoingToFast(api, event)) return;
let data = input.split(" ");
if (data.length < 2) {
sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: doubleStruck text" + "\n " + example[Math.floor(Math.random() * example.length)] + " doublestruck Hello World");
} else {
data.shift();
sendMessage(api, event, toDoublestruck(data.join(" ")));
}
} else if (testCommand(api, query2, "weather", event.senderID)) {
if (isGoingToFast(api, event)) return;
let data = input.split(" ");
Expand Down Expand Up @@ -3905,11 +3898,12 @@ async function ai(api, event) {
let repository = response.repository;
let author_email = response.author_email;
let message = {
body: "⦿ Name: " + name + " v" + version + "\n⦿ Author: " + author + "\n⦿ Email: " + author_email + "\n⦿ Updated on: " + last_published + "\n⦿ Repository: " + repository + "\n\n" + description,
body: "⦿ Name: " + name + " v" + version + "\n⦿ Author: " + author + "\n⦿ Email: " + author_email + "\n⦿ Updated on: " + last_published + "\n⦿ Repository: " + repository + "\n⦿ Downloads: " + downloads_this_year + "\n\n" + description,
};
if (repository != "None") {
message["url"] = repository;
}

sendMessage(api, event, message);
});
}
Expand Down Expand Up @@ -4310,7 +4304,7 @@ async function ai(api, event) {
let num = data.join(" ");
if (num > 1) {
sendMessage(api, event, "Opps! the limit is 1.");
} else if (num < -0) {
} else if (num < 0.1) {
sendMessage(api, event, "Opps! the minimum value 0.1");
} else {
settings.shared.temperature = num;
Expand Down Expand Up @@ -4583,8 +4577,8 @@ async function ai(api, event) {
.replace(/\s+/g, " ")
.replaceAll("__new_tab_here__", "\n")

.replace(/\%delete_span\%(.*?)\%\^delete_span\%/g, "")
.replace(/\%delete_span\%/g, "");
.replace(/%delete_span%(.*?)%\^delete_span%/g, "")
.replace(/%delete_span%/g, "");

construct += "\n\n" + formatMalRes(mal1("[itemprop=description]"), true).replace(/\s+/g, " ").replaceAll("__new_tab_here__", "\n");

Expand Down Expand Up @@ -4688,7 +4682,7 @@ async function ai(api, event) {
api.addUserToGroup(pref, event.threadID, (err) => {
if (err) {
if (err.error == 1545052) {
return sendMessage(api, event, data[id].firstName + " could not be added to the conversation. Please try again later.");
return sendMessage(api, event, pref + " could not be added to the conversation. Please try again later.");
}
return handleError({ stacktrace: err, cuid: api.getCurrentUserID(), e: event });
}
Expand Down Expand Up @@ -5291,7 +5285,7 @@ async function ai(api, event) {
api.getThreadInfo(event.threadID, (err, a) => {
if (err) sendMessage(api, event, handleError({ stacktrace: err, cuid: api.getCurrentUserID(), e: event }));

updateGroupData(gc, event.threadID);
updateGroupData(a, event.threadID);

let inf = "";
let usern = a.userInfo.length;
Expand Down Expand Up @@ -6077,7 +6071,6 @@ async function ai(api, event) {
fs.writeFileSync(__dirname + "/data/cookies/" + api.getCurrentUserID() + ".bin", getAppState(api), "utf8");
utils.logged("cookie_state synchronized");
sendMessage(api, event, "The AppState refreshed.");
fb_stateD = utils.getCurrentTime();
} else if (testCommand(api, query, "state--save", event.senderID, "owner", true)) {
saveState();
sendMessage(api, event, "The state have saved successfully.");
Expand All @@ -6091,7 +6084,7 @@ async function ai(api, event) {
} else if (testCommand(api, query, "setNickname--random", event.senderID, "user", true)) {
if (isGoingToFast(api, event)) return;
getResponseData("https://www.behindthename.com/api/random.json?usage=jap&key=me954624721").then((response) => {
if (response == null) return sendMessage(api, event, handleError({ stacktrace: err, cuid: api.getCurrentUserID(), e: event }));
if (response == null) return sendMessage(api, event, handleError({ stacktrace: response, cuid: api.getCurrentUserID(), e: event }));
api.setNickname(response.names[0] + " " + response.names[1], event.threadID, event.senderID, (err) => {
if (err) return sendMessage(api, event, handleError({ stacktrace: err, cuid: api.getCurrentUserID(), e: event }));
});
Expand Down Expand Up @@ -6494,7 +6487,7 @@ async function sendMessage(api, event, message, thread_id, message_id, bn, voice
message,
thread_id,
(err, messageInfo) => {
if (err) return sendMessageErr(api, event, thread_id, message_id, id, err);
if (err) return sendMessageErr(api, event, thread_id, message_id, event.senderID, err);
},
message_id
);
Expand Down
5 changes: 2 additions & 3 deletions src/redfox/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function getCurrentTime() {
}

function setProxy(url) {
if (typeof url == undefined)
if (!url)
return (request = bluebird.promisify(
require("request").defaults({
jar: true,
Expand Down Expand Up @@ -793,7 +793,6 @@ function getAdminTextMessageType(type) {
return "log:call_participant_joined";
case "pin_messages_v2":
return "log:pin_messages";
pin_messages;
case "unpin_messages_v2":
return "log:unpin_messages";
default:
Expand All @@ -806,7 +805,7 @@ function formatDeltaEvent(m) {
var logMessageData;
switch (m.class) {
default:
utils.logged(m.class);
logged(m.class);
break;
case "AdminTextMessage":
logMessageData = m.untypedData;
Expand Down
18 changes: 9 additions & 9 deletions src/welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ async function generateWelcomeGif(pictureFile, name, group, member) {
}

const callBack = async (ctx, width, height, totalFrames, currentFrame) => {
ctx.fillStyle = "#212121";
ctx.fillStyle = "#fff";
ctx.textAlign = "center";
ctx.font = 'bold 28px "Operator Mono Bold"';
ctx.font = 'bold 60px "Operator Mono"';
ctx.fillText(name, width * 0.5, height * 0.7);
ctx.font = '18px "Operator Mono"';
ctx.fillText(group, width * 0.5, height * 0.8);
ctx.font = '15px "Operator Mono"';
ctx.fillText(member, width * 0.5, height * 0.9);
ctx.font = '28px "Operator Mono"';
ctx.fillText(group, width * 0.5, height * 0.77);
ctx.font = '25px "Operator Mono"';
ctx.fillText(member, width * 0.5, height * 0.82);

x = width / 2;
y = height / 3;
radius = 50;
radius = 130;
ctx.save();
ctx.beginPath();
ctx.arc(x, y, radius, 0, 2 * Math.PI);

ctx.strokeStyle = "#212121";
ctx.strokeStyle = "#fff";
ctx.stroke();
ctx.clip();
let img = fs.readFileSync(pictureFile);
Expand All @@ -60,7 +60,7 @@ async function generateWelcomeGif(pictureFile, name, group, member) {
quality: 50,
};

return await canvasGif(__dirname + "/welcome/welcome" + Math.floor(Math.random() * 10) + ".gif", callBack, options)
return await canvasGif(__dirname + "/welcome/" + (Math.floor(Math.random() * 5) + 1) + ".gif", callBack, options)
.then((buffer) => {
let timesta = utils.getTimestamp();
fs.writeFileSync(returnD() + "/welcome_" + timesta + ".gif" , buffer);
Expand Down
Binary file added src/welcome/1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/welcome/2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/welcome/3.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/welcome/4.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/welcome/5.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed src/welcome/welcome0.gif
Binary file not shown.
Binary file removed src/welcome/welcome1.gif
Binary file not shown.
Binary file removed src/welcome/welcome2.gif
Binary file not shown.
Binary file removed src/welcome/welcome3.gif
Binary file not shown.
Binary file removed src/welcome/welcome4.gif
Binary file not shown.
Binary file removed src/welcome/welcome5.gif
Binary file not shown.
Binary file removed src/welcome/welcome6.gif
Binary file not shown.
Binary file removed src/welcome/welcome7.gif
Binary file not shown.
Binary file removed src/welcome/welcome8.gif
Binary file not shown.
Binary file removed src/welcome/welcome9.gif
Binary file not shown.

0 comments on commit 1d064f5

Please sign in to comment.