Chatrooms v4c
Lua 5 version by jiten and Dessamator
Based on: Chatrooms v3 by tezlo
Changelog:
- Changed: Profile permissions (requested by GeceBekcisi);
- Rewritten: Significant code and loops; code is more presentable;
- Added: Status for each chatroom;
- Changed: MyINFO handling to avoid flooding;
- Changed: Other small mods.
Grab it HERE (http://www.mznetwork.co.mz/scripts/chatrooms.v4c.rar).
why when i reboot my server the statistic it lost .. :((
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
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)
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?
mean the Top Chatters will be reset (the save data in chatstats.tbl whill be lost) when i reboot the server or the scripts
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.
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
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)
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 :]
[16:16] Syntax logs/chatrooms.dat:2: unexpected symbol near `'
get this error
pls help someone
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
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
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
thanx m8.the script worked fine.can u pls remove the key coming besides the chatrooms and add right click cmds for the script
Last script updated with all requests.
Best regards
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
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
hey the invite cmd doesnt work
pls help
QuoteOriginally posted by kunal
hey the invite cmd doesnt work
pls help
Fixed :]
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
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.
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
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.
thanx m8
no request now. ;)
perfect script.
yw m8 ;)
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
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
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
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
!delchat and !invite doesent work by me....any ideas? no syntax errors.
Greets
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
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.
I don?t get it to run...
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
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.
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...
hmm....hope u get some time for this
little Request ;)
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 ??
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
wow !!! thanx dude
can u do the other request I posted earlier
whenever u get time
Regards
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...
simple, to resolve, just create a chatroom for regusers, the rest is already part of the script
I didn't get u,
I don't think what u r saying will solve problem
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
How can I do that ???
!mkchat RegChat reg
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...
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
still I can't close rooms created by
registered users even being master :((
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 ;(
u obviously did something wrong, it should work !
QuoteOriginally posted by kash?
still I can't close rooms created by
registered users even being master :((
Second script updated.
Cheers
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 !
where to add the 2 nd one
got it m8
but i think horizontal one will look better and will be more suitable for finding the required person
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
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,
can anyone tell me how to do it
;( ;( ;( ;( ;(
no one seems to help me
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.")
ty m8 :] :] :] :] :]
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
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 !!!
Quote!mkchat Masterchat master
QuoteOriginally posted by Dessamator
Quote!mkchat Masterchat master
Thx for reply.
I tryed this way but operators too can join without invite.
?(
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.
Thanks Dessamator !!!!!!!!!
It worked !!!!
It's really what I needed.
:D :D :D
ur welcome
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
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
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()
can anyone modify the script so that the name of the owner appears in the description of the chatroom
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
That question has already been answered, read the previous posts .
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_platinumplz help me do it correct
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
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
... 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
[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
Maybe ur using an unfinished script, I have personally tested it with robocop, in the past, and it worked perfectly.
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
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.
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
-- 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
Thanks!!!!!!
Now - Take a well deserved rest
Next request might be for autojoin :D
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 .
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
You mean by profile, or by some other criteria?
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
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
>>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
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.
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
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
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
You copied it incorrectly, it should be like this :
bRestrict = false -- Warning: Only applies to command (without specifying a profile): !mkchat chatname
That did it!
You are awesome
Thanks again
Rick
QuoteOriginally posted by Rick
That did it!
You are awesome
Thanks again
Rick
You're welcome.
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)
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.
edit your posts and tick Delete post ;)
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
AWESOME AGAIN!!
Thanks
Rick
You are Welcome, "again"
We are geting to love this script
QuoteOriginally posted by Rick
We are geting to love this script
Yeah this script is very good. good work Dessamator ;)
I never touched the script, Jiten moded & i posted.
Just so he lnows that we all appreciate the effort :]
QuoteOriginally posted by Rick
Just so he lnows that we all appreciate the effort :]
Ill tell him, :]
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 ??
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"
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
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.
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
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.
When i want to make a chatroom by use the rightclick menu, i have been disconnected... :S
Works perfectly here, maybe you are using a version of the script with a bug.
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... ?(
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
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.
Sorry, i was careless, the problem was: in the makechat command there were two $ sign.. sry
No probs, nice to know you solved it.
-- 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!
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
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".
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
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?
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) )
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?
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
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.
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
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.
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 :-)
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 :)
Done . Updated members cmd, no invite added though.
First post updated with the latest Chatroom code before angers' board went offline.
First post updated with the 4c version (3/7/2006).
Best regards