PtokaX forum

Lua 5.3/5.2/5.1 Scripts (for PtokaX 0.4.0.0 and newer) => Finished Scripts => Topic started by: Tw?sT?d-d?v on 28 October, 2007, 14:48:29

Title: MainChat Locker and Cleaner [New API]
Post by: Tw?sT?d-d?v on 28 October, 2007, 14:48:29
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  :)
Title: Re: MainChat Locker and Cleaner [New API]
Post by: Yahoo on 02 January, 2008, 07:59:14
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)
Title: Re: MainChat Locker and Cleaner [New API]
Post by: speedX on 02 January, 2008, 08:55:32
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

Title: Re: MainChat Locker and Cleaner [New API]
Post by: Yahoo on 02 January, 2008, 09:46:22
Thanks speedx

The script is working great
Title: Re: MainChat Locker and Cleaner [New API]
Post by: shardana on 06 February, 2008, 12:39:27
Howto change the default locked main chat with unlocked main chat?
Title: Re: MainChat Locker and Cleaner [New API]
Post by: speedX on 06 February, 2008, 18:39:35
change

MainChatLock = 1


to

MainChatLock = nil
Title: Re: MainChat Locker and Cleaner [New API]
Post by: shardana on 06 February, 2008, 19:23:01
Thank
Title: Re: MainChat Locker and Cleaner [New API]
Post by: swee on 18 March, 2008, 12:51:32
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]
Title: Re: MainChat Locker and Cleaner [New API]
Post by: Tw?sT?d-d?v on 18 March, 2008, 18:24:49
Try this   
HERE (http://euro-op.no-ip.info:8080/files1/Mini-MainChat-Cleaner%20%7BNew%20API%7D.rar)
Title: Re: MainChat Locker and Cleaner [New API]
Post by: swee on 18 March, 2008, 23:19:53
Yes that worked very nice thank you
/regards swee
Title: Re: MainChat Locker and Cleaner [New API]
Post by: Tw?sT?d-d?v on 19 March, 2008, 18:58:58
Nps m8
Title: Re: MainChat Locker and Cleaner [New API]
Post by: reaper on 16 November, 2008, 19:09:20
Thx for this script its work very nice
Title: Re: MainChat Locker and Cleaner [New API]
Post by: ?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

Title: Re: MainChat Locker and Cleaner [New API]
Post by: vineetdhanawat on 22 November, 2008, 13:39:15
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..  :)
Title: Re: MainChat Locker and Cleaner [New API]
Post by: 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..
Title: Re: MainChat Locker and Cleaner [New API]
Post by: TZB on 18 July, 2009, 19:59:29
What is it? Request,Order?  ;D  ;)
Title: Re: MainChat Locker and Cleaner [New API]
Post by: DeAn on 19 July, 2009, 05:14:37
Its a request..
Title: Re: MainChat Locker and Cleaner [New API]
Post by: Yahoo on 19 July, 2009, 07:37:40
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
Title: Re: MainChat Locker and Cleaner [New API]
Post by: TZB on 19 July, 2009, 07:42:34
I agree to yahoo. 100%  :)
Title: Re: MainChat Locker and Cleaner [New API]
Post by: DeAn on 19 July, 2009, 11:52:23
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..
Title: Re: MainChat Locker and Cleaner [New API]
Post by: TZB on 19 July, 2009, 12:23:47
Search for Flexo AOI by madman there is a plug in called gag ball which will do what you want!
Title: Re: MainChat Locker and Cleaner [New API]
Post by: DeAn on 19 July, 2009, 13:03:20
OK.. Thanks TZB  :)
Title: Re: MainChat Locker and Cleaner [New API]
Post by: DeAn on 20 July, 2009, 05:23:38
Thanks Mutor..
Title: Re: MainChat Locker and Cleaner [New API]
Post by: 4uvak91 on 08 April, 2010, 16:47:24
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  ???
Title: Re: MainChat Locker and Cleaner [New API]
Post by: PTGenius on 17 May, 2012, 19:14:16
Hi

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

Sory my bad english.
Title: Re: MainChat Locker and Cleaner [New API]
Post by: the-master on 18 May, 2012, 10:02:18

-- 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