MainChat Locker and Cleaner [New API]
 

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.

Tw?sT?d-d?v

The following script has been tested but has its my first attempt on my own at scripting  :), it well more then likley contain bugs :P

-- 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 = 1
}

CleaningCommand = "clean"                                                       -- Cleaner command
LockingCommand = "mainchat on"                                                  -- Lock Mainchat
UnlockingCommand = "mainchat off"                                               -- 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 and (cmd == CleaningCommand) then
		Core.SendToAll("<"..cConfig.Botname.."> Mainchat cleaning started by "..User.sNick)
                Core.SendToAll("<"..cConfig.Botname.."> \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\tStill Cleaning Mainchat\n")
                Core.SendToAll("<"..cConfig.Botname.."> \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\tMainchat cleaning finished\n")
		return true
	end
        Core.GetUserAllData(User)
	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.."> Temporarily main chat is disabled for user access.")
					cConfig.MainChatLock = 1
				end
			elseif (arg == "on") then
				if sMainChatLock 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
		Core.SendToNick(User.sNick,"<"..cConfig.Botname.."> Main chat is disabled for user access.")
		return true
	end
end

NewUserConnected = 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;")
                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
end

OpConnected = NewUserConnected


Feel free to post comments and errors so i can fix/learn more  :)

Yahoo

#1
hello
I am using this script for  ptokax 0.4.0.0RC2 and found tht there is some bug in the script
when i lock main chat it gets lock
but when i try to unlock the main chat it is still lock and doesnt gets unlock (i.e the unlock command is not working)
"BoRN FIGhTEr"

speedX

Fixed
-- 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 = 1
}

CleaningCommand = "clean"                                                       -- Cleaner command
LockingCommand = "mainchat on"                                                  -- Lock Mainchat
UnlockingCommand = "mainchat off"                                               -- 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 and (cmd == CleaningCommand) then
		Core.SendToAll("<"..cConfig.Botname.."> Mainchat cleaning started by "..User.sNick)
                Core.SendToAll("<"..cConfig.Botname.."> \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\tStill Cleaning Mainchat\n")
                Core.SendToAll("<"..cConfig.Botname.."> \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\tMainchat cleaning finished\n")
		return true
	end
        Core.GetUserAllData(User)
	if User.bOperator then
		local s,e,cmd,arg = string.find(Data, "%b<>%s([^ ]+)%s*([^|]*)")
		if cmd and (cmd == "!mainchat") then
			if (arg == "on") then
				if cConfig.MainChatLock then
					Core.SendToNick(User.sNick,"<"..cConfig.Botname.."> Main chat is already disabled for user access.")
				else
					Core.SendToAll("<"..cConfig.Botname.."> Temporarily main chat is disabled for user access.")
					cConfig.MainChatLock = 1
				end
			elseif (arg == "off") 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 disabled for user access.")
		  return true
		end		  
	end
end

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

OpConnected = NewUserConnected

Thanking You,

speedX

Yahoo

Thanks speedx

The script is working great
"BoRN FIGhTEr"

shardana

Howto change the default locked main chat with unlocked main chat?

speedX

change
MainChatLock = 1


to
MainChatLock = nil
Thanking You,

speedX


swee

Done some changes in this script since all i needed was the cleaning part.
But it takes 2 minutes before it cleans the main chat why ??
/regards swee




-- 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"] = "Main",                                      -- Bot name
        ["Botdescription"] = "I clean",                                         -- Bot description
        ["Botmail"] = "clean@closet",                                           -- Bot email
        CanClean = {
       
  • = 1,         -- Master
            [1] = 0,         -- Operator
            [2] = 0,        -- Vip
            [3] = 0,        -- Registered User
            },
    }

    CleaningCommand = "clean"                                                       -- Cleaner command

    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 and (cmd == CleaningCommand) then
          Core.SendToAll("<"..cConfig.Botname.."> Mainchat cleaning started by "..User.sNick)
                    Core.SendToAll("<"..cConfig.Botname.."> \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\tStill Cleaning Mainchat\n")
                    Core.SendToAll("<"..cConfig.Botname.."> \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\tMainchat cleaning finished\n")
          return true
       end
    end

    NewUserConnected = function(user)
       Core.GetUserAllData(user)
       if (cConfig.CanClean[user.iProfile] == 1) then
          Core.SendToNick(user.sNick,"$UserCommand 1 3 Main\\Clean Mainchat$<%[mynick]> !clean|")
                    Core.SendToNick(user.sNick,"<"..SetMan.GetString(21).."> Mainchat commands are enabled, see hub Rightclicker for more.")
       end
    end

    OpConnected = NewUserConnected
    [/sub]

Tw?sT?d-d?v

#8
Try this   
HERE

swee

Yes that worked very nice thank you
/regards swee


reaper

#11
Thx for this script its work very nice

?StIfFLEr??

[05:53:50] <MainChat> Invalid argument. ( on / off )<---- when i tried to lock mainchat by right click
[05:54:02] <?StIfFLEr??> !clean<?StIfFLEr??> <----- clean by right click
[05:54:12] <MainChat> Invalid argument. ( on / off )<----- unlock by right click

previous version was much better


vineetdhanawat

yo.. nice script.. but i hav a situation. here on our lan, we are not allowed to open mainchat.. but jus for text commands.. we hav been allowed 4 charaters like +i etc.. but to use scripts like offline msging systems, games.. we need to have no mainchat restrictions..

so can this script be modified.. so as to allow 4 chars length only..(or mayb 2,3 depending) but if the input is a valid command.. it should allow that too..  :)

DeAn

This script still contains bugs..  Even when main chat is locked, users can type in main..
can this be corrected ?

Modifications Required :

1] Lock main for certian nicks for a default time.. if more or less than default time, an option to specify the time.
2] A clear right click menu which contains "Lock Main-Chat" %[line:Lock Main-Chat For Whom ?] [ dialogue box for nick ]
3] Unlock mainchat for the nick after the default lock time. [ Also can be able unliock before default time manually ]
4] Lock main-chat only allowed by master.
5] Main objective of this script is to lock and unlock main-chat.. for cleaning theres already a different script.. It would be great if the clean command is removed.
6] Option to list nicks for whom main chat is locked.

It would make a wonderful script with these modifications..
I would like to see the modified version..
Thanks,

DeAn

TZB


DeAn

Thanks,

DeAn

Yahoo

Quote from: DeAn on 18 July, 2009, 19:38:16
This script still contains bugs..  Even when main chat is locked, users can type in main..
can this be corrected ?

Modifications Required :

1] Lock main for certian nicks for a default time.. if more or less than default time, an option to specify the time.
2] A clear right click menu which contains "Lock Main-Chat" %[line:Lock Main-Chat For Whom ?] [ dialogue box for nick ]
3] Unlock mainchat for the nick after the default lock time. [ Also can be able unliock before default time manually ]
4] Lock main-chat only allowed by master.
5] Main objective of this script is to lock and unlock main-chat.. for cleaning theres already a different script.. It would be great if the clean command is removed.
6] Option to list nicks for whom main chat is locked.

It would make a wonderful script with these modifications..
I would like to see the modified version..

1] Lock main for certian nicks for a default time.. if more or less than default time, an option to specify the time.
For this request use Mute script or gag command which is there in ptokax by default

5] Main objective of this script is to lock and unlock main-chat.. for cleaning theres already a different script.. It would be great if the clean command is removed.
For this request Its upto the scripter what he wants to add and what he dont

And for remaining request which are completely related to mute script made by mutor so u can search for that script in the forum
"BoRN FIGhTEr"

TZB


DeAn

Quote
1] Lock main for certian nicks for a default time.. if more or less than default time, an option to specify the time.
For this request use Mute script or gag command which is there in ptokax by default
The user can again type on main chat when he reconnects the hub..

Quote
5] Main objective of this script is to lock and unlock main-chat.. for cleaning theres already a different script.. It would be great if the clean command is removed.
For this request Its upto the scripter what he wants to add and what he dont
Agreed..

Quote
And for remaining request which are completely related to mute script made by mutor so u can search for that script in the forum
Mute is a command which mutes the user completely.. The thing I requested is that only main chat be disabled for certain nicks..
Thanks,

DeAn

TZB

Search for Flexo AOI by madman there is a plug in called gag ball which will do what you want!

DeAn

Thanks,

DeAn

DeAn

Thanks,

DeAn

4uvak91

#23
Quote from: †StIfFLEr†™ on 17 November, 2008, 01:25:47
[05:53:50] <MainChat> Invalid argument. ( on / off )<---- when i tried to lock mainchat by right click
[05:54:02] <†StIfFLEr†™> !clean<†StIfFLEr†™> <----- clean by right click
[05:54:12] <MainChat> Invalid argument. ( on / off )<----- unlock by right click

previous version was much better




I have this problem too, can some1 please fix this script  ???

PTGenius

Hi

Its possible change that script for Block only the Private MSG?
And if its possible, only block unregusers

Sory my bad english.

SMF spam blocked by CleanTalk