-- Kenny2 v0.1.2 2005-03-13 -- Developed for Verlihub by Téper -- Makes users Kenny-clones, and replaces words with Kenny-words... -- Original version: -- Kenny Script by Hawk -- 31-03-04 Bot = "Kenny" KennyText = {"*umfl*", "*uuffum*", "*lluu*", "*mlmlff*", "*lfumfl*", "*lmmf*", "*uullu*", "*mmmm*", "*ommlu*", "*mflf*", "*olomum*", "*mhhhmmlm*", "*mhhl*", "*mujm*"} KennylizedNicks = {} function VH_OnOperatorCommand(Nick, Cmd) -- Operator commands: Cmd, Param = First(Cmd) if Cmd == "!kenny" then SubCmd, Param = First(Param) if SubCmd == "add" then -- !kenny add Kenylize(Param) return 0 elseif SubCmd == "remove" then -- !kenny remove UnKenylize(Param) return 0 elseif SubCmd == "list" then -- !kenny list ShowKennys(Nick) return 0 elseif SubCmd == "help" then -- !kenny help KennyHelp(Nick) return 0 end end return 1 end function VH_OnParsedMsgChat(Nick, msg) -- Users messages in mainchat if KennylizedNicks[Nick] == 1 then -- It is a clone, so replace all words with kenny-words text = string.gsub(msg, "%w+", function () return KennyText[math.random(1, table.getn(KennyText))] end ) -- Send out the kennylized message VH:SendDataToAll("<"..Nick.."> "..text.."|", 0, 10) -- Signal the hub, that the original message is not needed to be sent return 0 end return 1 end function Kenylize(User) -- Add a user to the Kennylilzed users' list if KennylizedNicks[User] == nil then KennylizedNicks[User] = 1 VH:SendDataToAll(CreateChat(Bot, User.." became a Kenny clone..."), 0, 10) end end function UnKenylize(User) -- Remove a user from the Kennylized usesrs' list if User == "all" then -- When used as !kenny remove all, empty the list KennylizedNicks = {} VH:SendDataToAll(CreateChat(Bot, "All Kenny clones changed back..."), 0, 10) elseif KennylizedNicks[User] == 1 then KennylizedNicks[User] = nil; VH:SendDataToAll(CreateChat(Bot, User.." changed back..."), 0, 10) end end function ShowKennys(User) -- Display a list of kennylized users local Names = "" for line, val in pairs(KennylizedNicks) do Names = Names.." "..line.."\r\n" end VH:SendDataToUser(CreateChat(Bot, "Kennylized users:\r\n"..Names), User) end function KennyHelp(User) -- Display some help?: list of commands VH:SendDataToUser(CreateChat(Bot, "Help on Kennylization:\r\n".. "- !kenny add \r\n- !kenny remove (also ''all'')\r\n".. "- !kenny list\r\n- !kenny help"), User) end -- Some useful tools function CreateChat(From, Msg) -- Makes a chat message return "<"..From.."> "..Msg.."|" end function CreaterPM(From, To, Msg) -- Makes a Private message return "$To: "..To.." $From: "..From.." $"..CreateChat(From, Msg) end function First(Str, Sep) -- Takes the First "word", and returns it, also returns the rest of line if Sep == nil then -- It is the RegExp, that select the first Word Sep = "%s" end local i = string.find(Str, Sep) if i == nil then -- If the whole Str is not containing 2 word, -- the whole Str is returned as the First word return Str, "" else return string.sub(Str, 1, i-1), string.sub(Str, i+1) end end