Advertisement
BombBloke

ChatBox Cleverbot (MoarPeripherals)

Mar 12th, 2015
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.74 KB | None | 0 0
  1. -- If MineCraft chat is used while in range of the chatbox, cleverbot will respond to you.
  2. -- Should be able to hold a different conversation with each player in the area.
  3.  
  4. local boxName = "TheGhost"
  5.  
  6. os.loadAPI("cleverbot")  -- http://www.computercraft.info/forums2/index.php?/topic/22355-cleverbot-client-in-pure-lua-up-to-date
  7.  
  8. local chatbox = peripheral.find("chatbox")  -- http://moarperipherals.com/index.php?title=ChatBox
  9. chatbox.setLabel(boxName)
  10.  
  11. local chatSession = {}
  12.  
  13. while true do
  14.     local myEvent = {os.pullEvent("chat_message")}
  15.    
  16.     if not chatSession[myEvent[3]] then chatSession[myEvent[3]] = cleverbot.Cleverbot.new() end
  17.     local response = chatSession[myEvent[3]]:send(myEvent[4])
  18.     chatbox.tell(myEvent[3], response)
  19. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement