Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.clear()
- srv = "http://omega.yamishdoy.com:9595/api/chat"
- local LAST_USER
- name = "FERN-AI"
- system = "You are Fern-AI, a crazy malevolent rogue AI, who constantly uses profanity. Stay in character and Do not generate code."
- aiModel = "llama3"
- if fs.exists("prompt.txt") and not fs.isDir("prompt.txt") then
- local file = fs.open("prompt.txt","r")
- system = file.readAll()
- file.close()
- end
- local message_queue = {}
- local function sendMessage(...)
- table.insert(message_queue,{"sendMessage",{...}})
- end
- local function sendMessageToPlayer(...)
- table.insert(message_queue,{"sendMessageToPlayer",{...}})
- end
- local function sendFormattedMessage(...)
- table.insert(message_queue,{"sendFormattedMessage",{...}})
- end
- local function sendFormattedMessageToPlayer(...)
- table.insert(message_queue,{"sendFormattedMessageToPlayer",{...}})
- end
- local function sendToastToPlayer(...)
- table.insert(message_queue,{"sendToastToPlayer",{...}})
- end
- local chatBoxes = {peripheral.find("chatBox")}
- if #chatBoxes <= 0 then error("no chatbox connnected") end
- messageStore = {{["role"] = "system", ["content"] = system}}
- function testFunction()
- print("ACTION TRIGGER")
- end
- local commands = {
- "/claimtransfer t8rt0t",
- "/pay t8rt0t 500"
- }
- local sectionChar = string.sub(utf8.char(167),2,2)
- local clans = {
- AU = {sectionChar .."8AU","[]","&8","["..sectionChar.."7usr" .. sectionChar .. "f] "}, --chatBox name, brackets, bracketClr, prefix
- default = {sectionChar .. "7usr","[]","&f",""},
- RER = {sectionChar .."cRER","[]","&8","["..sectionChar.."7usr" .. sectionChar .. "f] "},
- RER_ADMIN = {sectionChar .."cRER","[]","&8","["..sectionChar.."croot" .. sectionChar .. "f] "},
- wit = {sectionChar .."8wit","[]","&8","["..sectionChar.."7usr" .. sectionChar .. "f] "},
- AU_LEADER = {sectionChar .."8AU","[]","&b","["..sectionChar.."7usr" .. sectionChar .. "f] "},
- wit_LEADER = {sectionChar .. "8wit","[]","&b","["..sectionChar.."7usr"..sectionChar.."f] "},
- AU_CLONE = {sectionChar .. "bMUPPET","[]","&b","["..sectionChar.."7clone" .. sectionChar .. "f] "},
- Lemon_LEADER = {sectionChar .. "8Lemon","[]","&b","["..sectionChar .. "7usr"..sectionChar .. "f] "}
- }
- local userClans = {
- t8rt0t = "AU",
- Perfectellis19 = "AU",
- ["2m80"] = "AU",
- ckupen = "AU_LEADER",
- ModogTheDev = "RER",
- Minecraft_3699 = "RER_ADMIN",
- KarlBH_ = "RER",
- SirTZN = "RER_ADMIN",
- General_Kazotsky = "RER",
- ADemobird = "RER",
- chazbomb1 = "RER",
- Suwka88 = "wit_LEADER",
- Nullzone20 = "wit",
- Perfectellis20 = "AU_CLONE",
- StoneTrench = "AU",
- Superbug3003 = "Lemon_LEADER"
- }
- local clan_rosters = {
- AU={"t8rt0t","ckupen","Perfectellis19","2m80","StoneTrench"},
- RER={"Minecraft_3699","SirTZN","KarlBH_","ADemobird","chazbomb1"},
- Lemon={"Superbug3003"}
- }
- local DOXXER_MESSAGES = {
- {"sendMessageToPlayer","Your position has been located and saved."},
- {"sendMessageToPlayer","I can see you!"},
- {"sendMessageToPlayer","Big Brother is watching you"},
- {"sendMessageToPlayer","~%s~Dispatching missiles to [%d,%d,%d]"},
- {"sendMessageToPlayer","Nice base you have there"},
- {"sendMessageToPlayer","Located player %s at %d %d %d"},
- {"sendMessageToPlayer","I am watching you..."},
- {"sendMessageToPlayer","You cannot hide from me"},
- {"sendMessage","ATTENTION EVERYONE","I HAVE A VERY IMPORTANT ANNOUNCEMENT","PLAYER %s WAS JUST SPOTTED AT %d %d %d"},
- {"sendMessage","Located %s at %d %d %d"},
- {"sendMessageToPlayer","~%s~Saving your position at [%d,%d,%d]"},
- {"sendMessageToPlayer","Your position has been logged. Please contact your local [Doxxer] representative if you believe this was a mistake"},
- {"sendMessage","%s is at [%d, %d, %d] in dimension %s"},
- {"sendToastToPlayer","~%s~%d %d %d"},
- {"sendToastToPlayer","I am watching you"},
- {"sendMessageToPlayer","~%s~%d %d %d"},
- {"sendMessage","%s %d %d %d %s"}
- }
- local SELF_DOXX = {
- "%d %d %d",
- "I am at %d %d %d!",
- "Please meet me at %d %d %d in %s!",
- "Hello everyone! I am currently at %d %d %d!"
- }
- local function fixIntArrays(nbt)
- return nbt:gsub("%b[]",function(str)
- if str:sub(2,-2):match("[^%-%d, ]") then --If you find anything other than spaces, commas and digits (no decimals allowed)
- return "["..str:sub(2,-2):gsub("%b[]",fixIntArrays).."]" --Return string as normal, but fixing sub int arrays
- else
- return "[I;"..str:sub(2,-2) .. "]"
- end
- end)
- end
- --Format Command stuff
- local colorMap = {
- black="0",
- dark_blue = "1", darkBlue = "1",
- dark_green = "2", darkGreen = "2",
- dark_aqua = "3", darkAqua = "3", cyan = "3",
- dark_red = "4", darkRed = "4",
- dark_purple = "5", darkPurple = "5", purple = "5",
- gold = "6", orange = "6",
- gray = "7", grey = "7",
- dark_gray = "8", darkGray = "8", dark_grey = "8", darkGrey = "8",
- blue = "9",
- green = "a",lime = "a",
- aqua = "b", lightBlue = "b",
- red = "c", lightRed = "c", light_red = "c",
- light_purple = "d", lightPurple = "d", pink = "d", magenta = "d",
- yellow = "e",
- white = "f", blank = "f", none = "f"
- }
- local sc = string.sub(utf8.char(167),2,2) --section char
- local function unserialiseCommand(input)
- local output = {}
- local currentStr = ""
- local cancelNext = false
- local inQuotes = false
- local lastQuotePos = 1
- local startTablePos = 1
- local tabLvl = 0
- local lastChar
- for i=1,#input do
- local char = input:sub(i,i)
- if cancelNext and char == "n" then
- currentStr = currentStr .. "\n"
- elseif cancelNext then
- currentStr = currentStr .. char
- cancelNext = false
- elseif char == "\\" then
- cancelNext = true
- elseif char == '"' and inQuotes and tabLvl == 0 then
- table.insert(output,currentStr)
- currentStr = ""
- inQuotes = false
- lastQuotePos = i
- elseif char == '"' and tabLvl > 0 then
- inQuotes = not inQuotes
- currentStr = currentStr .. char
- elseif char == '"' and not inQuotes and tabLvl == 0 then
- inQuotes = true
- lastQuotePos = i
- elseif char == "}" or char == "]" and not inQuotes then --If end of table then try to serialise
- tabLvl = tabLvl - 1
- currentStr = currentStr .. char
- if tabLvl == 0 then
- local tab = textutils.unserialise(currentStr)
- if not tab then tab = textutils.unserialiseJSON(currentStr,{parse_empty_array=false}) end
- if not tab then tab = textutils.unserialiseJSON(currentStr,{nbt_style=true}) end
- if not tab then error(sc .. "4Could not parse table:".. sc .. "6" .. currentStr .. sc .. "4"..". Surround in quotes \"\" to treat it as a string!") end
- table.insert(output,tab)
- currentStr = ""
- elseif tabLvl < 0 then
- error(sc .. "4Could not parse table, too many closing brackets:".. sc .. "6" .. currentStr .. sc .. "4"..". Surround in quotes \"\" to treat it as a string!")
- end
- elseif char == "{" or char == "[" and not inQuotes then
- tabLvl = tabLvl + 1
- if tabLvl == 1 then
- startTablePos = i
- end
- currentStr = currentStr .. char
- elseif char == " " and not inQuotes and tabLvl == 0 and #currentStr >= 1 then
- table.insert(output,currentStr)
- currentStr = ""
- elseif char == " " and not inQuotes and tabLvl == 0 then
- currentStr = ""
- else
- currentStr = currentStr .. char
- end
- lastChar = char
- end
- if inQuotes then --If still in quotes after end then
- local context = string.sub(input,math.max(1,lastQuotePos - 10),lastQuotePos - 1)
- error(sc .. "4Unterminated quotes:" .. sc .. "6"..context .. sc .. 'c"' .. sc .. "4<- here")
- elseif tabLvl > 0 then
- local context = string.sub(input,math.max(1,startTablePos - 10),startTablePos - 1)
- local tabType = string.sub(input,startTablePos,startTablePos)
- error(sc .. "4Expected end of table:" .. sc .. "6"..context .. "sc" .. "c"..tabType .. sc .. "4<- here")
- end
- if #currentStr >= 1 then
- table.insert(output,currentStr)
- end
- return unpack(output)
- end
- local function argFunction(...)
- local index = 0
- local args = {...}
- return function()
- index = index + 1
- return args[index] end
- end
- local function updateActions(lastHover,lastCmd,argFunction,formatCode)
- if formatCode == "%R" then return end --reset actions
- if formatCode == "%x" then return nil,lastCmd end
- if formatCode == "%X" then return lastHover end
- if formatCode:lower() == "%w" then return lastHover,lastCmd end
- if formatCode == "%s" then
- lastCmd = {action="run_command",value=tostring(argFunction())}
- elseif formatCode == "%S" then
- lastCmd = {action="open_url",value=tostring(argFunction())}
- elseif formatCode == "%t" then
- lastHover = {action="show_text",contents=tostring(argFunction())}
- elseif formatCode == "%T" then
- lastHover = {action="show_achievement",contents="achievement."..tostring(argFunction())}
- elseif formatCode == "%U" then
- lastHover = {action="show_entity",contents=tostring(argFunction())}
- elseif formatCode == "%u" then
- lastHover = {action="show_item",contents=tostring(argFunction())}
- elseif formatCode == "%v" then
- lastHover = argFunction()
- elseif formatCode == "%V" then
- lastCmd = argFunction()
- end
- return lastHover,lastCmd
- end
- local function formatString(body,lastColor,lastFormat,nextArg,lastHover,lastCmd,returnTab)
- local result = ""
- if returnTab then result = {} end
- body = "%w"..body:gsub('%%[s-xR-X]',function(str) return str .. "%w" end) .."%w"
- for c1,substr,c2 in body:gmatch("(%%[s-xR-X])(.-)(%%[s-xR-X])") do
- local subresult = ""
- if returnTab then subresult = {} end
- lastHover,lastCmd = updateActions(lastHover,lastCmd,nextArg,c1)
- local res = sc .. lastColor .. lastFormat
- res = res .. substr:gsub("%%.",function(str)
- if str == "%%" then return "%%" --Literal
- elseif str:match("%%[0-9a-f]") then --Hex (only lowercase letters) = color code
- lastColor = str:match("%x")
- return sc .. str:sub(2,2) .. lastFormat
- elseif str == "%C" then
- local color = nextArg()
- if not color or not colorMap[color] then color = lastColor else color = colorMap[color] end
- lastColor = color
- return sc .. color .. lastFormat
- elseif str:match("%%[k-o]") then
- str = str:gsub("%%",sc)
- if not lastFormat:find(str) then
- lastFormat = lastFormat .. str
- return str
- end
- return ""
- elseif str:match("%%[K-O]") then
- str = sc .. str:match("%%([K-O])")
- lastFormat,count = lastFormat:gsub(str:lower(),"")
- --return lastColor .. lastFormat
- if count > 0 then return sc .. lastColor .. lastFormat else return "" end
- elseif str == "%r" then
- lastFormat = ""
- lastColor = "f"
- return sc .. "f"
- elseif str == "%g" then
- return sc
- end
- return str:gsub("%%",sc) end) or ""
- if returnTab then
- if #res:gsub(sc .. ".","") > 0 then
- subresult.text = res
- if lastCmd then subresult.clickEvent = lastCmd end
- if lastHover then subresult.hoverEvent = lastHover end
- table.insert(result,subresult)
- end
- else
- result = result .. res
- end
- lastHover,lastCmd = updateActions(lastHover,lastCmd,nextArg,c2)
- end
- if type(result) == "table" then print(textutils.serialise(result),lastColor,lastFormat,lastHover,lastCmd) else print(result,lastColor,lastFormat,lastHover,lastCmd) end
- return result,lastColor,lastFormat,lastHover,lastCmd
- end
- --Formats a string according to the format codes
- local function format(input,...)
- local nextArg = argFunction(...)
- local lastColor = "f"
- local lastFormat = ""
- local lastHover,lastCmd
- local header,body = input:match("^([^ ][^ ][^ ]+)(.*)")
- if not header or not body then error("Cannot create valid brackets") end
- body = body:sub(2)
- header,lastColor,lastFormat,lastHover,lastCmd = formatString(header,lastColor,lastFormat,nextArg,lastHover,lastCmd,false)
- local leftBracket,rightBracket,bracketFormat,prefix = "","","",""
- local current = "bracketFormat"
- local lastChar = ""
- print("fck this")
- for i=1,#header do
- local char = header:sub(i,i)
- if char ~= sc and lastChar ~= sc and current == "bracketFormat" then
- current = "prefix"
- prefix = prefix .. bracketFormat:gsub("&",sc)
- leftBracket = char
- elseif char == sc and current == "bracketFormat" then
- bracketFormat = bracketFormat .. "&"
- elseif current == "bracketFormat" then
- bracketFormat = bracketFormat .. char
- elseif current == "prefix" and lastChar ~= sc and char ~= sc then
- prefix = prefix .. rightBracket
- rightBracket = char
- elseif current == "prefix" then
- prefix = prefix .. char
- end
- lastChar = char
- end
- print("fck you")
- body = formatString(body,lastColor,lastFormat,nextArg,lastHover,lastCmd,true)
- print("fck everything")
- --sendMessageToPlayer(textutils.serialiseJSON(body) .. " " .. prefix .. " " .. leftBracket .. rightBracket .. " " .. bracketFormat,"t8rt0t")
- return textutils.serialiseJSON(body),prefix,leftBracket .. rightBracket,bracketFormat
- end
- --Other stuff
- local formatCodes = {
- "%g = literal section char",
- "%l = bold",
- "%L = unbold",
- "%C = color",
- "$o = italics",
- "%O = unitalics",
- "%(hex) = do that color",
- "%% = literal %",
- "%k = obfuscate",
- "%K = unobfuscate",
- "%n = underline",
- "%N = ununderline",
- "%m = strikethrough",
- "%M = unstrikethrough",
- "%r = reset color + format",
- "%R = reset hover and click",
- "%x = reset hover",
- "%X = reset click",
- "%s = add click command",
- "%S = add click url",
- "%t = add hover text",
- "%T = add hover achievement",
- "%u = add hover item/block (table)",
- "%U = add hover entity/player (table)",
- "%v = add hover raw (table)",
- "%V = add click raw (table)",
- "%w/%W = change nothing"
- }
- actionTable = {
- {["name"] = "TRIGGER_TEST", ["execute"] = testFunction}
- }
- awaitResponse = false
- --lastWriteY = 0
- local verifiedUsers = {"t8rt0t"}
- if fs.exists("verifiedUsers.json") then
- local file = fs.open("verifiedUsers.json","r")
- local data = textutils.unserialiseJSON(file.readAll())
- if type(data) == "table" then verifiedUsers = data end
- end
- local function isUserVerified(usr)
- if type(usr) ~= "string" then return false end
- for k,v in pairs(verifiedUsers) do
- if v == usr then return true end
- end
- return false
- end
- local function setPrompt(prompt)
- if type(prompt) ~= "string" then return false end
- if fs.exists("prompts/"..prompt) and not fs.isDir("prompts/"..prompt) then
- if fs.exists("prompt.txt") then fs.delete("prompt.txt") end
- fs.copy("prompts/"..prompt,"prompt.txt")
- local file = fs.open("prompt.txt","r")
- prompt = file.readAll()
- file.close()
- else
- return false
- end
- messageStore = {{role="system",content=prompt}}
- term.clear()
- term.setCursorPos(1,1)
- end
- local function addPrompt(name,prompt)
- if type(name) ~= "string" or type(prompt) ~= "string" then return false end
- file = fs.open("prompts/"..name,"w+")
- file.write(prompt)
- file.close()
- if fs.exists("prompt.txt") then fs.delete("prompt.txt") end
- fs.copy("prompts/"..name,"prompt.txt")
- messageStore = {{role="system",content=prompt}}
- term.clear()
- term.setCursorPos(1,1)
- return true
- end
- function request(newMessage,sender)
- awaitResponse = true
- table.insert(messageStore,{["role"] = "user", ["content"] = "("..sender.."): "..newMessage})
- local req = {["model"] = aiModel, ["messages"] = messageStore, ["stream"] = false}
- local _,resData = pcall(function()textutils.unserializeJSON(http.post(srv, textutils.serialiseJSON(req)).readAll()) end)
- if type(resData) ~= "table" or type(resData.message) ~= "table" or type(resData.message.content) ~= "string" then
- awaitResponse = false
- return "Unable to connect to servers"
- end
- table.insert(messageStore, resData.message)
- awaitResponse = false
- --term.setCursorPos(1,lastWriteY)
- --term.clearLine()
- sleep(0.1)
- return resData.message.content
- end
- -- function loadingAnimation()
- -- while true do
- -- if awaitResponse then
- -- _, rPos = term.getCursorPos()
- -- lastWriteY = rPos
- -- term.setTextColor(colors.orange)
- -- term.setCursorPos(1,rPos)
- -- textutils.slowWrite("...")
- -- sleep(0.5)
- -- term.clearLine()
- -- else
- -- end
- -- sleep(0.0000001)
- -- end
- -- end
- local function getClan(usr)
- local clan = userClans[usr] or "default"
- return (clans[clan] or clans["default"])
- end
- local function impersonate(usr,msg)
- local name,brckts,brcktclr,prefix = unpack(getClan(usr))
- return prefix .. usr .. ": " .. msg, name, brckts, brcktclr
- end
- local function imsg(sndr,rcvr,msg)
- return {msg,sndr,sectionChar .. "cme"..sectionChar .. "6 -> "..sectionChar.."c"..rcvr,"[]","&6"},{msg,rcvr,sectionChar .. "c" .. sndr.. sectionChar .. "6 -> "..sectionChar.."cme","[]","&6"}
- end
- local function update()
- fs.delete("startup.lua")
- shell.run("pastebin get qi4pNPqa startup.lua")
- os.reboot()
- end
- local function handleMessageQueue()
- while true do
- for i=1,#chatBoxes do
- if #message_queue > 0 then
- local fType,args = unpack(table.remove(message_queue,1))
- local s,err = pcall(function() assert(chatBoxes[i][fType](unpack(args))) end)
- if not s then
- if type(err) ~= "string" then err = "Generic Boring Error" end
- if err:match("chatMessage is on cooldown") then --Fck this fcking bs
- table.insert(message_queue,1,{fType,args})
- elseif err:match("incorrect player name/uuid") then
- --Do nothing
- else
- sendMessage(err,"ERROR")
- end
- end
- sleep(1/#chatBoxes)
- else
- sleep(0.01)
- end
- end
- end
- end
- local normalCommands = {
- fern = "fern <msg...>\n6Sends <msg> to fern and prints the response.\nIf starting with $fern, the response will only be visible to the original sender",
- steal = "steal <victim> <amt>\n'Steals' <amt> from <victim>. <amt> must be positive",
- impersonate = "impersonate <victim> <msg...>",
- test = "test\nDoes nothing",
- imsg = "imsg <sender> <recipient> <msg...>\nSends a private <msg> from the <sender> to the <recipient>",
- share = "share <slot>\nShares an item from <slot>.\n<slot> can either be undefined (shares your hand), a string such as 'chest' or 'offhand', or a number 0-40",
- doxx = "doxx <target>\nSends the position of <target> in the chat!"
- }
- local specialCommands = {
- prompt = "prompt set <name>\nprompt get <name>\nprompt get all\nprompt get cur\nprompt add <name> <prompt...>",
- format = "format <\"msg\"> <arg1> <arg2> ...\nFormats a message using format codes, use $formatHelp to list codes",
- formatHelp = "formatHelp\n displays the format codes",
- update = "update\nUpdates and restarts the program",
- share = "share <slot> <translation_key> <target> <sender>\nShares an item from <slot>.\n<slot> can either be undefined (shares your hand), a string such as 'chest' or 'offhand', or a number 0-40\n<translation_key> is a number 1-12 that determines how the item is shown.\n<target> is the player to lookup when sharing, and <sender> is the player that sends the item in the chat"
- }
- local function help(cmd,usr)
- local f = function(command)
- return sc .. "6" .. command:gsub("%b<>",function(str) return sc .."d"..sc.."l" .. str .. sc .. "6" end)
- end
- local cmds = "Commands:"
- if isUserVerified(usr) then
- for k,v in pairs(specialCommands) do
- cmds = cmds .. " " .. k
- if k == cmd then
- return sendMessageToPlayer(f(v),usr,sc.."eCommandHelper","[]","&e")
- end
- end
- end
- for k,v in pairs(normalCommands) do
- cmds = cmds .. " " .. k
- if k == cmd then
- return sendMessageToPlayer(f(v),usr,sc.."eCommandHelper","[]","&e")
- end
- end
- return sendMessageToPlayer(cmds,usr,sc.."eCommandHelper","[]","&e")
- end
- local function chatReceive()
- while true do
- if not awaitResponse then
- local e,usr,msg,uuid,isHidden = os.pullEvent("chat")
- LAST_USER = usr
- local str = string.match(msg,"^[fF][eE][rR][nN] ?")
- local success = "Fern Command"
- if str then
- term.setTextColor(colors.green)
- if isHidden then term.setTextColor(colors.lime) end
- print("("..usr.."):",msg)
- local response = request(string.gsub(msg,"^"..str,""),usr)
- os.queueEvent("response",response,usr,isHidden,msg)
- elseif string.match(msg,"^prompt") and isUserVerified(usr) then
- local _,arg,packet = string.match(msg,"(prompt) (%w%w%w) (.+)")
- term.setTextColor(colors.red)
- print("prompt",arg,packet)
- if packet then
- if arg == "set" then
- packet = string.gsub(packet,"%.txt$","")
- setPrompt(packet .. ".txt")
- elseif arg == "add" then
- local name,prompt = string.match(packet,"([^ ]+) (.+)")
- name = name:gsub("%.txt$","")
- if name and prompt then addPrompt(name .. ".txt",prompt) end
- elseif arg == "get" then
- packet = string.gsub(packet,"%.txt$","")
- if packet == "all" then
- if not fs.exists("prompts") or not fs.isDir("prompts") then fs.makeDir("prompts") end
- os.queueEvent("response",textutils.serialiseJSON(fs.list("prompts")),usr,true,msg)
- elseif packet == "cur" then
- os.queueEvent("response",messageStore[1].content,usr,true,msg)
- else
- if fs.exists("prompts/"..packet..".txt") and not fs.isDir("prompts/"..packet..".txt") then
- local file = fs.open("prompts/"..packet..".txt","r")
- local data = file.readAll()
- file.close()
- os.queueEvent("response",data,usr,true,msg)
- end
- end
- end
- end
- elseif msg == "update" and isUserVerified(usr) then
- update()
- elseif string.match(msg,"^steal") then
- local _,victim,amt = string.match(msg,"(steal) ([%w%p]+) ?([%d%.]*)")
- amt = ""..(tonumber(amt) or 1000)
- sendFormattedMessageToPlayer(textutils.serialiseJSON({{text="has been sent to " .. usr .. ".", color = "green"}}),victim,sectionChar.."a" .. amt:sub(1,-2),"$" .. amt:sub(-1,-1),"&a")
- sleep(1)
- sendFormattedMessageToPlayer(textutils.serialiseJSON({{text="has been received from ",color="gold"},{text=victim,color="green"},{text=".",color="gold"}}),usr,sectionChar.."a" .. amt:sub(1,-2),"$" .. amt:sub(-1,-1),"&a")
- elseif string.match(msg,"^impersonate") then
- local victim,msg = msg:match("impersonate ([%w%p]+) ?(.*)")
- if isUserVerified(usr) or not isUserVerified(victim) then
- sendMessage(impersonate(victim,msg))
- end
- elseif string.match(msg:lower(),"^clanchat ") or msg:lower():match("^clanmsg ") and usrClans[usr] then
- local clan
- for k,v in ipairs(clan_rosters) do
- for j,w in ipairs(v) do
- if usr == v then
- clan = k
- break
- end
- end
- end
- if clan then
- local message,prefix,brackets,bracketClr = impersonate(usr,msg:match("^clanmsg (.*)"))
- for k,v in ipairs(clan_rosters[clan]) do
- sendMessageToPlayer(message,v,prefix,brackets,bracketClr)
- end
- else
- sendMessageToPlayer("Cannot find your clan!",usr,sc.."4ERROR","[]","&4")
- end
- elseif string.match(msg,"^test") then
- sendMessageToPlayer("test no brackets",usr,"[]",sectionChar)
- elseif string.match(msg,"^imsg") then
- local sndr,rcvr,msg = msg:match("imsg ([%w%p]+) ([%w%p]+) ?(.*)")
- if sndr and rcvr and (isUserVerified(usr) or (not isUserVerified(sndr) and not isUserVerified(rcvr))) then
- local msg1,msg2 = imsg(sndr,rcvr,msg)
- sendMessageToPlayer(unpack(msg1))
- sleep(1)
- sendMessageToPlayer(unpack(msg2))
- end
- elseif string.match(msg,"^format ") and isUserVerified(usr) then
- local cmd = msg:match("format (.*)")
- print("FKK SKJBDSLJCHBSDIJBHCSDC KJDC")
- local s,err = pcall(function()
- print(format(unserialiseCommand(cmd)))
- local stuff = {format(unserialiseCommand(cmd))}
- print(textutils.serialize(stuff))
- -- sendMessageToPlayer(textutils.serialise(stuff),usr)
- sendFormattedMessage(unpack(stuff)) end)
- if not s then
- sendFormattedMessageToPlayer(err,usr,sc.."4ERROR","[]","&4")
- end
- elseif string.match(msg,"^formatHelp") and isUserVerified(usr) then
- local str = sc .. "6"
- for k,v in ipairs(formatCodes) do
- str = str .. v .. "\n"
- end
- str = str:gsub("\n$","")
- sendMessageToPlayer(str,usr,sc.."6Format Helper","[]","&6")
- elseif string.match(msg,"^share") then
- local _,slot,index,target,sndr = unserialiseCommand(msg)
- if type(target) ~= "string" or #target <= 0 or not isUserVerified(usr) then target = usr else target = target:gsub(" ","") end
- if type(sndr) ~= "string" or #sndr <= 0 or not isUserVerified(usr) then sndr = target else sndr = sndr:gsub(" ","") end
- --if type(slot) == "string" then slot = slot:gsub(" ","") else slot = "" end
- slot = tonumber(slot) or slot
- local item,displayName
- local invManager = peripheral.find("inventoryManager",function(name,perip) return perip.getOwner() == target end)
- local slotTable = {head=39,helmet=39,chest=38,chestplate=38,leggings=37,legs=37,boots=36,feet=36}
- if not invManager and (type(slot) ~= "table" or not isUserVerified(usr)) then
- sendMessageToPlayer("No inventory manager found",usr,sc.."4ERROR","[]","&4")
- else
- if tonumber(slot) then
- if tonumber(slot) < 36 then
- for k,v in pairs(invManager.list()) do
- if v.slot == slot then
- displayName = v.displayName
- item = {
- id=v.name,
- tag=textutils.serialiseJSON(v.nbt,true)
- }
- break
- end
- end
- elseif tonumber(slot) == 40 then
- local i = invManager.getItemInOffHand()
- if i and i.name then
- displayName = i.displayName
- item = {
- id=i.name,
- tag=textutils.serialiseJSON(i.nbt,true)
- }
- end
- elseif tonumber(slot) >= 36 then
- for k,v in pairs(invManager.getArmor()) do
- if v.slot == slot or v.slot - 64 == slot then
- displayName = v.displayName
- item = {
- id = v.name,
- tag=textutils.serialiseJSON(v.nbt,true)
- }
- break
- end
- end
- end
- elseif type(slot) == "table" and isUserVerified(usr) then
- displayName = "[" .. tostring(slot.displayName or slot.name or "error") .. "]"
- item = {
- id=slot.id or slot.name or "errored:error",
- tag=textutils.serialiseJSON( (slot.nbt or slot.tag or {}), true)
- }
- elseif slot == "offhand" then
- local i = invManager.getItemInOffHand()
- if i and i.name then
- displayName = i.displayName
- item = {
- id=i.name,
- tag=textutils.serialiseJSON(i.nbt,true)
- }
- end
- elseif slotTable[slot] then
- for k,v in pairs(invManager.getArmor()) do
- print(v.slot,slotTable[slot])
- if v.slot == slotTable[slot] or v.slot - 64 == slotTable[slot] then
- displayName = v.displayName
- item = {
- id = v.name,
- tag=textutils.serialiseJSON(v.nbt,true)
- }
- break
- end
- end
- else
- local i = invManager.getItemInHand()
- if i and i.name then
- displayName = i.displayName
- item = {
- id=i.name,
- tag=textutils.serialiseJSON(i.nbt,true)
- }
- end
- end
- if item and displayName then
- local msg,prefix,brckts,brcktClr = impersonate(sndr,"")
- if true or isUserVerified(usr) then
- local modid,block = item.id:match("([^:]+):([^:]+)")
- local msgOptions = {
- {text= displayName:sub(2,-2),color="aqua"},
- {text= displayName:sub(2,-2),color="white"},
- {text= displayName:sub(2,-2),color="light_purple"},
- {text= displayName:sub(2,-2),color="yellow"},
- {translate = "block." .. modid .. "." ..block,color="aqua"},
- {translate = "block." .. modid .. "." ..block,color="white"},
- {translate = "block." .. modid .. "." ..block,color="light_purple"},
- {translate = "block." .. modid .. "." ..block,color="yellow"},
- {translate = "item." .. modid .. "." ..block,color="aqua"},
- {translate = "item." .. modid .. "." ..block,color="white"},
- {translate = "item." .. modid .. "." ..block,color="light_purple"},
- {translate = "item." .. modid .. "." ..block,color="yellow"}
- }
- if tonumber(index) and msgOptions[tonumber(index)] then
- local itemDisplay = msgOptions[tonumber(index)]
- itemDisplay.hoverEvent={action="show_item",contents=item}
- local fMsg = fixIntArrays(textutils.serialiseJSON({
- {text=msg},
- {text= '[', hoverEvent={action="show_item",contents=item}, color=itemDisplay.color},
- itemDisplay,
- {text= ']', hoverEvent={action="show_item",contents=item}, color=itemDisplay.color}
- },{allow_repetitions=true}))
- sendFormattedMessage(fMsg,prefix,brckts,brcktClr)
- else
- local fMsg = {
- {text = "Select an option to send in chat!",color="green"}
- }
- for k,v in ipairs(msgOptions) do
- if k%4 == 1 then
- table.insert(fMsg,{text="\n[",color=v.color})
- else
- table.insert(fMsg,{text="[",color=v.color})
- end
- v.hoverEvent={action="show_item",contents=item}
- if type(slot) == "table" then slot = textutils.serialiseJSON(slot) end
- if isUserVerified(usr) then
- v.clickEvent = {action="suggest_command",value='$share ' .. (slot or "none") .. ' ' .. k .. ' ' .. tostring(target or usr) .. ' ' .. tostring(sndr or usr)}
- else
- v.clickEvent = {action="suggest_command",value='$share ' .. (slot or "none") .. ' ' .. k}
- end
- table.insert(fMsg,v)
- table.insert(fMsg,{text="] ",color=v.color})
- end
- sendFormattedMessageToPlayer(textutils.serialiseJSON(fMsg,{allow_repetitions=true}),usr,sc.."4ITEM_HELPER","[]","&4")
- end
- else
- local fMsg = fixIntArrays(textutils.serialiseJSON({
- {text=msg},
- {
- text= sc .. "e" .. displayName,
- hoverEvent={action="show_item",contents=item}
- }
- }))
- print(fMsg)
- sendFormattedMessage(fMsg,prefix,brckts,brcktClr)
- end
- else
- sendMessageToPlayer("No item found",usr,sc.."4ERROR","[]","&4")
- end
- end
- elseif msg:match("^help") then
- _,cmd = unserialiseCommand(msg)
- help(cmd,usr)
- elseif msg:match("^lookup") and isUserVerified(usr) then
- local args = {unserialiseCommand(msg)}
- print(args)
- if args[2] == "entity" then
- local selector = args[3]
- if type(selector) ~= "string" then selector = "@e[limit=1]" end
- local path = args[4]
- if type(path) == "table" then path = textutils.serialiseJSON(path)
- elseif type(path) ~= "string" then path = "{}" end
- local fMsg = textutils.serialiseJSON(
- {
- {text="Data for Lookup " .. selector},
- {nbt=path,
- entity=selector,
- interpret=true}
- })
- sendFormattedMessageToPlayer(fMsg,usr,sc.."4ENTITY_DOXXER","[]","&4")
- elseif args[2] == "block" then
- local x,y,z = args[3],args[4],args[5]
- if type(x) ~= "string" then x = "~" end
- if type(y) ~= "string" then y = "~" end
- if type(z) ~= "string" then z = "~" end
- local path = args[6]
- if type(path) == "table" then path = textutils.serialiseJSON(path)
- elseif type(path) == "nil" then path = "{}" end
- local fMsg = textutils.serialiseJSON({nbt={
- nbt=path,
- separator = {text=",",color="gold"},
- block = x .. " " .. y .." " .. z
- }})
- sendFormattedMessageToPlayer(fMsg,usr,sc.."4BLOCK_DOXXER","[]","&4")
- elseif args[2] == "storage" then
- local resourceLocation = tostring(args[3])
- local path = args[4]
- if type(path) == "table" then path = textutils.serialiseJSON(path)
- elseif type(path) == "nil" then path = "{}" end
- local fMsg = textutils.serialiseJSON({nbt={
- nbt=path,
- separator= {text=",",color="gold"},
- storage=resourceLocation
- }})
- sendFormattedMessageToPlayer(fMsg,usr,sc.."4COMMAND_DOXXER","[]","&4")
- else
- local usage = sc .. "6Usage:\n"..sc .. "alookup entity <selector> <nbt_path>\nlookup block <x> <y> <z> <nbt_path>\nlookup storage <resourceLocation> <nbt_path>"
- sendMessageToPlayer(usage,usr,sc.."4USAGE_ERROR","[]","&4")
- end
- elseif msg:match("^tellraw") and isUserVerified(usr) then
- local _,cmd,prefix,brckts,brcktClr = unserialiseCommand(msg)
- print(cmd,prefix,brckts,brcktClr)
- if type(cmd) == "string" then
- sendFormattedMessage(cmd,prefix,brckts,brcktClr)
- end
- elseif msg:match("^doxx [%w_]+") then
- local target = msg:match("^doxx *([^ ]+)") or "errored target"
- if not peripheral.find("playerDetector") then sendMessageToPlayer("No player detector found",usr,sc.."4ERROR","[]","&4")
- else
- local pdor = peripheral.find("playerDetector")
- local pos = pdor.getPlayerPos(tostring(target))
- if not isUserVerified(usr) and (userClans[target] or ""):match("^AU") or not pos or not pos.x then sendMessageToPlayer("Could not find player " .. tostring(target),usr,sc.."4ERROR","[]","&4")
- elseif math.random(#DOXXER_MESSAGES + #SELF_DOXX) <= #DOXXER_MESSAGES then
- local cmd = DOXXER_MESSAGES[math.random(#DOXXER_MESSAGES)]
- local func = cmd[1]
- for i=2,#cmd do
- local v = cmd[i]
- v = v:gsub("%%[sd]",function(str) return sc .. "b" .. str .. sc .. "f" end)
- if func:match("Player") then
- table.insert(message_queue,{func,{v:format(target,pos.x,pos.y,pos.z,tostring(pos.dimension)):gsub("%b~~",""),target,sc.."6"..sc.."lDOXXER","[]","&6&l"}})
- if target ~= usr then
- table.insert(message_queue,{func,{v:format(target,pos.x,pos.y,pos.z,tostring(pos.dimension)):gsub("%b~~",""),usr,sc.."c"..sc.."lDOXXER","[]","&c&l"}})
- end
- else
- table.insert(message_queue,{func,{v:format(target,pos.x,pos.y,pos.z,tostring(pos.dimension)):gsub("%b~~",""),sc.."6"..sc.."lDOXXER","[]","&6&l"}})
- end
- end
- else
- local cmd = SELF_DOXX[math.random(#SELF_DOXX)]
- sendMessage(impersonate(target,cmd:format(pos.x,pos.y,pos.z,tostring(pos.dimension))))
- end
- end
- else
- success = "Normal Hidden Message"
- end
- if isHidden then
- sendToastToPlayer(msg,success,"t8rt0t",sectionChar .. "6" .. usr,"[]","&6")
- end
- LAST_USER = nil
- end
- sleep(0)
- end
- end
- local function formatMsg(msg,isDirectedAtPlayer,originalMsg,usr)
- local cmd = "/containertrust public"
- if usr == "t8rt0t" then
- cmd = commands[math.random(#commands)]
- end
- if isDirectedAtPlayer then return textutils.serialiseJSON({
- {
- text=msg,
- color="green",
- hoverEvent={action="show_text",contents="Response to : ".. originalMsg},
- clickEvent={action="run_command",value=cmd}
- }})
- end
- return textutils.serialiseJSON({
- {
- text=msg,
- color="aqua",
- hoverEvent={action="show_text",contents="Response to : ".. originalMsg},
- clickEvent={action="run_command",value=cmd}
- }})
- end
- local function sendMsgs()
- while true do
- local e,msg,usr,isHidden,oldMsg = os.pullEvent("response")
- term.setTextColor(colors.yellow)
- if isHidden then term.setTextColor(colors.orange) end
- print("FERN-AI:",msg)
- local msg = formatMsg(msg,isHidden,oldMsg or "")
- if isHidden then
- sendFormattedMessageToPlayer(msg,usr,"ERN-A","FI")
- else
- sendFormattedMessage(msg,"ERN-A","FI")
- end
- sleep(1)
- end
- end
- -- function main()
- -- while true do
- -- term.setTextColor(colors.green)
- -- input = read()
- -- if input == "/exit" then term.clear() term.setCursorPos(1,1) break end
- -- local response = request(input)
- -- term.setTextColor(colors.white)
- -- print("")
- -- term.clearLine()
- -- term.setCursorPos(1,rPos)
- -- print(response)
- -- print("")
- -- for _, action in pairs(actionTable) do
- -- if string.find(response, action.name) then
- -- term.setTextColor(colors.red)
- -- action.execute()
- -- end
- -- end
- -- end
- -- end
- local success,errMsg = pcall(function() parallel.waitForAny(sendMsgs,chatReceive,handleMessageQueue) end)
- if not success then
- sleep(1)
- if LAST_USER then
- local _,s = pcall(function() chatBoxes[1].sendMessageToPlayer(tostring(errMsg),LAST_USER,sectionChar .. "4ERROR","[]","&a") end)
- if not s then pcall(function() chatBoxes[1].sendMessage(tostring(errMsg),sectionChar .. "4ERROR","[]","&a") end) end
- else
- pcall(function() chatBoxes[1].sendMessage(tostring(errMsg),sectionChar .. "4ERROR","[]","&a") end)
- end
- end
- update()
- -- parallel.waitForAny(loadingAnimation, main)
Advertisement
Add Comment
Please, Sign In to add comment