PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: NemeziS on 14 November, 2004, 00:53:23

Title: Chatrooms
Post by: NemeziS on 14 November, 2004, 00:53:23
Hello guys!

Another script request.

I wanted a script that will make a lot of chat rooms on my hub on different themes.
For example Chatroom "Auto" or "x3m".

I don't want chat window to appear when somebody writes in it (like PM), but to open when somebody writes !chatroom1  or !chatroom2.
And I also wanted to make something like MOTD when somebody joins a chatroom (different MOTDs) and  messages like this

User has just joined this chatroom

and

User has just left this chatroom

I don't know if it's possible to make a list of users there, like in a hub, but i wanted bot to show all the users who had joined this chatroom on cmd !showusers like that:

[02:38] Userlist (users, who are in a chatroom now)

                zorro1 ** **
                user ** **
                lolA ** **
                Cherry ** **
                HellBoy ** **
                Angel ** **
                Mafiozzy ** **
                GoodGuy ** **

- profiles from the list (Operator, Master, VIP, Reg, Unreg)

I also wanted to make some moderators for different chatrooms, who can edit Chatroom_MOTD, "kick", "ban", "unban", "gag", "ungag" and disconnect users from a chatroom, but not from a hub (if it's possible)

Who can help me with this script? Or maybe some genius can write it themselves?

Sorry about my English! ;)
Title:
Post by: NemeziS on 14 November, 2004, 15:35:26
Help me plz.....  ?(
Title:
Post by: nErBoS on 15 November, 2004, 01:15:35
Hi,

Some questions about your request....

1- Who creates that chatrooms ??
2- Is the chatroom visible to all ??
3- Who adds or remove access to the chatrooms ??

Best regards, nErBoS
Title:
Post by: NemeziS on 15 November, 2004, 02:15:31
Hi,  nErBoS !

1- Who creates that chatrooms ?? I want to create chatrooms myself (they will be entered in the script)
2- Are the chatrooms visible to all ?? Yes, they are. Everybody can chat in th? chatrooms.
3- Who adds or remove access to the chatrooms ?? I want to create some profiles, named like that "Chatroom#1 Moderator" or "Chatroom#2 Moderator", etc. So, only this profiles, masters and operator can do with this chatrooms every thing they want. So if user is "Chatroom#1 Moderator" or Master or Operator he can do everything with the chatrooms. I will make selected users "Chatroom# Moderator" by reging them in PtokaX
Title:
Post by: nErBoS on 15 November, 2004, 03:19:54
Hi,

OK i will start do it as soon as i can.

Best regards, nErBoS
Title:
Post by: NemeziS on 15 November, 2004, 03:58:55
Thanx! :)

[*edit]  

What can you tell about this? link (http://board.univ-angers.fr/thread.php?threadid=3052&boardid=11&styleid=1&sid=c673aac4437e16b8437c398d7dd1aa4f)
Title:
Post by: nErBoS on 16 November, 2004, 02:00:14
Hi,

Well like i said before i am having few time now, but i will see what i can do, when i can.

Best regards, nErBoS
Title:
Post by: NemeziS on 19 November, 2004, 09:54:45
Hi, nErBoS!

So, when will you finish it?

Best regards,

NemeziS
Title:
Post by: nErBoS on 19 November, 2004, 10:58:02
Hi,

In the weekend  :))

Best regards, nErBoS
Title:
Post by: bastya_elvtars on 19 November, 2004, 13:38:35
Till then, try chatrooms by tezlo (http://http://www.plop.nl/ptokaxbots/Tezlo/chatroom.lua)
Title:
Post by: nErBoS on 21 November, 2004, 03:35:32
Hi,

The script will have this commands...

--## ONLY FOR MASTERS:
--## +addchat - Creates a chat room with a motd
--## +delchat - Deletes a chat room
--## +addmoderator - Adds a Moderator to the chat room
--## +delmoderator - Removes a Moderator from the chat room
--##
--## ONLY FOR MASTERS, OPS AND MODERATOR:
--## +changemotd - Change the chat room motd
--## +showusers - Show the chat room users logged in
--## +gag - Gags a user from speaking on the Chat
--## +ungag - UnGags a user from speaking on the Chat
--##
--## FOR ALL USERS:
--## +showmoderator - Show the list of moderators of the chat room
--## +join - Joins a chat room
--## +leave - Leaves a chat room

Is it fine by you ??

About the kick,ban and disconnect command, is not possible.

Best regards, nErBoS
Title:
Post by: nErBoS on 22 November, 2004, 11:27:04
Hi,

Download the script HERE (http://nerbos.go.dyndns.org/Chat-Room.lua)
I have tested somethings, please test the script.

Best regards, nErBoS
Title:
Post by: NemeziS on 23 November, 2004, 13:50:26
Thanx, nErBoS!

I've downloaded the script and soon will test it on my hub.  ;)

Best regards,
NemeziS
Title:
Post by: NemeziS on 24 November, 2004, 19:27:11
Hi, nErBoS !

I've just tested your script!  Could you modify it a little for me please?

1) I want the commands been seen not only in main, but in the chatroom, too.

For example:

Moderator in chatroom writes !gag

And the  user in the chatroom is gagged!

He can also write in main +gag , but it's more easy for everybody if the commands will be seen in the chatroom ( without writing ).

2) And I wanted that all the messages will not be sent to PM (user:SendPM)! I want all the messages that pertain to a chatroom will be displayed in chatroom (like user:SendData) or in main -> it depends on where the command was sent

If the command was sent to the chatroom the user will seen all the messages like "Syntax Error, +leave , you must write a chat room name."  in the chatroom (not in PM). I don't like the variant with user:SendPM at all!

But if the command was sent to main, he will see a message in main (user:SendData), but not in PM.

I think it will be more correctly to write a function like ours SendChatToChatRoom  but that will display info and all the messages only for current user in the chatroom like user:SendData in main (not PM)

3) And I also wanted to make a help function for chatrooms. If somebody writes !chathelp then he will get help message with all available commands for him in the chatroom (not in PM!).

I like your script very much and it will be fantastic if you modify it for me! :)

Best regards,
NemeziS
Title:
Post by: nErBoS on 24 November, 2004, 22:47:50
Hi,

1) I made the script to have a Bot here you can write all the commands in PM or in Main, on doing that you will spent more resources.

2) Yes i can chage that

3) Yes i can do that

Best regards, nErBoS
Title:
Post by: NemeziS on 25 November, 2004, 11:52:29
Hi!

I have only one bot on my hub. I deleted line "frmHub:RegBot(sBot)" at all.

It's not good to write commands to bot's PM or in Main.

It's not a problem with resources for me, but it will be the best way if the commands work both in main and bot's PM and also in chatrooms!

Could you modify your script in this way too, pliz? :)

Best regards,
NemeziS
Title:
Post by: nErBoS on 25 November, 2004, 14:46:35
Hi,

OK i will see what i can do.

Best regards, nErBoS
Title:
Post by: NemeziS on 26 November, 2004, 08:47:49
Hi, nErBoS!

So, when will you modify the script? ;)

Best regards,
NemeziS
Title:
Post by: nErBoS on 26 November, 2004, 14:07:31
Hi,

In the weekend probably, my time stills missing.

Best regards, nErBoS
Title: Script modification
Post by: NemeziS on 30 November, 2004, 17:51:27
Hi, nErBoS!

Have you finished your modification?

Best regards,
NemeziS
Title:
Post by: nErBoS on 01 December, 2004, 03:14:31
Hi,

Sorry i am very busy, will do it as soon as i can.

Best regards, nErBoS
Title:
Post by: NemeziS on 06 December, 2004, 21:44:57
Hi, nErBoS!

If you have some free time, please finish it please!

I tried to modify it myself, but I have not to much experiense to do this. So I've broken the script at all.  :(

Best regards,
NemeziS
Title:
Post by: bastya_elvtars on 06 December, 2004, 21:52:48
QuoteOriginally posted by NemeziS
Hi, nErBoS!

If you have some free time, please finish it please!

I tried to modify it myself, but I have not to much experiense to do this. So I've broken the script at all.  :(

Best regards,
NemeziS

at least you had the courage to try!

;)
Title:
Post by: nErBoS on 07 December, 2004, 01:35:15
Hi,

This wednesday is holiday i will fix it.

Best regards, nErBoS
Title:
Post by: NemeziS on 07 December, 2004, 13:08:59
OK! I will be waiting for it.  :))
Title:
Post by: nErBoS on 08 December, 2004, 20:58:58
Hi,

I have made the request you made, just download from the link i have gave it on the first page.

--## CHAT ROOMS CREATOR BOT 1.0
--## Requested by NemeziS
--## Some BUGs corrected
--## Added the command +chathelp
--## Little modification on the interaction of the commands
--## Made by nErBoS
--## Commands:
--##
--## ONLY FOR MASTERS:
--## +addchat - Creates a chat room with a motd (must be used in main or in PM with sBot)
--## +delchat - Deletes a chat room (must be used in main or in PM with sBot)
--## +addmoderator - Adds a Moderator to the chat room
--## +delmoderator - Removes a Moderator from the chat room
--##
--## ONLY FOR MASTERS, OPS AND MODERATOR:
--## +changemotd - Change the chat room motd
--## +showusers - Show the chat room users logged in
--## +gag - Gags a user from speaking on the Chat
--## +ungag - UnGags a user from speaking on the Chat
--##
--## FOR ALL USERS:
--## +showmoderator - Show the list of moderators of the chat room
--## +join - Joins a chat room
--## +leave - Leaves a chat room
--## +chathelp - Shows the commands to use in Chats

Best regards, nErBoS
Title:
Post by: Themaster on 17 December, 2004, 18:00:06
why just write +join in main ??
 
Title:
Post by: NemeziS on 26 December, 2004, 18:36:05
Thanx, nErBoS!

Excuse me, I had no access to Internet for a long time, so I have not seen the script yet.

I will test it in a few days.  :)

I've already asked you about: What can you tell about this? link (http://board.univ-angers.fr/thread.php?threadid=3052&boardid=11&styleid=1&sid=c673aac4437e16b8437c398d7dd1aa4f)

Is it possible to write a script like that? I need it very much.  :(

If you have some free time, plese look what you can do.  ;)

Best regards,
NemeziS
Title:
Post by: Herodes on 26 December, 2004, 22:19:08
Nemezis good to have you online again ...
plop has offered to help you along as you built your script ..I think help is all around ... never fear to try ... but DO try ;)
Title:
Post by: exlepra on 04 January, 2005, 20:55:31
Nerbos the link to the script is broken.

I'd really like to try that srcipt, most of the scripts I saw here needed an invite by an op, I like that any user can join.
thx
Title:
Post by: nErBoS on 05 January, 2005, 02:13:34
Hi,

Sorry forgot to fix this one, link fixed  :))

Best regards, nErBoS
Title:
Post by: Themaster on 05 January, 2005, 02:20:06
Hello..
I just have try it out...but there a bug with join chatroom it do not work
Title:
Post by: exlepra on 05 January, 2005, 13:04:55
Thx nerbos, works perfectly for me.
Title:
Post by: nErBoS on 06 January, 2005, 01:32:24
Hi,

Ok, i need more info in that bug. Did the script editor gave you any error ?? Show me how did you used the join command.

Best regards, nErBoS
Title:
Post by: Themaster on 06 January, 2005, 02:15:22
i just creat a room and then i wright +join room....but i don't got a join message or a error ...
it only pass +join room
Title:
Post by: nErBoS on 07 January, 2005, 14:15:21
Hi,

The command has to be typed in the room, that was the last update.

Best regards, nErBoS
Title:
Post by: Themaster on 07 January, 2005, 16:29:37
hehe Ok...My fall Sry M8
Title:
Post by: TTB on 28 January, 2005, 19:49:02
Idea...

if someone has joined a chatroom, and enters nothing for xx period... it will be disconnected from the chatroom.

Is this easy to make?
Title:
Post by: nErBoS on 30 January, 2005, 21:01:26
Hi,

It would only take more resources, no need for that, the user only occupies a position in the table of the chat-room, nothing more.

Best regards, nErBoS
Title:
Post by: koji_nanami on 07 February, 2005, 13:15:46
Hi nerbos,

I'm trying your script since i'd like to do the following thing and I'd like to ask you if it's already possible with it or it need a modded one

1: it's possible to create a chat so that it starts already created when the hub starts or restarts? (resident channels?)

2: how can i do to make ppl join a chat created in this way as soon as they join the hub and for category? ie. I want a resident newbie chat and that unregged join it in auto as soon as they join the hub.

3: I'm using chatblocker for unregged and unregged cannot pm the chatbot .... how can avoid it???

Thanks,

koji
Title:
Post by: nErBoS on 07 February, 2005, 13:48:49
Hi,

1. No need to worry about that, when you create a chat the chat will stay there until you remove it;

2. The script needs a modification to do that (i will do it as soon as i can);

3. The script that blocks the unregged user has to be change to allow the user to talk in the chat, post here the script that you are using please.

Best regards, nErBoS
Title:
Post by: koji_nanami on 07 February, 2005, 13:56:23
Thanks for the fast reply.

For point 1: I've created a chatroom but it doesn't stay! As soon as I halt and restart the server the added room are gone.

For point 2: hope to get that mod THANKS!

For point 3: here is the script... can you check also why it doesn't allow also the PM???

here is the code...

--- --- --- --- --- --- --- --- --- --- ---

--- MainStop v 1

--- by Herodes

--- --- --- --- --- --- --- --- --- --- ---

---- Look at the NOTES of this script

--- stops mainchat for selected users or whole profiles

--- remembers state after hub restarts..

--- protects profiles ( set the priorities correctly look at the notes below .. )

--- --- --- --- --- --- --- --- --- --- ---

   --- NOTES:

--- Put this file in your scripts folder of Ptokax and then Start and Stop the Hub ...

--- Then go and open the File MainStop-Profiles.dat with Notepad.exe

--- explanation of contents follows ...

--

--   tProfiles = {

--      ["1"] = { --- this is the profile number for which the following settings apply ...

--         [1] = 1, ---  [1] = 0 means no chat, no scripts commands, 1 chat, no script commands, 2 both chat and command use allowed

--         [2] = 2, --- [2] = is the priority number .. the lower the better .. ( no negative values pls ... )

--         [3] = "Operator",

--      },   --- end for the settings of profile number : "1"

--      ["0"] = {

--         [1] = 2,

--         [2] = 1,

--         [3] = "Master",

--      },

--   }

--

--- --- --- --- --- --- --- --- --- --- ---

---- !!!!! Look at the NOTES of this script !!!!!!

cmdclist = "!lschat"

cmdcstop = "!chat"

cmdchelp = "!chelp"

cmdcprof = "!cprofile"

FiletoSaveNoChatNicks = "MainStop-Nicks.dat"

FiletoSaveNoChatProfiles = "MainStop-Profiles.dat"

tUsrs = {}



function Main()

   LoadFromFile(FiletoSaveNoChatNicks)

   if readfrom(FiletoSaveNoChatProfiles) == nil then

      tProfiles = {}

      local nu = 0

      for i, v in GetProfiles() do

         nu = nu + 1

         tProfiles[""..i..""] = { 1, nu, v }

      end

      tProfiles["-1"] = { 1, nu + 1, "Unregs" }

      SaveToFile(FiletoSaveNoChatProfiles , tProfiles , "tProfiles")

      readfrom()

   end

   readfrom()

   LoadFromFile(FiletoSaveNoChatProfiles)

end



function UserConnected(user)

   if tUsrs[user.sName] == 1 or tProfiles[""..user.iProfile..""][1] == 0 then

      user:SendData("MainChatBlocker", "You cant use the mainchat for now. ...")

   end

end



function DataArrival(user, data)

   if strsub(data, 1,1) == "<" or "*" then

      if tUsrs[user.sName] == 1 or tProfiles[""..user.iProfile..""][1] == 0 then

         user:SendData("MainChatBlocker", "You cant chat in main...")

         return 1

      else

         if tProfiles[""..user.iProfile..""][1] == 2 then

            data = strsub(data, 1, -2)

            s,e,cmd,args = strfind(data, "%b<>%s+(%S+)%s*(%S*)")

            if cmd == cmdclist then

               local msg = "\r\n - The following users are gagged in mainchat\r\n"

               for nick, v in tUsrs do

                  msg = msg.."\t -- "..nick.."\r\n"

               end

               msg = msg.." - The profile permissions are as follows\r\n"

               msg = msg.." - \tProfile Name\tCmds/MainChat\r\n"

               local cmds, chat = "yes", "yes"

               for i,v in tProfiles do

                  if v[1] == 0 then

                     cmds, chat = "no", "no"

                  elseif v[1] == 1 then

                     cmds , chat = "no", "yes"

                  elseif v[1] == 2 then

                     cmds , chat = "yes", "yes"

                  end

                  local prstr = v[3].." ("..i..")"

                  if strlen(prstr) < 8 then

                     prstr = prstr.."\t"

                  end

                  msg = msg.."\t+ "..prstr.."\t   "..cmds.."/"..chat.."\r\n"

               end

               user:SendData("MainChatBlocker", msg)

               return 1

            elseif cmd == cmdcstop then

               if (not args) or (strlen(args) == 0) then

                  user:SendData("MainChatBlocker", "Syntax Error! Please Use like : "..cmdstop.." ")

               else

                  local usr = GetItemByName(args)

                  if tUsrs[usr.sName] then

                     tUsrs[usr.sName] = nil

                     usr.SendData("MainChatBlocker", GetProfileName(user.iProfile).." "..user.sName.." you are now able to chat in mainchat.")

                     user:SendData("MainChatBlocker", usr.sName.." now can chat in main")

                  else

                     if usr then

                        tUsrs[usr.sName] = 1

                        usr.SendData("MainChatBlocker", GetProfileName(user.iProfile).." "..user.sName.." has blocked your ability to chat in mainchat.")

                        user:SendData("MainChatBlocker", usr.sName.." now can't chat in main")

                     else

                        user:SendData("MainChatBlocker", "Error : "..args.." is not in the hub.")

                     end

                  end

               end

               SaveToFile(FiletoSaveNoChatNicks , tUsrs , "tUsrs")

            elseif cmd == cmdchelp then

               local msg = "\t\t--- MainChatBlocker Commands --- \r\n"

               msg = msg.."][\t "..cmdclist.."\t - lists the users that are blocked\r\n"

               msg = msg.."][\t "..cmdcstop.." \t - gags the mainchat of nick\r\n"

               msg = msg.."][\t "..cmdcprof.." \t - It toggles the permission to chat in main for the specified profile number\r\n"

               msg = msg.."][\t "..cmdchelp.."\t - shows this helpful text :P\r\n"

               user:SendData(msg)

            elseif cmd == cmdcprof then

               if (not args) or (strlen(args) == 0) then

                  user:SendData("MainChatBlocker", "Syntax Error! Please Use like : "..cmdcprof.." ")

               else

                  if args == "-1" then

                     if tProfiles[args][1] == 1 then

                        tProfiles[args][1] = 0

                        user:SendData("MainChatBlocker", "Normal Users now are unable to chat in mainchat")

                        SendToAll("MainChatBlocker", "Notice! : Normal Users now are unable to chat in mainchat")

                     elseif tProfiles[args][1] == 0 then

                        tProfiles[args][1] = 1

                        user:SendData("MainChatBlocker", "Normal Users now are able to chat in mainchat")

                        SendToAll("MainChatBlocker", "Notice: Normal Users now are able to chat in mainchat")

                     end

                  else

                     s,e,pr = strfind(args, "(%d+)")

                     pr = tonumber(pr)

                     if GetProfiles()[pr] then

                        if tProfiles[""..user.iProfile..""][2] < tProfiles[""..pr..""][2] then --- priority checking ..

                           if tProfiles[""..pr..""][1] == 0 then

                              tProfiles[""..pr..""][1] = 1

                              user:SendData("MainChatBlocker", GetProfileName(pr).."s now are unable to chat in mainchat")

                              SendToAll("MainChatBlocker", "Notice: "..GetProfileName(pr).."s now are unable to chat in mainchat")

                           elseif  tProfiles[""..pr..""][1] == 1 then

                              tProfiles[""..pr..""][1] = 0

                              user:SendData("MainChatBlocker", GetProfileName(pr).."s now are able to chat in mainchat")

                              SendToAll("MainChatBlocker", "Notice: "..GetProfileName(pr).."s now are able to chat in mainchat")

                           end

                        else

                           user:SendData("MainChatBlocker", "Error! : You are not allowed to block the mainchat of "..GetProfileName(pr).."s")

                           SendToOps("MainChatBlocker", "Mr."..user.sName.." behaves stupidly ...")

                        end

                     else

                        user:SendData("MainChatBlocker", "There is no such profile number")

                     end

                  end

                  SaveToFile(FiletoSaveNoChatProfiles , tProfiles , "tProfiles")

               end

            end

         end

      end

   end

end



function Serialize(tTable, sTableName, sTab)

   assert(tTable, "tTable equals nil");

   assert(sTableName, "sTableName equals nil");



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

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



   sTab = sTab or "";

   sTmp = ""



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



   for key, value in tTable do

      local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);



      if(type(value) == "table") then

         sTmp = sTmp..Serialize(value, sKey, sTab.."\t");

      else

         local sValue = (type(value) == "string") and format("%q",value) or tostring(value);

         sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue

      end



      sTmp = sTmp..",\n"

   end



   sTmp = sTmp..sTab.."}"

   return sTmp

end



function SaveToFile(file , table , tablename)

   writeto(file)

   write(Serialize(table, tablename))

   writeto()

end



function LoadFromFile(file)

   if (readfrom(file) ~= nil) then

      readfrom(file)

      dostring(read("*all"))

      readfrom()

   end

end
Title:
Post by: koji_nanami on 09 February, 2005, 09:09:41
Please Nerbos help me =)
Title:
Post by: nErBoS on 10 February, 2005, 01:03:55
Hi,

1. That should be a bad configuration of the script, which version of Ptokax are you using, what do you have in the option "uLaterPtokax =" in the script ??

2. Needs free time, something that i don't have in this next two weeks, because of universaty exams.

3. The script that you showed will gag a user in the main and in PM.

Best regards, nErBoS
Title:
Post by: koji_nanami on 10 February, 2005, 09:23:48
1- what you mean for uLaterPtokax?? i don't see it in the script or configfile. I'm using ptokax testdrive4 (there's a better version?)

2-  Hope you find soon time to help, no problems =)

3-  Maybe it will be better if the script advert user in pm only or in status bar.

thanks,

koji
Title:
Post by: nErBoS on 13 February, 2005, 17:45:51
Hi,

1- Have you check the script code ?? There is a part in the script code that starts as this "--## Configuration ##--" and ends like this "--## END ##--" in the midle of this you will find that configuration that i have talked about it.

Best regards, nErBoS
Title:
Post by: koji_nanami on 16 February, 2005, 11:46:21
Sorry i tought you were talking about the chatblock and not your script... found that part. Hope you'll work on the script soon. Thanks!!!
Title:
Post by: nErBoS on 25 February, 2005, 20:27:47
Hi,

My life its very complicated at this time, i will do it as soon as i can.

Best regards, nErBoS
Title:
Post by: NemeziS on 25 March, 2005, 17:43:23
Hi, nErBoS!

I have a little question.
When I write a command in a chatroom, all the users can see what command I've just written. I don't like this.

Is it possible to add some strings to a script (like a mod) or to write another script to disable this for "+" and "!" commands in chatrooms and in PM messages (In PMs users can also see what commands I use). I don't want them see this commands. Thanks a lot, my friend.  :))

Best regards,
NemeziS