Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local modem = peripheral.wrap("right")
- local monitor = peripheral.wrap("top")
- local tArgs = { ... }
- RNPR = shell.getRunningProgram()
- modemC = tonumber(tArgs[1])
- adminPass = tArgs[2]
- serverName = tArgs[3]
- shell.run("clear")
- clientSlot1 = false
- clientSlot2 = false
- clientSlot3 = false
- clientSlot4 = false
- adminSlot1 = false
- clientSlot1Coords = {0, 0, 0}
- clientSlot2Coords = {0, 0, 0}
- clientSlot3Coords = {0, 0, 0}
- clientSlot4Coords = {0, 0, 0}
- clientSlot1Nick = " "
- clientSlot2Nick = " "
- clientSlot3Nick = " "
- clientSlot4Nick = " "
- adminSlot1Nick = " "
- modem.open(2919)
- curr = 0
- totalOpenSlots = 4
- bannedNames = {"Guest", "Bot", "Notch", "Jeb", "Nil", " ", " ", " "}
- Ma_B_N = 4
- Mi_B_N = 9
- R_C_N = 18
- B_B_N = 84
- function modemT(Chn, Str)
- modem.transmit(modemC, tonumber(Chn), Str)
- end
- function mR()
- local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- end
- function drawScreen()
- shell.run("monitor top clear")
- monitor.setCursorPos(1,1)
- monitor.write("Client Slot 1 Nick: "..clientSlot1Nick)
- monitor.setCursorPos(1,2)
- monitor.write("Client Slot 2 Nick: "..clientSlot2Nick)
- monitor.setCursorPos(1,3)
- monitor.write("Client Slot 3 Nick: "..clientSlot3Nick)
- monitor.setCursorPos(1,4)
- monitor.write("Client Slot 4 Nick: "..clientSlot4Nick)
- monitor.setCursorPos(1,5)
- monitor.write("Admin1 Nick: "..adminSlot1Nick)
- monitor.setCursorPos(1, 12)
- monitor.write("Version: IRC Beta "..Ma_B_N.."."..Mi_B_N.."."..R_C_N.."."..B_B_N)
- end
- curr = 1
- function checkNames()
- print("Number: "..curr)
- while curr <= #bannedNames do
- if message == bannedNames[curr] then
- v = 1
- end
- curr = curr + 1
- end
- print("Done")
- end
- drawScreen()
- if #tArgs < 3 then
- print("Usage: "..RNPR.." <port> <adminPassword> <serverName>")
- return
- end
- if modemC > 5999 and modemC < 13968 then
- modem.open(65012)
- modem.transmit(65012, modemC, "ChkChn")
- local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- if message == "chnOpn" then
- modem.open(modemC)
- else
- print("This channel is in use. Press any key to exit.")
- os.pullEvent("char")
- return
- end
- else
- print("Number not in range 6000-7974, 8001-9976, 10001-11962, 12001-13968. Press any key to exit.")
- return
- term.isColour()
- end
- while true do
- print("Startyz")
- if adminSlot1 then
- AO = true
- end
- local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- checkNames()
- if replyChannel == 12123 then
- if v == 0 then
- if clientSlot1 == false then
- clientSlot1Nick = message
- clientSlot1 = true
- modem.transmit(modemC, 1, "/accept")
- modem.transmit(modemC, modemC, "User "..clientSlot1Nick.." has joined.")
- totalOpenSlots = totalOpenSlots - 1
- drawScreen()
- elseif clientSlot2 == false then
- clientSlot2Nick = message
- clientSlot2 = true
- modem.transmit(modemC, 2, "/accept")
- modem.transmit(modemC, modemC, "User "..clientSlot2Nick.." has joined.")
- totalOpenSlots = totalOpenSlots - 1
- drawScreen()
- elseif clientSlot3 == false then
- clientSlot3Nick = message
- clientSlot3 = true
- modem.transmit(modemC, 3, "/accept")
- modem.transmit(modemC, modemC, "User "..clientSlot3Nick.." has joined.")
- totalOpenSlots = totalOpenSlots - 1
- drawScreen()
- elseif clientSlot4 == false then
- clientSlot4Nick = message
- clientSlot4 = true
- modem.transmit(modemC, 4, "/accept")
- modem.transmit(modemC, modemC, "User "..clientSlot4Nick.." has joined.")
- totalOpenSlots = totalOpenSlots - 1
- drawScreen()
- else
- modemT(modemC, "/full")
- end
- elseif v == 1 then
- modemT(modemC, "Banned name attempted connect.")
- else
- modem.transmit(modemC, modemC, "/full")
- end
- elseif replyChannel == 12124 and message == adminPass then
- if adminSlot1 == false then
- local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- adminSlot1 = true
- adminSlot1Nick = message
- modem.transmit(modemC, 5, "/accept")
- drawScreen()
- else
- modem.transmit(modemC, 5, "/ADFull")
- end
- elseif message == "/ping" then
- modem.transmit(2919, modemC, serverName)
- elseif replyChannel == 12125 and AO then
- if message == "1" then
- clientSlot1 = false
- modem.transmit(modemC, modemC, "User "..clientSlot1Nick.." disconnected. [Connection ended.]")
- totalOpenSlots = totalOpenSlots - 1
- clientSlot1Nick = " "
- drawScreen()
- elseif message == "2" then
- clientSlot2 = false
- modem.transmit(modemC, modemC, "User "..clientSlot2Nick.." disconnected. [Connection ended.]")
- totalOpenSlots = totalOpenSlots - 1
- clientSlot2Nick = " "
- drawScreen()
- elseif message == "3" then
- clientSlot3 = false
- modem.transmit(modemC, modemC, "User "..clientSlot3Nick.." disconnected. [Connection ended.]")
- totalOpenSlots = totalOpenSlots - 1
- clientSlot3Nick = " "
- drawScreen()
- elseif message == "4" then
- clientSlot4 = false
- modem.transmit(modemC, modemC, "User "..clientSlot4Nick.." disconnected. [Connection ended.]")
- totalOpenSlots = - 1
- clientSlot4Nick = " "
- drawScreen()
- elseif message == adminPass then
- adminSlot1 = false
- modem.transmit(modemC, modemC, "User "..adminSlot1Nick.." disconnected. [Connection ended.]")
- adminSlot1Nick = " "
- drawScreen()
- else
- end
- elseif replyChannel == 50148 and message == adminPass and AO then
- local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- if message == "/kick" then
- if replyChannel == 1 then
- local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- clientSlot1 = false
- clientSlot1Nick = " "
- modem.transmit(modemC, modemC, "User "..clientSlot1Nick.." disconnected. [User kicked: "..message..".]")
- drawScreen()
- elseif replyChannel == 2 then
- local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- clientSlot2 = false
- clientSlot2Nick = " "
- modem.transmit(modemC, modemC, "User "..clientSlot2Nick.." disconnected. [User kicked: "..message..".]")
- drawScreen()
- elseif replyChannel == 3 then
- local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- clientSlot3 = false
- clientSlot3Nick = " "
- modem.transmit(modemC, modemC, "User "..clientSlot3Nick.." disconnected. [User kicked: "..message..".]")
- drawScreen()
- elseif replyChannel == 4 then
- local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- clientSlot4 = false
- clientSlot4Nick = " "
- modem.transmit(modemC, modemC, "User "..clientSlot4Nick.." disconnected. [User kicked: "..message..".]")
- drawScreen()
- end
- elseif message == "/ban" then
- if replyChannel == 1 then
- clientSlot1 = false
- table.insert(bannedNames, clientSlot1Nick)
- clientSlot1Nick = " "
- modem.transmit(modemC, modemC, "User "..clientSlot1Nick.." foreplyChanneled disconnect. [User banned: "..message..".]")
- drawScreen()
- elseif replyChannel == 2 then
- clientSlot2 = false
- table.insert(bannedNames, clientSlot2Nick)
- clientSlot2Nick = " "
- modem.transmit(modemC, modemC, "User "..clientSlot2Nick.." foreplyChanneled disconnect. [User banned: "..message..".]")
- drawScreen()
- elseif replyChannel == 3 then
- clientSlot3 = false
- table.insert(bannedNames, clientSlot3Nick)
- clientSlot3Nick = " "
- modem.transmit(modemC, modemC, "User "..clientSlot3Nick.." foreplyChanneled disconnect. [User banned: "..message..".]")
- drawScreen()
- elseif replyChannel == 4 then
- clientSlot4 = false
- table.insert(bannedNames, clientSlot4Nick)
- clientSlot4Nick = " "
- modem.transmit(modemC, modemC, "User "..clientSlot4Nick.." foreplyChanneled disconnect. [User banned: "..message..".]")
- drawScreen()
- end
- elseif message == "/restart" then
- h = fs.open("SRestart", "w")
- h.write("shell.run(\""..RNPR.." "..modemC.." "..adminPass.." "..serverName.."\"")
- modemT(5000, "Saving banned names...")
- sleep(2)
- modemT(5000, "Disconnecting users...")
- clientSlot1 = false
- clientSlot1Nick = " "
- clientSlot2 = false
- clientSlot2Nick = " "
- clientSlot3 = false
- clientSlot3Nick = " "
- clientSlot4 = false
- clientSlot4Nick = " "
- modemT(5000, "Disconnected users. Full reboot initializing...")
- shell.run("SRestart")
- return
- elseif message == "/shutdown" then
- modemT(5000, "Saving banned names...")
- sleep(2)
- modemT(5000, "Disconnecting users...")
- clientSlot1 = false
- clientSlot1Nick = " "
- clientSlot2 = false
- clientSlot2Nick = " "
- clientSlot3 = false
- clientSlot3Nick = " "
- clientSlot4 = false
- clientSlot4Nick = " "
- drawScreen()
- modemT(5000, "Disconnected users. Full shutdown initializing...")
- os.shutdown()
- return
- end
- else
- if replyChannel == 1 and clientSlot1 == true then
- modem.transmit(modemC, 1, clientSlot1Nick..": "..message)
- print(clientSlot1Nick..": "..message)
- elseif replyChannel == 2 and clientSlot2 == true then
- modem.transmit(modemC, 2, clientSlot2Nick..": "..message)
- print(clientSlot2Nick..": "..message)
- elseif replyChannel == 3 and clientSlot3 == true then
- modem.transmit(modemC, 3, clientSlot3Nick..": "..message)
- print(clientSlot3Nick..": "..message)
- elseif replyChannel == 4 and clientSlot4 == true then
- modem.transmit(modemC, 4, clientSlot4Nick..": "..message)
- print(clientSlot4Nick..": "..message)
- elseif replyChannel == 65 and adminSlot1 == true and message == adminPass then
- local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- modem.transmit(modemC, 65, adminSlot1Nick..": "..message)
- print(adminSlot1Nick..": "..message)
- elseif replyChannel == 66 and adminSlot2 == true and message == adminPass then
- local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- modem.transmit(modemC, 65, adminSlot2Nick..": "..message)
- print(adminSlot2Nick..": "..message)
- else
- modem.transmit(modemC, modemC, "Unknown entity: "..message)
- print("Unknown entity: "..message)
- end
- end
- replyChannel = 0
- message = " "
- curr = 1
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement