Post by spohnz on Jun 30, 2017 10:56:16 GMT -6
Said I would post what we have so we can start working on her again. Feel free to copy this and test her out in your environment. Change what you want and when you get comfortable with her start adding to her. When you have something you like we can add it to the online kate-bot.
from mine import *
import time
import random
import re
mc=Minecraft.create()
kb = '<Kate>'#kb = for kate-bot
GREETING_KEYWORDS = ("hello", "hi", "greetings", "sup", "morning",'hey')#seems that two words do not work
GREETING_RESPONSES = ["<Kate>'sup PyCrafter", "<Kate>hey", "<Kate>*nods*", "<Kate>Yay PyCraft!!!", 'Oh! hey, how are you?']
KB_NAMES =('kate', 'kbot', '<kate-bot>', 'katebot', 'kate-bot', 'kb','kbot?', '<kate-bot>?', 'katebot?', 'kate-bot?', 'kb?')
KB_RESPONSES = ['...', '<Kate>Yo!!', '<Kate>Can I help you?', '<Kate>yes?', '<Kate>That is my name, do not wear it out.', '<Kate>Hello, I am an on going project built by the students and teachers of PyCraft. Please let us know if we can improve your PyCrafting experience.']
SWEARWORDS = ('*****')
DEPARTURE = ('gtg','gtg bye','got to go','bye','adios')
DEPARTURE_RESPONSE = ['<Kate> Bye! See you later','<Kate> Bye! Ttyl',kb+'Bye! Have a great day!',kb+'Hasta la vista, baby',kb+'go away already:)']
def rules():
mc.postToChat(kb+'http://www.thecodingkids.comg/pycraft-rules')
time.sleep(2)
mc.postToChat(kb+'''Rule #1: No Griefing
You may only touch, build or destroy items that belong to you and that you yourself have built. Griefing will not be tolerated and violators will be banned or temp-banned depending on the extent of damage''')
time.sleep(2)
mc.postToChat(kb+'Rule #2: No Cursing or Swear Words or Offensive Language')
time.sleep(2)
mc.postToChat(kb+'Rule #3: No Sharing Personal Information')
time.sleep(2)
mc.postToChat(kb+'Rule #5: No Sharing Links to Outside websites. PyCraft is a kid-safe Minecraft Server.')
time.sleep(2)
mc.postToChat(kb+'Rule #6: Do not be annoying in Chat')
time.sleep(2)
mc.postToChat(kb+'Rule #7: No Mods or Cheats unless written in Python')
time.sleep(2)
mc.postToChat(kb+'Rule#8: All scripts you write must be submitted and approved before live on the server. Until you are approved for a security key to run your scripts live.')
time.sleep(2)
def greeting():
fsplit = f.split()
for word in fsplit:
if word.lower() in GREETING_KEYWORDS:
return mc.postToChat(random.choice(GREETING_RESPONSES))
def KB():
if f.lower() in KB_NAMES:
return mc.postToChat(random.choice(KB_RESPONSES))
def depart():
if f.lower() in DEPARTURE:
return mc.postToChat(random.choice(DEPARTURE_RESPONSE))
def swear():
fsplit = f.split()
for word in fsplit:
if word.lower() in SWEARWORDS:
return mc.postToChat('The word '+word+' is against the rules to say. This event log is being emailed to support@thecodingkids.com')
def SEARCH_FOR_WORD_RULES():
fsplit = f.split()
for word in fsplit:
if word.lower() =='rules':
return rules()
#MAIN LOOP
while True:
try:
chat = mc.events.pollChatPosts()#Gets the chat from server
if len(str(chat)) > 23:#verify that it has characters and not a blank poll
ncha=str(chat)#think it is a list, turned into string
a = ncha[27:]#removes [ChatEvent(ChatEvent.POST, from [ChatEvent
b = a[:-2]#removes the end 2 characters = )]
c = b.split(',')
d=c.pop(0)
e=''.join(c)
f=(e[1:])
if str(f) == swear():
swear()
if str(f) == SEARCH_FOR_WORD_RULES():
SEARCH_FOR_WORD_RULES()
if f == greeting():
greeting()
if str(f) == KB():
time.sleep(2)
KB()
if str(f) == depart():
time.sleep(2)
depart()
# if 'thanks' or 'thank you' in f:
# mc.postToChat('<Kate>You are welcome!')
if str(f) == '*sigh*':
time.sleep(2)
mc.postToChat('<Kate>Aww, are you bored?')
if str(f) == '...':
time.sleep(2)
mc.postToChat('<Kate>The ellipsis can consist of either three or four periods, or "dots." A single dot is called an ellipsis point. An ellipsis that indicates the omission of one or more words within a sentence consists of three spaced dots.')
if str(f) == 'help':
mc.postToChat('<Kate>Hello, If you need immediate help, please email support@thecodingkids.com')
time.sleep(2)
mc.postToChat('<Kate>To see a list of scripts you can run, type /py <tab> twice, To run a script like melon type /py melon')
if f == 'server':
mc.postToChat('<Kate>Server is probably not at her desk at this time, may I take a message?')
if 'i need' in f:
mc.postToChat(kb+'Have you looked for'+f[6:]+', Possibly learn some python and make what you would need on the fly. It is as easy as opening a Python shell')
time.sleep(2)
mc.postToChat(kb+'Getting the software installed is easy.')
time.sleep(2)
mc.postToChat(kb+'Getting a security key is easy')
time.sleep(2)
mc.postToChat(kb+'knowing how to script what you want on the fly.....')
time.sleep(4)
mc.postToChat(kb+'Priceless!!!!!!')
#TestingArea
if str(f) == 'time':
t=time.ctime()
mc.postToChat(t)
print(f)
time.sleep(2)
else:
continue
except:
time.sleep(5)
continue