Chatrooms v3 (tezlo) LUA 5 - Page 4
 

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

Chatrooms v3 (tezlo) LUA 5

Started by jiten, 02 March, 2005, 19:58:55

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

front242

#75
QuoteOriginally posted by Dessamator
That question has already been answered, read the previous posts .
yes, but if i delete "and user.bOperator" then creating chat, inviting e.t.c. will be able ALL non-op reg profiles

i need manually set laws for each command depending on profile name

for example:
if cmd == tCmds.MakeChat and profilename=reg_advanced or reg_platinum

plz help me do it correct

Rick

Where am I supposed to see the commands? I don't see a right click menu in DC++ on the chatroom other than the default
!mkchat works but delchat doesn't seem to
I am new to this so please go slow :D
THanks
Rick

Rick

What I am trying to do is set up chatrooms that anyone can enter. I understand that !mkchat Talk VIP would make one named "Talk" that VIPs and presumabley above could enter

If I don't add a profile (i.e VIP) as the last argument will it be available to all members?
Thanks
Rick

Rick

... and the right click menu suddenly appeared when clicking on the chat name in DC++
Will test it later but looks great so far
Thanks
Rick

osse

[09:51:49] Robocop\RoboCopv10.01e.lua:369: attempt to index field `?' (a nil value)


When i use the script ...Any1 who know why???

?????

Thnx 4 helping me....

Osse

Dessamator

Maybe ur using an unfinished script, I have personally tested it with robocop, in the past, and it worked perfectly.
Ignorance is Bliss.

Rick

QuoteOriginally posted by Dessamator
how often do u restart the scripts?
We were having a similar issue - I had created a chatroom with no parameter for level. Every one can enter but lately the get "you are not a member) 9or soething like that) and get in anyway. I have made all the changes posted in this thread except the very latest

How many times SHOULD the sctipt be restarted(how often?)

You have made a lot of changes - is there anywhere that we can get the fully updated script?

FWIW  We really enjoy it and appreciate the work put into it
Thanks

Rick

Dessamator

Well a good script doesnt need to be restarted, only when debugging is it required, and about creating room without parameters, the script wasnt written to work that way, its obviously a bug , and no theres isnt a full updated as far as i know,  too many requests and different views make this hard.
Ignorance is Bliss.

Rick

QuoteOriginally posted by Dessamator
how often do u restart the scripts?

either way ,change this :

I've made the chages in this thread and will test them

Any chance of you (Dessamator) posting an updated version of the script with all the suggestions implemented? (and any other features you are thinking of implementing)

We could start there and all be on the same page and it would rule out those issues that may have more to do with editing that your script

thanks
Rick

Dessamator

#84
-- chatrooms v3 by tezlo

-- Lua 5 version by jiten
-- fixed chatroom loading/saving onexit by jiten (5/28/2005)
-- Changed: Commands structure (5/29/2005)
-- Changed: Chatrooms don't have key now
-- Added: Rightclick support
-- Added: Chatroom Key Switch (6/19/2005)
-- Removed: Extra rightclick endpipes
-- Added: Optional Tag
-- Changed: Chatroom deleting and user removing to creator and operators (7/14/2005)
-- Added: Custom Profile Permission for commands 
-- Added: Option to create chatrooms for all users. Set bRestrict to false and type: !mkchat chatroom_name
-- Added: Option to set chatroom only for same profile users / allow operators
-- Fixed: File Handling (10/24/2005)


tKey = 1			-- 0 = Chatrooms don't have key; 1 = Chatrooms have Key
sTag = ""			-- Set your Chatrooms Tag here. If you don't want it, set it to: sTag = ""
fChat = "Chatrooms.tbl"		-- Chatrooms' Database
bRestrict = true		-- Warning: Only applies to command (without specifying a profile): !mkchat chatname
				-- If true, the chatroom will be available only to those invited by the owner.
				-- If false, it will be availabe to everyone.

-- If you're using Robocop profiles don't change this. If not, remove Profile 4 and 5 and follow this syntax: 
-- [Profile number] = value (higher value means more rights)
Levels = { [-1] = 1, [3] = 2, [2] = 3, [1] = 4, [4] = 5, [0] = 6, [5] = 7, }

tCmds = {	-- Set Profile Permissions according to "value" in Levels table.
		-- Example: MakeChat = { "mkchat", 2 },
		--	    Reg and above users are allowed to create chatrooms.
	MakeChat = { "mkchat", 4 },
	Away = { "away", 1 },
	Leave = { "leave", 1 },
	Members = { "members", 1 },
	Invite = { "invite", 4 },
	Remove = { "remove", 4 },
	DelChat = { "delchat", 4 },
}

Main = function()
	chatrooms:load()
end

OnExit = function()
	chatrooms:save()
end

ChatArrival = function(user, data)
	local s, e, cmd, args = string.find(data, "^%b<> %!(%a+)%s*(.*)|$")
	if CheckPermission(user,cmd,tCmds.MakeChat[1]) then
		local s, e, name, profiles = string.find(args, "(%S+)%s*(.*)")
		if not s then
			return user:SendData(frmHub:GetHubBotName(),"*** Syntax Error: Type !mkchat  [groups]"), 1
		elseif chatrooms.items[name] then	
			return user:SendData(frmHub:GetHubBotName(),"*** Error: "..name.." is already a Chatroom."), 1
		elseif GetItemByName(name) then
			return user:SendData(frmHub:GetHubBotName(),"*** There is a user with that name"), 1
		else
			if tKey == 1 then frmHub:RegBot(sTag..name) else frmHub:RegBot(sTag..name,0,"","") end
			local tmp
			if profiles == "public" then tmp = chatrooms:new(sTag..name, user.sName,"public")
			else tmp = chatrooms:new(sTag..name, user.sName) end
			string.gsub(profiles, "(%S+)", function(profile)
			profile = tonumber(profile) or GetProfileIdx(profile)
				if GetProfileName(profile) then tmp.groups[profile] = 1 end
			
			end); tmp:chat("Hello", sTag..name)
			chatrooms:save()
			return 1
		end
	end
end

ToArrival = function(user,data)
	local s, e, to, str = string.find(data, "^$To: (%S+) From: %S+ $%b<> (.*)|$")
	if chatrooms.items[to] then
		local tmp = chatrooms.items[to]
		if not tmp.members[user.sName] then
			if next(tmp.groups) then
				if user.bOperator or tmp.groups[user.iProfile] == 1 then
--				if tmp.groups[user.iProfile] == 1 then  -- Uncomment this line and comment the above one if you want
									-- the chatroom to be available only for users of the same 
									-- profile. So, Operators won't join like they do in the other line.
					tmp.members[user.sName] = 1
					tmp:chat(user.sName.." joined", to)
					tmp:chat(str, user.sName)
					chatrooms:save()
				else
					user:SendPM(to, "You're not a member here.")
				end
			else
				if bRestrict then
					user:SendPM(to, "You're not a member here.")
				else
					tmp.members[user.sName] = 1
					tmp:chat(user.sName.." joined", to)
					tmp:chat(str, user.sName)
					chatrooms:save()
				end
			end
		else
			local isowner = (tmp.owner == user.sName)
			local s, e, cmd, args = string.find(str, "^%!(%a+)%s*(.*)$")
			if not s then
				tmp.members[user.sName] = 1
				tmp:chat(str, user.sName)
			elseif CheckPermission(user,cmd,tCmds.Away[1]) then
				tmp:chat(user.sName.." is away.. "..args, to)
				tmp.members[user.sName] = 0
			elseif CheckPermission(user,cmd,tCmds.Leave[1]) then
				tmp:chat(user.sName.." left. "..args, to)
				tmp.members[user.sName] = nil
				chatrooms:save()
			elseif CheckPermission(user,cmd,tCmds.Members[1]) then
				local n, na, msg = 0, 0
				for nick, stat in tmp.members do
					if not GetItemByName(nick) then msg = " (offline)"
					elseif stat == 0 then msg = " (away)"
					else msg, na = "", na+1
					end; n = n+1
					user:SendPM(to, "\t"..nick..msg)
				end; user:SendPM(to, na.."/"..n.." active members.")
			elseif CheckPermission(user,cmd,tCmds.Invite[1]) then
				string.gsub(args, "(%S+)", function(nick)
					if not tmp.members[nick] then
						tmp.members[nick] = 1
						tmp:chat(nick.." has been invited to the room. Type !leave to leave, and !members to see who's invited.", to)
					end
				end); chatrooms:save()
			elseif CheckPermission(user,cmd,tCmds.Remove[1]) then
				string.gsub(args, "(%S+)", function(nick)
					if tmp.members[nick] and nick ~= tmp.owner then
						tmp:chat(nick.." has been removed from the room", to)
						tmp.members[nick] = nil
					end
				end); chatrooms:save()
			elseif CheckPermission(user,cmd,tCmds.DelChat[1]) then
				tmp:chat("End of session.", to)
				chatrooms.items[to] = nil
				chatrooms:save()
				frmHub:UnregBot(to)
			else
				tmp:chat(str, user.sName)
			end
		end; return 1
	end
end

botchat = function(self, msg, from)
	if self.status =="public" then
		for _,user in frmHub:GetOnlineUsers() do 
			if  not (user.sName ==from) then
				SendToNick(user.sName, "$To: "..user.sName.." From: "..self.name.." $<"..from.."> "..msg)
			end
		end
	else
		for nick, id in self.members do
			if nick ~= from and id == 1 then
				SendToNick(nick, "$To: "..nick.." From: "..self.name.." $<"..from.."> "..msg)
			end
		end
	end
end

chatrooms = {
	new = function(self, name, owner,status)
		local tmp = {
			name = name,
			owner = owner,
			status =status,
			groups = {},
			members = { [owner] = 1 },
			chat = botchat
			
			}; self.items[name] = tmp
		return tmp
	end,

	load = function(self)
		self.items = dofile(fChat) or {}
		for name, room in self.items do
			if tKey == 1 then frmHub:RegBot(name) else frmHub:RegBot(name,0,"","") end
			room.chat = botchat
			room:chat("Hello", name)
		end
	end,

	save = function(self)
		if loadfile(fChat) then 
			local f = io.open(fChat, "w+")
			f:write("return {\n");
			for name, tmp in self.items do
				f:write(string.format("\t[%q] = {\n\t\tname = %q,\n\t\towner = %q,\n\t\tstatus = %q,\n\t\tgroups = {\n", name, tmp.name, tmp.owner,tmp.status))
				for id, stat in tmp.groups do
					f:write(string.format("\t\t\t[%d] = %d,\n", id, stat))
				end; f:write("\t\t},\n\t\tmembers = {\n")
				for nick, stat in tmp.members do
					f:write(string.format("\t\t\t[%q] = %d,\n", nick, stat))
				end; 
				f:write("\t\t}\n\t},\n");
			end; 
			f:write("}"); f:close()
		else
			local f = io.open(fChat, "w+")
			f:write("return {\n"); f:write("}"); f:close()
		end
	end
}

CheckPermission = function(user,cmd,tCmd)
	for i,v in tCmds do
		if cmd == tCmd and v[1] == tCmd then
			if Levels[user.iProfile] >= v[2] then
				return true
			end
			return false
		end
	end
end

NewUserConnected = function(user)
	user:SendData("$UserCommand 1 2 Chatrooms\\Leave$$To: %[line:Chatroom] From: %[mynick] $<%[mynick]> !"..tCmds.Leave[1].."|")
	user:SendData("$UserCommand 1 2 Chatrooms\\Members$$To: %[line:Chatroom] From: %[mynick] $<%[mynick]> !"..tCmds.Members[1].."|")
	user:SendData("$UserCommand 1 2 Chatrooms\\Away$$To: %[line:Chatroom] From: %[mynick] $<%[mynick]> !"..tCmds.Away[1].."|")
end

OpConnected = function(user)
	NewUserConnected(user)
	user:SendData("$UserCommand 1 2 Chatrooms\\Delete$$To: %[line:Chatroom] From: %[mynick] $<%[mynick]> !"..tCmds.DelChat[1].." %[line:Chatroom]|")
	user:SendData("$UserCommand 1 2 Chatrooms\\Invite$$To: %[line:Chatroom] From: %[mynick] $<%[mynick]> !"..tCmds.Invite[1].." %[line:Nick]|")
	user:SendData("$UserCommand 1 2 Chatrooms\\Remove$$To: %[line:Chatroom] From: %[mynick] $<%[mynick]> !"..tCmds.Remove[1].." %[line:Nick]|")
	user:SendData("$UserCommand 1 3 Chatrooms\\Make$<%[mynick]> !"..tCmds.MakeChat[1].." %[line:Chatroom] %[line:Profile (optional)]|")
end
Ignorance is Bliss.

Rick

Thanks!!!!!!
Now - Take a well deserved rest

Next request might be for autojoin  :D

Dessamator

#86
Well, I never touched the script, jiten did it all and asked me to post it, he's currently busy with his personal matters.
btw, autojoin???, it already has autojoin .
Ignorance is Bliss.

Rick

By autojoin I mean being able to have everyone automatically put in a chatroom at login. We used to use UnHub and enjoyed that feature as it put everyone in a place to "play" rather than mainchat

Can this be done with this script? If so please share - but that is not a front-burner "need"

Thanks

Rick

Dessamator

You mean by profile, or by some other criteria?
Ignorance is Bliss.

Rick

We use YnHub and the chatrooms there could be configured so that everyone was one upon login

We have a "bar & Grill" and we would like every profile to be automatically entered into the chatroom at login

But again - if it happens great if not the script is still great

2 issues I have found but not investigated (yet) in the newly posted script
MAKE appears at the top and bottom of the right click menu and
Creating a chatroom doesn't give the option to make it for VIPs (and above) I get around this by using
"!mkchat"

Thanks again

Rick

Dessamator

QuoteOriginally posted by Rick
We use YnHub and the chatrooms there could be configured so that everyone was one upon login

We have a "bar & Grill" and we would like every profile to be automatically entered into the chatroom at login

But again - if it happens great if not the script is still great

2 issues I have found but not investigated (yet) in the newly posted script
MAKE appears at the top and bottom of the right click menu and
Creating a chatroom doesn't give the option to make it for VIPs (and above) I get around this by using
"!mkchat"

Thanks again

Rick
You basically want to use a chatroom, as main chat?

The Second issue did u reconnect to the hub?

the Third thing is fixed, script edited
Ignorance is Bliss.

Rick

>>You basically want to use a chatroom, as main chat?

Instead of mainchat

<
Yes - and the second "make" is gone

<
I don't see that - if I use the right click menu to create a chatroom it never prompts for "VIP", OP etc

Thanks
Rick

Dessamator

Well, copy the script again, restart the scripts , and reconnect.

As for chatroom instead of maincha,t I'll have a look at it later on.
Ignorance is Bliss.

Rick

I made 2 errors - the new script seems to no longer put the table in a LOGS folder - which I had not removed
I edited the script and save it through ptokax.

After deleteing the table files andlog folder and editing with notepad (deleting the contents and pasting the script provided) it worked fine, prompting for a user level - go figure on that one

ANyway the autojoin is back burner. If you get a bright idea and post it we will implement and test it but not a burning need, just a feature we were used to and liked

Is there any way with the current script to invite everyone at once (wildcards etc)?

Thanks again

Rick

Dessamator

QuoteOriginally posted by Rick
I made 2 errors - the new script seems to no longer put the table in a LOGS folder - which I had not removed
I edited the script and save it through ptokax.

After deleteing the table files andlog folder and editing with notepad (deleting the contents and pasting the script provided) it worked fine, prompting for a user level - go figure on that one

ANyway the autojoin is back burner. If you get a bright idea and post it we will implement and test it but not a burning need, just a feature we were used to and liked

Is there any way with the current script to invite everyone at once (wildcards etc)?

Thanks again

Rick

Glad to see you sorted it out, either way autojoin is now available in the current script(script edited) , the cmd is
"!mkchat name public"

btw you need to change this :

bRestrict = true
 

to this

bRestrict =false
Ignorance is Bliss.

Rick

Ptokax syntax checker is coming up with

[16:11] Syntax [string "bRestrict- chatrooms v3 by tezlo
..."]:1: `=' expected near `-'

It came up with that before the change from "true" to false"

It seems to be working anyway

btw - Thanks!

Rick

Dessamator

You copied it incorrectly, it should be like this :

bRestrict = false -- Warning: Only applies to command (without specifying a profile): !mkchat chatname
Ignorance is Bliss.

Rick

That did it!
You are awesome
Thanks again

Rick

Dessamator

QuoteOriginally posted by Rick
That did it!
You are awesome
Thanks again

Rick

You're  welcome.
Ignorance is Bliss.

fichtenberg

Get always this error. And the rooms can not be saved

Syntax G:\Hub\scripts\chatrooms v3 by tezlo.lua:195: bad argument #5 to `format' (string expected, got nil)

SMF spam blocked by CleanTalk