------------------------------------------------------- --------------- Dirtybot - Lua Edition ---------------- ------------------- by DirtyFinger -------------------- ---------------- DirtyFinger@gmx.net ------------------ ------------------ ICQ : 145873101 -------------------- ------- http://www30.brinkster.com/dirtyfinger/ ------- ------------------------------------------------------- version = "0.012 " ----------------------------------- ------------------------------------------------------- -- This script is still in development, but it's goind to be an admin bot -- for the PtokaX hub-software . -- This file is just one of many. For the bot to work you need these files : -- scripts\Dirtybot.lua -- scripts\DirtyBot\Commands.lua -- scripts\DirtyBot\DirtyUsers.lua -- scripts\DirtyBot\DataToolkit.lua -- It also generates and accesses several files : -- scripts\DirtyBot\IP.xml -- scripts\DirtyBot\users.xml -- scripts\DirtyBot\rules.txt TAB = "\t" -- tabulator CRLF = "\r\n" -- newline sBotname = "DirtyBot-LuaEdition" version = "0.012 " second = 1000 minute = second*60 hour = minute*60 day = hour*24 week = day*7 month = day*30 year = day*365 timerIntervall = 10*minute -- dofile imports sourcecode from other scripts assert(dofile("scripts/DirtyBot/DirtyUsers.lua")) assert(dofile("scripts/DirtyBot/Commands.lua")) assert(dofile("scripts/DirtyBot/DataToolkit.lua")) FileUserList = "scripts/DirtyBot/users.xml" FileIPList = "scripts/DirtyBot/IP.xml" FileHubRules = "scripts/DirtyBot/rules.txt" --// This function is fired at the serving start function Main() print(sBotname.." "..version..date(" launched at %B %d %Y %X ")) SetTimer(timerIntervall) StartTimer() frmHub:RegBot(sBotname) DirtyUsers:loadFromXMLFile(FileUserList,FileIPList) end --// This function is fired when a new data arrives function DataArrival(curUser, sData) if DataToolkit:isMainchatMessage(curUser,sData) or DataToolkit:isPrivateMessage(curUser,sData) then local command,parameter = Commands:isCommand(Commands:toCommand(curUser,sData)) if command then -- command has a value or is nil, depending on if the command exists Commands:executeCommand(curUser,command,parameter) else print("Command unknown") end end -- TODO your code here end --// This function is fired when a new user finishes the login function NewUserConnected(curUser) end --// This function is fired when an operator enters the hub function OpConnected(curUser) -- TODO your code here end --// This function is fired when an user disconnects function UserDisconnected(curUser) -- TODO your code here end --// This function is fired when an operator disconnects function OpDisconnected(curUser) -- TODO your code here end -- This function gets fired after each previously defined intervall function OnTimer() DirtyUsers:saveToFile(FileUserList,FileIPList) end ------ -- Little helpers ----- -- Function : print -- Usage : print(string1,string2, ...) -- Effect : displays given strings in the mainchat. Multiple strings are seperated by tabs. -- This overwrites the standard print method which doesn't get used in dcHub scripts anyway. function print (...) local s ="" for i=1,arg.n do s = s..tostring(arg[i])..TAB end SendToAll ("-=*=-",s) end -- end print ------ -- Function : placeargs -- Usage : placeargs ("Hello $1. Welcome to $2. $1 rulez!",string1,string2,...) -- Effect : returns a string where all $x are replaced by the other given strings. -- The above example with string1="Dirty" and string2="Hentaizone" would return this : -- Hello Dirty. Welcome to Hentaizone. Dirty rulez! function placeargs (s, ...) local l = gsub(s, "$(%d)", function(i) return %arg[tonumber(i)] end ) return l end -- end placeargs ------