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

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mrepol742 committed Apr 5, 2024
1 parent 9b67f69 commit 015e7d8
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 109 deletions.
38 changes: 21 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)

<img src="https://mrepol742.github.io/images/orion-banner.png" align="right" width="500px"/>
<img src="https://mrepol742.github.io/images/orion-banner.png" align="right" width="300px"/>

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 <br>
https://github.com/mrepol742/project-orion/fork
- Clone fork the repository
```
_> using https
git clone https://github.com/<your-username>/project-orion
_> using ssh
git clone [email protected]:<your-username>/project-orion
```
```
# using https
git clone https://github.com/<your-username>/project-orion
# using ssh
git clone [email protected]:<your-username>/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
```
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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/",
Expand Down
46 changes: 46 additions & 0 deletions src/downloadFile.js
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
*
*/

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;
});
}
Empty file added src/fonts.js
Empty file.
87 changes: 87 additions & 0 deletions src/generatePoster.js
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
*
*/

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);
}
});
}
89 changes: 0 additions & 89 deletions src/redfox/src/generatePoster.js

This file was deleted.

2 changes: 2 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const fileNames = [
'getProjectTotalSize',
'getTimestamp',
'getUserProfile',
'generatePoster',
'downloadFile',
'isBlockedSentence',
'isNumeric',
'log',
Expand Down
3 changes: 3 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const generatePoster = require("./src/generatePoster");

generatePoster("null", "null", "null")

0 comments on commit 015e7d8

Please sign in to comment.