Disable\Enable MainChat
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Disable\Enable MainChat

Started by 6Marilyn6Manson6, 08 December, 2004, 09:36:10

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

6Marilyn6Manson6

Hello.... I search script for disable MainChat with 5 command. Example:

with command:

!stopchat   I disable MainChat and when user write in MainChat.. he / she receive... You can't Write In Mainchat
!startchat   I enable MainChat in normal mode
!permession   I let at user of write in MainChat disable mode
!removepermission   I delete let at user of write in MainChat
!showlistpermession   I see list of user with let write in MainChat

Is it possible? is it most important for me.. please help me

Thanks a LOT

Herodes

#1
try this 1 ...
--- --- --- --- --- --- --- --- --- --- ---
--- MainStop v 1 
--- by Herodes
--- --- --- --- --- --- --- --- --- --- ---
---- Look at the NOTES of this script
--- stops mainchat for selected users or whole profiles
--- remembers state after hub restarts..
--- protects profiles ( set the priorities correctly look at the notes below .. )
--- --- --- --- --- --- --- --- --- --- ---
	--- NOTES: 
--- Put this file in your scripts folder of Ptokax and then Start and Stop the Hub ...
--- Then go and open the File MainStop-Profiles.dat with Notepad.exe
--- explanation of contents follows ...
--
--	tProfiles = {
--		["1"] = { --- this is the profile number for which the following settings apply ...
--			[1] = 1, ---  [1] = 0 means no chat, no scripts commands, 1 chat, no script commands, 2 both chat and command use allowed
--			[2] = 2, --- [2] = is the priority number .. the lower the better .. ( no negative values pls ... )
--			[3] = "Operator", 
--		},	--- end for the settings of profile number : "1"
--		["0"] = {
--			[1] = 2,
--			[2] = 1,
--			[3] = "Master",
--		},
--	}
--
--- --- --- --- --- --- --- --- --- --- ---
---- !!!!! Look at the NOTES of this script !!!!!!
cmdclist = "!lschat"
cmdcstop = "!chat"
cmdchelp = "!chelp"
cmdcprof = "!cprofile"
FiletoSaveNoChatNicks = "MainStop-Nicks.dat"
FiletoSaveNoChatProfiles = "MainStop-Profiles.dat"
tUsrs = {}

function Main()
	LoadFromFile(FiletoSaveNoChatNicks)
	if readfrom(FiletoSaveNoChatProfiles) == nil then
		tProfiles = {}
		local nu = 0
		for i, v in GetProfiles() do
			nu = nu + 1
			tProfiles[""..i..""] = { 1, nu, v }
		end
		tProfiles["-1"] = { 1, nu + 1, "Unregs" }
		SaveToFile(FiletoSaveNoChatProfiles , tProfiles , "tProfiles")
		readfrom()
	end
	readfrom()
	LoadFromFile(FiletoSaveNoChatProfiles)
end

function UserConnected(user)
	if tUsrs[user.sName] == 1 or tProfiles[""..user.iProfile..""][1] == 0 then
		user:SendData("MainChatBlocker", "You cant use the mainchat for now. ...")
	end
end

function DataArrival(user, data)
	if strsub(data, 1,1) == "<" or "*" then 
		if tUsrs[user.sName] == 1 or tProfiles[""..user.iProfile..""][1] == 0 then
			user:SendData("MainChatBlocker", "You cant chat in main...")
			return 1 
		else
			if tProfiles[""..user.iProfile..""][1] == 2 then
				data = strsub(data, 1, -2)
				s,e,cmd,args = strfind(data, "%b<>%s+(%S+)%s*(%S*)")
				if cmd == cmdclist then
					local msg = "\r\n - The following users are gagged in mainchat\r\n"
					for nick, v in tUsrs do
						msg = msg.."\t -- "..nick.."\r\n"
					end
					msg = msg.." - The profile permissions are as follows\r\n"
					msg = msg.." - \tProfile Name\tCmds/MainChat\r\n"
					local cmds, chat = "yes", "yes"
					for i,v in tProfiles do
						if v[1] == 0 then
							cmds, chat = "no", "no"
						elseif v[1] == 1 then
							cmds , chat = "no", "yes"
						elseif v[1] == 2 then
							cmds , chat = "yes", "yes"
						end
						local prstr = v[3].." ("..i..")"
						if strlen(prstr) < 8 then 
							prstr = prstr.."\t"
						end
						msg = msg.."\t+ "..prstr.."\t   "..cmds.."/"..chat.."\r\n"
					end
					user:SendData("MainChatBlocker", msg)
					return 1
				elseif cmd == cmdcstop then
					if (not args) or (strlen(args) == 0) then
						user:SendData("MainChatBlocker", "Syntax Error! Please Use like : "..cmdstop.." ")
					else
						local usr = GetItemByName(args)
						if tUsrs[usr.sName] then
							tUsrs[usr.sName] = nil
							usr.SendData("MainChatBlocker", GetProfileName(user.iProfile).." "..user.sName.." you are now able to chat in mainchat.")
							user:SendData("MainChatBlocker", usr.sName.." now can chat in main")
						else 
							if usr then
								tUsrs[usr.sName] = 1
								usr.SendData("MainChatBlocker", GetProfileName(user.iProfile).." "..user.sName.." has blocked your ability to chat in mainchat.")
								user:SendData("MainChatBlocker", usr.sName.." now can't chat in main")
							else 
								user:SendData("MainChatBlocker", "Error : "..args.." is not in the hub.")
							end
						end
					end
					SaveToFile(FiletoSaveNoChatNicks , tUsrs , "tUsrs")
				elseif cmd == cmdchelp then
					local msg = "\t\t--- MainChatBlocker Commands --- \r\n"
					msg = msg.."][\t "..cmdclist.."\t - lists the users that are blocked\r\n"
					msg = msg.."][\t "..cmdcstop.."  \t - gags the mainchat of nick\r\n"
					msg = msg.."][\t "..cmdcprof.." \t - It toggles the permission to chat in main for the specified profile number\r\n"
					msg = msg.."][\t "..cmdchelp.."\t - shows this helpful text :P\r\n"
					user:SendData(msg)
				elseif cmd == cmdcprof then
					if (not args) or (strlen(args) == 0) then
						user:SendData("MainChatBlocker", "Syntax Error! Please Use like : "..cmdcprof.." ")
					else
						if args == "-1" then
							if tProfiles[args][1] == 1 then
								tProfiles[args][1] = 0
								user:SendData("MainChatBlocker", "Normal Users now are unable to chat in mainchat")
								SendToAll("MainChatBlocker", "Notice! : Normal Users now are unable to chat in mainchat")
							elseif tProfiles[args][1] == 0 then
								tProfiles[args][1] = 1
								user:SendData("MainChatBlocker", "Normal Users now are able to chat in mainchat")
								SendToAll("MainChatBlocker", "Notice: Normal Users now are able to chat in mainchat")
							end
						else 
							s,e,pr = strfind(args, "(%d+)")
							pr = tonumber(pr)
							if GetProfiles()[pr] then
								if tProfiles[""..user.iProfile..""][2] < tProfiles[""..pr..""][2] then --- priority checking ..
									if tProfiles[""..pr..""][1] == 0 then 
										tProfiles[""..pr..""][1] = 1 
										user:SendData("MainChatBlocker", GetProfileName(pr).."s now are unable to chat in mainchat")
										SendToAll("MainChatBlocker", "Notice: "..GetProfileName(pr).."s now are unable to chat in mainchat")
									elseif  tProfiles[""..pr..""][1] == 1 then
										tProfiles[""..pr..""][1] = 0
										user:SendData("MainChatBlocker", GetProfileName(pr).."s now are able to chat in mainchat")
										SendToAll("MainChatBlocker", "Notice: "..GetProfileName(pr).."s now are able to chat in mainchat")
									end
								else
									user:SendData("MainChatBlocker", "Error! : You are not allowed to block the mainchat of "..GetProfileName(pr).."s")
									SendToOps("MainChatBlocker", "Mr."..user.sName.." behaves stupidly ...")
								end
							else 
								user:SendData("MainChatBlocker", "There is no such profile number")
							end
						end
						SaveToFile(FiletoSaveNoChatProfiles , tProfiles , "tProfiles")
					end
				end
			end
		end
	end
end

function Serialize(tTable, sTableName, sTab)
	assert(tTable, "tTable equals nil");
	assert(sTableName, "sTableName equals nil");

	assert(type(tTable) == "table", "tTable must be a table!");
	assert(type(sTableName) == "string", "sTableName must be a string!");

	sTab = sTab or "";
	sTmp = ""

	sTmp = sTmp..sTab..sTableName.." = {\n"

	for key, value in tTable do
		local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);

		if(type(value) == "table") then
			sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
		else
			local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
			sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
		end

		sTmp = sTmp..",\n"
	end

	sTmp = sTmp..sTab.."}"
	return sTmp
end

function SaveToFile(file , table , tablename)
	writeto(file)
	write(Serialize(table, tablename))
	writeto()
end

function LoadFromFile(file)
	if (readfrom(file) ~= nil) then
		readfrom(file)
		dostring(read("*all"))
		readfrom()
	end
end

6Marilyn6Manson6

MAGICCCCCCCCCCCCCCCCCCC ^___^

Herodes

thank u ;)

tell me if there is smth more to add ...

6Marilyn6Manson6

Herodes... very very thanks ^_^

6Marilyn6Manson6

Hi Herodes.... you're script is not easy :P.
I have it in my personal hub tester and..... command

!chelp

not found. WHy? :C

very very thanks for help ^__^

Herodes

if you mean that it doesnt respond when you type !chelp in mainchat be sure that you have edited the file concerning the profiles in the scripts folder ... ( read the notes )

in any other case I'd like you to explain a bit more ...
I can't guess what you mean by "not found" ;)

6Marilyn6Manson6

Hi Herodes,
In MainStop-Profiles.dat I have copy it:

   tProfiles = {
      ["1"] = { --- this is the profile number for which the following settings apply ...
         [1] = 1, ---  [1] = 0 means no chat, no scripts commands, 1 chat, no script commands, 2 both chat and command use allowed
         [2] = 2, --- [2] = is the priority number .. the lower the better .. ( no negative values pls ... )
         [3] = "Operator",
      },   --- end for the settings of profile number : "1"
      ["0"] = {
         [1] = 2,
         [2] = 1,
         [3] = "Master",
      },
   }

and  !chelp found.. but other not :C
file MainStop-Profiles.dat is empty.. is it ok= thanks a lot ^^

Herodes

MainStop-Profiles.dat is created automatically if there isnt a file called like that in the scripts folder ...

it is created based on the profiles you have in PtokaX ...
when you have a problem :
1. delete the file from the scripts folder
2. Start the hub ...
3. Stop the hub
4. edit the MainStop-Profiles.dat file using Notepad according to the NOTES part of the script ...
5.  Ready to go ...


btw what version of PtokaX are u using ?

6Marilyn6Manson6

PtokaX 330 15.25 ;)

koji_nanami

Hi,

I found this script searching for one that could block main-chat for unregged users.

I've the following problems:

1- Even if I'm op when I connect I get this:

*** Connected
L'hub sta funzionante PtokaX DC Hub 0.3.2.6 TestDrive 4  (UpTime: 0 hours, 4 minutes)
You cant chat in main...
MOTD di PROVA
Logged in.

and if I'm not I get this three times!!:

*** Connected
L'hub sta funzionante PtokaX DC Hub 0.3.2.6 TestDrive 4  (UpTime: 0 hours, 2 minutes)
You cant chat in main...
You cant chat in main...
You cant chat in main...
MOTD di PROVA


2- The main chat is blocked for unregged but every tentative to write a msg I get in main the
" You cant chat in main..." message. Isn't possible to make the script send this in status bar?

3- I get the message also if I try to PM someone which I don't want. Isn't possible to block only mainchat and not the PM.

4- I'm going to add a chatroom will it be blocked too??? I'd like this chat  to be used by unregged...

THanks,

koji

koji_nanami

Herodes or someone else can help on this issue??

bastya_elvtars

as you can see it creates a profiles file. go edit that according to the notes in the  main lua file.
Everything could have been anything else and it would have just as much meaning.

koji_nanami

I've done so and the problems come after that. If i set no chat for unregged then unregged cannot even pm or chat in chatbot rooms. And I see the message for everything in main

bastya_elvtars

post that config file here as CODE
Everything could have been anything else and it would have just as much meaning.

koji_nanami

here you are, only mod the set to chat block for unregged

tProfiles = {
	["1"] = {
		[1] = 1,
		[2] = 2,
		[3] = "Operator",
	},
	["0"] = {
		[1] = 1,
		[2] = 1,
		[3] = "Master",
	},
	["3"] = {
		[1] = 1,
		[2] = 4,
		[3] = "Reg",
	},
	["2"] = {
		[1] = 1,
		[2] = 3,
		[3] = "VIP",
	},
	["-1"] = {
		[1] = 0,
		[2] = 5,
		[3] = "Unregs",
	},
}

here it is

Madman

can anyone convert this to lua5? I couldnt.. still no good on the file handling.. ;)
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

Dessamator

#17
 --- lua5 version by  Dessamator
--- --- --- --- --- --- --- --- --- --- ---
--- MainStop v 1 
--- by Herodes
--- --- --- --- --- --- --- --- --- --- ---
---- Look at the NOTES of this script
--- stops mainchat for selected users or whole profiles
--- remembers state after hub restarts..
--- protects profiles ( set the priorities correctly look at the notes below .. )
--- --- --- --- --- --- --- --- --- --- ---
	--- NOTES: 
--- Put this file in your scripts folder of Ptokax and then Start and Stop the Hub ...
--- Then go and open the File MainStop-Profiles.dat with Notepad.exe
--- explanation of contents follows ...
--
--	tProfiles = {
--		["1"] = { --- this is the profile number for which the following settings apply ...
--			[1] = 1, ---  [1] = 0 means no chat, no scripts commands, 1 chat, no script commands, 2 both chat and command use allowed
--			[2] = 2, --- [2] = is the priority number .. the lower the better .. ( no negative values pls ... )
--			[3] = "Operator", 
--		},	--- end for the settings of profile number : "1"
--		["0"] = {
--			[1] = 2,
--			[2] = 1,
--			[3] = "Master",
--		},
--	}
--
--- --- --- --- --- --- --- --- --- --- ---
---- !!!!! Look at the NOTES of this script !!!!!!
cmdclist = "!lschat"
cmdcstop = "!chat"
cmdchelp = "!chelp"
cmdcprof = "!cprofile"
FiletoSaveNoChatNicks = "MainStop-Nicks.dat"
FiletoSaveNoChatProfiles = "MainStop-Profiles.dat"
tUsrs = {}

function Main()
	LoadFromFile(FiletoSaveNoChatNicks)
	if not(verify("MainStop-Profiles.dat")==true) then
		tProfiles = {}
		local nu = 0
		for i, v in GetProfiles() do
			nu = nu + 1
			tProfiles[""..i..""] = { 1, nu, v }
		end
		tProfiles["-1"] = { 1, nu + 1, "Unregs" }
		SaveToFile(FiletoSaveNoChatProfiles , tProfiles , "tProfiles")
		--readfrom()
	end
	--readfrom()
	LoadFromFile(FiletoSaveNoChatProfiles)
end

function UserConnected(user)
	if tUsrs[user.sName] == 1 or tProfiles[""..user.iProfile..""][1] == 0 then
		user:SendData("MainChatBlocker", "You cant use the mainchat for now. ...")
	end
end

function ChatArrival(user, data)
	if string.sub(data, 1,1) == "<" or "*" then 
		if tUsrs[user.sName] == 1 or tProfiles[""..user.iProfile..""][1] == 0 then
			user:SendData("MainChatBlocker", "You cant chat in main...")
			return 1 
		else
			if tProfiles[""..user.iProfile..""][1] == 2 then
				data = string.sub(data, 1, -2)
				s,e,cmd,args = string.find(data, "%b<>%s+(%S+)%s*(%S*)")
				if cmd == cmdclist then
					
					local msg = "\r\n - The following users are gagged in mainchat\r\n"
					for nick, v in tUsrs do
						msg = msg.."\t -- "..nick.."\r\n"
					end
					msg = msg.." - The profile permissions are as follows\r\n"
					msg = msg.." - \tProfile Name\tCmds/MainChat\r\n"
					local cmds, chat = "yes", "yes"
					for i,v in tProfiles do
						if v[1] == 0 then
							cmds, chat = "no", "no"
						elseif v[1] == 1 then
							cmds , chat = "no", "yes"
						elseif v[1] == 2 then
							cmds , chat = "yes", "yes"
						end
						local prstr = v[3].." ("..i..")"
						if string.len(prstr) < 8 then 
							prstr = prstr.."\t"
						end
						msg = msg.."\t+ "..prstr.."\t   "..cmds.."/"..chat.."\r\n"
					end
					user:SendData("MainChatBlocker", msg)
					return 1
				elseif cmd == cmdcstop then
					if not(args) or (string.len(args) == 0) then
						user:SendData("MainChatBlocker", "Syntax Error! Please Use like : "..cmdcstop.." ")
					else
						local usr = GetItemByName(args)
						if tUsrs[usr.sName] then
							tUsrs[usr.sName] = nil
							usr.SendData("MainChatBlocker", GetProfileName(user.iProfile).." "..user.sName.." you are now able to chat in mainchat.")
							user:SendData("MainChatBlocker", usr.sName.." now can chat in main")
						else 
							if usr then
								tUsrs[usr.sName] = 1
								usr.SendData("MainChatBlocker", GetProfileName(user.iProfile).." "..user.sName.." has blocked your ability to chat in mainchat.")
								user:SendData("MainChatBlocker", usr.sName.." now can't chat in main")
							else 
								user:SendData("MainChatBlocker", "Error : "..args.." is not in the hub.")
							end
						end
					end
					SaveToFile(FiletoSaveNoChatNicks , tUsrs , "tUsrs")
					return 1
				elseif cmd == cmdchelp then
					local msg = "\t\t--- MainChatBlocker Commands --- \r\n"
					msg = msg.."][\t "..cmdclist.."\t - lists the users that are blocked\r\n"
					msg = msg.."][\t "..cmdcstop.."  \t - gags the mainchat of nick\r\n"
					msg = msg.."][\t "..cmdcprof.." \t - It toggles the permission to chat in main for the specified profile number\r\n"
					msg = msg.."][\t "..cmdchelp.."\t - shows this helpful text :P\r\n"
					user:SendData(msg)
					return 1
				elseif cmd == cmdcprof then
					if (not args) or (string.len(args) == 0) then
						user:SendData("MainChatBlocker", "Syntax Error! Please Use like : "..cmdcprof.." ")
					else
						if args == "-1" then
							if tProfiles[args][1] == 1 then
								tProfiles[args][1] = 0
								user:SendData("MainChatBlocker", "Normal Users now are unable to chat in mainchat")
								SendToAll("MainChatBlocker", "Notice! : Normal Users now are unable to chat in mainchat")
							elseif tProfiles[args][1] == 0 then
								tProfiles[args][1] = 1
								user:SendData("MainChatBlocker", "Normal Users now are able to chat in mainchat")
								SendToAll("MainChatBlocker", "Notice: Normal Users now are able to chat in mainchat")
							end
						else 
							s,e,pr = string.find(args, "(%d+)")
							pr = tonumber(pr)
							if GetProfiles()[pr] then
								if tProfiles[""..user.iProfile..""][2] < tProfiles[""..pr..""][2] then --- priority checking ..
									if tProfiles[""..pr..""][1] == 0 then 
										tProfiles[""..pr..""][1] = 1 
										user:SendData("MainChatBlocker", GetProfileName(pr).."s now are unable to chat in mainchat")
										SendToAll("MainChatBlocker", "Notice: "..GetProfileName(pr).."s now are unable to chat in mainchat")
									elseif  tProfiles[""..pr..""][1] == 1 then
										tProfiles[""..pr..""][1] = 0
										user:SendData("MainChatBlocker", GetProfileName(pr).."s now are able to chat in mainchat")
										SendToAll("MainChatBlocker", "Notice: "..GetProfileName(pr).."s now are able to chat in mainchat")
									end
								else
									user:SendData("MainChatBlocker", "Error! : You are not allowed to block the mainchat of "..GetProfileName(pr).."s")
									SendToOps("MainChatBlocker", "Mr."..user.sName.." behaves stupidly ...")
								end
							else 
								user:SendData("MainChatBlocker", "There is no such profile number")
							end
						end
						SaveToFile(FiletoSaveNoChatProfiles , tProfiles , "tProfiles")
						return 1
					end
				end
			end
		end
	end
end

function Serialize(tTable, sTableName, sTab)
        assert(tTable, "tTable equals nil");
        assert(sTableName, "sTableName equals nil");

        assert(type(tTable) == "table", "tTable must be a table!");
        assert(type(sTableName) == "string", "sTableName must be a string!");

        sTab = sTab or "";
        sTmp = ""

        sTmp = sTmp..sTab..sTableName.." = {\n"

        for key, value in tTable do
                local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);

                if(type(value) == "table") then
                        sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
                else
                        local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
                        sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
                end

                sTmp = sTmp..",\n"
        end

        sTmp = sTmp..sTab.."}"
        return sTmp
end

function SaveToFile(file , table , tablename)
	local handle = io.open(file,"w+")
        handle:write(Serialize(table, tablename))
	handle:flush()
        handle:close()
end

function LoadFromFile(file)
local handle = io.open(file,"r")
        if (handle ~= nil) then
                dofile(file)
handle:flush()
handle:close()
        end

end

function verify(filename)
local f = io.open(filename, "r")
	if f then
		f:close()
		return true
	end
end


Done !!
tested slightly, probably still has a lot of bugs !!!
pls read the main comments(notes), b4 complaining about it not working!!!!
Ignorance is Bliss.

Madman

thanks m8, works great =)
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

Dessamator

yw m8, it was sooooooooo darn simple, hehehe, lua 4 to 5 converter did most of the work !!!, just edited some tables, and file handling of course , :D
Ignorance is Bliss.

SMF spam blocked by CleanTalk