Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = { ... }
- local passwordread
- local function clear()
- term.clear()
- term.setCursorPos(1, 1)
- end
- function findModem()
- for _, v in pairs( rs.getSides() ) do
- if peripheral.isPresent( v ) and peripheral.getType( v ) == "modem" then
- rednet.open(v)
- end
- end
- end
- if #tArgs < 1 then
- clear()
- term.setTextColor(colors.white)
- print("Usage: ")
- print("email create")
- print("email send")
- print("email download")
- print("email delete")
- print("email admin")
- print("email update")
- term.setTextColor(colors.white)
- return
- end
- local Args = shell.resolve( tArgs[1] )
- if Args == "create" then
- term.clear()
- term.setCursorPos(1, 1)
- term.setTextColor(colors.lightBlue)
- print("ComputerCraft Email Setup")
- write("New Username: ")
- UserName = read().."@Cc.com"
- print()
- write("New Password: ")
- pass1 = read("*")
- print()
- write("Repeat Password: ")
- pass2 = read("*")
- if pass1 == pass2 then
- if fs.exists("/disk/"..UserName) then
- clear()
- term.setTextColor(colors.red)
- print("The email address "..UserName.." is in use!")
- term.setTextColor(colors.white)
- return
- end
- w = fs.open("/disk/"..UserName, "w")
- w.writeLine(pass1)
- w.writeLine(os.getComputerID())
- w.close()
- print()
- clear()
- term.setTextColor(colors.green)
- print("Successfully created "..UserName.."!")
- term.setTextColor(colors.white)
- os.sleep(3)
- os.reboot()
- else
- clear()
- term.setTextColor(colors.red)
- print("The password did not match!")
- term.setTextColor(colors.white)
- return
- end
- elseif Args == "send" then
- term.setTextColor(colors.yellow)
- print("If you're stuck here press and hold CTRL + R to reboot your pc (this error can be caused by an network error).")
- findModem()
- rednet.broadcast("getid")
- id, msg = rednet.receive()
- clear()
- term.setTextColor(colors.lightBlue)
- print("ComputerCraft Email Sender")
- print("Please login with your email account")
- print()
- write("Email Address: ")
- mail = read()
- print()
- if not fs.exists("/disk/"..mail) then
- clear()
- term.setTextColor(colors.red)
- print("Email Address is not valid!")
- term.setTextColor(colors.white)
- return
- elseif mail == nil or mail == "" then
- clear()
- term.setTextColor(colors.red)
- print("Email Address is not valid!")
- term.setTextColor(colors.white)
- return
- end
- write("Password: ")
- pass = read("*")
- print()
- r = fs.open("/disk/"..mail, "r")
- passwordread = r.readLine()
- r.close()
- if pass ~= passwordread then
- clear()
- term.setTextColor(colors.red)
- print("The password is incorrect!")
- term.setTextColor(colors.white)
- return
- end
- clear()
- write("Receiver Email Address: ")
- sendmail = read()
- print()
- print("Message to "..sendmail.." (Type ^Z to end the message)")
- local Message = {}
- local lenght
- local nownr
- nownr = 1
- local nr
- nr = 1
- while true do
- messagesend = read()
- if messagesend == "^Z" then
- rednet.send(id, "receive")
- os.sleep(.5)
- rednet.send(id, sendmail)
- os.sleep(.5)
- rednet.send(id, "receive2")
- os.sleep(0.2)
- rednet.send(id, mail)
- lenght = table.getn(Message)
- while nownr ~= lenght + 1 do
- os.sleep(0.1)
- rednet.send(id, Message[nownr])
- nownr = nownr + 1
- end
- rednet.send(id, "end8765432190")
- clear()
- term.setTextColor(colors.green)
- print("The email has been sent to "..sendmail..".")
- term.setTextColor(colors.white)
- return
- else
- Message[nr] = messagesend
- nr = nr + 1
- end
- end
- elseif Args == "download" then
- term.setTextColor(colors.yellow)
- print("If you're stuck here press and hold CTRL + R to reboot your pc (this can be caused by an network error).")
- findModem()
- rednet.broadcast("getid")
- id, msg = rednet.receive()
- clear()
- term.setTextColor(colors.lightBlue)
- print("ComputerCraft Email Download")
- print("Please login with your email account to download your mail")
- print()
- write("Email Address: ")
- mail = read()
- print()
- if not fs.exists("/disk/"..mail) then
- clear()
- term.setTextColor(colors.red)
- print("Email Address is not valid!")
- term.setTextColor(colors.white)
- return
- elseif mail == nil or mail == "" then
- clear()
- term.setTextColor(colors.red)
- print("Email Address is not valid!")
- term.setTextColor(colors.white)
- return
- end
- write("Password: ")
- pass = read("*")
- print()
- r = fs.open("/disk/"..mail, "r")
- passwordread = r.readLine()
- r.close()
- if pass ~= passwordread then
- clear()
- term.setTextColor(colors.red)
- print("The password is incorrect!")
- term.setTextColor(colors.white)
- return
- end
- rednet.send(id, "receive")
- os.sleep(0.5)
- rednet.send(id, mail)
- os.sleep(0.5)
- rednet.send(id, "download")
- o = fs.open("mail", "w")
- id, mailmsg = rednet.receive()
- o.writeLine(mailmsg)
- o.close()
- x = fs.open("/disk/startup", "w")
- x.writeLine('fs.delete("/mail")')
- x.writeLine('fs.delete("/disk/startup")')
- x.close()
- shell.run("edit mail")
- term.setTextColor(colors.green)
- print("The mail has been read!")
- os.sleep(3)
- os.reboot()
- elseif Args == "delete" then
- term.clear()
- term.setCursorPos(1, 1)
- term.setTextColor(colors.lightBlue)
- print("ComputerCraft Email Remove")
- print("Please login with your email account to delete it")
- print()
- write("Email Address: ")
- mail = read()
- print()
- if not fs.exists("/disk/"..mail) then
- clear()
- term.setTextColor(colors.red)
- print("Email Address is not valid!")
- term.setTextColor(colors.white)
- return
- elseif mail == nil or mail == "" then
- clear()
- term.setTextColor(colors.red)
- print("Email Address is not valid!")
- term.setTextColor(colors.white)
- return
- end
- write("Password: ")
- pass = read("*")
- print()
- r = fs.open("/disk/"..mail, "r")
- passwordread = r.readLine()
- r.close()
- if pass ~= passwordread then
- clear()
- term.setTextColor(colors.red)
- print("The password is incorrect!")
- term.setTextColor(colors.white)
- return
- end
- if string.lower(mail) == "admin@cc.com" then
- term.setTextColor(colors.red)
- print("You cannot delete the admin account!")
- term.setTextColor(colors.white)
- return
- end
- clear()
- term.setTextColor(colors.red)
- print("Are you sure with the removal of the account "..mail.."? [Yes/No]")
- answ = read()
- if string.lower(answ) == "yes" then
- clear()
- term.setTextColor(colors.green)
- print(mail.." has been removed!")
- os.sleep(3)
- writer = fs.open("/startup", "w")
- writer.writeLine('fs.delete("/disk/'..mail..'")')
- writer.writeLine('fs.delete("startup")')
- writer.close()
- os.reboot()
- else
- clear()
- end
- elseif Args == "admin" then
- term.clear()
- term.setCursorPos(1, 1)
- term.setTextColor(colors.yellow)
- print("ComputerCraft Email Admin")
- print("Please login with your admin account")
- print()
- write("Email Address: ")
- mail = read()
- print()
- if not fs.exists("/disk/"..mail) then
- clear()
- term.setTextColor(colors.red)
- print("Email Address is not valid!")
- term.setTextColor(colors.white)
- return
- elseif mail == nil or mail == "" then
- clear()
- term.setTextColor(colors.red)
- print("Email Address is not valid!")
- term.setTextColor(colors.white)
- return
- end
- write("Password: ")
- pass = read("*")
- print()
- r = fs.open("/disk/"..mail, "r")
- passwordread = r.readLine()
- typ = r.readLine()
- r.close()
- if pass ~= passwordread or typ ~= "admin" then
- clear()
- term.setTextColor(colors.red)
- print("The password is incorrect or the type is invalid!")
- term.setTextColor(colors.white)
- return
- end
- clear()
- term.setTextColor(colors.yellow)
- print("ComputerCraft Email Admin")
- while true do
- term.setTextColor(colors.yellow)
- write("> ")
- term.setTextColor(colors.white)
- cmd = read()
- if cmd == "help" then
- print("Available commands: ")
- print("help")
- print("delete")
- print("list")
- print("clear")
- print("exit")
- elseif cmd == "send" then
- term.setTextColor(colors.red)
- print("This command is available in non-admin mode!")
- elseif cmd == "create" then
- term.setTextColor(colors.red)
- print("This command is available in non-admin mode!")
- elseif cmd == "download" then
- term.setTextColor(colors.red)
- print("This command is available in non-admin mode!")
- elseif cmd == "update" then
- term.setTextColor(colors.red)
- print("This command is available in non-admin mode!")
- elseif cmd == "admin" then
- term.setTextColor(colors.red)
- print("Admin mode is already active!")
- elseif cmd == "delete" then
- clear()
- term.setTextColor(colors.yellow)
- print("Admin credentials")
- print()
- write("Email Address: ")
- mail = read()
- print()
- if not fs.exists("/disk/"..mail) then
- clear()
- term.setTextColor(colors.red)
- print("Email Address is not valid!")
- term.setTextColor(colors.white)
- return
- elseif mail == nil or mail == "" then
- clear()
- term.setTextColor(colors.red)
- print("Email Address is not valid!")
- term.setTextColor(colors.white)
- return
- end
- write("Password: ")
- pass = read("*")
- print()
- r = fs.open("/disk/"..mail, "r")
- passwordread = r.readLine()
- typ = r.readLine()
- r.close()
- if pass ~= passwordread or typ ~= "admin" then
- clear()
- term.setTextColor(colors.red)
- print("The password is incorrect or the type is invalid!")
- term.setTextColor(colors.white)
- return
- end
- clear()
- term.setTextColor(colors.red)
- print("ComputerCraft Admin Email Account Remover")
- print("YOU WILL NOT BE ASKED FOR CONFIRMATION!")
- print()
- write("Email Address: ")
- term.setTextColor(colors.white)
- mailadr = read()
- if string.lower(mailadr) == "admin@cc.com" then
- term.setTextColor(colors.red)
- print("This account cannot be deleted!")
- elseif fs.exists("/disk/"..mailadr) then
- fs.delete("/disk/"..mailadr)
- term.setTextColor(colors.green)
- print(mailadr.." has been deleted.")
- else
- term.setTextColor(colors.red)
- print("This account doesn't exist!")
- end
- elseif cmd == "exit" then
- os.reboot()
- elseif cmd == "clear" then
- clear()
- elseif cmd == "list" then
- term.setTextColor(colors.lime)
- print("List of email accounts: ")
- term.setTextColor(colors.blue)
- for i = 1, table.getn(fs.list("/disk")) do
- if fs.list("/disk")[i] ~= "email" and fs.list("/disk")[i] ~= "install" then
- print(fs.list("/disk")[i])
- end
- end
- else
- term.setTextColor(colors.red)
- print("No such command")
- end
- end
- elseif Args == "update" then
- clear()
- term.setTextColor(colors.lightBlue)
- print("ComputerCraft Email Updater")
- print("Creating backup folder...")
- os.sleep(.3)
- fs.makeDir("/temp")
- print("Moving program to backup folder...")
- if fs.exists("/email") then
- os.sleep(0.1)
- fs.move("email", "/temp/email")
- end
- print("Downloading and installing new program...")
- os.sleep(0.5)
- shell.run("pastebin", "get Z5UQsBGd /email")
- print("Finalizing...")
- os.sleep(1.5)
- if fs.exists("/email") then
- fs.delete("/temp/email")
- fs.delete("/temp")
- term.setTextColor(colors.green)
- print("Update Completed")
- os.sleep(3)
- clear()
- shell.run("email", "firstuse")
- else
- term.setTextColor(colors.red)
- print("Finalizing failed!")
- term.setTextColor(colors.white)
- fs.move("/temp/email", "email")
- fs.delete("/temp")
- end
- elseif Args == "firstuse" then
- term.setTextColor(colors.white)
- print("All email commands")
- print()
- print("email create -- creates a mail account")
- print("email send -- send a mail")
- print("email download -- receive your mails")
- print("email delete -- delete your mail account")
- print("email admin -- admin only!")
- print("email update -- updates the program")
- else
- term.setTextColor(colors.red)
- print("Usage: ")
- print("email create")
- print("email send")
- print("email download")
- print("email delete")
- print("email admin")
- print("email update")
- term.setTextColor(colors.white)
- return
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement