Compare commits

..

8 Commits

Author SHA1 Message Date
e37c000842 add MEDIA_DIR to .env.example 2023-02-10 08:29:59 -05:00
687a99fb39 allow calling so replybot can do regular statuses 2023-02-10 08:27:57 -05:00
6601b853b7 allows replybot to post regular statuses too 2023-02-10 08:12:07 -05:00
fcc56236d4 fix issue 2023-02-10 08:03:44 -05:00
ce687e56b0 update license file (like I need to lmao) 2023-02-09 20:37:21 -05:00
f8b788e670 fuckin markdown 2023-02-09 20:21:13 -05:00
9005fd302e update readme 2023-02-09 20:20:40 -05:00
a73d4ae70c remove errant README file 2023-02-09 20:19:35 -05:00
6 changed files with 24 additions and 15 deletions

View File

@ -1,3 +1,4 @@
ADMIN_BEARER=""
NIGGER_BEARER=""
REPLYBOT_BEARER=""
MEDIA_DIR="./lib/media"
INSTANCE_NAME="example.tld"

View File

@ -219,8 +219,7 @@ If you develop a new program, and you want it to be of the greatest possible use
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
Copyright (C) 2023 Matty Boombalatty
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

View File

@ -4,6 +4,6 @@ This project requires NodeJS 18.14.0 and will probably only run effectively on a
2. Enter `yarn` into terminal and press enter
3. Copy/move `.env.example` to `.env` in the root directory
4. Fill out the necessary information (_BEARER entries require BEARER tokens for authentication)
5. Run script by entering in to console "node nice-bot.js <SELECTION> <OPTIONS (if applicable)>"
5. Run script by entering in to console "node nice-bot.js [SELECTION] [OPTIONS] (if applicable)"
I'll update this and add more features as times goes on. Yes, it is retarded spaghetti code but it works. I would recommend using `crontab` (see [CrontabGuru](https://crontab.guru/#*/_*_*_*_*)) to run the script every however long you'd like, if you want it to be automated. At the moment, this script does not support replying to mentions as they come, like how the `ebooks` accounts do.

View File

@ -1,3 +0,0 @@
# ncd-bot
Repository for the development and deployment of bots for the Fediverse.

View File

@ -19,7 +19,7 @@ const emoteChoice = async () =>{ // pulls current emojis from the instance
return emoteArray[Math.floor(Math.random() * emoteArray.length)];
};
const replyChoice = async () =>{
const statusChoice = async () =>{
const replyArr = [ // add desired replies here - it's just a big ass array
"example1",
"example 2",
@ -28,6 +28,18 @@ const replyChoice = async () =>{
return replyArr[Math.floor(Math.random() * replyArr.length)];
};
export const postRegularStatus = async () =>{
const headers = {Authorization: `Bearer ${process.env.REPLYBOT_BEARER}`, "Content-Type": "application/json"};
const emoji = await emoteChoice();
const word = await statusChoice();
const res = await fetch(`https://${process.env.INSTANCE_NAME}/api/v1/statuses`, {
method: "POST",
headers: headers,
body: JSON.stringify({status: `${word} :${emoji}:`}),
});
if (res.status === 200) {console.log('Replybot posted regular status!')} else {console.log('Replybot failed (regular status):', res.status, res.statusText, res.url, word, emoji)}
};
export const postReply = async () =>{
const headers = {Authorization: `Bearer ${process.env.REPLYBOT_BEARER}`, "Content-Type": "application/json"};
const mentions = [];
@ -39,7 +51,7 @@ export const postReply = async () =>{
}
};
const emoji = await emoteChoice();
const word = await replyChoice();
const word = await statusChoice();
const res = await fetch(`https://${process.env.INSTANCE_NAME}/api/v1/statuses`, {
method: "POST",
headers: headers,

View File

@ -3,18 +3,18 @@
'use strict';
import 'dotenv/config';
import { postReply } from './lib/replybot.js';
import { postRegularStatus, postReply } from './lib/replybot.js';
const choice = process.argv[2]; // command line switch
try{
switch (choice.toLowerCase()){
case 'replybot':
await postReply();
break;
case 'replybot': // node nice-bot.js replybot [reply]
process.argv[3] === 'reply' ? postReply() : postRegularStatus();
break;
default:
console.log('Something went wrong with nice-bot (ya dun goof\'d)');
break;
console.log('Something went wrong with nice-bot (ya dun goof\'d)');
break;
};
} catch (error){
throw Error(error);