1
0
mirror of https://github.com/spacebarchat/spacebarchat.git synced 2024-11-08 11:42:39 +01:00
This commit is contained in:
Madeline 2023-05-03 00:43:26 +10:00
parent a4f5bf777e
commit b689541434
No known key found for this signature in database
GPG Key ID: 1958E017C36F2E47
32 changed files with 0 additions and 6970 deletions

View File

@ -1,3 +0,0 @@
{
"token": ""
}

File diff suppressed because it is too large Load Diff

View File

@ -1,18 +0,0 @@
{
"name": "github",
"version": "1.0.0",
"description": "",
"main": "rename_issues.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"arg": "^5.0.0",
"node-fetch": "^2.6.1",
"prompts": "^2.4.1",
"puppeteer": "^10.2.0"
}
}

View File

@ -1,42 +0,0 @@
const { token } = require("./config.json");
const fetch = require("node-fetch");
const base = "https://api.github.com";
const organization = "fosscord";
const request = async (path, opts = {}) =>
await fetch(`${base}${path}`, {
...opts,
headers: {
...opts.headers,
Authorization: `token ${token}`,
},
}).then((response) => response.json());
async function getRepos() {
return (await request(`/orgs/${organization}/repos`)).map((repo) => repo.name);
}
async function main() {
// const repos = await getRepos();
const repos = ["fosscord-gateway"];
for (const repo of repos) {
var page = 1;
do {
var issues = await request(`/repos/${organization}/${repo}/issues?state=all&per_page=100&page=${page}`);
for (const issue of issues) {
console.log(`issue #${issue.number}`);
// continue;
await request(`/repos/${organization}/${repo}/issues/${issue.number}`, {
method: "PATCH",
body: JSON.stringify({ labels: ["gateway"] }),
});
}
page++;
} while (issues.length);
}
}
main()
.then(() => console.log("done"))
.catch(console.error);

View File

@ -1,101 +0,0 @@
const arg = require("arg");
const puppeteer = require("puppeteer");
const prompts = require("prompts");
const { token } = require("./config.json");
const fetch = require("node-fetch");
const base = "https://api.github.com";
const request = async (path, opts = {}) =>
await fetch(`${base}${path}`, {
...opts,
headers: {
...opts.headers,
Authorization: `token ${token}`,
},
}).then((response) => response.json());
const args = arg({
"--org": String,
"--from": String,
"--to": String,
"--type": String,
"--username": String,
"--password": String,
"--otp": String,
});
console.log(args);
if (Object.keys(args).length < 5) {
console.log(
`usage:\nnode transfer-issues.js --org org-name --from original-repo-name --to new-repo-name --type closed --username username --password password`
);
process.exit();
}
async function main() {
var issues = (
await request(`/repos/${args["--org"]}/${args["--from"]}/issues?state=all&per_page=100&page=1`)
).filter((x) => !x.pull_request);
const browser = await puppeteer.launch({ headless: false });
const page = await browser.newPage();
await page.goto("https://github.com/login");
await page.waitForSelector("#login_field");
await page.type("#login_field", args["--username"]);
await page.type("#password", args["--password"]);
const wait = page.waitForNavigation();
await page.click(".btn.btn-primary.btn-block");
await wait;
let otp;
if (args["--otp"]) {
otp = args["--otp"];
} else {
const response = await prompts({
type: "text",
name: "otp",
message: "Enter OTP for GitHub",
});
otp = response.otp;
}
await page.waitForSelector("#otp");
await page.type("#otp", otp);
await page.waitFor(500);
try {
await page.click(".btn.btn-primary.btn-block");
await page.waitForNavigation();
} catch (error) {}
for (const issue of issues) {
await page.goto(issue.html_url);
const transfer = `[action="${issue.html_url.replace("https://github.com", "")}/transfer"]`;
await page.waitForSelector(transfer);
await page.click(transfer);
await page.waitForSelector(`${transfer} .select-menu-button`);
await page.click(`${transfer} .select-menu-button`);
await page.waitFor(1000);
await page.waitForSelector('[placeholder="Find a repository"]');
await page.type('[placeholder="Find a repository"]', args["--to"]);
await page.waitFor(2000);
await page.waitForSelector("#transfer-possible-repositories-menu .select-menu-item");
await page.click("#transfer-possible-repositories-menu .select-menu-item");
await page.waitForSelector('[data-disable-with="Transferring issue…"');
await page.click('[data-disable-with="Transferring issue…"');
await page.waitFor(500);
}
}
main();

View File

@ -1,236 +0,0 @@
require("missing-native-js-functions");
const fetch = require("node-fetch");
const { Client } = require("@notionhq/client");
const bodyParser = require("body-parser");
const express = require("express");
const app = express();
const PRIORITIES = ["low priority", "medium priority", "high priority"];
class GithubNotionSync {
constructor({ github, notion }) {
this.githubAuth = github.token;
this.githubWebhookSecret = github.webhookSecret;
this.notionAuth = notion.token;
this.databaseID = notion.database_id;
this.org = github.organization;
this.notion = new Client({ auth: this.notionAuth });
this.urls = {
base: "https://api.github.com/",
};
}
async init() {
this.allNotionPages = await this.getAllNotionPages();
this.repos = await this.getAllIssueUrls();
app.use(bodyParser({}));
app.post("/github", this.handleWebhook.bind(this));
app.listen(3010, () => {
console.log("Github <-> Notion sync listening on :3010");
});
}
async handleWebhook(req, res) {
const { hook, issue } = req.body;
await this.addItemToDb(GithubNotionSync.convertIssue(issue));
res.sendStatus(200);
}
async execute() {
await this.init();
let issues = 0;
for (let repo of this.repos) {
for (let issue of await this.getAllIssuesPerRepo(repo)) {
this.addItemToDb(issue);
issues++;
}
}
return issues;
}
/**
* @returns array of urls in the following form:
* https://api.github.com/repos/${this.org}/${repo_name}/issues
*/
async getAllIssueUrls() {
let repos = await fetch(`${this.urls.base}orgs/${this.org}/repos`, {
headers: {
Authorization: `token ${this.githubAuth}`,
"User-Agent": this.org,
},
}).then((r) => r.json());
return repos.map((repo) => `${this.urls.base}repos/${this.org}/${repo.name}/issues`);
}
/**
* @param repoIssueUrl element of array returned by `getAllIssueUrls()`
* @returns array of issues for the given repo in the following json form:
* ```
* {
* url: 'https://api.github.com/repos/fosscord/fosscord-server/issues/78',
* title: '[Route] /guilds/:id/regions',
* body: '- [ ] regions',
* number: 78,
* state: 'open',
* label: 'Route',
* assignee: 'Stylix58'
* }
* ```
*/
async getAllIssuesPerRepo(repoIssueUrl) {
var allIssues = [];
var page = 1;
do {
var issues = await fetch(`${repoIssueUrl}?state=all&direction=asc&per_page=100&page=${page}`, {
headers: {
Authorization: `token ${this.githubAuth}`,
"User-Agent": this.org,
},
}).then((r) => r.json());
issues = issues.filter((x) => !x.pull_request).map(GithubNotionSync.convertIssue);
page++;
allIssues = allIssues.concat(issues);
} while (issues.length);
return allIssues;
}
static convertIssue(x) {
return {
url: x?.html_url,
title: x?.title,
body: x?.body,
number: x?.number,
state: x?.state,
labels: x?.labels,
assignees: x?.assignees,
};
}
/**
* @returns {Promise<import("@notionhq/client/build/src/api-types").Page[]>}
*/
async getAllNotionPages() {
var allPages = [];
var start_cursor;
do {
var pages = await this.notion.databases.query({
database_id: this.databaseID,
page_size: 100,
...(start_cursor && { start_cursor }),
});
start_cursor = pages.next_cursor;
allPages = allPages.concat(pages.results);
} while (pages.has_more);
return allPages;
}
async addItemToDb(issue) {
const priority = issue.labels.find((x) => PRIORITIES.includes(x.name.toLowerCase()))?.name;
const options = {
parent: { database_id: this.databaseID },
properties: {
Name: {
title: [
{
text: {
content: issue.title,
},
},
],
},
State: {
select: {
name: issue.state,
},
},
Repo: {
select: {
name: GithubNotionSync.getRepoNameFromUrl(issue.url),
},
},
Url: {
url: issue.url,
},
Number: { number: issue.number },
...(issue.assignees && {
Assignee: {
multi_select: issue.assignees.map((x) => ({ name: x.login })),
},
}),
...(issue.labels && {
Label: {
multi_select: issue.labels
.filter((x) => !PRIORITIES.includes(x.name.toLowerCase()))
.map((x) => ({ name: x.name })),
},
}),
...(priority && {
Priority: {
select: { name: priority },
},
}),
},
children: [
{
object: "block",
type: "paragraph",
paragraph: {
text: [
{
type: "text",
text: {
content: issue.body?.slice(0, 1990) || "",
},
},
],
},
},
],
};
const exists = this.allNotionPages.find(
(x) =>
x.properties.Number.number == issue.number &&
x.properties.Repo.select.name === GithubNotionSync.getRepoNameFromUrl(issue.url)
);
try {
if (exists) {
if (
exists.properties.Name?.title?.[0].plain_text !== issue.title ||
exists.properties.Priority?.select.name !== priority ||
exists.properties.State?.select.name !== issue.state ||
JSON.stringify(issue.labels.map((x) => x.name)) !==
JSON.stringify(exists.properties.Label?.multi_select.map((x) => x.name)) ||
JSON.stringify(issue.assignees.map((x) => x.login)) !==
JSON.stringify(exists.properties.Assignee?.multi_select.map((x) => x.name))
) {
console.log("update existing one");
await this.notion.pages.update({ page_id: exists.id, properties: options.properties });
exists.properties = options.properties;
}
} else {
console.log("adding new one");
const index = this.allNotionPages.push(options) - 1; // directly insert it as they might be inserted twice if the webhook is triggered in very short amount of time
this.allNotionPages[index] = await this.notion.pages.create(options);
}
} catch (error) {
console.log(issue);
console.error(error.body, error);
}
}
static getRepoNameFromUrl(url) {
return url?.match(/fosscord\/(fosscord-)?([\w.-]+)/)[2];
}
}
module.exports = { GithubNotionSync };

View File

@ -1,11 +0,0 @@
{
"github": {
"token": "",
"webhookSecret": "",
"organization": ""
},
"notion": {
"token": "",
"database_id": ""
}
}

View File

@ -1,7 +0,0 @@
const config = require("./config.json");
const { GithubNotionSync } = require("./GithubNotionSync");
const sync = new GithubNotionSync(config);
sync.execute()
.then((x) => console.log(`Successfuly synced ${x} issues!`))
.catch(console.error);

File diff suppressed because it is too large Load Diff

View File

@ -1,22 +0,0 @@
{
"name": "notion",
"version": "1.0.0",
"description": "",
"main": "main.js",
"scripts": {
"start": "node main.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"@notionhq/client": "^0.2.4",
"body-parser": "^1.19.0",
"express": "^4.17.1",
"missing-native-js-functions": "^1.2.9",
"node-fetch": "^2.6.1"
},
"devDependencies": {
"ts-node": "^10.2.0"
}
}

View File

@ -1,4 +0,0 @@
1. auth to github
2. get all issues from all repos
3. auth to notion
4. create a card for each issue with a tag for the corressponding repo and its status (BUG, FEATURES, etc)

View File

@ -1,251 +0,0 @@
{
"name": "test",
"version": "1.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"amqplib": "^0.8.0"
}
},
"node_modules/amqplib": {
"version": "0.8.0",
"resolved": "https://registry.npmjs.org/amqplib/-/amqplib-0.8.0.tgz",
"integrity": "sha512-icU+a4kkq4Y1PS4NNi+YPDMwdlbFcZ1EZTQT2nigW3fvOb6AOgUQ9+Mk4ue0Zu5cBg/XpDzB40oH10ysrk2dmA==",
"dependencies": {
"bitsyntax": "~0.1.0",
"bluebird": "^3.7.2",
"buffer-more-ints": "~1.0.0",
"readable-stream": "1.x >=1.1.9",
"safe-buffer": "~5.2.1",
"url-parse": "~1.5.1"
},
"engines": {
"node": ">=10"
}
},
"node_modules/bitsyntax": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/bitsyntax/-/bitsyntax-0.1.0.tgz",
"integrity": "sha512-ikAdCnrloKmFOugAfxWws89/fPc+nw0OOG1IzIE72uSOg/A3cYptKCjSUhDTuj7fhsJtzkzlv7l3b8PzRHLN0Q==",
"dependencies": {
"buffer-more-ints": "~1.0.0",
"debug": "~2.6.9",
"safe-buffer": "~5.1.2"
},
"engines": {
"node": ">=0.8"
}
},
"node_modules/bitsyntax/node_modules/safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
},
"node_modules/bluebird": {
"version": "3.7.2",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz",
"integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg=="
},
"node_modules/buffer-more-ints": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/buffer-more-ints/-/buffer-more-ints-1.0.0.tgz",
"integrity": "sha512-EMetuGFz5SLsT0QTnXzINh4Ksr+oo4i+UGTXEshiGCQWnsgSs7ZhJ8fzlwQ+OzEMs0MpDAMr1hxnblp5a4vcHg=="
},
"node_modules/core-util-is": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
},
"node_modules/debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"dependencies": {
"ms": "2.0.0"
}
},
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
},
"node_modules/isarray": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
"integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8="
},
"node_modules/ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
},
"node_modules/querystringify": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz",
"integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ=="
},
"node_modules/readable-stream": {
"version": "1.1.14",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
"integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
"dependencies": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.1",
"isarray": "0.0.1",
"string_decoder": "~0.10.x"
}
},
"node_modules/requires-port": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
"integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8="
},
"node_modules/safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
]
},
"node_modules/string_decoder": {
"version": "0.10.31",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
"integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ="
},
"node_modules/url-parse": {
"version": "1.5.10",
"resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz",
"integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==",
"dependencies": {
"querystringify": "^2.1.1",
"requires-port": "^1.0.0"
}
}
},
"dependencies": {
"amqplib": {
"version": "0.8.0",
"resolved": "https://registry.npmjs.org/amqplib/-/amqplib-0.8.0.tgz",
"integrity": "sha512-icU+a4kkq4Y1PS4NNi+YPDMwdlbFcZ1EZTQT2nigW3fvOb6AOgUQ9+Mk4ue0Zu5cBg/XpDzB40oH10ysrk2dmA==",
"requires": {
"bitsyntax": "~0.1.0",
"bluebird": "^3.7.2",
"buffer-more-ints": "~1.0.0",
"readable-stream": "1.x >=1.1.9",
"safe-buffer": "~5.2.1",
"url-parse": "~1.5.1"
}
},
"bitsyntax": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/bitsyntax/-/bitsyntax-0.1.0.tgz",
"integrity": "sha512-ikAdCnrloKmFOugAfxWws89/fPc+nw0OOG1IzIE72uSOg/A3cYptKCjSUhDTuj7fhsJtzkzlv7l3b8PzRHLN0Q==",
"requires": {
"buffer-more-ints": "~1.0.0",
"debug": "~2.6.9",
"safe-buffer": "~5.1.2"
},
"dependencies": {
"safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
}
}
},
"bluebird": {
"version": "3.7.2",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz",
"integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg=="
},
"buffer-more-ints": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/buffer-more-ints/-/buffer-more-ints-1.0.0.tgz",
"integrity": "sha512-EMetuGFz5SLsT0QTnXzINh4Ksr+oo4i+UGTXEshiGCQWnsgSs7ZhJ8fzlwQ+OzEMs0MpDAMr1hxnblp5a4vcHg=="
},
"core-util-is": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
},
"debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"requires": {
"ms": "2.0.0"
}
},
"inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
},
"isarray": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
"integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8="
},
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
},
"querystringify": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz",
"integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ=="
},
"readable-stream": {
"version": "1.1.14",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
"integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.1",
"isarray": "0.0.1",
"string_decoder": "~0.10.x"
}
},
"requires-port": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
"integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8="
},
"safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="
},
"string_decoder": {
"version": "0.10.31",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
"integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ="
},
"url-parse": {
"version": "1.5.10",
"resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz",
"integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==",
"requires": {
"querystringify": "^2.1.1",
"requires-port": "^1.0.0"
}
}
}
}

View File

@ -1,15 +0,0 @@
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "rabbitmq.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"amqplib": "^0.8.0"
}
}

View File

@ -1,29 +0,0 @@
var amqp = require("amqplib");
var queue = "hellotes53";
var send_at;
async function main() {
const conn = await amqp.connect("amqp://localhost");
const recv_ch = await conn.createChannel();
await recv_ch.assertQueue(queue);
recv_ch.consume(
queue,
function (msg) {
if (msg !== null) {
console.log(`received ${msg.content.toString()} with latency of ${Date.now() - send_at}ms`);
}
},
{ noAck: true }
);
const send_ch = await conn.createChannel();
// await send_ch.assertQueue(queue);
setInterval(() => {
send_at = Date.now();
send_ch.sendToQueue(queue, Buffer.from("hello"));
}, 100);
}
main();

View File

@ -1 +0,0 @@
/node_modules/

View File

@ -1,52 +0,0 @@
const { Client } = require("discord-rpc");
var startTimestamp = new Date();
async function reconnect() {
try {
await login();
} catch (error) {
console.error("discord not open:", error);
setTimeout(async () => {
await reconnect();
}, 1000 * 10);
}
}
reconnect();
async function login() {
console.log("login");
rpc = new Client({
transport: "ipc",
});
rpc.on("ready", () => {
console.log("logged in: ", rpc.user.username);
rpc.setActivity({
details: `Free open source selfhostable`,
state: `Chat, voice, video and discord-compatible platform`,
startTimestamp,
smallImageText: "flam3rboy",
largeImageKey: "logo2",
largeImageText: "Fosscord",
instance: false,
buttons: [
{ label: "Discord", url: "https://discord.gg/ZrnGQP6p3d" },
{
label: "Website",
url: "https://fosscord.com",
},
],
});
});
rpc.on("disconnected", async () => {
console.log("disconnected");
await reconnect();
});
return rpc.login({ clientId: "807686638742142988" });
}

File diff suppressed because it is too large Load Diff

View File

@ -1,15 +0,0 @@
{
"name": "rpc",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"discord-rpc": "github:discordjs/rpc",
"pm2": "^4.5.4"
}
}

View File

@ -1 +0,0 @@
node index.js

View File

@ -1,16 +0,0 @@
# Getting Started
To use this method, you must have [NodeJS and NPM](https://nodejs.org) installed.
### Windows
1. Open cmd
2. Type this command:
```
curl https://raw.githubusercontent.com/fosscord/fosscord/main/scripts/setup/setup.bat --output setup.bat && setup.bat
```
### Linux or macOS
1. Open Terminal
2. Type this command:
```
curl https://raw.githubusercontent.com/fosscord/fosscord/main/scripts/setup/setup.sh --output setup.sh && bash setup.sh
```

View File

@ -1,16 +0,0 @@
git clone https://github.com/fosscord/css-mediaquery.git css-mediaquery
git clone https://github.com/fosscord/docker.git docker
git clone https://github.com/fosscord/fosscord.git fosscord
git clone https://github.com/fosscord/fosscord-client.git client
git clone https://github.com/fosscord/fosscord-client-native.git client-native
git clone https://github.com/fosscord/fosscord-docs.git docs
git clone https://github.com/fosscord/fosscord-landingpage.git landingpage
git clone https://github.com/fosscord/fosscord-plugins.git plugins
git clone https://github.com/fosscord/fosscord-server.git server
git clone https://github.com/fosscord/fosscord-themes.git themes
git clone https://github.com/fosscord/fosscord-ui.git ui
git clone https://github.com/fosscord/fosscord-voice-gateway.git voice-gateway
git clone https://github.com/fosscord/fosscord.js.git fosscord.js
git clone https://github.com/fosscord/fosscord.js-builders.git fosscord.js-builders
git clone https://github.com/fosscord/fosscord.py.git fosscord.py
git clone https://github.com/fosscord/react-native-withcss.git react-native-withcss

View File

@ -1 +0,0 @@
{"folders": [{"path": "css-mediaquery"}, {"path": "docker"}, {"path": "fosscord"}, {"path": "client"}, {"path": "client-native"}, {"path": "docs"}, {"path": "landingpage"}, {"path": "plugins"}, {"path": "server"}, {"path": "themes"}, {"path": "ui"}, {"path": "voice-gateway"}, {"path": "fosscord.js"}, {"path": "fosscord.js-builders"}, {"path": "fosscord.py"}, {"path": "react-native-withcss"}]}

View File

@ -1,8 +0,0 @@
____ _____ ____ ____ ____ _____ ____ ____
/\ _`\ /\ __`\ /\ _`\ /\ _`\ /\ _`\ /\ __`\ /\ _`\ /\ _`\
\ \ \L\_\\ \ \/\ \\ \,\L\_\\ \,\L\_\\ \ \/\_\\ \ \/\ \\ \ \L\ \\ \ \/\ \
\ \ _\/ \ \ \ \ \\/_\__ \ \/_\__ \ \ \ \/_/_\ \ \ \ \\ \ , / \ \ \ \ \
\ \ \/ \ \ \_\ \ /\ \L\ \ /\ \L\ \\ \ \L\ \\ \ \_\ \\ \ \\ \ \ \ \_\ \
\ \_\ \ \_____\\ `\____\\ `\____\\ \____/ \ \_____\\ \_\ \_\\ \____/
\/_/ \/_____/ \/_____/ \/_____/ \/___/ \/_____/ \/_/\/ / \/___/

View File

@ -1,22 +0,0 @@
# script to:
# - get all repo git urls from the fosscord orga and format them to make the process of updating the setup script less tiresome
# - create a workspace file for VScode
import requests
workspace = {
"folders":[]
}
repos = ""
response = requests.get("https://api.github.com/users/fosscord/repos").json()
for repo in response:
name = repo['name'].replace('fosscord-','')
workspace["folders"].append({"path":f"{name}"})
repos += f"git clone {repo['git_url']} {name}\n"
with open("clone_all_repos.sh","w") as f:
f.write(repos)
with open("fosscord.code-workspace", "w") as f:
f.write(str(workspace).replace("'",'"'))

View File

@ -1,85 +0,0 @@
@ECHO off
ECHO.
ECHO
ECHO ____ _____ ____ ____ ____ _____ ____ ____
ECHO /\ _`\ /\ __`\ /\ _`\ /\ _`\ /\ _`\ /\ __`\ /\ _`\ /\ _`\
ECHO \ \ \L\_\\ \ \/\ \\ \,\L\_\\ \,\L\_\\ \ \/\_\\ \ \/\ \\ \ \L\ \\ \ \/\ \
ECHO \ \ _\/ \ \ \ \ \\/_\__ \ \/_\__ \ \ \ \/_/_\ \ \ \ \\ \ , / \ \ \ \ \
ECHO \ \ \/ \ \ \_\ \ /\ \L\ \ /\ \L\ \\ \ \L\ \\ \ \_\ \\ \ \\ \ \ \ \_\ \
ECHO \ \_\ \ \_____\\ `\____\\ `\____\\ \____/ \ \_____\\ \_\ \_\\ \____/
ECHO \/_/ \/_____/ \/_____/ \/_____/ \/___/ \/_____/ \/_/\/ / \/___/
ECHO \n--------------------------------
ECHO This will clone and setup all fosscord repositories,
ECHO if you only want to work on one specific repository
ECHO follow their specific "Getting Started" Guide and exit this script
ECHO.
CHOICE /C YN /m "Are you sure you want to continue (y/n)?"
IF %ERRORLEVEL% == 2 GOTO :end
where /q git
IF ERRORLEVEL 1 (
ECHO Error: git is not installed.
ECHO Please Install git from: https://git-scm.com/downloads
ECHO And make sure its in the path
GOTO :end
)
where /q node
IF ERRORLEVEL 1 (
ECHO Error: node is not installed.
ECHO Please Install NodeJS from: https://nodejs.org/en/download
ECHO And make sure its in the path
GOTO :end
)
where /q npm
IF ERRORLEVEL 1 (
ECHO 'Error: npm is not installed.' >&2
ECHO Please install npm from: https://nodejs.org/en/download
ECHO And make sure its in the path
GOTO :end
)
echo Dependencies are already installed
ECHO.
echo Creating organization directory
ECHO.
MKDIR fosscord
cd fosscord
ECHO Cloning all repositories
ECHO.
git clone https://github.com/fosscord/fosscord overview
git clone https://github.com/fosscord/fosscord-server server
git clone https://github.com/fosscord/fosscord-themes themes
git clone https://github.com/fosscord/fosscord-plugins plugins
git clone https://github.com/fosscord/fosscord-ui ui
git clone https://github.com/fosscord/fosscord-client client
git clone https://github.com/fosscord/fosscord-landingpage landingpage
git clone https://github.com/fosscord/css-mediaquery css-mediaquery
git clone https://github.com/fosscord/react-native-withcss react-native-withcss
echo {"folders":[{"path":"overview"},{"path":"cdn"},{"path":"api"},{"path":"gateway"},{"path":"media"},{"path":"server-util"},{"path":"ui"},{"path":"client"},{"path":"plugins"},{"path":"themes"},{"path":"landingpage"},{"path":"dashboard"},{"path":"support"},{"path":"css-mediaquery"},{"path":"react-native-withcss"}]}> fosscord.code-workspace
IF ERRORLEVEL 0 (
CHOICE /c yn /m "Do you want to launch the VS Code workspace?"
IF %ERRORLEVEL% == 2 GOTO :rpc
ECHO Opening VS Code Workspace
code fosscord.code-workspace
)
:rpc
CHOICE /c yn /m "Do you want to install the Discord Rich Presence?"
IF %ERRORLEVEL% == 2 GOTO :end
cd ..
cd rpc
npm install
npm i pm2 -g
pm2 start --name rpc index.js
pm2 save
pm2-startup install
:end
ECHO finished installation
@ECHO on
PAUSE

View File

@ -1,59 +0,0 @@
#!/bin/sh
cat fosscord.txt
echo
cat << EOF
--------------------------------------
Fosscord Open Source Contribution Setup
strg+c/strg+d to exit
-------------------------------------------
This will clone and setup all repositories,
if you only want to work on one specific repository
follow their specific Getting Started Guide and exit this script
----------------------------------------------------------------
EOF
printf "Are you sure you want to continue (y/N)?"
read -p "" CONT
if [ "$CONT" != "y" ]; then
echo Aborting setup
exit 1
fi
echo ---------------------
echo Checking dependencies
if ! [ -x "$(command -v git)" ]; then
echo Error: git is not installed.
echo Please Install git from: https://git-scm.com/downloads
echo And make sure its in the path
exit 1
fi
if ! [ -x "$(command -v node)" ]; then
echo Error: node is not installed.
echo Please Install NodeJS from: https://nodejs.org/en/download
echo And make sure its in the path
exit 1
fi
if ! [ -x "$(command -v npm)" ]; then
echo 'Error: npm is not installed.' >&2
echo Please install npm from: https://nodejs.org/en/download
echo And make sure its in the path
exit 1
fi
echo ✓ Dependencies are already installed
echo -------------------------------
echo Creating organization directory
mkdir fosscord
cd fosscord
echo Cloning all repositories
sh ../clone_all_repos.sh
mv ../fosscord.code-workspace ./fosscord.code-workspace
while true; do
echo "Do you wish to launch the VSCode workspace?"
read -p "[y/n]: " yn
case $yn in
[Yy]* ) echo Opening VS Code Workspace ; code fosscord.code-workspace ; break;;
[Nn]* ) break;;
esac
done
echo Installation finished

View File

@ -1,4 +0,0 @@
@ECHO on
.\update-git.bat
cd fosscord\scripts\update
.\update-npm.bat

View File

@ -1,2 +0,0 @@
sh update-git.sh
sh update-npm.sh

View File

@ -1,6 +0,0 @@
@ECHO off
ECHO Update for Git...
cd ..\..
FOR /D %%a IN (%CD%\*) do echo -------------- && echo %%~fa && cd %%~fa && git pull
cd ..\..
@ECHO on

View File

@ -1,9 +0,0 @@
echo Update files...
cd ../..
for D in */; do
echo --------------
echo "$D";
cd $D
git sync
cd ..
done

View File

@ -1,11 +0,0 @@
@ECHO off
ECHO Update all dependencies...
cd ..\..
where /q pnpm
IF ERRORLEVEL 1 (
FOR /D %%a IN (%CD%\*) do echo -------------- && echo %%~fa && cd %%~fa && npm i
) ELSE (
FOR /D %%a IN (%CD%\*) do echo -------------- && echo %%~fa && cd %%~fa && pnpm i
)
cd ..\..
@ECHO on

View File

@ -1,13 +0,0 @@
echo Update all dependancies...
cd ../..
for D in */; do
echo --------------
echo "$D";
cd $D
if [ $pnpm = true ]
if ! [ -x "$(command -v pnpm)" ]; then
npm i
else
pnpm i
fi
done