Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- pastebin get NQVPiSWZ ourchat-rl
- -- std pb NQVPiSWZ ourchat-rl
- tMess = {}
- tArg = {...}
- scr_x, scr_y = term.getSize()
- playerNames = {} --list of player names to keep track of nicknames
- chat = peripheral.find("chatbox_admin")
- if not chat then
- chat = peripheral.find("chatbox")
- if not chat then
- chat = peripheral.find("chat_box")
- if not chat then
- error("Requires a chatbox.")
- end
- end
- end
- function send(data)
- local a = http.post("http://minechat.x10host.com/index.php?words="..textutils.urlEncode(data))
- return a
- end
- commands = {
- ["me"] = function()
- if string.len(arg1) > 0 then
- send( "* "..playerNames[playername].." "..arg1 )
- else
- chat.tell(playername, "/me <whatever>")
- end
- end,
- ["nick"] = function()
- if not playerNames[playername] then
- playerNames[playername] = playername
- end
- if string.len(arg1) > 0 then
- playerNames[playername] = "'"..arg1.."'"
- send( "* "..playerNames[playername].." is now known as "..arg1 )
- else
- chat.tell(playername, "/nick <newname>")
- end
- end,
- ["help"] = function()
- chat.tell(playername, "Available commands:")
- local sCommands = "*"
- for sCommand, fnCommand in pairs( commands ) do
- sCommands = sCommands .. " ##:" .. sCommand
- end
- chat.tell(playername, sCommands)
- end,
- ["insult"] = function() --the insult command is a very useful utility in making children cry
- insults = {
- "USERNAME can go eat a bag of shiza.",
- "USERNAME is fat and ugly and really, really stupid.",
- "USERNAME is a fat sack o' crap.",
- "If USERNAME was admin...eh, I don't want to think of such things...",
- "No one is more pathetic than USERNAME.",
- "USERNAME is known to suck more than Kirby.",
- "USERNAME was the inspiration of Bubsy 3D.",
- "USERNAME's IQ is his age...times two!",
- "USERNAME's programming skills rival that of the Software Toolworks.",
- "Down with USERNAME, the killer of kings!",
- "USERNAME can go suck it!",
- "Stop being so adversarial, USERNAME!",
- "USERNAME cannot beat Air Man!",
- "USERNAME likes Daikatana and Bubsy.",
- "USERNAME is like King Midas, except with coagulated blood rather than gold.",
- "USERNAME's mother was a hampster, and his father smells of elderberry!",
- "Ni!",
- "USERNAME is a dishonorable Ferrengi p'tach!",
- "Pepperoni is too spicy for USERNAME.",
- }
- send(string.gsub(insults[math.random(1,#insults)],"USERNAME",arg1))
- end,
- ["kill"] = function() --a useless command, I admit. But funny.
- if #arg1 < 1 then
- send(playerNames[playername].." was killed.")
- else
- send(arg1.." was killed.")
- end
- end,
- ["whois"] = function()
- local names = seperateMethods(playerNames)
- for a = 1, #names do
- if names[2] == "'"..arg1.."'" then
- chat.tell(playername, arg1.." is actually '"..names[2].."'")
- break
- end
- end
- end,
- ["id"] = function()
- send(playerNames[playername].." is not a computer.")
- end,
- }
- local function seperateMethods(input)
- output={}
- for key,value in pairs(input) do
- table.insert(output, {key,value})
- end
- return output
- end
- function b()
- while true do
- ev, side, playername, mess = os.pullEvent("chat_message")
- if not playerNames[playername] then
- playerNames[playername] = playername
- end
- local sCommand = string.match( mess, ":([a-z]+)" )
- if sCommand then
- local fnCommand = commands[sCommand]
- if fnCommand then
- if string.find(mess," ") then
- arg1 = string.sub(mess,string.find(mess," ")+1)
- ab = fnCommand(arg1)
- else
- arg1 = ""
- ab = fnCommand()
- end
- if ab == true then
- return true
- end
- else
- chat.tell(playername, "Bad command!")
- end
- else
- fullMess = "<"..playerNames[playername].."> "..mess
- tMess[#tMess+1] = fullMess
- send( fullMess )
- end
- end
- end
- function clearLines(top, bottom)
- for a = top, bottom do
- term.setCursorPos(1,a)
- term.clearLine()
- end
- end
- function a()
- while true do
- local b = http.post("http://minechat.x10host.com/index.php?true=true")
- if b then
- b = b.readAll()
- else
- error("Server not found. :(")
- end
- if (b ~= tMess[#tMess]) and (b ~= fullMess) then
- tMess[#tMess+1] = b
- chat.say(tMess[#tMess])
- end
- end
- end
- function showListofAllNames()
- while true do
- term.clear()
- term.setCursorPos(1,1)
- for a = 1, #tMess do
- print(tMess[a])
- end
- repeat
- oldPlayerNames = playerNames
- sleep(0.5)
- until oldPlayerNames ~= playerNames
- end
- end
- parallel.waitForAny(a, b, showListofAllNames)
- term.setCursorPos(1,1)
- term.clear()
- print("Thank you for using OurChat!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement