diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dcf65eb --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +auto_joe.json diff --git a/documentation/setting up a new jail.md b/documentation/setting up a new jail.md new file mode 100644 index 0000000..5ae77bb --- /dev/null +++ b/documentation/setting up a new jail.md @@ -0,0 +1,6 @@ +https://blog.pm2.io/2018-09-19/Manage-Python-Processes/ +https://www.npmjs.com/package/pm2 + +pm2 is super useful so install it + +use the first part of this guide to enable ssh https://github.com/nfarina/homebridge/wiki/FreeNAS-9.10-BSD-Jail \ No newline at end of file diff --git a/robots/auto_joe.json b/robots/auto_joe.json new file mode 100644 index 0000000..70ae615 --- /dev/null +++ b/robots/auto_joe.json @@ -0,0 +1,3 @@ +{ + "token":"" +} \ No newline at end of file diff --git a/robots/auto_joe.py b/robots/auto_joe.py new file mode 100644 index 0000000..dc188fe --- /dev/null +++ b/robots/auto_joe.py @@ -0,0 +1,44 @@ +import discord +import sys +import os +import asyncio +import git +import time +import json + +g = git.cmd.Git('~/discord') + +with open("auto_joe_responses.json", "r") as f: # Load all the responses + responses = json.load(f) + +def restart_program(): # def defines a function, this one in particular restarts the program + #g.pull() # Would pull a new version from github if in a git repo + python = sys.executable # use executable in following line + os.execl(python, python, * sys.argv) # restart + + +client = discord.Client() +@client.event # On any event from the discord connection (client) +async def on_message(message): #When a message comes in + content=message.content # Get the content of the message + user=message.author # Get the author of the message + channel=message.channel # the the channel the message was sent in + + if user == client.user: # If the user is the robot itself + return # dont say anything in response to something the robot says + + for key in responses: # For all the keys in the loaded dict + if key.upper() in (content.strip()).upper(): # if in the string content, exists the content of the key (ignoring uppercase) + print(responses[key]) # Log the update + await channel.send(responses[key]) # using await so we sync with discord API, send the message ASAP + + if "define the word is" in content.strip(): + print("Reboot called by " + str(user)) + await channel.send("Rebooted") + restart_program() # call function + +with open("auto_joe.json", "r") as f: + robot_data = json.load(f) + +print("Starting robot with id: " + (robot_data["token"])) +client.run(robot_data["token"]) diff --git a/robots/auto_joe_responses.json b/robots/auto_joe_responses.json new file mode 100644 index 0000000..6e77846 --- /dev/null +++ b/robots/auto_joe_responses.json @@ -0,0 +1,12 @@ +{ + ":0":":0", + "What is the meaning of life":"42.", + "When is vive fest":"The 30th! WOO LETS GO!", + "How do i download more ram":"Its easy, simply go here: https://downloadmoreram.com/", + "AutoJoe can i see an example of":"Nope, that feature is not available yet.", + "can you do my homework":"If i could do your homework do you think i would be here?", + "classroom code":"I dont actually know what it is lol for B or C block", + "who is joe":"Joe mamma", + "beep beep boop":"What?! My mother was a saint!", + "Where is my dinner":"Honey im home" +} diff --git a/robots/requirements.txt b/robots/requirements.txt new file mode 100644 index 0000000..5afbb65 --- /dev/null +++ b/robots/requirements.txt @@ -0,0 +1,3 @@ +async-timeout==3.0.1 +discord.py==1.2.3 +GitPython==3.0.3 \ No newline at end of file