diff --git a/README.md b/README.md
index b5c7dcde..f954fcf2 100644
--- a/README.md
+++ b/README.md
@@ -1,31 +1,35 @@
# project-orion [![Project Orion CI](https://github.com/mrepol742/project-orion/actions/workflows/npm.yml/badge.svg)](https://github.com/mrepol742/project-orion/actions/workflows/npm.yml)
-
+
-Meet my lightning-fast Facebook Messenger chatbot, seamlessly managing multiple accounts with access to 271 commands. With distinct privileges for admins, owners, roots, and users, it's the lightweight solution for efficient and personalized interactions.
+Meet the lightning-fast Facebook Messenger chatbot, seamlessly managing multiple accounts with access to 271 commands and more.
## Pre-requisites
- Install [Node.js](https://nodejs.org/en/) version 20.x.x
## Getting started
-- Fork the repository
-Click https://github.com/mrepol742/project-orion/fork
+- Fork the repository
+ https://github.com/mrepol742/project-orion/fork
- Clone fork the repository
-```
-_> using https
-git clone https://github.com//project-orion
-
-_> using ssh
-git clone git@github.com:/project-orion
-```
+ ```
+ # using https
+ git clone https://github.com//project-orion
+
+ # using ssh
+ git clone git@github.com:/project-orion
+ ```
- Install dependencies
-```
-cd project-orion && npm i
-```
+ ```
+ cd project-orion && npm i
+ ```
- Run the project
-```
-npm run start
-```
+ ```
+ npm run start
+ ```
+
+
+## Contribute
+Code contributions are welcome! Please commit any pull requests against the master branch. Security audits and feedback are welcome. Please open an issue or email us privately if the report is sensitive in nature.
## License
```
diff --git a/index.js b/index.js
index 609cec78..5f7c8a98 100644
--- a/index.js
+++ b/index.js
@@ -1432,7 +1432,7 @@ function main(fca_state, login, cb) {
let dirp = __dirname + "/cache/welcome_p_" + utils.getTimestamp() + ".jpg";
downloadFile(getProfilePic(names[0][0]), dirp).then(async (response) => {
- redfox.generatePoster(dirp, names[0][1], gname, getSuffix(gc.participantIDs.length) + " member").then(
+ utils.generatePoster(dirp, names[0][1], gname, getSuffix(gc.participantIDs.length) + " member").then(
(data) => {
let message = {
body: gret,
@@ -1524,7 +1524,7 @@ function main(fca_state, login, cb) {
let dirp = __dirname + "/cache/sayonara_p_" + utils.getTimestamp() + ".jpg";
downloadFile(getProfilePic(id), dirp).then(async (response) => {
- redfox.generatePoster(dirp, "Sayonara", data[id].name, "may the force be with you :(").then(
+ utils.generatePoster(dirp, "Sayonara", data[id].name, "may the force be with you :(").then(
(data) => {
let message = {
diff --git a/package.json b/package.json
index 7f8d484b..bac9c041 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "project-orion",
"version": "9.1.0",
- "description": "A Chatbot thats trained to understand and respond to a wide range of commands and requests. Providing a valuable service that poeple find useful. Strive to create a platform that is easy to use and provides helpful features that make poeple's lives easier.",
+ "description": "Meet the lightning-fast Facebook Messenger chatbot, seamlessly managing multiple accounts with access to 271 commands. With distinct privileges for admins, owners, roots, and users, it's the lightweight solution for efficient and personalized interactions.",
"main": "index.js",
"private": true,
"homepage": "https://mrepol742.github.io/project-orion/",
diff --git a/src/downloadFile.js b/src/downloadFile.js
new file mode 100644
index 00000000..ec985aa9
--- /dev/null
+++ b/src/downloadFile.js
@@ -0,0 +1,46 @@
+/*
+ *
+ * This file is part of Project Orion.
+ * Copyright (c) 2022 Melvin Jones
+ *
+ * Orion is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License
+ *
+ * Orion is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Orion. If not, see .
+ *
+ */
+
+const fs = require("fs");
+
+module.exports = (fileUrl, outputLocationPath) => {
+ const writer = fs.createWriteStream(outputLocationPath);
+ return axios({
+ method: "get",
+ url: fileUrl,
+ responseType: "stream",
+ })
+ .then((response) => {
+ return new Promise((resolve, reject) => {
+ response.data.pipe(writer);
+ let error = null;
+ writer.on("error", (err) => {
+ error = err;
+ writer.close();
+ reject(err);
+ });
+ writer.on("close", () => {
+ if (!error) {
+ resolve(true);
+ }
+ });
+ });
+ })
+ .catch(function (err) {
+ return err;
+ });
+}
\ No newline at end of file
diff --git a/src/fonts.js b/src/fonts.js
new file mode 100644
index 00000000..e69de29b
diff --git a/src/generatePoster.js b/src/generatePoster.js
new file mode 100644
index 00000000..9f56372b
--- /dev/null
+++ b/src/generatePoster.js
@@ -0,0 +1,87 @@
+/*
+ *
+ * This file is part of Project Orion.
+ * Copyright (c) 2022 Melvin Jones
+ *
+ * Orion is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License
+ *
+ * Orion is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Orion. If not, see .
+ *
+ */
+
+const canvasGif = require("canvas-gif");
+const Canvas = require("canvas");
+const fs = require("fs");
+const utils = require("./redfox/utils");
+
+module.exports = (pictureFile, name, group, member) => {
+ return new Promise((resolve, reject) => {
+ try {
+ name = name.normalize("NFKC").replace(/[^a-z0-9\s]/gi, '')
+ group = group.normalize("NFKC").replace(/[^a-z0-9\s]/gi, '')
+
+ if (name.length > 26) {
+ name = name.substring(0, 26) + "...";
+ }
+ if (group.length > 26) {
+ group = group.substring(0, 26) + "...";
+ }
+
+ const callBack = (ctx, width, height, totalFrames, currentFrame) => {
+ ctx.fillStyle = "#fff";
+ ctx.textAlign = "center";
+ ctx.font = 'bold 60px "Operator Mono"';
+ ctx.fillText(name, width * 0.5, height * 0.7);
+ 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);
+
+ let x = width / 2;
+ let y = height / 3;
+ let radius = 130;
+ ctx.save();
+ ctx.beginPath();
+ ctx.arc(x, y, radius, 0, 2 * Math.PI);
+
+ ctx.strokeStyle = "#fff";
+ ctx.stroke();
+ ctx.clip();
+ let img = fs.readFileSync(pictureFile);
+ let img1 = new Canvas.Image();
+ img1.src = img;
+ ctx.drawImage(img1, x - radius, y - radius, radius * 3, radius * 3);
+ ctx.restore();
+ ctx.stroke();
+ };
+
+ let options = {
+ coalesce: false,
+ delay: 0,
+ repeat: 0,
+ algorithm: "neuquant",
+ optimiser: true,
+ fps: 40,
+ quality: 50,
+ };
+
+ canvasGif("./assets/welcome/" + (Math.floor(Math.random() * 5) + 1) + ".gif", callBack, options)
+ .then((buffer) => {
+ let timesta = utils.getTimestamp();
+ fs.writeFileSync("./cache/welcome_" + timesta + ".gif", buffer);
+ resolve("./cache/welcome_" + timesta + ".gif");
+ })
+ .catch((err) => {
+ reject(err);
+ });
+ } catch (err) {
+ reject(err);
+ }
+ });
+}
\ No newline at end of file
diff --git a/src/redfox/src/generatePoster.js b/src/redfox/src/generatePoster.js
deleted file mode 100644
index 5ca9a419..00000000
--- a/src/redfox/src/generatePoster.js
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- *
- * This file is part of Project Orion.
- * Copyright (c) 2022 Melvin Jones
- *
- * Orion is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3 of the License
- *
- * Orion is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with Orion. If not, see .
- *
- */
-
-const canvasGif = require("canvas-gif");
-const Canvas = require("canvas");
-const fs = require("fs");
-const utils = require("../utils");
-
-module.exports = function (defaultFuncs, api, ctx) {
- return function generatePoster(pictureFile, name, group, member) {
- return new Promise((resolve, reject) => {
- try {
- name = name.normalize("NFKC").replace(/[^a-z0-9\s]/gi, '')
- group = group.normalize("NFKC").replace(/[^a-z0-9\s]/gi, '')
-
- if (name.length > 26) {
- name = name.substring(0, 26) + "...";
- }
- if (group.length > 26) {
- group = group.substring(0, 26) + "...";
- }
-
- const callBack = (ctx, width, height, totalFrames, currentFrame) => {
- ctx.fillStyle = "#fff";
- ctx.textAlign = "center";
- ctx.font = 'bold 60px "Operator Mono"';
- ctx.fillText(name, width * 0.5, height * 0.7);
- 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);
-
- let x = width / 2;
- let y = height / 3;
- let radius = 130;
- ctx.save();
- ctx.beginPath();
- ctx.arc(x, y, radius, 0, 2 * Math.PI);
-
- ctx.strokeStyle = "#fff";
- ctx.stroke();
- ctx.clip();
- let img = fs.readFileSync(pictureFile);
- let img1 = new Canvas.Image();
- img1.src = img;
- ctx.drawImage(img1, x - radius, y - radius, radius * 3, radius * 3);
- ctx.restore();
- ctx.stroke();
- };
-
- let options = {
- coalesce: false,
- delay: 0,
- repeat: 0,
- algorithm: "neuquant",
- optimiser: true,
- fps: 40,
- quality: 50,
- };
-
- canvasGif("../assets/welcome/" + (Math.floor(Math.random() * 5) + 1) + ".gif", callBack, options)
- .then((buffer) => {
- let timesta = utils.getTimestamp();
- fs.writeFileSync("../cache/welcome_" + timesta + ".gif", buffer);
- resolve("../cache/welcome_" + timesta + ".gif");
- })
- .catch((err) => {
- reject(err);
- });
- } catch (err) {
- reject(err);
- }
- });
- }
-}
\ No newline at end of file
diff --git a/src/utils.js b/src/utils.js
index 1a70adbe..0b8d1c24 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -31,6 +31,8 @@ const fileNames = [
'getProjectTotalSize',
'getTimestamp',
'getUserProfile',
+ 'generatePoster',
+ 'downloadFile',
'isBlockedSentence',
'isNumeric',
'log',
diff --git a/test.js b/test.js
new file mode 100644
index 00000000..985c66b6
--- /dev/null
+++ b/test.js
@@ -0,0 +1,3 @@
+const generatePoster = require("./src/generatePoster");
+
+generatePoster("null", "null", "null")
\ No newline at end of file