diff --git a/lib/replybot.js b/lib/replybot.js index 33585bd..460cf5f 100644 --- a/lib/replybot.js +++ b/lib/replybot.js @@ -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, diff --git a/nice-bot.js b/nice-bot.js index 586ff8f..eaeff29 100755 --- a/nice-bot.js +++ b/nice-bot.js @@ -3,15 +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': + case 'replybot reply': // you can choose "reply" or "status" from here when calling in Crontab await postReply(); break; + case 'replybot status': + await postRegularStatus(); + break; default: console.log('Something went wrong with nice-bot (ya dun goof\'d)'); break;