Skip to content
Permalink
Browse files

Added custom code functionality

  • Loading branch information...
hollan84 committed May 3, 2020
1 parent fa4f930 commit 0fc6cc0d35e2f7a43e51571b066d0f23909f1d43
Showing with 17 additions and 6 deletions.
  1. +2 −1 .gitignore
  2. +9 −1 lib/bot.py
  3. +6 −4 templates/customTemplate.py
@@ -3,4 +3,5 @@ Custom.py

nicknames/
oldCustom/
__pycache__/
__pycache__/
lib/custom.py
@@ -4,9 +4,14 @@
from mcstatus import MinecraftServer
from datetime import datetime
from datetime import timedelta
from shutil import copyfile

server = MinecraftServer(os.environ['SERVER'], int(os.environ['PORT']))

if os.environ['CUSTOM'] == "TRUE":
copyfile("Custom.py", "lib/custom.py")
import custom

status = server.status()
print("The server has {0} players and replied in {1} ms".format(status.players.online, status.latency))
query = server.query()
@@ -93,7 +98,10 @@
f.close()
msg = "Set " + splitMessage[1] + "'s nickname to " + splitMessage[2]
elif message.content.startswith(prefix):
msg = "That is not a valid command, use ?help for help"
if os.environ['CUSTOM'] == "TRUE":
msg = custom.customCode(message.content, msg)
if msg == "":
msg = "That is not a valid command, use ?help for help"
else:
return
if (message.content == oldcommand) and (message.author == oldauthor):
@@ -1,13 +1,15 @@
def customCode(inputMessage):
def customCode(inputMessage, message):
import os
prefix = os.environ['PREFIX'] #This gets the prefix
if not inputMessage[:len(prefix)]: #Checks to see if the prefix is at the start of the message
return #If it isn't, ignore the rest of the code
return message #If it isn't, ignore the rest of the code
inputMessage = inputMessage[len(prefix):]
'''Do not modify any code above this'''


if message == "example":
if inputMessage == "example":
message = "This is an example of the custom code you can write"
elif message == "example2"
elif inputMessage == "example2":
message = "This is also an example of the custom code you can write"


0 comments on commit 0fc6cc0

Please sign in to comment.
You can’t perform that action at this time.