Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local msg = ""
- local allow = true
- local messages = {}
- while true do
- local event, key, is_held = os.pullEvent("key")
- term.clear()
- for i=1,#messages do
- ms = messages[i]
- role = ms["role"]
- content = ms["content"]
- term.setCursorPos(1,i)
- if role == "user" then
- term.write("[YOU]"..content)
- else
- term.write("[BOT]"..content)
- end
- end
- term.setCursorPos(1,#messages+1)
- term.write(msg)
- if not is_held then
- if key == 257 then
- local request = http.get("https://keyexternalentropy.kirkashow.repl.co/"..os.computerID().."/ask?text="..msg)
- messages = textutils.unserializeJSON(request.readAll())
- request.close()
- elseif key == 259 then
- msg = string.sub(msg,1,-2)
- elseif #keys.getName(key) == 1 then
- msg = msg..keys.getName(key)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement