PtokaX forum

Archive => Archived 5.0 boards => Finished Scripts => Topic started by: jiten on 02 March, 2005, 19:58:55

Title: Chatrooms v3 (tezlo) LUA 5
Post by: jiten on 02 March, 2005, 19:58:55
Chatrooms v4c

Lua 5 version by jiten and Dessamator
Based on: Chatrooms v3 by tezlo

Changelog:


Grab it HERE (http://www.mznetwork.co.mz/scripts/chatrooms.v4c.rar).
Title: one question
Post by: dragos_sto on 05 April, 2005, 17:58:31
why when i reboot my server the statistic it lost .. :((
Title:
Post by: jiten on 05 April, 2005, 21:11:36
QuoteOriginally posted by dragos_sto
why when i reboot my server the statistic it lost .. :((

Are u sure u're talking about this script?
Maybe it's this (http://board.univ-angers.fr/thread.php?threadid=3840&boardid=29&sid=5155a5ff62f07dac39e9bcac9f099fc7)  one.

Cheers
Title:
Post by: dragos_sto on 06 April, 2005, 19:44:55
i run PtokaX 0.3.3.0 build 16.09 server on windows xp whit sp2
and yes, i copy the script from here ,(little above whit 3 post)
Title:
Post by: jiten on 06 April, 2005, 20:01:45
QuoteOriginally posted by dragos_sto
why when i reboot my server the statistic it lost .. :((

What do u mean by statistic?
Can u explain it better?
Title: i will try
Post by: dragos_sto on 06 April, 2005, 20:36:17
mean the Top Chatters will be reset (the save data in chatstats.tbl whill be lost) when i reboot the server or the scripts
Title:
Post by: jiten on 06 April, 2005, 20:50:56
Guess that u posted in the wrong thread  :D
This one a chatroom based script.
That's why I asked u if it wasn't this (http://board.univ-angers.fr/thread.php?threadid=3840&boardid=29&sid=5155a5ff62f07dac39e9bcac9f099fc7) one.
Title:
Post by: jiten on 06 April, 2005, 20:52:24
Anyway, here it goes:

-- ChatStats v3 Made By Optimus
-- Based on Tezlo chats
-- Added Send Commands By TiMeTrAVelleR
-- Madman fixed some in commands
-- Converted to lua5 by Madman with very little help by Jelf
-- with some help by ?
-- fixed stats saving on exit by jiten

sBot = "Chatstats" -- Name of Bot
SendComm = 1 -- Send UserCommands 1 = On  0 = Off
pMenu = "-=( ChatStats )=-" -- Name of Menu

Chatstats = {}

Sortstats = 2 -- 1=words / 2=posts

ChatStatsFile = "chatstats.tbl"

EnableChatStats = {
[0] = 1, -- Master
[1] = 1, -- Operators
[2] = 1, -- Vips
[3] = 1, -- Regs
[4] = 1, -- Moderators
[5] = 1, -- NetFounders
[-1] = 1, -- Users (UnRegged)
}

AllowedProfiles = {
[0] = 1,   -- Masters
[1] = 0,   -- Operators
[4] = 0,   -- Moderator
[5] = 0,   -- NetFounder
}

function Main()
frmHub:RegBot(sBot)
dofile(ChatStatsFile)
end

function NewUserConnected(user)
if SendComm == 1 and EnableChatStats[user.iProfile] == 1 then
if Chatstats[user.sName] then
user:SendData(sBot, "---===[ Your Chat Stats:  You Made "..Chatstats[user.sName]["post"].." Posts In Main Used "..Chatstats[user.sName]["chars"].."  Characters, And "..Chatstats[user.sName]["words"].." Words ]===---")
end
user:SendData("$UserCommand 1 3 "..pMenu.."\\TopChatters$<%[mynick]> !topchatters||")
user:SendData("$UserCommand 1 3 "..pMenu.."\\My Chat Stat$<%[mynick]> !mychatstat||")
if AllowedProfiles[user.iProfile] == 1 then
user:SendData("$UserCommand 1 3 "..pMenu.."\\Del Chatter$<%[mynick]> !delchatter %[line:Nick]||")
user:SendData("$UserCommand 1 3 "..pMenu.."\\Clear Chat Stats$<%[mynick]> !clearchatstats||")
end
end
end

OpConnected = NewUserConnected

function OnExit()
if isEmpty(Chatstats) then
else
saveTableToFile(ChatStatsFile, Chatstats, "Chatstats")
end
end

function ChatArrival(user, data)
if (string.sub(data, 1, 1) == "<" ) then
if EnableChatStats[user.iProfile] == 1 then
local s,e,str = string.find(data, "^%b<> (.*)%|$")
updStats(user.sName, str)
end
data=string.sub(data,1,string.len(data)-1)
s,e,cmd=string.find(data, "%b<>%s+(%S+)")
if (cmd == "!mychatstat") then
if Chatstats[user.sName] then
user:SendData(sBot, "---===[ Your Chat Stats:  You Made "..Chatstats[user.sName]["post"].." Posts In Main Used "..Chatstats[user.sName]["chars"].."  Characters, And "..Chatstats[user.sName]["words"].." Words ]===---")
return 1
else
user:SendData(sBot, "*** No chat statics found!")
return 1
end
elseif (cmd=="!topchatters") then
TCopy={}
if Chatstats then
for i,v in Chatstats do
table.insert(TCopy,{i,v.post,v.chars,v.words})
end
table.sort(TCopy,function(a,b) return (a[Sortstats] > b[Sortstats]) end)
local chat = "Current Top Chatters:\r\n\r\n"
chat = chat.."\t ------------------------------------------------------------------------\r\n"
chat = chat.."\t Nr.\tPosts:\tChars:\tWords:\tName:\r\n"
chat = chat.."\t ------------------------------------------------------------------------\r\n"
for i = 1,25 do
if TCopy[i] then
-- Nr: Posts: Chars: Words: Name:
chat = chat.."\t "..i..".\t "..TCopy[i][2].."\t "..TCopy[i][3].."\t "..TCopy[i][4].."\t"..TCopy[i][1].."\r\n"
end
end
user:SendData(sBot, chat)
TCopy={}
end
return 1
elseif (cmd == "!delchatter") and AllowedProfiles[user.iProfile] == 1 then
local s,e,cmd,name = string.find( data, "%b<>%s+(%S+)%s+(%S+)" )
if name then
if Chatstats[name] then
Chatstats[name] = nil
user:SendData(sBot, "Chatstats from user "..name.." are now removed!")
saveTableToFile(ChatStatsFile, Chatstats, "Chatstats")
else
user:SendData(sBot, "*** Chatstats from user "..name.." not found!")
end
else
user:SendData(sBot, "*** Usage: !delchatter ")
end
return 1
elseif (cmd == "!clearchatstats") and AllowedProfiles[user.iProfile] == 1 then
Chatstats = {}
saveTableToFile(ChatStatsFile, Chatstats, "Chatstats")
user:SendData(sBot, "Chatstats are cleared by "..user.sName)
return 1
end
end
end

function updStats(nick, str)
local tmp = Chatstats[nick] or {["post"]=0, ["chars"]=0, ["words"]=0, ["time"]=os.date("%x")}
tmp["post"], tmp["chars"], tmp["words"], tmp["time"] = tmp["post"]+1, tmp["chars"]+string.len(str), tmp["words"]+cntargs(str,"(%a+)"), os.date("%x")
Chatstats[nick] = tmp
-- saveTableToFile(ChatStatsFile, Chatstats, "Chatstats")
end

function cntargs(str, rule)
local s,n = string.gsub(str, rule, "")
return n
end

----------------------------------------------
-- load & save Tables
----------------------------------------------
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 saveTableToFile(file, table, tablename)
local handle = io.open(file,"w+")
handle:write(Serialize(table, tablename))
handle:flush()
handle:close()
end
-----------------------------------------------------------
function loadTableFromFile(file)
local handle = io.open(file,"r")
if (handle ~= nil) then
loadstring(handle:read("*all"))
handle:flush()
handle:close()
end
end

-------------table checker by herodes
--- for an associative table, like ["smth"] = "smth else",
function isEmpty(t)
for i,v in t do
return false;
end
return true;
end;


Cheers
Title:
Post by: dragos_sto on 06 April, 2005, 22:05:27
ahammm .. i dont read the whole post , now i  understand why ... sorry for my insensitiveness ... :D

and sorry for my english .. i will try my best english to romanian (http://www.dictionare.com/english/dictionaries.htm)
Title:
Post by: jiten on 07 April, 2005, 10:49:56
QuoteOriginally posted by dragos_sto
ahammm .. i dont read the whole post , now i  understand why ... sorry for my insensitiveness ... :D

and sorry for my english .. i will try my best english to romanian (http://www.dictionare.com/english/dictionaries.htm)

No problem m8. You're welcome  :]
Title:
Post by: kunal on 28 May, 2005, 13:11:58
[16:16] Syntax logs/chatrooms.dat:2: unexpected symbol near `'
get this error
pls help someone
Title:
Post by: jiten on 28 May, 2005, 13:22:45
QuoteOriginally posted by kunal
[16:16] Syntax logs/chatrooms.dat:2: unexpected symbol near `'
get this error
pls help someone
1. Copy the last script I posted and replace it with the one you got;
2. Go to your /logs folder and delete that "chatrooms.dat" file;
3. Restart your scripts.

That error should be gone then.

Cheers
Title:
Post by: kash? on 28 May, 2005, 16:56:51
Can u make commands editable please
also can rooms be shown below all the users
with prefiix "zz" [so that it will be shown below all
the users] instead above near op

Regards
Title:
Post by: jiten on 28 May, 2005, 22:27:04
QuoteOriginally posted by kash?
Can u make commands editable please
Sure ;)
Quotealso can rooms be shown below all the users
with prefiix "zz" [so that it will be shown below all
the users] instead above near op
I'm going to think about this. Btw, why do you want to "hide" the bot?

Cheers
Title:
Post by: kunal on 29 May, 2005, 07:46:28
thanx m8.the script worked fine.can u pls remove the key coming besides the chatrooms and add right click cmds for the script
Title:
Post by: jiten on 29 May, 2005, 11:06:34
Last script updated with all requests.

Best regards
Title:
Post by: kash? on 29 May, 2005, 12:58:45
thx jiten
gr8 work !!!
Can u add help command to show
commands available for users
and all users should be able to
create chat room instead of only ops
Title:
Post by: jiten on 29 May, 2005, 21:05:02
QuoteOriginally posted by kash?
Can u add help command to show
commands available for users
and all users should be able to
create chat room instead of only ops
Well, I guess that there's no need to create a command just to show all available commands to users, as there's the rightclick.

Btw, for all users to be able to create a chatroom, delete the red selection in this code:
ChatArrival = function(user, data)
local s, e, cmd, args = string.find(data, "^%b<> %!(%a+)%s*(.*)|$")
if cmd == tCmds.MakeChat [COLOR=red]and user.bOperator[/COLOR] then
local s, e, name, profiles = string.find(args, "(%S+)%s*(.*)")
if not s then
user:SendData(">> Syntax: !mkchat [groups]")
elseif chatrooms.items[name] then
user:SendData(">> "..name.." is already a Chatroom.")
elseif GetItemByName(name) then
user:SendData(">> There is a user with that name")
else
frmHub:RegBot(name,0,"","")
local tmp = chatrooms:new(name, user.sName)
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", name)
chatrooms:save()
return 1
end
end
end

Cheers
Title:
Post by: kunal on 30 May, 2005, 06:06:17
hey the invite cmd doesnt work
pls help
Title:
Post by: jiten on 30 May, 2005, 07:39:26
QuoteOriginally posted by kunal
hey the invite cmd doesnt work
pls help
Fixed :]
Title:
Post by: kunal on 30 May, 2005, 09:42:32
hey jiten
the script works fine
but can u add a cmd so that users can join the room on their own
1 more request probably the last one
Title:
Post by: jiten on 30 May, 2005, 10:19:59
QuoteOriginally posted by kunal
hey jiten
the script works fine
but can u add a cmd so that users can join the room on their own
1 more request probably the last one
Well, this script has an option to create a chatroom for an entire profile. Something like: !mkchat . So, if the "invited" user feels like chatting, he just needs to type something in the chatroom and he'll be automatically logged in.
Title:
Post by: kunal on 30 May, 2005, 10:33:28
wouldnt the chatroom window  open in every reg user 's dc++ if someone is chatting in the chatroom and the chatroom is enabled for the profile reg users
Title:
Post by: jiten on 30 May, 2005, 11:45:13
QuoteOriginally posted by kunal
wouldnt the chatroom window  open in every reg user 's dc++ if someone is chatting in the chatroom and the chatroom is enabled for the profile reg users
If it's enabled for REG profile, and someone is chatting, the window only pops up to those that have "logged in" by typing something previously in that chatroom.
Title:
Post by: kunal on 30 May, 2005, 12:27:44
thanx m8
no request now. ;)
perfect script.
Title:
Post by: jiten on 30 May, 2005, 14:02:40
yw m8 ;)
Title:
Post by: Krysalis on 19 June, 2005, 14:07:18
Hello,
Syntax logs/chatrooms.dat:2: unexpected symbol near `'
i had this error at th first postet Script here.
I try clear or delete chatrooms.dat, but also this error.

I would Use the first script, because i want chatrooms appear as Operators/bots.

Greets
Title:
Post by: jiten on 19 June, 2005, 16:06:11
QuoteOriginally posted by Krysalis
Hello,
Syntax logs/chatrooms.dat:2: unexpected symbol near `'
i had this error at th first postet Script here.
I try clear or delete chatrooms.dat, but also this error.

I would Use the first script, because i want chatrooms appear as Operators/bots.

Greets
Hi there.
Changed the last script so that you can choose if the chatrooms need or not a Key.

Cheers
Title:
Post by: Krysalis on 19 June, 2005, 17:17:07
thx much,
can i change that there is an standart-tag before chat like [Chat]
if i type !mkchat Vip
there appears [Chat]Vip in the userlist?

Greets
Title:
Post by: jiten on 19 June, 2005, 18:14:51
QuoteOriginally posted by Krysalis
thx much,
can i change that there is an standart-tag before chat like [Chat]
if i type !mkchat Vip
there appears [Chat]Vip in the userlist?

Greets
Second script updated with your request.

Cheers
Title:
Post by: Krysalis on 19 June, 2005, 23:23:28
!delchat and !invite doesent work by me....any ideas? no syntax errors.

Greets
Title:
Post by: jiten on 20 June, 2005, 09:26:24
QuoteOriginally posted by Krysalis
!delchat and !invite doesent work by me....any ideas? no syntax errors.

Greets
Tested here and it's working fine.
Those commands work in PM and are only available to the creator of the chatroom.

Best regards
Title:
Post by: Krysalis on 20 June, 2005, 15:46:46
Sure Jiten. I Try in Pm and I?m the creator.
But i cant delete chats i made.

Will try today evening again, if i?m at home.
Title:
Post by: Krysalis on 21 June, 2005, 17:51:28
I don?t get it to run...
Title:
Post by: jiten on 21 June, 2005, 20:01:18
QuoteOriginally posted by Krysalis
I don?t get it to run...
Are you using the rightclick to invite and delete the chatrooms? If yes, and if you have the Tag enabled, you need to type the chatroom name with the prefix included.

Cheers
Title:
Post by: kash? on 29 June, 2005, 19:07:14
can u add command where typing +help
will show all commands and instead of profiles
the room creator will decide whether it's public or
private room [public room = all can join ]
and masters can see the room...
something like this

Following the the hub commands
-----General-----------------------------------------------------------------------------------
+help                                                               this menu
+list                    List all room mates.
+exit                    Leave the room.
-----Onwer-----------------------------------------------------------------------------------
+add                  Add user to the conference. eg +add jiten
+remove                  Kick a user from the room.
+set 1                    Make the room private.
+set 2                    Make the room public.
+close                    Close the conference room.
-----------------------------------------------------------------------------------------------

- (optional)
Note: Operators are able see the conference room messages.
Title:
Post by: jiten on 30 June, 2005, 14:23:34
QuoteOriginally posted by kash?
can u add command where typing +help
will show all commands and instead of profiles
the room creator will decide whether it's public or
private room [public room = all can join ]
and masters can see the room...
Currently, I don't have much time and as this is something extra (not a real bug), so, it won't be possible. Sorry for that. Maybe later, who knows...
Title:
Post by: kash? on 30 June, 2005, 17:30:37
hmm....hope u get some time for this
little Request ;)
Title:
Post by: kash? on 30 June, 2005, 22:42:38
Registered users [not op's] can create rooms after editing that line as u told but they don't get
right click cmd to make room
What can be done ??
Title:
Post by: jiten on 01 July, 2005, 10:08:49
QuoteOriginally posted by kash?
Registered users [not op's] can create rooms after editing that line as u told but they don't get
right click cmd to make room
What can be done ??
Add this to NewUserConnected function:
user:SendData("$UserCommand 1 3 Chatrooms\\Make$<%[mynick]> !"..tCmds.MakeChat.." %[line:Chatroom]|")

Cheers
Title:
Post by: kash? on 01 July, 2005, 10:23:29
wow !!! thanx dude
can u do the other request I posted earlier
whenever u get time

Regards
Title:
Post by: kash? on 01 July, 2005, 10:40:34
Main problem...
Very IMP for me =

How a reg user can join a room unless he is
Invited, I wanted reg users to join rooms with
right click cmd without any invitation [any1 can
join any room and chat ]

And rooms can be closed only by op's and not
reg users, now it can be closed by only room
owners.[me being master also can not close a
room not made by me :(]

all op's and master don't need to
join room, they should be able to see chatting
without joining whenever the chatting is
going on [ essential ]

and +help command in the room will display
basic commands to users

Looks long but it isn't that big problem for u to solve,
PLZ...help me

Regards...
Title:
Post by: Dessamator on 01 July, 2005, 14:25:11
simple, to resolve, just create a chatroom for regusers, the rest is already part of the script
Title:
Post by: kash? on 01 July, 2005, 17:46:33
I didn't get u,
I don't think what u r saying will solve problem
Title:
Post by: jiten on 01 July, 2005, 22:52:29
QuoteOriginally posted by kash?
I didn't get u,
I don't think what u r saying will solve problem
Dessamator is right. You just need to create a chatroom for the reg profile, and everyy user with that profile will be able to speak without being manually invited by an operator.
By the way, if you want the rooms to be closed by all operators add the red text to this line in the script:
elseif cmd == tCmds.Remove and [COLOR=red]([/COLOR]isowner [COLOR=red]or user.bOperator)[/COLOR] then


Cheers
Title:
Post by: kash? on 03 July, 2005, 18:14:56

How can I do that ???
Title:
Post by: Dessamator on 03 July, 2005, 19:44:53
!mkchat RegChat reg
Title:
Post by: kash? on 03 July, 2005, 20:10:31
even after replacing that still reg ppl can
close room, I want only op's to close room and
see all the chatting without joining

Regards...
Title:
Post by: jiten on 04 July, 2005, 09:28:46
QuoteOriginally posted by kash?
even after replacing that still reg ppl can
close room, I want only op's to close room and
see all the chatting without joining

Regards...
kash?, with that code I posted, operators and the creator of the specific chatroom are able to delete it. In your case, a reg user must've created it, so, he was able to delete it.
If you only want it for operators, leave it like this:
elseif cmd == tCmds.Remove and user.bOperator then
Best regards,

jiten
Title:
Post by: kash? on 07 July, 2005, 20:20:21
still I can't close rooms created by
registered users even being master :((
Title:
Post by: kunal on 13 July, 2005, 12:37:50
i also cant close rooms and pls keep a nick check for these rooms coz while inviting someone if i make a error
eg if i mispell  !invite testing as !invite testnig it invites testnig and it appears as a member and cant remove it also coz the remove cmd doesnt work ;(
Title:
Post by: Dessamator on 14 July, 2005, 00:58:51
u obviously did something wrong, it should work !
Title:
Post by: jiten on 14 July, 2005, 13:38:06
QuoteOriginally posted by kash?
still I can't close rooms created by
registered users even being master :((
Second script updated.

Cheers
Title:
Post by: Dessamator on 15 July, 2005, 17:50:06
change this in the script

tCmds = {
MakeChat = "mkchat",
Away = "away",
Leave = "leave",
Members = "members",
Invite = "invite",
Remove = "remove",
DelChat = "delchat",
         Joinroom = "joinroom"
}


and this
ChatArrival = function(user, data)
local s, e, cmd, args = string.find(data, "^%b<> %!(%a+)%s*(.*)|$")
if cmd == tCmds.MakeChat and user.bOperator then
local s, e, name, profiles = string.find(args, "(%S+)%s*(.*)")
if not s then
user:SendData(">> Syntax: !mkchat [groups]")
elseif chatrooms.items[name] then
user:SendData(">> "..name.." is already a Chatroom.")
elseif GetItemByName(name) then
user:SendData(">> There is a user with that name")
else
if tKey == 1 then frmHub:RegBot(sTag..name) else frmHub:RegBot(sTag..name,0,"","") end
local tmp = chatrooms:new(sTag..name, user.sName)
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
elseif cmd== tCmds.Joinroom then
user:SendPM(args,"hello")
return 1
end
end


as for putting it horizontally, i see no advantage of that !
it works fine as is !
Title:
Post by: kEwL on 15 July, 2005, 17:54:48
where to add the 2 nd one
Title:
Post by: kEwL on 15 July, 2005, 17:58:54
got it m8
but i think horizontal one will look better and will be more suitable for finding the required person
Title:
Post by: kEwL on 15 July, 2005, 18:06:04
also when i restart scripts all the chatrooms pop up to all users in the chatrooms saying hello so think if i m in 10 rooms it pops up 10 windows and for no reason
Title:
Post by: Dessamator on 15 July, 2005, 18:26:48
how often do u restart the scripts?

either way ,change this :

load = function(self)
self.items = dofile("logs/chatrooms.tbl") 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,

to this
load = function(self)
self.items = dofile("logs/chatrooms.tbl") or {}
for name, room in self.items do
if tKey == 1 then frmHub:RegBot(name) else frmHub:RegBot(name,0,"","") end
room.chat = botchat
end
         end,
Title:
Post by: kunal on 17 July, 2005, 18:13:57
can anyone tell me how to do it
Title:
Post by: kunal on 18 July, 2005, 15:26:32
;(   ;(  ;(  ;(  ;(
no one seems to help me
Title:
Post by: Dessamator on 18 July, 2005, 16:07:52
find this part of the script and change  this :

elseif cmd == tCmds.Members 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.")


to this :


elseif cmd == tCmds.Members then
local n, na, msg,offline,away,on = 0, 0,"","Offline --> ","Away --> ", "Online --> "
for nick, stat in tmp.members do
if not GetItemByName(nick) then offline = offline..nick.."  "
elseif stat == 0 then away = away..nick.."  "
else msg, na = "", na+1
on = on..nick.."  "
end; n = n+1
end;
user:SendPM(to, "\r\n"..on.."\r\n"..offline.."\r\n"..away.."\r\n"..na.."/"..n.." active members.")
Title:
Post by: kunal on 18 July, 2005, 16:19:08
ty m8  :]  :]  :]  :]  :]
Title:
Post by: kash? on 25 July, 2005, 17:58:41
many reg users create room as !mkchat ABCD
without mentioning profile like !mkchat ABCD reg
because of this other users can't join the room
As a result, there are many rooms with just
room owner and ops and other users are not able to join rooms

- You're not a member here.
- hh
- You're not a member here.
- hh


I wanted to have cmd as !mkchat ABCD where
other users can join without mentioning their profile
[no need to mention any profile]

In short let anybody create room, all users should be
able to join

PLZ reply...quite major problem
Title: ONLY MASTERS
Post by: HairBear on 07 August, 2005, 20:23:47
Hi m8 !

Is there any way  to limit chat creation and invite only for masters ?

I want to create a chat only for master profile not for all Operators.

Thx !!!
Title:
Post by: Dessamator on 07 August, 2005, 21:42:58
Quote!mkchat Masterchat master
Title:
Post by: HairBear on 08 August, 2005, 09:33:04
QuoteOriginally posted by Dessamator
Quote!mkchat Masterchat master

Thx for reply.
I tryed this way but operators too can join without invite.
 ?(
Title:
Post by: Dessamator on 09 August, 2005, 11:34:51
if not tmp.members[user.sName] then
[COLOR=skyblue]if user.bOperator or tmp.groups[user.iProfile] == 1 then[/COLOR]
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


change the line in blue to this :

if  tmp.groups[user.iProfile] == 1 then

btw if or when u do that, each chatroom will be restricted to its profile, regs can only chat with regs and masters only with masters.
Title:
Post by: HairBear on 09 August, 2005, 17:03:56
Thanks Dessamator  !!!!!!!!!
It worked !!!!
It's really what I needed.

  :D  :D  :D
Title:
Post by: Dessamator on 09 August, 2005, 21:11:20
ur welcome
Title:
Post by: enigma on 17 August, 2005, 00:24:53
i used second script.
jus pasted it from here in my ptokax script editor.saved it thn restarted scripts.thn got error in ptokax
[03:46] Syntax cannot read logs/chatrooms.tbl: No such file or directory
thn i reconected my hub, with help of right click created room
!mkchat Exatt
room was not created
i got error in ptokax
[03:47] Syntax C:\HUB\0.3.3.21.9X.DBG\scripts\chatrooms.lua:40: attempt to index field `items' (a nil value)

script not working this end mate
i want to use this script
please some1 help.

using windows 98 se

anyways im dkt a reged user here but i lost my password here..and i donno how to recover it..tats y created another account here as enigma.pls some1 help
Title:
Post by: kunal on 01 September, 2005, 19:27:12
i want all ops to be able to remove users from any chatrooms.Now only the owner of the room can remove users in the rooms
Title:
Post by: Dessamator on 01 September, 2005, 21:38:25
change this :

elseif cmd == "remove" and isowner 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()


to this :

elseif cmd == "remove" and user.bOperator  or isowner 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()
Title:
Post by: kunal on 02 September, 2005, 12:07:02
can anyone modify the script so that the name of the owner appears in the description of the chatroom
Title:
Post by: front242 on 18 September, 2005, 10:52:36
how add ability to some non-op profiles that they could removing and inviting users

need distribution of the rights by profile names or profile numbers

sorry my bad english
Title:
Post by: Dessamator on 18 September, 2005, 16:05:09
That question has already been answered, read the previous posts .
Title:
Post by: front242 on 19 September, 2005, 15:22:04
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
Title:
Post by: Rick on 27 September, 2005, 01:25:23
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
Title:
Post by: Rick on 27 September, 2005, 02:24:20
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
Title:
Post by: Rick on 27 September, 2005, 12:39:40
... 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
Title:
Post by: osse on 23 October, 2005, 09:55:20
[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
Title:
Post by: Dessamator on 23 October, 2005, 11:43:47
Maybe ur using an unfinished script, I have personally tested it with robocop, in the past, and it worked perfectly.
Title:
Post by: Rick on 23 October, 2005, 15:42:35
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
Title:
Post by: Dessamator on 23 October, 2005, 16:38:41
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.
Title:
Post by: Rick on 23 October, 2005, 18:53:07
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
Title:
Post by: Dessamator on 24 October, 2005, 20:45:38
-- 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

Title:
Post by: Rick on 25 October, 2005, 03:45:03
Thanks!!!!!!
Now - Take a well deserved rest

Next request might be for autojoin  :D
Title:
Post by: Dessamator on 25 October, 2005, 10:34:43
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 .
Title:
Post by: Rick on 25 October, 2005, 11:40:26
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
Title:
Post by: Dessamator on 25 October, 2005, 12:01:15
You mean by profile, or by some other criteria?
Title:
Post by: Rick on 25 October, 2005, 12:42:06
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
Title:
Post by: Dessamator on 25 October, 2005, 13:07:43
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
Title:
Post by: Rick on 25 October, 2005, 23:15:08
>>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
Title:
Post by: Dessamator on 26 October, 2005, 10:33:49
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.
Title:
Post by: Rick on 26 October, 2005, 12:28:46
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
Title:
Post by: Dessamator on 26 October, 2005, 13:38:20
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
Title:
Post by: Rick on 26 October, 2005, 22:13:30
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
Title:
Post by: Dessamator on 26 October, 2005, 22:51:16
You copied it incorrectly, it should be like this :

bRestrict = false -- Warning: Only applies to command (without specifying a profile): !mkchat chatname
Title:
Post by: Rick on 26 October, 2005, 23:33:14
That did it!
You are awesome
Thanks again

Rick
Title:
Post by: Dessamator on 27 October, 2005, 15:29:32
QuoteOriginally posted by Rick
That did it!
You are awesome
Thanks again

Rick

You're  welcome.
Title:
Post by: fichtenberg on 29 October, 2005, 11:58:31
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)
Title:
Post by: Dessamator on 29 October, 2005, 15:22:02
Do the following:

1) Stop the script.
2)Delete chatrooms.tbl
3)Start the script

btw use the last script i posted, to avoid any errors that were fixed b4.
Title:
Post by: ??????Hawk?????? on 29 October, 2005, 18:17:05
edit your posts and tick  Delete post   ;)
Title:
Post by: Dessamator on 30 October, 2005, 20:06:33
Erase the Chatrooms.tbl, before you use this script:

-- 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)
-- Changed: Command Parsing
-- Added: Autologin switch for each chatroom: !autologin on/off
-- Code optimized a bit (10/30/2005)

tCmds = {}
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 = false -- 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, }

Commands = { -- 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 },
AutoLogin = { "autologin", 4 },
}

Main = function()
chatrooms:load()
end

OnExit = function()
chatrooms:save()
end

ChatArrival = function(user,data)
local data = string.sub(data,1,-2)
local s,e,cmd = string.find(data,"%b<>%s+%!(%S+)")
if cmd then
local mCmds = {
["mkchat"] = function(user, data)
local s,e,args = string.find(data, "^%b<>%s+%S+%s*(.*)")
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 = chatrooms:new(sTag..name, user.sName, "")
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 }
if mCmds[cmd] then
for i,v in Commands do
if Levels[user.iProfile] >= v[2] then return mCmds[cmd](user,data), 1 end
end
end
end
end

ToArrival = function(user,data)
local data = string.sub(data,1,-2)
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
local Messager = function()
if tmp.status == "auto" then
tmp:chat(str, user.sName)
else
tmp.members[user.sName] = 1 tmp:chat(user.sName.." joined", to) tmp:chat(str, user.sName) chatrooms:save()
end
end
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.

Messager()
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 Messager() end
end
else
local s,e,cmd,args = string.find(str, "^%!(%a+)%s*(.*)$")
if cmd then
local tCmds = {
[Commands.Away[1]] = function(user, data, tmp, to, args)
tmp:chat(user.sName.." is away.. "..args, to)
if tmp.status == "auto" then tmp.away[user.sName] = 1 else tmp.members[user.sName] = 0 end
end,
[Commands.Leave[1]] = function(user, data, tmp, to, args)
tmp:chat(user.sName.." left. "..args, to)
if tmp.status == "auto" then tmp.away[user.sName] = 1 else tmp.members[user.sName] = nil end
chatrooms:save()
end,
[Commands.Members[1]] = function(user, data, tmp, to)
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.")
end,
[Commands.Invite[1]] = function(user, data, tmp, to, args)
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()
end,
[Commands.Remove[1]] = function(user, data, tmp, to, args)
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()
end,
[Commands.DelChat[1]] = function(user, data, tmp, to)
tmp:chat("End of session.", to)
chatrooms.items[to] = nil
chatrooms:save()
frmHub:UnregBot(to)
end,
[Commands.AutoLogin[1]] = function(user, data, tmp, to, args)
if string.lower(args) == "on" then
tmp.status = "auto" chatrooms:save()
user:SendPM(to, "Chatroom AutoLogin Mode has been enabled.")
elseif string.lower(args) == "off" then
tmp.status = "" chatrooms:save()
user:SendPM(to, "Chatroom AutoLogin Mode has been disabled.")
else
user:SendPM(to, "*** Syntax Error: Type !autologin on/off")
end
end, }
if tCmds[cmd] then
for i,v in Commands do
if Levels[user.iProfile] >= v[2] then return tCmds[cmd](user, data, tmp, to, args), 1 end
end
end
elseif not s then
tmp.members[user.sName] = 1 tmp:chat(str, user.sName)
else
tmp:chat(str, user.sName)
end
end;
return 1
end
end

botchat = function(self, msg, from)
local SendPM = function(a,b,tTable,tMode)
for a, b in tTable do
if tMode == 1 then
if b.sName ~= from and not self.away[b.sName] then
SendToNick(b.sName, "$To: "..b.sName.." From: "..self.name.." $<"..from.."> "..msg)
end
else
if a ~= from and b == 1 then
SendToNick(a, "$To: "..a.." From: "..self.name.." $<"..from.."> "..msg)
end
end
end
end
if self.status == "auto" then
if next(self.groups) then
for v, i in self.groups do SendPM(_,user,frmHub:GetOnlineUsers(v), 1) end SendPM(nick, id, self.members, 0)
else
SendPM(_,user,frmHub:GetOnlineUsers(), 1)
end
else
SendPM(nick, id, self.members, 0)
end
end

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

load = function(self)
if loadfile(fChat) then
self.items = dofile(fChat)
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
else
local f = io.open(fChat, "w+") f:write("return {\n"); f:write("}"); f:close() self.items = dofile(fChat)
end
end,

save = function(self)
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\taway = {\n");
for user, stat in tmp.away do f:write(string.format("\t\t\t[%q] = %d,\n", user, stat)) end;
f:write("\t\t}\n\t},\n");
end;
f:write("}"); f:close()
end
}

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

OpConnected = function(user)
NewUserConnected(user)
user:SendData("$UserCommand 1 2 Chatrooms\\Delete$$To: %[line:Chatroom] From: %[mynick] $<%[mynick]> !"..Commands.DelChat[1].." %[line:Chatroom]|")
user:SendData("$UserCommand 1 2 Chatrooms\\Invite$$To: %[line:Chatroom] From: %[mynick] $<%[mynick]> !"..Commands.Invite[1].." %[line:Nick]|")
user:SendData("$UserCommand 1 2 Chatrooms\\Remove$$To: %[line:Chatroom] From: %[mynick] $<%[mynick]> !"..Commands.Remove[1].." %[line:Nick]|")
user:SendData("$UserCommand 1 3 Chatrooms\\Make$<%[mynick]> !"..Commands.MakeChat[1].." %[line:Chatroom] %[line:Profile (optional)]|")
user:SendData("$UserCommand 1 2 Chatrooms\\Set AutoLogin$$To: %[line:Chatroom] From: %[mynick] $<%[mynick]> !"..Commands.AutoLogin[1].." %[line:On/Off]|")
end
Title:
Post by: Rick on 30 October, 2005, 21:34:22
AWESOME AGAIN!!

Thanks

Rick
Title:
Post by: Dessamator on 30 October, 2005, 21:56:56
You are Welcome, "again"
Title:
Post by: Rick on 30 October, 2005, 22:28:10
We are geting to love this script
Title:
Post by: 6Marilyn6Manson6 on 30 October, 2005, 22:42:11
QuoteOriginally posted by Rick
We are geting to love this script

Yeah this script is very good. good work Dessamator ;)
Title:
Post by: Dessamator on 31 October, 2005, 09:48:17
I never touched the script, Jiten moded & i  posted.
Title:
Post by: Rick on 31 October, 2005, 11:34:01
Just so he lnows that we all appreciate the effort :]
Title:
Post by: Dessamator on 31 October, 2005, 13:14:09
QuoteOriginally posted by Rick
Just so he lnows that we all appreciate the effort :]

Ill tell him,  :]
Title:
Post by: enigma on 04 November, 2005, 05:45:58
users cant join if thy are not a member..
can u edit the above script...so that any user can join rooms without invitation from operator or owner... and who can cr8 rooms in the above script any user or jus the operators ??
Title:
Post by: Dessamator on 04 November, 2005, 09:12:41
No editing is required,  the script already does that, do the following:
1. Create a chatroom, e.g.: "!mkchat chatbot "
2. Send a Private message to the bot and type "!autologin on"
Title:
Post by: enigma on 04 November, 2005, 22:20:56
im using this script edited a bit with help from this thread
tKey = 0   -- 0 = Chatrooms don't have key; 1 = Chatrooms have Key
sTag = "zz" -- Set your Chatrooms Tag here. If you don't want it, set it to: sTag = ""

tCmds = {
   MakeChat = "mkchat",
   Away = "away",
   Leave = "leave",
   Members = "members",
   Invite = "invite",
   Remove = "remove",
   DelChat = "delchat",
   Joinroom = "joinroom"
}
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 cmd == tCmds.MakeChat then
      local s, e, name, profiles = string.find(args, "(%S+)%s*(.*)")
      if not s then
         user:SendData(">> Syntax: !mkchat [groups]")
      elseif chatrooms.items[name] then   
         user:SendData(">> "..name.." is already a Chatroom.")
      elseif GetItemByName(name) then
         user:SendData(">> There is a user with that name")
      else
         if tKey == 1 then frmHub:RegBot(sTag..name) else frmHub:RegBot(sTag..name,0,"","") end
         local tmp = chatrooms:new(sTag..name, user.sName)
         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
   elseif cmd== tCmds.Joinroom then
      user:SendPM(args,"hello")
      return 1
   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  tmp.groups[user.iProfile] == 1 then
            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
         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 cmd == tCmds.Away then
            tmp:chat(user.sName.." is away.. "..args, to)
            tmp.members[user.sName] = 0
         elseif cmd == tCmds.Leave then
            tmp:chat(user.sName.." left. "..args, to)
            tmp.members[user.sName] = nil
            chatrooms:save()
                  elseif cmd == tCmds.Members then
            local n, na, msg,offline,away,on = 0, 0,"","Offline --> ","Away --> ", "Online --> "
            for nick, stat in tmp.members do
               if not GetItemByName(nick) then offline = offline..nick.."  "
               elseif stat == 0 then away = away..nick.."  "
               else msg, na = "", na+1
               on = on..nick.."  "
               end; n = n+1
            end;
            user:SendPM(to, "\r\n"..on.."\r\n"..offline.."\r\n"..away.."\r\n"..na.."/"..n.." active members.")
         elseif cmd == tCmds.Invite 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 cmd == tCmds.Remove and (isowner or user.bOperator) 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 cmd == tCmds.DelChat and (isowner or user.bOperator) 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)
   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

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

   load = function(self)
      self.items = dofile("logs/chatrooms.tbl") or {}
      for name, room in self.items do
         if tKey == 1 then frmHub:RegBot(name) else frmHub:RegBot(name,0,"","") end
         room.chat = botchat
      end
         end,
   save = function(self)
      if loadfile("logs/chatrooms.tbl") then
         local f = io.open("logs/chatrooms.tbl", "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\tgroups = {\n", name, tmp.name, tmp.owner))
            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("logs/chatrooms.tbl", "w+")
         f:write("return {\n"); f:write("}"); f:close()
      end
   end
}

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

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

>>>>> now wat i want from this script is tat, users shld type something in tat chatrrom created already and thy get logined automatically in tat room, alos user may leave wenever thy want. <<<<<<

dessamator i tried ur last script, but tats not wat i want as the !autologin on enables for the whole profile i guess and also wen u login as an operator in tat room and do !members it jus shows my name as i have created room and reged profile users can chat thn
and also wen u restart this script for dessamator u get a pm from room as Hello. quite irritating.
anyways some1 help me , i need this >>>>  <<<<< urgent
Title:
Post by: Dessamator on 05 November, 2005, 07:42:46
QuoteOriginally posted by enigma
im using this script edited a bit with help from this thread
tKey = 0   -- 0 = Chatrooms don't have key; 1 = Chatrooms have Key
sTag = "zz" -- Set your Chatrooms Tag here. If you don't want it, set it to: sTag = ""

tCmds = {
   MakeChat = "mkchat",
   Away = "away",
   Leave = "leave",
   Members = "members",
   Invite = "invite",
   Remove = "remove",
   DelChat = "delchat",
   Joinroom = "joinroom"
}
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 cmd == tCmds.MakeChat then
      local s, e, name, profiles = string.find(args, "(%S+)%s*(.*)")
      if not s then
         user:SendData(">> Syntax: !mkchat [groups]")
      elseif chatrooms.items[name] then   
         user:SendData(">> "..name.." is already a Chatroom.")
      elseif GetItemByName(name) then
         user:SendData(">> There is a user with that name")
      else
         if tKey == 1 then frmHub:RegBot(sTag..name) else frmHub:RegBot(sTag..name,0,"","") end
         local tmp = chatrooms:new(sTag..name, user.sName)
         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
   elseif cmd== tCmds.Joinroom then
      user:SendPM(args,"hello")
      return 1
   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  tmp.groups[user.iProfile] == 1 then
            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
         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 cmd == tCmds.Away then
            tmp:chat(user.sName.." is away.. "..args, to)
            tmp.members[user.sName] = 0
         elseif cmd == tCmds.Leave then
            tmp:chat(user.sName.." left. "..args, to)
            tmp.members[user.sName] = nil
            chatrooms:save()
                  elseif cmd == tCmds.Members then
            local n, na, msg,offline,away,on = 0, 0,"","Offline --> ","Away --> ", "Online --> "
            for nick, stat in tmp.members do
               if not GetItemByName(nick) then offline = offline..nick.."  "
               elseif stat == 0 then away = away..nick.."  "
               else msg, na = "", na+1
               on = on..nick.."  "
               end; n = n+1
            end;
            user:SendPM(to, "\r\n"..on.."\r\n"..offline.."\r\n"..away.."\r\n"..na.."/"..n.." active members.")
         elseif cmd == tCmds.Invite 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 cmd == tCmds.Remove and (isowner or user.bOperator) 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 cmd == tCmds.DelChat and (isowner or user.bOperator) 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)
   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

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

   load = function(self)
      self.items = dofile("logs/chatrooms.tbl") or {}
      for name, room in self.items do
         if tKey == 1 then frmHub:RegBot(name) else frmHub:RegBot(name,0,"","") end
         room.chat = botchat
      end
         end,
   save = function(self)
      if loadfile("logs/chatrooms.tbl") then
         local f = io.open("logs/chatrooms.tbl", "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\tgroups = {\n", name, tmp.name, tmp.owner))
            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("logs/chatrooms.tbl", "w+")
         f:write("return {\n"); f:write("}"); f:close()
      end
   end
}

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

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

>>>>> now wat i want from this script is tat, users shld type something in tat chatrrom created already and thy get logined automatically in tat room, alos user may leave wenever thy want. <<<<<<

dessamator i tried ur last script, but tats not wat i want as the !autologin on enables for the whole profile i guess and also wen u login as an operator in tat room and do !members it jus shows my name as i have created room and reged profile users can chat thn
and also wen u restart this script for dessamator u get a pm from room as Hello. quite irritating.
anyways some1 help me , i need this >>>>  <<<<< urgent


Well, you dont want them to autologin, simple, just use
"!mkchat chatbot".
Leaving the Chatroom, is as simple as typing "!leave"

The last script includes all those features that were requested(including what u asked now) .
As For "hello bug" , solved, script edited.
Title:
Post by: enigma on 05 November, 2005, 22:10:48
dessamator , !members bug fixed ?
i used ur last script
made a room
typed !autologin on in tat room
thn i logined as a reg profile  in my hub to test script
thn typed something in tat room, thn i guess it would have popped up to evry1, as i don want this, i want only a user who types anything 1ce in tat becomes a member there...
woah wat confussion ..lol  .. :S
thn i logined as a master in my hub
thn send a message to room...but i donno wat happened ..no1 replied maybe thy maybe afk or maybe thy might have not recieved my message....but thn i did !members only to find me in members list :9
now where are the remaainig users who chatted there ??

regards dessamator
Title:
Post by: Dessamator on 06 November, 2005, 12:59:58
QuoteOriginally posted by enigma
dessamator , !members bug fixed ?
i used ur last script
made a room
typed !autologin on in tat room
thn i logined as a reg profile  in my hub to test script
thn typed something in tat room, thn i guess it would have popped up to evry1, as i don want this, i want only a user who types anything 1ce in tat becomes a member there...
woah wat confussion ..lol  .. :S
thn i logined as a master in my hub
thn send a message to room...but i donno wat happened ..no1 replied maybe thy maybe afk or maybe thy might have not recieved my message....but thn i did !members only to find me in members list :9
now where are the remaainig users who chatted there ??

regards dessamator

Well, autologin was meant to do that, if you dont want that to happen just disable autologin , or remove the chatroom and create a new one. There isnt any problem with the !members, it acted like that because autologin was on.

Hope it helps.
Title:
Post by: Thor on 06 November, 2005, 14:28:25
When i want to make a chatroom by use the rightclick menu, i have been disconnected... :S
Title:
Post by: Dessamator on 06 November, 2005, 17:19:27
Works perfectly here, maybe you are using a version of the script with a bug.
Title:
Post by: Thor on 06 November, 2005, 17:33:35
I copied the last script from here, everything go perfectly, just it isn't... I use PtokaX 0.3.3.21. All other command work perfectly, i tried it, but this one not... ?(
Title:
Post by: Rick on 06 November, 2005, 17:57:01
I have found that if the chatroom is not woking correctly I restart the script but that hasn't been neeeded much at all. If I make changes and restart the script and someone can't access all they need to do is reconnect to the hub

If you are having an issue with the chatroom in your client, reconnect to the hub and 9 times out of 10 things will be working correctly. If not restart the script then again reconnect to the hub.

One time we had to delete the TBL file, then follow the above steps again which corrected a problem

DESSEMINATOR AND JITEN - please correct or add to this with the official response 8)

This is what has worked for us
Title:
Post by: Dessamator on 06 November, 2005, 19:38:44
QuoteHungarista           I copied the last script from here, everything go perfectly, just it isn't... I use PtokaX 0.3.3.21. All other command work perfectly, i tried it, but this one not... ?(

Can you show me the NewUserConnected, and OpConnected functions?

QuoteOriginally posted by Rick
I have found that if the chatroom is not woking correctly I restart the script but that hasn't been neeeded much at all. If I make changes and restart the script and someone can't access all they need to do is reconnect to the hub

If you are having an issue with the chatroom in your client, reconnect to the hub and 9 times out of 10 things will be working correctly. If not restart the script then again reconnect to the hub.

One time we had to delete the TBL file, then follow the above steps again which corrected a problem

DISSEMINATOR AND JITEN - please correct or add to this with the official response 8)

This is what has worked for us

Hmm, Disseminator, nice nick, either way, restart helps sometimes, but mostly its not needed.

The time you had to delete the TBL file was because some changes were made to the way the script saves and loads the file, it wouldnt be compatible with the older TBL.
Title:
Post by: Thor on 06 November, 2005, 19:48:51
Sorry, i was careless, the problem was: in the makechat command there were two $ sign.. sry
Title:
Post by: Dessamator on 06 November, 2005, 20:08:51
No probs, nice to know you solved it.
Title:
Post by: Dessamator on 12 November, 2005, 20:37:22
-- 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)
-- Changed: Command Parsing
-- Added: Autologin switch for each chatroom: !autologin on/off
-- Code optimized a bit (10/30/2005)
-- Added: hide chatrooms from non members !hide on/off by Dessamator

tCmds = {}
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 = false -- 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, }

Commands = { -- 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 },
AutoLogin = { "autologin", 4 },
Hide = { "hide",4},
}

Main = function()
chatrooms:load()
end

OnExit = function()
chatrooms:save()
end


MyINFOArrival = function(user, data)
chatrooms:load(user)
end

ChatArrival = function(user,data)
local data = string.sub(data,1,-2)
local s,e,cmd = string.find(data,"%b<>%s+%!(%S+)")
if cmd then
local mCmds = {
["mkchat"] = function(user, data)
local s,e,args = string.find(data, "^%b<>%s+%S+%s*(.*)")
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 = chatrooms:new(sTag..name, user.sName, "")
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 }
if mCmds[cmd] then
for i,v in Commands do
if Levels[user.iProfile] >= v[2] then return mCmds[cmd](user,data), 1 end
end
end
end
end

ToArrival = function(user,data)
local data = string.sub(data,1,-2)
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
local Messager = function()
if tmp.status == "auto" then
tmp:chat(str, user.sName)
else
tmp.members[user.sName] = 1 tmp:chat(user.sName.." joined", to) tmp:chat(str, user.sName) chatrooms:save()
end
end
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.

Messager()
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 Messager() end
end
else
local s,e,cmd,args = string.find(str, "^%!(%a+)%s*(.*)$")
if cmd then
local tCmds = {
[Commands.Away[1]] = function(user, data, tmp, to, args)
tmp:chat(user.sName.." is away.. "..args, to)
if tmp.status == "auto" then tmp.away[user.sName] = 1 else tmp.members[user.sName] = 0 end
end,
[Commands.Leave[1]] = function(user, data, tmp, to, args)
tmp:chat(user.sName.." left. "..args, to)
if tmp.status == "auto" then tmp.away[user.sName] = 1 else tmp.members[user.sName] = nil end
chatrooms:save()
end,
[Commands.Members[1]] = function(user, data, tmp, to)
local n, na, msg,offline,away,on = 0, 0,"","Offline :\r\n"..string.rep ("=", 20),"Away :\r\n"..string.rep ("=", 20), "Online :\r\n"..string.rep ("=", 20)
if tmp.status=="on" and tmp.groups  then
user:SendPM(to, "This room is private, only Members can chat here.")
elseif tmp.status=="on" then
user:SendPM(to, "This room is public, all users can chat.")
else
for nick, stat in tmp.members do
if not GetItemByName(nick) then offline = offline.."\r\n"..nick
elseif stat == 0 then away = away.."\r\n"..nick
else msg, na = "", na+1
on = on.."\r\n"..nick
end; n = n+1
end;
user:SendPM(to, "\r\n"..on.."\r\n\r\n"..offline.."\r\n\r\n"..away.."\r\n\r\n"..na.."/"..n.." active members.")
end
end,
[Commands.Invite[1]] = function(user, data, tmp, to, args)
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()
end,
[Commands.Remove[1]] = function(user, data, tmp, to, args)
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()
end,
[Commands.DelChat[1]] = function(user, data, tmp, to)
tmp:chat("End of session.", to)
chatrooms.items[to] = nil
chatrooms:save()
SendToAll("$Quit "..to)
end,
[Commands.AutoLogin[1]] = function(user, data, tmp, to, args)
if string.lower(args) == "on" then
tmp.status = "auto" chatrooms:save()
user:SendPM(to, "Chatroom AutoLogin Mode has been enabled.")
elseif string.lower(args) == "off" then
tmp.status = "" chatrooms:save()
user:SendPM(to, "Chatroom AutoLogin Mode has been disabled.")
else
user:SendPM(to, "*** Syntax Error: Type !autologin on/off")
end
end,
[Commands.Hide[1]] = function(user, data, tmp, to, args)
if string.lower(args) == "on" then
tmp.hide="on"

user:SendPM(to, "Chatroom hide Mode has been enabled.")
elseif string.lower(args) == "off" then
tmp.hide = "off"
user:SendPM(to, "Chatroom Hide Mode has been disabled.")
else
user:SendPM(to, "*** Syntax Error: Type !hide on/off")
end
chatrooms:save()
chatrooms:load()
end,  
}
if tCmds[cmd] then
for i,v in Commands do
if Levels[user.iProfile] >= v[2] then return tCmds[cmd](user, data, tmp, to, args), 1 end
end
end
elseif not s then
tmp.members[user.sName] = 1 tmp:chat(str, user.sName)
else
tmp:chat(str, user.sName)
end
end;
return 1
end
end

botchat = function(self, msg, from)
local SendPM = function(a,b,tTable,tMode)
for a, b in tTable do
if tMode == 1 then
if b.sName ~= from and not self.away[b.sName] then
SendToNick(b.sName, "$To: "..b.sName.." From: "..self.name.." $<"..from.."> "..msg)
end
else
if a ~= from and b == 1 then
SendToNick(a, "$To: "..a.." From: "..self.name.." $<"..from.."> "..msg)
end
end
end
end
if self.status == "auto" then
if next(self.groups) then
for v, i in self.groups do SendPM(_,user,frmHub:GetOnlineUsers(v), 1) end SendPM(nick, id, self.members, 0)
else
SendPM(_,user,frmHub:GetOnlineUsers(), 1)
end
else
SendPM(nick, id, self.members, 0)
end
end

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

load = function(self,user)
local function HideBots(room,Status,v)
local KeyCheck
if tKey then KeyCheck = "$OpList "..room.name  else KeyCheck ="$MyINFO $ALL "..room.name.." ".." ".."$ $".." ".." $".." ".."$".."0".."$" end
if Status then SendToAll(KeyCheck) end
v=v or user
for i,v in frmHub:GetOnlineUsers() do
if v.sName~= room.owner and not(room.members[v.sName]) or not(room.groups[v.iProfile]) then v:SendData("$Quit "..room.name)
else v:SendData(KeyCheck) end
if user then break end
end
end

if loadfile(fChat) then
self.items = dofile(fChat)
for name, room in self.items do
-- room:chat("Hello", name)
room.chat = botchat
if user and room.hide =="on" then HideBots(room,"",user)
elseif room.hide =="off" then     HideBots(room,"on")
elseif not user then  HideBots(room)
end
end

else
local f = io.open(fChat, "w+") f:write("return {\n"); f:write("}"); f:close() self.items = dofile(fChat)
end
end,

save = function(self)
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\thide = %q,\n\t\tgroups = {\n", name, tmp.name, tmp.owner, tmp.status,tmp.hide))
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\taway = {\n");
for user, stat in tmp.away do f:write(string.format("\t\t\t[%q] = %d,\n", user, stat)) end;
f:write("\t\t}\n\t},\n");
end;
f:write("}"); f:close()
end
}

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

OpConnected = function(user)
NewUserConnected(user)
user:SendData("$UserCommand 0 2")
user:SendData("$UserCommand 1 2 Chatrooms\\Delete$$To: %[line:Chatroom] From: %[mynick] $<%[mynick]> !"..Commands.DelChat[1].." %[line:Chatroom]|")
user:SendData("$UserCommand 1 2 Chatrooms\\Invite$$To: %[line:Chatroom] From: %[mynick] $<%[mynick]> !"..Commands.Invite[1].." %[line:Nick]|")
user:SendData("$UserCommand 1 2 Chatrooms\\Remove$$To: %[line:Chatroom] From: %[mynick] $<%[mynick]> !"..Commands.Remove[1].." %[line:Nick]|")
user:SendData("$UserCommand 1 3 Chatrooms\\Make$<%[mynick]> !"..Commands.MakeChat[1].." %[line:Chatroom] %[line:Profile (optional)]|")
user:SendData("$UserCommand 1 2 Chatrooms\\Set AutoLogin$$To: %[line:Chatroom] From: %[mynick] $<%[mynick]> !"..Commands.AutoLogin[1].." %[line:On/Off]|")
user:SendData("$UserCommand 1 2 Chatrooms\\Set Hide$$To: %[line:Chatroom] From: %[mynick] $<%[mynick]> !"..Commands.Hide[1].." %[line:On/Off]|")
end


Script edited!
Title:
Post by: Rick on 12 November, 2005, 21:41:20
Is there any way to
Run the commands from the command line? (Invite etc)
and
Any way to invite all into a chatroom?

We set up special chatrooms for holidays and birthdays etc and setting to autojoin is a great feature but it doesn affect the ones already logged in.

Thanks
Rick
Title:
Post by: Dessamator on 12 November, 2005, 22:05:57
QuoteOriginally posted by Rick
Is there any way to
Run the commands from the command line? (Invite etc)
and
Any way to invite all into a chatroom?

We set up special chatrooms for holidays and birthdays etc and setting to autojoin is a great feature but it doesn affect the ones already logged in.

Thanks
Rick
Running from command line?, do you mean main chat?, if so well, its possible but more coding would have to be added, and the syntax would have to be, "!invite chatroom nick", personally i see no advantage of that.

"Inviting all", autologin should do that,  but u need to create the room without parameters, "!mkchat holidays&bdays".
Title:
Post by: Rick on 13 November, 2005, 03:50:30
We've been setting autologin with the right click menu and setting the chatroom to "public" as we create it
THat seems to work and I am assuming nothing changed in the most recent script to affect this

The scenario I was thinking of is we create a chatroom with auto login but there are a fair amount of people already logged in so that doesn't affect them nor does restarting the script

I would like to be able to create a chatroom and have all those already logged in be automatically put in the chatroom - not just when creating but even an existing chatroom  

This would be a great feature but we are very happy with what we have already!!! :D
Title:
Post by: Dessamator on 13 November, 2005, 13:25:21
Well that already happens, unless the room was created for a certain profile, if so only those in that profile will join the room automatically.
Is that what u mean?
Is your request a feature  to change/remove the room's profile and enable autologin for all?
Title:
Post by: Rick on 13 November, 2005, 14:00:53
Correct me if I am wrong but autologin for a chatroom set to "public" will automatically brin people into the room as they log into the hub

But if I create one now and you have been logged in for (say) a few hour already it will not log you in (not would I expect it to) !members will verify that they ARE coming in at logon but the already logged in need to be invited

I was looking for a way to bring all the ones not in the chatroom in. and "invite all, invite * etc that would bring everyone in. (and hopefully if there are 25 not in the room not put 25 "hellos" in the chatroom) :D

Another possibility would to have it work on multiple selected users (we are all on DC++) but I suspect that would open issues across the various clients

Call this a feature suggestion - we hare having great success with it as-is (and thanks again! 8)  )
Title:
Post by: Dessamator on 13 November, 2005, 14:57:15
QuoteOriginally posted by Rick
Correct me if I am wrong but autologin for a chatroom set to "public" will automatically brin people into the room as they log into the hub
Nop, it doesnt work that way, if you set to "public" , the chat is sent to all in that profile, or all in the hub(depending on the settings), it has nothing to do with login or logout.

QuoteOriginally posted by Rick
But if I create one now and you have been logged in for (say) a few hour already it will not log you in (not would I expect it to) !members will verify that they ARE coming in at logon but the already logged in need to be invited
Unless the users are "!away" or have left("!leave") it should send the info to whoever.

QuoteI was looking for a way to bring all the ones not in the chatroom in. and "invite all, invite * etc that would bring everyone in. (and hopefully if there are 25 not in the room not put 25 "hellos" in the chatroom) :D
It does that, unless you have created a room with a profile,
and havent enabled autologin, but it could be added to change a room from profile based(private room to public).
Lol, 25 hellos?, it sends 1 per user, maybe it shows that the user has been invited.

QuoteAnother possibility would to have it work on multiple selected users (we are all on DC++) but I suspect that would open issues across the various clients

Call this a feature suggestion - we hare having great success with it as-is (and thanks again! 8)  )

You mean on right click, or cmd based, or both?
Title:
Post by: Rick on 13 November, 2005, 16:01:47
I thought  "public" was created so all could join from any profile - that's the way it seems to be working

WHen we made it with no profile people were having trouble entering - but that was a couple of revisions ago

I just made a testchat with the latest script and no profile. I am the only one in it out of 19 logged in. I tried it with autologin both off and on

How would I invite these 19 people all at once?

Thanks

Rick
Title:
Post by: Dessamator on 13 November, 2005, 16:32:46
For now, you can only do it manually, maybe later I'll implement a command to do so.
Just so you know, public chat is created when you create a room without profiles, and autologin, is for the chatroom to send the "chat" to everyone in the hub or in that profile.

If nothing is typed in the chatroom nothing will be sent to the others, and a member is only added when he/she types in the room.

Hope that answers your questions.
Title:
Post by: Rick on 13 November, 2005, 17:03:58
QuoteHope that answers your questions.
I may be misunderstanding something
QuoteJust so you know, public chat is created when you create a room without profiles, and autologin, is for the chatroom to send the "chat" to everyone in the hub or in that profile.

If nothing is typed in the chatroom nothing will be sent to the others, and a member is only added when he/she types in the room.

I just created a chatroom with no profile and autologin set to ON. I sent a message and I am still the only one in there. I know if I invite them manually the WILL be in there and anyone that logins from now on will automatically be in the room (unless they leave etc)
I guess what we are looking for is a way to PUT people already logged in - into the chatroom with one command and not have to individually invite each one

QuoteFor now, you can only do it manually, maybe later I'll implement a command to do so.

Thanks! I'll say it again though - it isn't a major issue. I enjoy the discussion and will use the command if you get it created (and test it if you want to provide the code changes before releasing). All your work is appreciated
Title:
Post by: Dessamator on 13 November, 2005, 18:53:29
Well,I  see your point, your message is sent,and the other users receive it, but until they reply, they wont be added to the members list.

The prob with changing it, is imagine in big hubs, 1000 users in the list. that would cause a big list, what i can do is change the members list, if autojoin is on then it would send a msg "public chat", or "private chat for profile", instead of the normal message, as for inviting ill add it ASAP.
Title:
Post by: Rick on 13 November, 2005, 18:59:01
Dessamator - Thanks - we will test it for you but again don't rush - if it is a beautiful day where you are - go out and enjoy it  :-)
Title:
Post by: Dessamator on 13 November, 2005, 21:52:38
QuoteOriginally posted by Rick
Dessamator - Thanks - we will test it for you but again don't rush - if it is a beautiful day where you are - go out and enjoy it  :-)

Thanks, I'll take my sweet time :)
Title:
Post by: Dessamator on 14 November, 2005, 21:18:46
Done . Updated members cmd, no invite added though.
Title: Re: Chatrooms v3 (tezlo) LUA 5
Post by: jiten on 28 February, 2006, 19:45:37
First post updated with the latest Chatroom code before angers' board went offline.
Title: Chatrooms v. 4c
Post by: jiten on 07 March, 2006, 19:10:53
First post updated with the 4c version (3/7/2006).

Best regards