Posted 22 April 2012 - 04:11 PM
Before i begin i did not write the bulk of the code it is an adaptation of ComputerCraftFan11's irc program
When i try to run this i get this error
bios:206: [string "irc"]:106: '<eof>' expected
here is the code
if you are wondering what i have added before you have read the code i have attempted to make an auto op system so if youre oped it saves it and when you join it re ops you
hope you can help
When i try to run this i get this error
bios:206: [string "irc"]:106: '<eof>' expected
here is the code
Spoiler
rednet.open("top")
local sFile, sName = "ops.txt", ""
local channel = "";
local user = "";
local ip = os.computerID()
local channelID = 0;
local chatHistory = ""
local messages = 4;
local opmode = false;
local kkmode = false;
local isChatter = false;
local deopmode = false;
local oldUser = ""
--------------------------------------------------
local function cPrint(text)
local x,y = term.getSize()
x2,y2 = term.getCursorPos()
term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
write(text)
end
--------------------------------------------------
--------------------------------------------------
term.clear()
term.setCursorPos(1,1)
-----------------------------------------------------
function status()
print("Status: " ..channel)
print("--------------------------------")
end
-----------------------------------------------------
-----------------------------------------------------
function getops()
if fs.exists(sFile) then
local hRead = assert(fs.open(sFile, "r"))
sName = hRead.readLine()
hRead.close()
else
print("Creating file")
io.open("sFile", "w"):close()
end
end
-----------------------------------------------------
-----------------------------------------------------
function chatbox()
term.clear()
term.setCursorPos(1,1)
status()
print("[" ..channel.. "] "..user.." joined the server!")
term.setCursorPos(1, sizeY)
term.setCursorBlink( true )
while true do
local e, pie, test = os.pullEvent()
if e == "rednet_message" then
if test == "pinged " ..channel then
rednet.send(pie, "chatbox")
else
if(test == "["..channel.."] /op " ..user)then
oldUser = user
user = "@" .. user
isChatter = true
if os.computerID() == 1473 then
fsfile.writeLine(cammy)
hWrite.close()
end
rednet.broadcast("*" ..user.. " is now OP!")
term.setCursorPos(1, messages)
messages = messages +1
print("You are now OP!")
elseif(test == "["..channel.."] /deop " ..user)then
rednet.broadcast("*" ..user.. " is no longer OP!")
user = oldUser
isChatter = false
term.setCursorPos(1, messages)
messages = messages +1
print("You are no longer OP!")
elseif(test == "["..channel.."] /kick " ..user)then
rednet.broadcast("*" ..user.. " left.")
menu()
elseif(test == "["..channel.."] /ls")then
rednet.send(pie, "[List:] " ..user)
end
local x,y = term.getSize()
if messages < y then
term.setCursorPos(1, messages)
messages = messages +1
print(test)
else
term.clear()
term.setCursorPos(1,1)
status()
messages = 3
term.setCursorPos(1, messages)
messages = messages +1
print("test")
end
end
end
end
end
elseif e == "char" then
local x,y = term.getSize()
term.setCursorPos(1,1)
chatHistory = chatHistory.. "" ..pie
term.clearLine()
write(chatHistory)
elseif e == "key" and pie == 28 or pie == 14 then
if pie == 28 then
if chatHistory == "/exit" then
rednet.broadcast("*" ..user.. " left.")
chatHistory = ""
menu()
elseif chatHistory == "/ping" then
term.setCursorPos(1, messages)
messages = messages +1
print("[" ..channel.. "] Pong")
elseif chatHistory == "/help" then
term.setCursorPos(1, messages)
messages = messages +1
if isChatter == true then
print("[" ..channel.. "] Commands: /help, /ping, /exit, /op, /kick, /ls")
else
print("[" ..channel.. "] Commands: /help, /ping, /exit, /ls")
end
else
if isChatter == true then
if opmode == true then
rednet.broadcast("["..channel.."] " ..chatHistory)
term.setCursorPos(1, messages)
messages = messages +1
print("["..channel.."] " ..chatHistory)
elseif kkmode == true then
rednet.broadcast("["..channel.."] " ..chatHistory)
term.setCursorPos(1, messages)
messages = messages +1
print("["..channel.."] " ..chatHistory)
elseif deopmode == true then
rednet.broadcast("["..channel.."] " ..chatHistory)
term.setCursorPos(1, messages)
messages = messages +1
print("["..channel.."] " ..chatHistory)
else
rednet.broadcast("[" ..user.. "] " ..chatHistory)
term.setCursorPos(1, messages)
messages = messages +1
print("[" ..user.. "] " ..chatHistory)
end
else
rednet.broadcast("<" ..user.. "> " ..chatHistory)
term.setCursorPos(1, messages)
messages = messages +1
print("<" ..user.. "> " ..chatHistory)
end
end
end
if chatHistory == "/ls" then
term.setCursorPos(1, messages)
messages = messages +1
print("[List:] " ..user)
rednet.broadcast("["..channel.."] /ls")
end
chatHistory = ""
local x,y = term.getSize()
term.setCursorPos(1, y)
term.clearLine()
opmode = false
kkmode = false
deopmode = false
elseif e == "key" and pie == 57 then
if chatHistory == "/op" or chatHistory == "/op " then
opmode = true
elseif chatHistory == "/kick" or chatHistory == "/kick " then
kkmode = true
elseif chatHistory == "/deop" or chatHistory == "/deop " then
deopmode = true
end
end
end
end
-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
function connector()
term.clear()
term.setCursorPos(1,1)
status()
print("Logging in...")
print(user.. " ["..ip.."] logged in to MJ-IRC!")
print("Connecting to " ..channel.."...")
rednet.broadcast("pinged " ..channel)
id, message = rednet.receive(1)
if message == "chatbox" then
print("Connected! Joining...")
rednet.broadcast("[" ..channel.. "] "..user.." joined the server!")
sleep(0.5)
channelID = id
chatbox()
else
print("Server Does Not Exist... Hosting")
print("Connected! Joining...")
isChatter = true
user = "@" ..user
rednet.broadcast("[" ..channel.. "] "..user.." joined the server!")
sleep(0.5)
channelID = id
chatbox()
end
if os.computerID() == 1473 then
oldUser = user
user = "@" .. user
isChatter = true
else
break
end
end
-----------------------------------------------
-----------------------------------------------
function login()
term.clear()
term.setCursorPos(1,1)
cPrint("NeXuS IRC \n")
cPrint("Nickname: ")
nick = read()
cPrint("Channel: #")
chan = read()
channel = "#" ..chan
user = nick
connector()
end
-----------------------------------------------
-----------------------------------------------
function menu()
term.clear()
term.setCursorPos(1,1)
cPrint("MJ IRC \n \n")
cPrint("1:) Login\n")
cPrint("2:) Exit \n \n")
cPrint("Selection: ")
input = read()
if input == "1" then
login()
elseif input == "2" then
else
menu()
end
end
menu()
if you are wondering what i have added before you have read the code i have attempted to make an auto op system so if youre oped it saves it and when you join it re ops you
hope you can help