OpChat++ - Page 3
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

OpChat++

Started by jiten, 01 April, 2005, 13:53:24

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jiten

QuoteOriginally posted by Krysalis
Now i miss the other CMDs (Invite, deinvite, invitelist, talklog)
Why removed this? And can u put in again? I need this function really

Best Regards
I didn't remove those functions.
My last post has the stand-alone bot with the add, del and read function you requested.
The OpChat bot is still there. Check the first page of this thread. I just splitted them.

Cheers

Krysalis

#51
hmmm....I didnt request a Releasebot. I requestet as it was before u split. With all funktions, because i need this all in this one.

The Releasebot now is not interesting for me, and same with the op script from Page 1. I need a script that can both.

I dont want anyone release, i want a extra chat for some special users and some of my vips/Ops/sus.
Whre i (Master) can invite and deinvite people and del entrys per +del.
invitet users should can use the cmds (read add invitelist and talklog)....

Maybe its my english... :rolleyes:


Greetings

Krysalis

understand what i mean, jiten?

jiten

#53
That script I posted before is a Release bot based one and the only thing that differs are the messages. Anyway, here goes one:
--/ Lua 5 version 1.1a by jiten
-- Changed: Profile Permissions;
-- Added: Optional message to every user invited on Hub Start/Script Restart
-- Added: Automatic Folder creating
-- Added: add, read and del commands (requested by Krisalys)
-- Fixed: Commands handling
-- Optimized and removed arrOpLevel table
-- Changed the add comand parsing

--## OpChat++ By nErBoS 
--## Commands: 
--## +invite  -- Invites an user to OpChat
--## +delinvite  -- Removes the user from OpChat
--## +invitelist -- List all OpChat invited users
--## +talklog -- Show all the talking while you were offline

--## Settings ##-- 
sOpChat = "sOpChat"					-- OpChat Bot Name (Set it to everything but "OpChat")
sBot = frmHub:GetHubBotName()				-- Bot Name
sFolder = "Logs"					-- Folder where the .tbl files are stord
fInvite = "Invite.tbl"					-- File where the invited users are stored
fLog = "Log.tbl"					-- File where the chat logs are stored
fRelease = "Releases.tbl"				-- File where the Address File is stored
sendCustom = 0						-- 1 = Custom Message to invited user on Hub/Script Restart; 0 = Not
customMsg = "You are currently invited to OpChat"	-- Message sent to them

--## END ##--

arrInvite = {} arrLog = {} Releases = {}

Main = function() 
	frmHub:RegBot(sOpChat)
	if loadfile(sFolder.."/"..fInvite) then dofile(sFolder.."/"..fInvite) else os.execute("mkdir "..sFolder) end
	if loadfile(sFolder.."/"..fLog) then dofile(sFolder.."/"..fLog) end Refresh() if loadfile(sFolder.."/"..fRelease) then dofile(sFolder.."/"..fRelease) end
	if sendCustom == 1 then
		for usr, aux in arrInvite do 
			if (GetItemByName(usr) ~= nil) then 
				SendToNick(GetItemByName(usr).sName, "$To: "..GetItemByName(usr).sName.." From: "..sOpChat.." $<"..sOpChat.."> "..customMsg..".") 
			end 
		end
	end
end 

OnExit = function() 
	SaveToFile(sFolder.."/"..fInvite , arrInvite , "arrInvite") 
	SaveToFile(sFolder.."/"..fLog , arrLog , "arrLog") 
end 

OpConnected = function(user) 
	if (arrLog[user.sName] == nil) then 
		Refresh() 
	elseif (arrLog[user.sName]["Talk"] ~= "") then 
		user:SendPM(sOpChat, "There was chat while you were offline. Type +talklog to read it.") 
	end 
	arrLog[user.sName]["Mode"] = "online" 
end 

OpDisconnected = function(user) 
	arrLog[user.sName]["Mode"] = "offline" 
end 

ChatArrival = function(user, data) 
	local data = string.sub(data, 1, -2) 
	local s,e,cmd = string.find(data,"%b<>%s+[%!%?%+%#](%S+)")
	if (string.sub(data,1,1) == "<") or (string.sub(data,1,5+string.len(sOpChat)) == "$To: "..sOpChat) then
		if cmd then
			local tCmds = {
			["invitelist"] =	function(user)
							local sTmp,op,usr = "List of Users invited to OpChat:\r\n\r\n" 
							for usr, op in arrInvite do 
								sTmp = sTmp.."User: "..usr.."\tInvited by: "..op.."\r\n" 
							end 
							user:SendPM(sOpChat, sTmp) 
						end,
			["talklog"] =		function(user)
							if (arrLog[user.sName]["Talk"] == "") then 
								user:SendPM(sOpChat, "There aren't any chat logs for you to see. You were always online.") 
							else 
								user:SendPM(sOpChat, "Chat while you were offline:\r\n\r\n"..arrLog[user.sName]["Talk"]) 
								user:SendPM(sOpChat, "The chat logs were cleaned.") 
								arrLog[user.sName]["Talk"] = "" 
								SaveToFile(sFolder.."/"..fLog , arrLog , "arrLog") 
							end 
						end,
			["add"]	=	function(user,data)
						local s,e,rel,desc = string.find(data, "%b<>%s+%S+%s+(.*)%s+(ftp+.*)")
						if rel == nil or desc == nil then
							user:SendData(sBot,"*** Error: Type +add  
") else table.insert( Releases, { user.sName, rel, desc, os.date(), } ) SaveToFile(sFolder.."/"..fRelease,Releases,"Releases") SendToAll(sBot, user.sName.." added a new Address: "..rel..". For more details type: +read") end end, ["read"] = function(user,data) local msg, Exists = "", nil for i = 1, table.getn(Releases) do if Releases[i] then msg = msg.."\r\n\tNumber "..i..".\r\n\t["..Releases[i][2].."]\r\n\t["..Releases[i][3].."]\r\n\tPosted by: "..Releases[i][1].." on "..Releases[i][4].."\r\n" Exists = 1 end end if Exists == nil then user:SendData(sBot,"*** Error: The Address list is empty.") else user:SendPM(sBot,msg) end end, } local mCmds = { ["invite"] = function(user,data) local s,e,nick = string.find(data, "%b<>%s+%S+%s+(%S+)") if (nick == nil) then user:SendPM(sOpChat, "Syntax Error, +invite . You have to type a nick.") elseif (arrInvite[string.lower(nick)] ~= nil) then user:SendPM(sOpChat, "User "..nick.." has already been invited to OpChat.") else arrInvite[string.lower(nick)] = user.sName user:SendPM(sOpChat, "User "..nick.." was invited to OpChat.") if (GetItemByName(nick) ~= nil) then GetItemByName(nick):SendPM(sOpChat, "You were invited to OpChat by Operator "..user.sName) end SendPmToOps(sOpChat, "User "..nick.." was invited to OpChat by Operator "..user.sName) SaveToFile(sFolder.."/"..fInvite , arrInvite , "arrInvite") end end, ["delinvite"] = function(user,data) local s,e,nick = string.find(data, "%b<>%s+%S+%s+(%S+)") if (nick == nil) then user:SendPM(sOpChat, "Syntax Error, +delinvite . You have to type a nick.") elseif (arrInvite[string.lower(nick)] == nil) then user:SendPM(sOpChat, "User "..nick.." wasn't invited to OpChat.") else arrInvite[string.lower(nick)] = nil user:SendPM(sOpChat, "User "..nick.." is no longer invited to OpChat.") if (GetItemByName(nick) ~= nil) then GetItemByName(nick):SendPM(sOpChat, "The invitation to OpChat was removed by Operator "..user.sName) end SendPmToOps(sOpChat, ""..nick.." 's invitation to OpChat was removed by Operator "..user.sName) SaveToFile(sFolder.."/"..fInvite , arrInvite , "arrInvite") end end, ["del"] = function(user,data) local s,e,i = string.find(data,"%b<>%s+%S+%s+(%S+)") if i then if Releases[tonumber(i)] then table.remove(Releases,i) SaveToFile(sFolder.."/"..fRelease,Releases,"Releases") user:SendData(sBot,"Address "..i..". was deleted succesfully!") else user:SendData(sBot,"*** Error: There is no Address "..i..".") end else user:SendData(sBot,"*** Error: Type +del ") end end, } if tCmds[cmd] then if user.bOperator or arrInvite[string.lower(user.sName)] then return tCmds[cmd](user,data),1 else return user:SendData(sBot,"*** Error: You are not allowed to use this command."),1 end elseif mCmds[cmd] then if user.iProfile == 0 then return mCmds[cmd](user,data),1 else return user:SendData(sBot,"*** Error: You are not allowed to use this command."),1 end end end end local _,_,whoTo = string.find(data,"$To:%s+(%S+)") if (whoTo == sOpChat) then if (user.bOperator or arrInvite[string.lower(user.sName)] ~= nil) then SendTalkToOps(data) SendTalkToInvited(data) return 1 else user:SendPM(sOpChat, "You can't talk in OpChat.") return 1 end end end ToArrival = ChatArrival SendTalkToOps = function(data) local s,e,from,talk = string.find(data, "$To:%s+%S+%s+From:%s+(%S+)%s+$%b<>%s+(.+)") local aux,profile,usr if (from ~= nil and talk ~= nil) then SaveToLog(from, talk) for aux, profile in GetProfiles() do for aux, usr in GetUsersByProfile(profile) do if (GetItemByName(usr) ~= nil and GetItemByName(usr).bOperator and GetItemByName(usr).sName ~= from) then SendToNick(GetItemByName(usr).sName, "$To: "..GetItemByName(usr).sName.." From: "..sOpChat.." $<"..from.."> "..talk) end end end end end SendTalkToInvited = function(data) local s,e,from,talk = string.find(data, "$To:%s+%S+%s+From:%s+(%S+)%s+$%b<>%s+(.+)") local aux,usr if (from ~= nil and talk ~= nil) then for usr, aux in arrInvite do if (GetItemByName(usr) ~= nil and GetItemByName(usr).sName ~= from) then SendToNick(GetItemByName(usr).sName, "$To: "..GetItemByName(usr).sName.." From: "..sOpChat.." $<"..from.."> "..talk) end end end end Refresh = function() local i,usr for i,usr in frmHub:GetOperators() do usr = usr.sNick if (arrLog[usr] == nil) then arrLog[usr] = {} if (GetItemByName(usr) == nil) then arrLog[usr]["Mode"] = "offline" else arrLog[usr]["Mode"] = "online" end arrLog[usr]["Talk"] = "" elseif (GetItemByName(usr) == nil) then arrLog[usr]["Mode"] = "offline" else arrLog[usr]["Mode"] = "online" end end SaveToFile(sFolder.."/"..fLog , arrLog , "arrLog") end SaveToLog = function(from, talk) local usr,aux for usr, aux in arrLog do if (arrLog[usr]["Mode"] == "offline") then arrLog[usr]["Talk"] = arrLog[usr]["Talk"].."<"..from.."> "..talk.."\r\n" end end SaveToFile(sFolder.."/"..fLog , arrLog , "arrLog") end Serialize = function(tTable,sTableName,hFile,sTab) sTab = sTab or ""; hFile:write(sTab..sTableName.." = {\n"); for key,value in tTable do if (type(value) ~= "function") then local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key); if(type(value) == "table") then Serialize(value,sKey,hFile,sTab.."\t"); else local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value); hFile:write(sTab.."\t"..sKey.." = "..sValue); end hFile:write(",\n"); end end hFile:write(sTab.."}"); end SaveToFile = function(file,table,tablename) local hFile = io.open(file,"w+") Serialize(table,tablename,hFile); hFile:close() end

Cheers

GrinSlaW

Hello jiten  :))

the script works just as i wanted very nice work  :D
tnx alot for your work  :))

cheers
.:: AcExtreme ::. | .:: AcPro ::.

jiten

That's what I most like to hear, ups, read :D
Lets see if it's OK with Krysalis too.

Best regards

Krysalis

#56
Same opinion. Seems to work absolutely fine ;-)
Where i have to change that the Result from the +read cmd came in bot pm and not in Hubbot pm?
Thats the last one ;-)

Very good work.

Best regards

PS: Another Change please ;-)
-- Added: add, read and del commands (requested by Krisalys)
into
-- Added: add, read and del commands (requested by Krysalis)

Thats really all *g*

jiten

QuoteOriginally posted by Krysalis
Where i have to change that the Result from the +read cmd came in bot pm and not in Hubbot pm?
In this code I'm copying, replace every "sBot" with "sOpChat" and that should do it:
["read"] =	function(user,data)
						local msg, Exists = "", nil
						for i = 1, table.getn(Releases) do
							if Releases[i] then
								msg = msg.."\r\n\tNumber "..i..".\r\n\t["..Releases[i][2].."]\r\n\t["..Releases[i][3].."]\r\n\tPosted by: "..Releases[i][1].." on "..Releases[i][4].."\r\n" Exists = 1
							end
						end
						if Exists == nil then 
							user:SendData(sBot,"*** Error: The Address list is empty.")
						else
							user:SendPM(sBot,msg)
						end
					end,
Best regards,

jiten

Krysalis

#58
Thx,

if i have changed botname, i have renamed to this, and not in sOPChat, right? If i renamed to "Mystery" i musst replace sbot to Mystery.

Maybe i Find a little Bug. (But can?t testet enough yesterday to say is really one)

I invitet a user and he is typing +read in pm. The CMD works right, but same time "Youre not allowed to use this command" in Mainchat. But all functions work correct.
How i Say, it can be that this was only one time.

and another help need;-)
Where i must change to become this messages also in PM to this bot?;-)

I love your work;-)

Greets

jiten

QuoteOriginally posted by Krysalis
if i have changed botname, i have renamed to this, and not in sOPChat, right? If i renamed to "Mystery" i musst replace sbot to Mystery.
and another help need;-)
Where i must change to become this messages also in PM to this bot?;-)
Can you explain in better? I didn't understand it.
QuoteI invitet a user and he is typing +read in pm. The CMD works right, but same time "Youre not allowed to use this command" in Mainchat. But all functions work correct.
Last script updated. Copy it again and guess that's the final one.

Best regards

Krysalis

I tell shit, thats how u don?t understand what i want. Ive thinking 5 more seconds ago and is was clear *g*

Sorry for this;-)

I?ll try your last fix today evening and test it more. Don?t think there where bugs again;-)

Let you know when finished ;-)

gemini

i have this error
[13:20] Syntax ...sktop\0.3.3.0.b17.08.nt.dbg \scripts\OpChat++.lua:55: attempt to index field `?' (a nil value)
why?
 thanks jiten

gemini

thanks
cordial greetings jiten

jiten

I'll be waiting for your reports.

gemini, it had to do with the "arrOpLevel" table that probably wasn't well set up with the extra profiles you could have (e.g. Moderator, NetFounder), but, it's nice to know that you sorted it out.

Best regards,

jiten

gemini

my profile

netfounder
master
moderator
operator
vip
reg user
user


in zright clicker
SendTo = { --> 1=on/0=off
[0] = 1,   -- Masters
[1] = 1,   -- Operators
[2] = 1,   -- Vips
[3] = 1,   -- Regs
[4] = 1,   -- Moderator
[5] = 1,   -- NetFounder


arrOpLevel = { --Put here the profile with operator privileges and its respective level
["Master"] = ?,
["Operator"] = ?,
["Moderator"] = ?,
["NetFounder"] = ?,

}

that you number I put on
thanks cordial greetings

jiten

gemini, this would be your correct table then:
arrOpLevel = { --Put here the profile with operator privileges and its respective level
	["Master"] = 0, 
	["Operator"] = 1, 
	["Moderator"] = 4, 
	["NetFounder"] = 5, 
}
Cheers

gemini

now return this error

[16:50] Syntax ...m\Desktop\0.3.3.0.b17.08.nt.dbg\scripts\OpChat++.lua:51: attempt to index field `?' (a nil value)

repeat why lol
bye thanks

jiten

QuoteOriginally posted by gemini
now return this error

[16:50] Syntax ...m\Desktop\0.3.3.0.b17.08.nt.dbg\scripts\OpChat++.lua:51: attempt to index field `?' (a nil value)

repeat why lol
bye thanks
After replacing your old table with the one I posted a while ago, save the .lua file, restart your scripts and then reconnect. That error will be gone.
Just to be sure, delete all old .tbl files before doing this.

Best regards

Krysalis

#68
QuoteOriginally posted by jiten
QuoteOriginally posted by Krysalis
Where i have to change that the Result from the +read cmd came in bot pm and not in Hubbot pm?
In this code I'm copying, replace every "sBot" with "sOpChat" and that should do it:
["read"] =	function(user,data)
						local msg, Exists = "", nil
						for i = 1, table.getn(Releases) do
							if Releases[i] then
								msg = msg.."\r\n\tNumber "..i..".\r\n\t["..Releases[i][2].."]\r\n\t["..Releases[i][3].."]\r\n\tPosted by: "..Releases[i][1].." on "..Releases[i][4].."\r\n" Exists = 1
							end
						end
						if Exists == nil then 
							user:SendData(sBot,"*** Error: The Address list is empty.")
						else
							user:SendPM(sBot,msg)
						end
					end,
Best regards,

jiten

changed into, but messages came again in main. i rstartet script. What can it be?
changed also this:

sOpChat = "???Heaven?"               -- OpChat Bot Name (Set it to everything but "OpChat")
sBot = "???Heaven?"            -- Bot Name

Anyway, script in this form works fine and can be made Final called^^
Many Thanx for your Time jiiten. Will use this 4 long time now ;-)

Greets

jiten

QuoteOriginally posted by Krysalis
changed into, but messages came again in main. i rstartet script. What can it be?
changed also this:

sOpChat = "???Heaven?"               -- OpChat Bot Name (Set it to everything but "OpChat")
sBot = "???Heaven?"            -- Bot Name
How do those messages appear on main?
Something like "Private message from... "?

Krysalis

#70
[23:35] aerith hat : xxx eingetragen.
[23:35] aerith hat : und eingetragen.
[00:00] Address 1. wurde erfolgreich gel?scht!
[00:00] *** Error: Dieser Befehl ist dir nicht gestattet.
[00:00] Address 2. wurde erfolgreich gel?scht!
[00:00] *** Error: Dieser Befehl ist dir nicht gestattet.
[00:01] *** Error: Dieser Befehl ist dir nicht gestattet.
[00:01] Address 1. wurde erfolgreich gel?scht!
[00:02] *** Error: Dieser Befehl ist dir nicht gestattet.
[00:02] Address 1. wurde erfolgreich gel?scht!
[00:02] *** Error: Nix da.

came into main, not in pm to bot window. But its not  a bug, only silly *g*

But find a big Bug for me.
Invitet Users are not automatically invitet after scriptrestart or hubrestart. How can i fix this? This should be integratet in "Final Version" :)

However, this is a "stable" Version right now

Best Regards

jiten

Quotecame into main, not in pm to bot window. But its not a bug, only silly *g*
Krysalis, everywhere you find the red selection:
user:[COLOR=red]SendData[/COLOR](sBot,"*** Error: The Address list is empty.")
replace it with the green one:
user:[COLOR=green]SendPM[/COLOR](sBot,"*** Error: The Address list is empty.")
QuoteInvitet Users are not automatically invitet after scriptrestart or hubrestart. How can i fix this? This should be integratet in "Final Version" :)
Just set SendCustom to 1 and it will work then.

Cheers

Krysalis

Great Work, Jiten. Now its Perfekt ;-)

Is it much work to integrate a +help cmd with available cmds in pm? (Maybe read help from text?)

But this i must?nt have, only if ya want;-)


Greets

jiten

QuoteOriginally posted by Krysalis
Great Work, Jiten. Now its Perfekt ;-)

Is it much work to integrate a +help cmd with available cmds in pm? (Maybe read help from text?)

But this i must?nt have, only if ya want;-)


Greets
If I had more time, probably I would, but, at the moment, I rather leave it this way ;)

Cheers

Krysalis

#74
EDIT: Found a bug ;-) Invitet users arent invitet after Scriptrestart.

They stay invitet after they disconnect but not if scripts where restartet. Can u fix this?

SMF spam blocked by CleanTalk