Compare commits
8 Commits
5da3a80317
...
develop
Author | SHA1 | Date | |
---|---|---|---|
e37c000842 | |||
687a99fb39 | |||
6601b853b7 | |||
fcc56236d4 | |||
ce687e56b0 | |||
f8b788e670 | |||
9005fd302e | |||
a73d4ae70c |
@ -1,3 +1,4 @@
|
||||
ADMIN_BEARER=""
|
||||
NIGGER_BEARER=""
|
||||
REPLYBOT_BEARER=""
|
||||
MEDIA_DIR="./lib/media"
|
||||
INSTANCE_NAME="example.tld"
|
||||
|
3
LICENSE
3
LICENSE
@ -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.
|
||||
|
||||
|
@ -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.
|
||||
|
@ -1,3 +0,0 @@
|
||||
# ncd-bot
|
||||
|
||||
Repository for the development and deployment of bots for the Fediverse.
|
@ -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,
|
||||
|
@ -3,14 +3,14 @@
|
||||
'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();
|
||||
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)');
|
||||
|
Reference in New Issue
Block a user