Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- chat= peripheral.wrap("bottom")
- while true do
- e,sender,input = os.pullEvent("chat")
- word = {}
- jarvCheck = false
- sendCheck
- --converts input into an array and checks the
- --message to make sure it was adressed to jarvis
- for match in string.gmatch(input,"[^%s]+") do
- table.insert(word,match)
- end
- --checking sender is a kalmocorps employee
- for match in string.gmatch(input,"[^%s]+") do
- if string.lower(match) == "jarvis" or "jarv" then
- jarvCheck = true
- break
- end
- end
- if jarvCheck == true then
- file = io.open("perms")
- for line in file:lines() do
- if sender == line then
- sendCheck = true
- break
- end
- end
- end
- if sendCheck == true then
- reply =" "
- print("valid message recieved ".. sender ..":".. input)
- --add replies here, using the word[] array, and reply var
- if reply == " " then reply = "sorry i didnt understand" end
- chat.say("Jarvis: "..reply)
- else
- chat.say("Jarvis: sorry ".. sender .. " you are not permitted to talk to me")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment