------------------------------------------------------------------------ --//BCDCrazy Script 1.0 by ßottledHatê --//tested in BCDC.4032 --//dynamic right-click command support on hub tab. (not dynamic in 1.0... waiting on dc protocol updates.) --//idea from, and some code from plops crazy bot for pto. --//after seeing it's capabilites.. i had to take them 'on the road' ;) in a client script that is. --//mad props to plop for the original bot and functions!--> www.plop.nl --//more crazy options to come... :) ------------------------------------------------------------------------ local crazyFileName = "scripts/_CrazyData.tbl" --//file to save data in. path can be relative to script dir: "data/StabTable.dat" or absolute: "c:\\path\\to\\file.bleh" ---------blah blah don't mess around bellow----------------------------- local hA = "" cVer = "1.0" ------------------------- local f,e = io.open( crazyFileName, "a+" ) --//Error handle.. makes sure save file and dir exist... if f then f:write("") f:close() else --//and if it doesn't.. make the path, then the file. local _,_,path = string.find(crazyFileName, "(.+[/_\\]).+$") if path ~= nil then os.execute("mkdir ".."\""..gsub(path, "/", "\\").."\"") end f,e = io.open( crazyFileName, "a+" ) if f then f:write("" ) f:close() --// file and path did not exist.. now they do. else DC():PrintDebug(" ****BCDCrazy "..cVer.." ERROR: INVALID FILENAME OR PATH****") crazyFileName = "_CrazyData.dat"--//this is only if the path provided is invalid to winblows. defaults to a file in the current dir. end end ------------------------- saveCrazyData = function() local sstring = "" sstring = SerializeCrazy(cTable, "cTable", "") local f,e = io.open(crazyFileName, "w+") if f then f:write(sstring) f:close() end end ------------------------- SerializeCrazy = function(tTable, sTableName, sTab) sTab = sTab or ""; sTmp = "" sTmp = sTmp..sTab..sTableName.."={" local tStart = 0 for key, value in tTable do if tStart == 1 then sTmp = sTmp..",\r\n" else sTmp = sTmp.."\r\n" tStart = 1 end local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key); if(type(value) == "table") then sTmp = sTmp..SerializeCrazy(value, sKey, sTab.."\t"); else local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value); sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue end end sTmp = sTmp.."\r\n"..sTab.."}" return sTmp end -------------------------//this part will be revised many times i'm sure, as the wiki is changing on it..(hopefully for the better.) dynRclick = function(h,hA,t,o)--Currently the right clicks are not dynamic for 1.0 (waiting for DC Protocol update).. they only get updated when you recconect to the hub. -- --//old rclicks removed using - -- --//no, this doesn't play nice if the hub sends hub tab right clicks also(context 1).. on update it will remove the hubs rclicks. local cX = 0 t = t or 0 if t == 1 then --update mode from isCommand (erase old) --h:injectChat("$UserCommand 255 1|") --rOldDynRclick(h,hA,o) end if t == 0 then --new hub connected. from connected listener or script start. if not cTable["Hubs"][hA] then cTable["Hubs"][hA]={["Mode"]=0} cX = 1 --trying not to save table data with hubs where the cmd isn't used. end end h:injectChat( "$UserCommand 1 1 -=BCDCrazy "..cVer.."=-\\Hub Status$$To: %[mynick] From: %[mynick] $<%[mynick]> /crazy status||") h:injectChat("$UserCommand 1 1 -=BCDCrazy "..cVer.."=-\\Help$$To: %[mynick] From: %[mynick] $<%[mynick]> /crazy help||") --"$UserCommand 0 1|") -- if cTable["Settings"]["OnOff"] == 0 then --//null'd for prerelease h:injectChat( "$UserCommand 1 1 -=BCDCrazy "..cVer.."=-\\Script Status\\ Enabled$$To: %[mynick] From: %[mynick] $<%[mynick]> /crazy on|| ") -- h:injectChat( "$UserCommand 1 1 -=BCDCrazy "..cVer.."=-\\Script Status\\X-> Disabled$$To: %[mynick] From: %[mynick] $<%[mynick]> /crazy off||") -- else -- h:injectChat( "$UserCommand 1 1 -=BCDCrazy "..cVer.."=-\\Script Status\\X-> Enabled$$To: %[mynick] From: %[mynick] $<%[mynick]> /crazy on|| ") h:injectChat( "$UserCommand 1 1 -=BCDCrazy "..cVer.."=-\\Script Status\\ Disabled$$To: %[mynick] From: %[mynick] $<%[mynick]> /crazy off||") -- end for k,v in cCmds do -- if k == cTable["Hubs"][hA]["Mode"] then --//null'd for v1.0 (waiting for DC Protocol Update) -- h:injectChat( "$UserCommand 1 1 -=BCDCrazy "..cVer.."=-\\Hub Crazy Output\\X-> "..Stats[k].."$$To: %[mynick] From: %[mynick] $<%[mynick]> /crazy "..v.."||") -- else h:injectChat( "$UserCommand 1 1 -=BCDCrazy "..cVer.."=-\\Hub Crazy Output\\ "..Stats[k].."$$To: %[mynick] From: %[mynick] $<%[mynick]> /crazy "..v.."||") -- end end if cX == 1 then cTable["Hubs"][hA] = nil end --trying not to save table data with hubs where the cmd isn't used. end --function rOldDynRclick(h,hA,o) --//not working in 1.0... (waiting on DC Protocol Update) -- h:injectChat("removeing old....................") -- h:injectChat( "$UserCommand -1 1 -=BCDCrazy "..cVer.."=-\\Hub Status$$To: %[mynick] From: %[mynick] $<%[mynick]> /crazy status||") -- h:injectChat( "$UserCommand -1 1 -=BCDCrazy "..cVer.."=-\\Help$$To: %[mynick] From: %[mynick] $<%[mynick]> /crazy help||") -- --"$UserCommand 0 1|") -- if o["OnOff"] == 0 then -- h:injectChat( "$UserCommand -1 1 -=BCDCrazy "..cVer.."=-\\Script Status\\ Enabled$$To: %[mynick] From: %[mynick] $<%[mynick]> /crazy on|| ") -- h:injectChat( "$UserCommand -1 1 -=BCDCrazy "..cVer.."=-\\Script Status\\X-> Disabled$$To: %[mynick] From: %[mynick] $<%[mynick]> /crazy off||") -- else -- h:injectChat( "$UserCommand -1 1 -=BCDCrazy "..cVer.."=-\\Script Status\\X-> Enabled$$To: %[mynick] From: %[mynick] $<%[mynick]> /crazy on|| ") -- h:injectChat( "$UserCommand -1 1 -=BCDCrazy "..cVer.."=-\\Script Status\\ Disabled$$To: %[mynick] From: %[mynick] $<%[mynick]> /crazy off||") -- end -- for k,v in cCmds do -- if k == o["Mode"] then -- h:injectChat( "$UserCommand -1 1 -=BCDCrazy "..cVer.."=-\\Hub Crazy Output\\X-> "..Stats[k].."$$To: %[mynick] From: %[mynick] $<%[mynick]> /crazy "..v.."||") -- else -- h:injectChat( "$UserCommand -1 1 -=BCDCrazy "..cVer.."=-\\Hub Crazy Output\\ "..Stats[k].."$$To: %[mynick] From: %[mynick] $<%[mynick]> /crazy "..v.."||") -- end -- end -- return "done" --end ------------------------- massInjectChat = function(t) for k,v in dcpp._hubs do v:injectChat(t) end end ------------------------- sndCht = function(h,n,msg) DC():SendHubMessage(h:getId(), "<"..n.."> "..msg.."|") end --plop------------------- function Replace(letter, table, b) if table[letter] then letter = table[letter] end return letter..(b or "") end --plop------------------- function tohex(char) local char = string.byte(char) if type(char) == "number" and math.floor(char) == char then return string.format("%X", char) else return tostring(char) -- uses old version for other values end end ------------------------- function cHelpDisplay(h) local helpString = "" for k,v in cCmds do if string.len(v) >= 9 then helpString=helpString.."\t"..v.."\t"..Stats[k].."\r\n" else helpString=helpString.."\t"..v.."\t\t"..Stats[k].."\r\n" end end h:injectChat("\r\n-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-".. "\r\n\r\n\t***** Help Menu for BCDCrazy "..cVer.." ****\r\n".. "\r\n".. "Mouse:\r\n".. "\tFull right click support on each hubs tab.\r\n".. "\r\n".. "Syntax:\r\n".. "\t/crazy [command]\r\n".. "\r\n".. "Commands: (note that output commands are set for each hub.)\r\n".. "\t[on/off]\t\tOutput globally On or Off. (all hubs)\r\n".. "\tstatus\t\tBCDCrazy Status for the current hub.\r\n"..helpString.. "\thelp\t\tYou're lookin' at it!\r\n".. "\r\n".. "Example: /crazy eliteold\r\n".. "-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-") end ------------------------- cStatus = function(h, hA) h:injectChat("***** BCDCrazy Status: "..bleg[cTable["Settings"]["OnOff"]].. " , Hub Mode: "..Stats[cTable["Hubs"][hA]["Mode"]].." *****") end ------------------------- function isCommand(h,hA,t,N) local old = {} local cmd=string.lower(string.sub(t,8)) if not cTable["Hubs"][hA] then cTable["Hubs"][hA]={["Mode"]=0,["Name"] = N} end if cmd == nil then h:injectChat("Syntax Error: no options specified. '/crazy help' for commands.") return 1 elseif cmd == "status" then cStatus(h,hA) return elseif cmd == "on" then cTable["Settings"]["OnOff"] = 1 massInjectChat("***** BCDCrazy Status: "..bleg[cTable["Settings"]["OnOff"]].." *****") --dynRclick(h,hA,1,old) saveCrazyData() return elseif cmd == "off" then cTable["Settings"]["OnOff"] = 0 massInjectChat("***** BCDCrazy Status: "..bleg[cTable["Settings"]["OnOff"]].." *****") --dynRclick(h,hA,1,old) saveCrazyData() return elseif cmd == "help" then cHelpDisplay(h) return else for k,v in cCmds do if cmd == v then old={["OnOff"] = cTable["Settings"]["OnOff"], ["Mode"] = cTable["Hubs"][hA]["Mode"]} cTable["Hubs"][hA]["Mode"] = k cStatus(h,hA) --dynRclick(h,hA,1,old) saveCrazyData() return end end end h:injectChat("Syntax Error: incorrect options. '/crazy help' for commands") end ---------------------------------------------------------------- dcpp:setListener( "connected", "BCDCrazyConnected", --//tells you if you have BCDCrazy allready on in that hub when you join. function( hub ) hA = hub:getAddress() dynRclick(hub,hA,0) if not cTable["Hubs"][hA] then return end if cTable["Hubs"][hA]["Mode"] ~= 0 then if cTable["Settings"]["OnOff"] == 1 then hub:injectChat("\r\n\r\n-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-".. "\r\n\r\n *****BCDCrazy Bot is On! Outgoing chat text in this hub will be chaged to "..Stats[cTable["Hubs"][hA]["Mode"]].." *****\r\n".. "-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-\r\n\r\n") end end end ) ------------------------- dcpp:setListener( "ownChatOut", "BCDCrazyOwnChat", function( hub, text ) DC():InjectHubMessage( hub, "$UserCommand 2 6 -=Ann=-\\Disable All Nicks/Trigs$$To: %[mynick] From: %[mynick] $<%[mynick]> /annoy disableall||") hA = hub:getAddress() if string.sub( text, 1, 6 ) == "/crazy" then local s,e,hN = string.find(hub:getHubName(), "([%S+_%s+_.+_%w+]+) %(%d+.%d+.") isCommand(hub,hA,text,hN) return 1 elseif string.sub(text,1,5)=="/help" then hub:injectChat("*** (BCDCrazy Bot) /crazy help -for help") return end if string.sub(text,1,1) =="/" then return end if cTable["Settings"]["OnOff"] == 0 then return end if not cTable["Hubs"][hA] then return end if cTable["Hubs"][hA]["Mode"] == 0 then return end local nick = hub:getOwnNick() local m = cTable["Hubs"][hA]["Mode"] MODES[m](hub,nick,text) return 1 end ) ------------------------- dcpp:setListener( "pm", "BCDCrazyRclickCapture", ---right click commands support. function( hub, user, text ) if user:getNick() == hub:getOwnNick() then if string.sub( text, 1, 6 ) ~= "/crazy" then return end hA = hub:getAddress() local s,e,hN = string.find(hub:getHubName(), "([%S+_%s+_.+_%w+]+) %(%d+.%d+.") isCommand(hub,hA,text,hN) return 1 end end ) ----------------------------------------------------------------- bleg={[0]="Disabled", [1] = "Enabled"} Stats={ [0] = "normal text.", [1] = "Elite talk. ( 1337 7@1]{ )", [2] = "Old elite talk. ( 01d 1337 741k )", [3] = "Breezer talk. ( ß®ëëZë® Tâ£K )", [4] = "Morse Code. ( -- --- .-. ... . -.-. --- -.. . )", [5] = "Crazy Morse Code. ( bleeeepbleep )", [6] = "Binary. ( 01100010 )", [7] = "Hexadecimal. ( 626C6F6F70 )", [8] = "Camel talk. ( CaMeL tAlK )", } cCmds ={ [0] = "normal", [1] = "elite", [2] = "eliteold", [3] = "breezer", [4] = "morse", [5] = "morselong", [6] = "binary", [7] = "hex", [8] = "camel", } --modded plop------------ MODES = { [1] = function(h,n,data)--Elite msg = string.gsub(data, "(.)", function(letter) return Replace(letter, ELITE, " ") end) sndCht(h,n,msg) end , [2] = function(h,n,data)--Elite old msg = string.gsub(data, "(.)", function(letter) return Replace(letter, ELITEOLD) end) sndCht(h,n,msg) end , [3] = function(h,n,data)--Breezer msg = string.gsub(string.lower(data), "(.)", function(letter) return Replace(letter, BREEZ) end) sndCht(h,n,msg) end , [4] = function(h,n,data)--Morse code short msg = string.gsub(string.lower(data), "(.)", function(letter) return Replace(letter, MORSE, " ") end) sndCht(h,n,msg) end , [5] = function(h,n,data)--Morse code long msg = string.gsub(string.lower(data), "(.)", function(letter) return Replace(letter, MORSELONG, " ") end) sndCht(h,n,msg) end , [6] = function(h,n,data) --Ascii to Binary msg = string.gsub(string.lower(data), "(.)", function(letter) return Replace(letter, BINARY, " ") end) --msg = string.gsub(string.lower(data), "(.)", function(letter) return tobin(letter) end) sndCht(h,n,msg) end , [7] = function(h,n,data) --ascii to hex msg = string.gsub(string.lower(data), "(%S)", function(letter) return tohex(letter) end) sndCht(h,n,msg) end, [8] = function(h,n,data) --//Camel msg = data count = string.len(msg) local lines = {} local line = "" if updown == nil then updown = 0 end for i=1,(count) do msg2 = string.sub(msg, -1, (string.len(msg))) if string.len(msg) == 1 then table.insert(lines, msg) else table.insert(lines, msg2) msg = string.sub(msg, 1, (string.len(msg)-1)) end end for i=1,(count) do if updown == 0 then lines[i] = string.upper(lines[i]) updown = 1 else lines[i] = string.lower(lines[i]) updown =0 end line = lines[i]..line end sndCht(h,n,line) end, } BREEZ={ ["a"] = "â", ["b"] = "ß", ["c"] = "Ç", ["d"] = "Ð", ["e"] = "ë", ["f"] = "ƒ", ["g"] = "G", ["h"] = "H", ["i"] = "Î", ["j"] = "J", ["k"] = "K", ["l"] = "£", ["m"] = "M", ["n"] = "ñ", ["o"] = "Ö", ["p"] = "P", ["q"] = "Q", ["r"] = "®", ["s"] = "§", ["t"] = "T", ["u"] = "ú", ["v"] = "V", ["w"] = "W", ["x"] = "X", ["y"] = "Ý", ["z"] = "Z", } MORSE = { ["a"] = ".-", ["b"] = "-...", ["c"] = "-.-.", ["d"] = "-..", ["e"] = ".", ["f"] = "..-.", ["g"] = "--.", ["h"] = "....", ["i"] = "..", ["j"] = ".---", ["k"] = "-.-", ["l"] = ".-..", ["m"] = "--", ["n"] = "-.", ["o"] = "---", ["p"] = ".--.", ["q"] = "--.-", ["r"] = ".-.", ["s"] = "...", ["t"] = "-", ["u"] = "..-", ["v"] = "...-", ["w"] = ".--", ["x"] = "-..-", ["y"] = "-.--", ["z"] = "--..", ["0"] = "-----", ["1"] = ".----", ["2"] = "..---", ["3"] = "...--", ["4"] = "....-", ["5"] = ".....", ["6"] = "-....", ["7"] = "--...", ["8"] = "---..", ["9"] = "----.", ["."] = ".-.-.-", [","] = "--..--", ["?"] = "..--..", } MORSELONG = { ["a"]="beepbeeeep", ["c"]="beeeepbeepbeeeepbeep", ["b"]="beeeepbeepbeepbeep", ["e"]="beep", ["d"]="beeeepbeepbeep", ["g"]="beeeepbeeeepbeep", ["f"]="beepbeepbeeeepbeep", ["i"]="beepbeep", ["h"]="beepbeepbeepbeep", ["k"]="beeeepbeepbeeeep", ["j"]="beepbeeeepbeeeepbeeeep", ["m"]="beeeepbeeeep", ["l"]="beepbeeeepbeepbeep", ["o"]="beeeepbeeeepbeeeep", ["n"]="beeeepbeep", ["1"]="beepbeeeepbeeeepbeeeepbeeeep", ["0"]="beeeepbeeeepbeeeepbeeeepbeeeep", ["3"]="beepbeepbeepbeeeepbeeeep", ["2"]="beepbeepbeeeepbeeeepbeeeep", ["u"]="beepbeepbeeeep", ["4"]="beepbeepbeepbeepbeeeep", ["w"]="beepbeeeepbeeeep", ["v"]="beepbeepbeepbeeeep", ["y"]="beeeepbeepbeeeepbeeeep", ["x"]="beeeepbeepbeepbeeeep", ["z"]="beeeepbeeeepbeepbeep", ["?"]="beepbeepbeeeepbeeeepbeepbeep", ["5"]="beepbeepbeepbeepbeep", ["6"]="beeeepbeepbeepbeepbeep", ["7"]="beeeepbeeeepbeepbeepbeep", ["8"]="beeeepbeeeepbeeeepbeepbeep", ["9"]="beeeepbeeeepbeeeepbeeeepbeep", ["."]="beepbeeeepbeepbeeeepbeepbeeeep", [","]="beeeepbeeeepbeepbeepbeeeepbeeeep", ["p"]="beepbeeeepbeeeepbeep", ["q"]="beeeepbeeeepbeepbeeeep", ["r"]="beepbeeeepbeep", ["s"]="beepbeepbeep", ["t"]="beeeep", } BINARY = { ["a"]="01100001", ["c"]="01100011", ["b"]="01100010", ["e"]="01100101", ["d"]="01100100", ["g"]="01100111", ["f"]="01100110", ["i"]="01101001", ["h"]="01101000", ["k"]="01101011", ["j"]="01101010", ["m"]="01101101", ["l"]="01101100", ["o"]="01101111", ["n"]="01101110", ["q"]="01110001", ["p"]="01110000", ["s"]="01110011", ["r"]="01110010", ["u"]="01110101", ["t"]="01110100", ["w"]="01110111", ["v"]="01110110", ["y"]="01111001", ["x"]="01111000", ["{"]="01111011", ["z"]="01111010", ["}"]="01111101", ["|"]="01111100", ["~"]="01111110", ["!"]="00100001", ["#"]="00100011", ["\""]="00100010", ["%"]="00100101", ["$"]="00100100", ["'"]="01100000", ["&"]="00100110", [")"]="00101001", ["("]="00101000", ["*"]="00101010", ["-"]="00101101", [","]="00101100", ["/"]="01011100", ["."]="00101110", ["A"]="01000001", ["C"]="01000011", ["B"]="01000010", ["E"]="01000101", ["D"]="01000100", ["G"]="01000111", ["F"]="01000110", ["I"]="01001001", ["H"]="01001000", ["K"]="01001011", ["J"]="01001010", ["M"]="01001101", ["L"]="01001100", ["O"]="01001111", ["N"]="01001110", ["Q"]="01010001", ["P"]="01010000", ["S"]="01010011", ["R"]="01010010", ["U"]="01010101", ["T"]="01010100", ["W"]="01010111", ["V"]="01010110", ["Y"]="01011001", ["X"]="01011000", ["["]="01011011", ["Z"]="01011010", ["]"]="01011101", ["_"]="01011111", ["^"]="01011110", } ELITEOLD = { ["A"]="4", ["a"]="4", ["B"]="8", ["b"]="8", ["E"]="3", ["e"]="3", ["G"]="6", ["g"]="9", ["I"]="1", ["i"]="1", ["L"]="1", ["l"]="1", ["O"]="0", ["o"]="0", ["S"]="5", ["s"]="5", ["T"]="7", ["t"]="7", ["z"] = "2", ["Z"] = "2" } ELITE={ [" "] = " ", ["A"] = "/-\\", ["a"] = "@", ["b"] = "ß", ["B"] = "]3", ["c"] = "©", ["C"] = "(", ["d"] = "Ð", ["D"] = "])", ["e"] = "3", ["E"] = "£", ["f"] = "#", ["F"] = "]=", ["g"] = "9", ["G"] = "9", ["h"] = "]-[", ["H"] = "]-[", ["i"] = "!", ["I"] = "][", ["j"] = "_]", ["J"] = "_]", ["k"] = "]{", ["K"] = "]<", ["l"] = "1", ["L"] = "[_", ["m"] = "/\\/\\", ["M"] = "]\\/]", ["n"] = "/\\/", ["N"] = "]\\]", ["o"] = "¤", ["O"] = "()", ["p"] = "Þ", ["P"] = "]D", ["q"] = "¶", ["Q"] = "&", ["r"] = "®", ["R"] = "]2", ["s"] = "§", ["S"] = "5", ["t"] = "+", ["T"] = "7", ["u"] = "[_[", ["U"] = "[_[", ["v"] = "\\/", ["V"] = "\\/", ["w"] = "\\/\\/", ["W"] = "\\/\\[", ["x"] = "}{", ["X"] = "><", ["y"] = "ý", ["Y"] = "¥", ["z"] = "2", ["Z"] = "2" } ------------------------- if cTable == nil then --//script started cTable={["Settings"]={["OnOff"]=1}, ["Hubs"] ={}} dofile(crazyFileName) for k,v in dcpp._hubs do hA = v:getAddress() dynRclick(v,hA,0) end DC():PrintDebug(" ***** BCDCrazy "..cVer.." loaded. *****") else --//script restarted DC():PrintDebug(" ***** BCDCrazy "..cVer.." RE-loaded. *****") end ------------------------- --//BCDCrazy Script by ßottledHatê.