Predifened Chat
 

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

Predifened Chat

Started by Pit, 07 November, 2004, 19:28:33

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Pit

Greetings

First of all i want to say that this is not my first post in this great forum, cos my nick was another one: (monnie)
but i don't know what the hell hapenned but i missed..

My request is simple:

I know that is a lot of comun chatrooms, but i can not find what i want;
I really want a chatroom to insert in my hub, but with acess defined by me on script,
The porpuse of this is that we are thinking of getting into a network ( 3 hubs) and we all have a opchat in comun, so in this case i can define who will be able to get in this one.
Is that possible??
Thanks

Pit
Regards to all

bastya_elvtars

tezlo's chatrooms is good 4 one solution

bots = {}

function Main()
	loadchat()
	for name, users in bots do
		frmHub:RegBot(name)
	end
end

function OnExit()
	savechat()
end

function DataArrival(user, data)
	if strsub(data, 1, 1) == "<" then
		local s, e, cmd, args = strfind(data, "^%b<> %!(%a+)%s*(.*)|$")
		if cmd == "mkchat" and user.bOperator then mkchat(user, args) return 1 end
	elseif strsub(data, 1, 4) == "$To:" then
		local s, e, to, str = strfind(data, "^$To: (%S+) From: %S+ $%b<> (.*)|$")
		if bots[to] then
			if not tfind(bots[to], user.sName) then
				user:SendPM(to, "youre not a member here") return
			end
			local isowner = user.sName == bots[to][1]
			local s, e, cmd, args = strfind(str, "^%!(%a+)%s*(.*)$")
			if cmd == "leave" then leave(user, to)
			elseif cmd == "members" then members(user, to)
			elseif cmd == "delchat" and isowner then delchat(user, to)
			elseif cmd == "invite" and isowner then invite(user, args, to)
			elseif cmd == "remove" and isowner then remove(user, args, to)
			else dochat(to, user.sName, str) end
		end
	end
end

function loadchat()
	bots = dofile("chatrooms.dat") or {}
end

function savechat()
	local f = openfile("chatrooms.dat", "w+")
	assert(f, "chatrooms.dat")
	write(f, "return {\n")
	for name, users in bots do
		write(f, "\t"..format("[%q]", name).." = { ")
		for i = 1, getn(users) do write(f, format("%q", users[i])..", ") end
		write(f, "},\n")
	end write(f, "}") closefile(f)
end

function dochat(to, from, str)
	local users = bots[to]
	for i = 1, getn(users) do
		local nick = users[i]
		if nick ~= from then SendToNick(nick, "$To: "..nick.." From: "..to.." $<"..from.."> "..str) end
	end
end

function mkchat(user, args)
	local s, e, name, members = strfind(args, "(%S+)%s*(.*)")
	if not s then user:SendData(">> syntax: !mkchat  [userlist]") return end
	if bots[name] then user:SendData(">> "..name.." belongs to "..bots[name][1]) return end
	frmHub:RegBot(name) bots[name] = { user.sName }
	invite(user, members, name) dochat(name, name, "hello")
end

function delchat(user, to)
	dochat(to, to, "bye bye")
	frmHub:UnregBot(to)
	bots[to] = nil
end

function leave(user, to)
	local id = tfind(bots[to], user.sName)
	if id == 1 then user:SendPM(to, "you cant")
	else dochat(to, to, user.sName.." has left the room") tremove(bots[to], id) end
end

function members(user, to)
	local users = bots[to]
	for i = 1, getn(users) do user:SendPM(to, i..". "..users[i]) end
end

function invite(user, args, to)
	local n = 0
	gsub(args, "(%S+)", function(nick)
		local tmp, bool = GetItemByName(nick), tfind(bots[%to], nick)
		if tmp and not bool then
			tinsert(bots[%to], nick)
			dochat(%to, %to, nick.." has been invited to the room")
		end
	end)
end

function remove(user, args, to)
	gsub(args, "(%S+)", function(nick)
		local id = tfind(bots[%to], nick)
		if id and id ~= 1 then
			dochat(%to, %to, nick.." has been removed from the room")
			tremove(bots[%to], id)
		end
	end)
end

function tfind(table, item)
	for key, value in table do
		if value == item then return key end
	end
end
Everything could have been anything else and it would have just as much meaning.

Pit

Thanks Bastya_elvtars

But how do i make the 'chatroom.dat'??
in a simple notepad??
just put there the nicks??
like


1st username
2nd username
...

Can you explain to me this??

Thanks

bastya_elvtars

!mkchat new chatroom

!delchat delete a room

!invite invite, many usernames can be used if u separate with spaces

!remove contrary of invite :P

if im wrong sorry, havent used it for a half year
Everything could have been anything else and it would have just as much meaning.

Pit

yes in deed...

Thanks a lot
i did not understand in the first place!

Keep up the good works



Topic closed

6Marilyn6Manson6

Hi bast... Is it possible change this script for my bot?
This is profile:


0|Master|11111111111111111111111000000001
1|Operator|11111100011001111111111000000001
2|VIP|10000000000001111100000000000000
3|Reg|10000000000000000000000000000000
4|Moderator|11111110011101111111110000000001


I want ... this 5 commands use only Moderator and Master.. thanks ^_^

bastya_elvtars

QuoteOriginally posted by 6Marilyn6Manson6
Hi bast... Is it possible change this script for my bot?
This is profile:


0|Master|11111111111111111111111000000001
1|Operator|11111100011001111111111000000001
2|VIP|10000000000001111100000000000000
3|Reg|10000000000000000000000000000000
4|Moderator|11111110011101111111110000000001


I want ... this 5 commands use only Moderator and Master.. thanks ^_^

replace this

Quoteuser.bOperator

to this:

Quote(user.iProfile==4 or user.iProfile==0)
Everything could have been anything else and it would have just as much meaning.

Pit

#7
Hi bastya_elvtars

The script works fine thanks!
I think in another thing:
Can you insert in the script some nicks who be able to create those chatrooms??
I mean, there is varios op's but only certain nicks defined in the script can be able to create chatrooms.
as if it's not ask to much...can it be send in PM for those who try to creat them without the permission, a line saying:
-you're not allowed to create a chatroom!Sorry

Can you do this??
Thanks

Keep up the good work

6Marilyn6Manson6


SMF spam blocked by CleanTalk