MainChat Locker and Cleaner [New API] - Page 2
 

MainChat Locker and Cleaner [New API]

Started by Tw?sT?d-d?v, 28 October, 2007, 14:48:29

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

the-master

-- MainChat Locker and Cleaner [New API] by Tw?sT?d-d?v?l (28/10/07)
-- Version 1.01
-- Getting started with lua
-- Version 1.02
-- Added Mainchat locker
-- Added Rightclicker
-- Version 1.03
-- Added profiles (tested but might still be bugs)


cConfig = {
	["Botname"] = "MainChat",						-- Bot name
        ["Botdescription"] = "I clean and lock",                                -- Bot description
        ["Botmail"] = "clean@closet",                                           -- Bot email
        CanClean = {
        [0] = 1,	-- Master
        [1] = 0,	-- Operator
        [2] = 0,        -- Vip
        [3] = 0,        -- Registered User
        },
        Block = {
        [-1] = 1,       -- Unregistered User
        [0] = 0,        -- Master
        [1] = 0,        -- Operator
        [2] = 0,        -- Vip
        [3] = 1,        -- Registered User
        },
        MainChatLock = nil,
}

CleaningCommand = "clean"                                                       -- Cleaner command
LockingCommand = "mainchat off"                                                  -- Lock Mainchat
UnlockingCommand = "mainchat on"                                               -- Unlock Mainchat

function OnStartup()
                 Core.RegBot(cConfig.Botname,cConfig.Botdescription,cConfig.Botmail,true)
end

ChatArrival = function(User,Data)
	Core.GetUserAllData(User)
	local _,_,cmd = string.find(Data, "%b<>%s%p(%S+)|")
	if cmd == "clean" and (cConfig.CanClean[User.iProfile] == 1) then
		Core.SendToAll("Mainchat cleaning started by "..User.sNick..string.rep("\n",26).."Still Cleaning Mainchat\n"..string.rep("\n",26).."Mainchat cleaning finished\n")
		return true
	end
	if User.bOperator then
		local s,e,cmd,arg = string.find(Data, "%b<>%s([^ ]+)%s*([^|]*)")
		if cmd and cmd  == "!mainchat" then
			if arg == "off" then
				if cConfig.MainChatLock then
					Core.SendToNick(User.sNick,"<"..cConfig.Botname.."> Main chat is already disabled for user access.")
				else
					Core.SendToAll("<"..cConfig.Botname.."> Main chat is temporarily disabled for user access.")
					cConfig.MainChatLock = 1
				end
			elseif arg == "on" then
				if cConfig.MainChatLock then
					Core.SendToAll("<"..cConfig.Botname.."> Main chat is now enabled for user access.")
					cConfig.MainChatLock = nil
				else
					Core.SendToNick(User.sNick,"<"..cConfig.Botname.."> Main chat is already enabled for user access.")
				end
			else
				Core.SendToNick(User.sNick,"<"..cConfig.Botname.."> Invalid argument. ( on / off )")
			end
			return true
		end
	end
	if cConfig.Block[User.iProfile] == 1 then
	  if cConfig.MainChatLock then
		  Core.SendToNick(User.sNick,"<"..cConfig.Botname.."> Main chat is curently disabled for user access.")
		  return true
		end		  
	end
end

OpConnected = function(user)
	Core.GetUserAllData(user)
	if (cConfig.CanClean[user.iProfile] == 1) then
		Core.SendToNick(user.sNick,"$UserCommand 1 3 MainChat\\Clean Mainchat$<%[mynick]> !clean&#124;|")
	end
		Core.SendToNick(user.sNick,"$UserCommand 1 3 MainChat\\Lock Mainchat$<%[mynick]> !mainchat off&#124;|")
        Core.SendToNick(user.sNick,"$UserCommand 1 3 MainChat\\Unlock Mainchat$<%[mynick]> !mainchat on&#124;|")
        Core.SendToNick(user.sNick,"<"..SetMan.GetString(21).."> Mainchat commands are enabled, see hub Rightclicker for more.")

end
keep on sharing :)

SMF spam blocked by CleanTalk