PtokaX forum

Archive => Archived 5.0 boards => Finished Scripts => Topic started by: jiten on 01 April, 2005, 13:53:24

Title: OpChat++
Post by: jiten on 01 April, 2005, 13:53:24
--[[

OpChat++  v.1.1d by jiten (1/7/2006)

Based on: OpChat++ By nErBoS

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

Changelog:

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
Fixed: Hopefully fixed bug with OpConnected/Disconnected function
Changed: OpChat++'s Bot Name can be set to anything
Added: Profile permission for each command (12/20/2005)
Fixed: Bug with command table return (thx to TM)
Removed: ChatArrival (12/27/2005)
Added: Option to choose which profiles can read/write in OpChat (1/7/2006)

]]--
Title:
Post by: Krysalis on 28 May, 2005, 10:44:44
Hello,

can u try change it, so only Masters can invite Users.
invitet Users should also be invitet after Hub/Scriptrestart.

And finally, the users should can use

+add [line1] [line2]
+read

+add [line1] [line2] is for adding some like homeFTP Adresses.
(+adds [Whats on it?] [http or ftp Adress]

+read is for invitet Users to take this List.

I hope u can do this.
Title:
Post by: jiten on 28 May, 2005, 11:56:23
QuoteOriginally posted by Krysalis
can u try change it, so only Masters can invite Users.
invitet Users should also be invitet after Hub/Scriptrestart.
I'll check this.
And finally, the users should can use

+add [line1] [line2]
+read

+add [line1] [line2] is for adding some like homeFTP Adresses.
(+adds [Whats on it?] [http or ftp Adress]

+read is for invitet Users to take this List.

Well, this isn't a OpChat++ task.
Seems like a release bot, add and read function. Search the forum for "release bot" and you'll find matches that will suit your needs for this request.

Cheers
Title:
Post by: jiten on 28 May, 2005, 12:35:11
Here you go:
--## OpChat++
--## By nErBoS
--## Converted to Lua 5 by jiten (english version)
--## Changed: Invite and delinvite to Masters
--## Changed: Message on restart scripts to every invited user
--## Operator 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 u were offline-

sOpChat = "sOpChat"

arrInvite = {} arrLog = {}
fInvite = "logs/invite.dat"
fLog = "logs/log.dat"

--## Settings ##--

arrOpLevel = { --Put here the profile with operator privileges and its respective level
["Master"] = 0,
["Operator"] = 1,
["Moderator"] = 4,
["NetFounder"] = 5,
}

--## FIM ##--

function Main()
frmHub:RegBot(sOpChat)
if loadfile(fInvite) then dofile(fInvite) end
if loadfile(fLog) then dofile(fLog) end Refresh()
for usr, aux in arrInvite do
if (GetItemByName(usr) ~= nil) then
SendToNick(GetItemByName(usr).sName, "$To: "..GetItemByName(usr).sName.." From: "..sOpChat.." $<"..sOpChat.."> You are currently invited to OpChat.")
end
end
end

function OnExit()
SaveToFile(fInvite , arrInvite , "arrInvite")
SaveToFile(fLog , arrLog , "arrLog")
end

function OpConnected(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

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

function ChatArrival(user, data)
local data = string.sub(data, 1, -2)
local s,e,cmd = string.find(data, "%b<>%s+(%S+)")
if user.bOperator then
if (cmd == "+invitelist") then
InviteList(user)
return 1
elseif (cmd == "+talklog") then
ShowTalkLog(user)
return 1
end
elseif user.iProfile == 0 then
if (cmd == "+invite") then
InviteUser(user, data)
return 1
elseif (cmd == "+delinvite") then
RemoveInvite(user, data)
return 1
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

InviteUser = 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(fInvite , arrInvite , "arrInvite")
end
end

RemoveInvite = 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(fInvite , arrInvite , "arrInvite")
end
end

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

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 aux,aux2,usr,profile
for profile, aux in arrOpLevel do
for aux2, usr in GetUsersByProfile(profile) do
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
end
SaveToFile(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(fLog , arrLog , "arrLog")
end

ShowTalkLog = 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(fLog , arrLog , "arrLog")
end
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
Title:
Post by: Krysalis on 03 June, 2005, 10:25:31
And finally, the users should can use

+add [line1] [line2]
+read

+add [line1] [line2] is for adding some like homeFTP Adresses.
(+adds [Whats on it?] [http or ftp Adress]

+read is for invitet Users to take this List.


This only i miss now;-)
And i don?t need a release bot. What i need is a extra chat where i can insert FTP Adresses and HTTP Adresses into a .txt List. And finally, invitet Users should can read this txt-file with +read everytime.
Not invitete User should see absolutely nothing, even they are OPs.
I hope u understand my thinking.

Thanks for your time and work, jiiten, i hope you can do this ;-)

Gruss
Title:
Post by: jiten on 03 June, 2005, 11:30:46
QuoteOriginally posted by Krysalis
And finally, the users should can use

+add [line1] [line2]
+read

+add [line1] [line2] is for adding some like homeFTP Adresses.
(+adds [Whats on it?] [http or ftp Adress]

+read is for invitet Users to take this List.


This only i miss now;-)
And i don?t need a release bot. What i need is a extra chat where i can insert FTP Adresses and HTTP Adresses into a .txt List. And finally, invitet Users should can read this txt-file with +read everytime.
Not invitete User should see absolutely nothing, even they are OPs.
I hope u understand my thinking.

Thanks for your time and work, jiiten, i hope you can do this ;-)

Gruss
Seems like Chatrooms by tezlo with some extra functions.
I'll see what I can do about it.

Best regards
Title:
Post by: Krysalis on 03 June, 2005, 12:40:48
I have used Tezlos Chatscript long time now, this where perfect with my needet Modifications:

Exactly i Need following CMDs

For Master:

+invite user
+deinvite User
+add NAME ADRESS (Entry will save in txt]
+delete NAME (delete entry from txt)
+read (read txt)
+Users (show invitet Users with Online/offline Status)

For all other Users:

+add NAME ADRESS
+read
+users

Invitet Users should be stay invitet  even the Hub or Script restarts
And no funktion by typing anything in PM to non invitet Users. ( But a editable Message to them would be great )

The List should appear like This
Nr 1
-[NAME1]
-[ADRESS1]
-Eingetragen von: [Username] am [Date] um [time]

Nr 2
-[NAME2]
-[ADRESS2]
-Eingetragen von: [Username] am [Date] um [time]

Maybe you can do the +delete command using the Number of the saved entry. +delete 1 and so on.

So, thats all i think and i hope, u know now what i mean ;-)
Its difficult, i think, but i look for this for a very long time.
It would be great if you can help me out ;-)

Best Regards
Title:
Post by: Krysalis on 03 June, 2005, 12:45:13
--## +talklog -- Show all the talking while u were offline-


maybe this funktion too...its nice ;-)
Title:
Post by: GrinSlaW on 03 June, 2005, 23:42:25
hello jiten  :))

why can't i change the bot name ? when i do it will not apear i user list  ?(  is it a bug or i just can't change the name ?

cheers  8)
Title:
Post by: jiten on 04 June, 2005, 09:36:23
QuoteOriginally posted by GrinSlaW
hello jiten  :))

why can't i change the bot name ? when i do it will not apear i user list  ?(  is it a bug or i just can't change the name ?

cheers  8)
Well, if you renamed the bot to "OpChat", the script will be working fine, but, the botname won't be visible to the non-operators as, that's its default setting, (although the invited users are able to talk). But, with the new PtokaX build there'll be a "small checkbox for profile, to allow opchat".

Best regards
Title:
Post by: Krysalis on 05 June, 2005, 13:31:26
Jit?n, are you trying with tezlos Script?

Greets
Title:
Post by: jiten on 05 June, 2005, 18:38:43
QuoteOriginally posted by Krysalis
Jit?n, are you trying with tezlos Script?

Greets
Not yet, need to get some free time (that lacks lately), but, it's on my todo list ;)

Cheers
Title:
Post by: jiten on 05 June, 2005, 21:38:19
Here you go:
--/ Lua 5 version 1.1 by jiten
-- Changed: Profile Permissions;
-- Added: Optional message to every user invited on Hub Start/Script Restart
-- Added: Automatic Folder creating

--## 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")
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
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
arrOpLevel = { -- Put here the profile with operator privileges and its respective level
["Master"] = 0,
["Operator"] = 1,
}
--## END ##--

arrInvite = {} arrLog = {}

Main = function()
frmHub:RegBot(sOpChat)
if loadfile(fInvite) then dofile(fInvite) else os.execute("mkdir "..sFolder) end
if loadfile(fLog) then dofile(fLog) end Refresh()
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 user.bOperator then
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
end,
["invite"] = function(user,data)
if user.iProfile == 0 then
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
else
user:SendData(frmHub:GetHubBotName(),"*** Error: You are not allowed to use this command.")
end
end,
["delinvite"] = function(user,data)
if user.iProfile == 0 then
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
else
user:SendData(frmHub:GetHubBotName(),"*** Error: You are not allowed to use this command.")
end
end,
}
if tCmds[cmd] then return tCmds[cmd](user,data),1 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 aux,aux2,usr,profile
for profile, aux in arrOpLevel do
for aux2, usr in GetUsersByProfile(profile) do
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
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

Best regards
Title:
Post by: Krysalis on 06 June, 2005, 10:00:33
Well, looks great. I will test it today afternoon ;-)
Title: i have this error in OpChat++
Post by: gemini on 06 June, 2005, 10:32:25
i have this error
Syntax ...m\Desktop\0.3.3.0.b17.08.nt.dbg\scripts\OpChat++.lua:61: attempt to index field `?' (a nil value)
what is error?
I await a your reply. cordial greetings
thanks
Title:
Post by: jiten on 06 June, 2005, 11:00:36
QuoteOriginally posted by gemini
i have this error
Syntax ...m\Desktop\0.3.3.0.b17.08.nt.dbg\scripts\OpChat++.lua:61: attempt to index field `?' (a nil value)
what is error?
I await a your reply. cordial greetings
thanks
Can you tell me when does this happen?
I can't reproduce the error here.

Best regards
Title: reply
Post by: gemini on 06 June, 2005, 11:06:29
I start the script works immediately and after about 3 seconds the mistake happens
thanks bye
Title:
Post by: jiten on 06 June, 2005, 12:34:18
QuoteOriginally posted by gemini
I start the script works immediately and after about 3 seconds the mistake happens
thanks bye
I tested everything here and didn't get any error. It's working fine.
Did you change something in the script? The Levels table?

Cheers
Title:
Post by: Krysalis on 06 June, 2005, 13:09:41
I love it.
Everythings seem to work correctly.

I received a Syntax Error, but Script ean as usual.

Syntax C:\Programme\Ptokax\scripts\MysteryHeaven.lua:240: attempt to index local `hFile' (a nil value)

Its normal?
Title:
Post by: jiten on 06 June, 2005, 14:35:57
QuoteOriginally posted by Krysalis
I received a Syntax Error, but Script ean as usual.

Syntax C:\Programme\Ptokax\scripts\MysteryHeaven.lua:240: attempt to index local `hFile' (a nil value)

Its normal?
No, that's not normal. What did you change in the script?

Cheers
Title:
Post by: Krysalis on 06 June, 2005, 16:13:03
I received this Error from beginning, before i made any changes.

After this, i made some Language Translations. But the Error was there before.
The Script runs good, i will use in this Form.
I thought u know what its mean ;-)

Many Many Thanx for this good work ;-)
Title:
Post by: Dessamator on 06 June, 2005, 16:49:57
hmm, i see an error here :

Serialize = function(tTable,sTableName,hFile,sTab)

SaveToFile(fLog , arrLog , "arrLog")  

there seems to be an extra value in the serialize function, although it shouldnt really cause those errors , anyways serialize should be something like this :

Serialize = function(tTable,sTableName,hFile)
Title:
Post by: jiten on 06 June, 2005, 17:17:29
First post updated with a fix.

Cheers
Title:
Post by: Krysalis on 06 June, 2005, 19:21:53
-- 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,


Jiten, can you maybe explain me this part? I dont have Robocop Profiles....what exactly i have to change.....and for what? ^^    

Thanks in Advance
Title:
Post by: jiten on 06 June, 2005, 19:32:13
QuoteOriginally posted by Krysalis
-- 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,
  • = 6, [5] = 7, }



Jiten, can you maybe explain me this part? I dont have Robocop Profiles....what exactly i have to change.....and for what? ^^    

Thanks in Advance
Change your Levels table to this then:
-- 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, -- Unreg
[3] = 2, -- Reg
[2] = 3, -- VIP
[1] = 4, -- Operator
[0] = 5, -- Master
}
As you can see in the table, it gives more rights to higher profiles by assigning a higher value (the one in the right). So, a lower Profile means lower rights.
After changing this you'll have to change the values in the Commands table. Something like this:
["talklog"] = {
function(user,data)
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(fLog , arrLog , "arrLog")
end
end, [COLOR=red]4[/COLOR], },
The number in red is based on the Levels table. So, with this function, only profiles equal or higher than Operators can use it.
Hope this helps.

Cheers
Title:
Post by: Krysalis on 06 June, 2005, 20:32:29
I understand ;-) Thanx

If i invite a reguser, and he is typing in pm to bot, i cant read what he?s wrote...how can i fix this?

I think this would be last ;-)
Title:
Post by: jiten on 06 June, 2005, 20:49:24
QuoteOriginally posted by Krysalis
I understand ;-) Thanx

If i invite a reguser, and he is typing in pm to bot, i cant read what he?s wrote...how can i fix this?

I think this would be last ;-)
Well, just don't set "sOpchat = "OpChat"" and it should work.
If not, copy the script all over again, delete all old .tbl files and run it.

Best regards,

jiten
Title:
Post by: Krysalis on 06 June, 2005, 20:57:07
Changed only this:

sOpChat = "Mystery"
sBot = frmHub:GetHubBotName()

isnt correct?


Syntax ...tor\Desktop\0.3.3.0.b17.05.nt.rls\scripts\heaven.lua:169: attempt to compare number with nil
Syntax ...tor\Desktop\0.3.3.0.b17.05.nt.rls\scripts\heaven.lua:270: attempt to index local `handle' (a nil value)


I have those 2 Syntax errors.


Edit:  Commands are acceptet in Main, in PM an in every other PM. Can u fix it, so only cmds in pm to bot are acceptet?
Title:
Post by: jiten on 06 June, 2005, 21:15:14
Going to test it tomorrow thoroughly to find the bug with the handle.
Btw, the first error is related to Levels table. You had to change the red values in the other commands. Anyway, I'll post the debugged version tomorrow (compatible with the normal profiles).

Best regards,

jiten
Title:
Post by: Krysalis on 06 June, 2005, 21:26:23
 
-
-
  Master
  11111111111111111111111111111111
 

-
  Operator
  11111100011001111111111111111000
 

-
  S-Operator
  11111111111111111111111111111111
 

-
  Moderator
  10000000000000000000000000000000
 

-
  S-VIP
  10000000000000000000000000000000
 

-
  VIP
  10000000000000000000000000000000
 

-
  SUser
  10000000000000000000000000000000
 

-
  DUser
  10000000000000000000000000000000
 

-
  Stammie
  10000000000000000000000000000000
 

-
  User
  10000000000000000000000000000000
 

-
  Anw?rter
  10000000000000000000000000000000
 

 


this is my profile xml.
where i find the Profile Numbers ?

i think:
 
-- [Profile number] = value (higher value means more rights)
Levels = {
[-1] = 1,   
[10] = 1,   
[9] = 1,   
[8] = 1,   
[7] = 1,   
[6] = 1,   
[5] = 1,   
[4] = 1,   
[3] = 1,   
[2] = 1,   
[1] = 1,   
}

even with this settings i see nothing anything invitet users typing
Title:
Post by: Krysalis on 06 June, 2005, 22:11:10
btw, red nr is always set to 1
Title:
Post by: jiten on 07 June, 2005, 12:40:33
First post updated with a debugged version (hopefully).

Cheers
Title:
Post by: Krysalis on 07 June, 2005, 15:00:16
Thx for ur fast fix. i?ll try today evening ;-)
Title:
Post by: jiten on 07 June, 2005, 15:08:38
QuoteOriginally posted by Krysalis
Thx for ur fast fix. i?ll try today evening ;-)
Hoping to hear from you if it's working well, so that I can post the Release part.

Best regards
Title:
Post by: Krysalis on 07 June, 2005, 17:55:38
still testing at the moment, master :)
Title:
Post by: Krysalis on 07 June, 2005, 18:12:39
First little thing.

I cant change Botname anymore. If i do,  the bot doesnt appear in the userlist.

Can u tell me what i have to do to change?

Greets
Title:
Post by: jiten on 07 June, 2005, 18:31:19
QuoteOriginally posted by Krysalis
First little thing.

I cant change Botname anymore. If i do,  the bot doesnt appear in the userlist.

Can u tell me what i have to do to change?

Greets
Well, if you change the Botname to "OpChat" (default one) it will disappear for non-operators as it's its default setting. That's why you can use every nick except "OpChat".
But, with the new PtokaX build there'll be a "small checkbox for profile, to allow opchat" (so it will be visible to whom you choose).


Best regards
Title:
Post by: Krysalis on 07 June, 2005, 19:02:59
QuoteOriginally posted by jiten

there'll be a "small checkbox for profile, to allow opchat"
 

dont find it....
Title:
Post by: jiten on 07 June, 2005, 19:08:01
QuoteOriginally posted by Krysalis
QuoteOriginally posted by jiten

there'll be a "small checkbox for profile, to allow opchat"
 

dont find it....
It hasn't been released yet, so, till then, better use a botname different than "OpChat".
Something like "Mistery", "sOpChat", etc...
Apart from that, is the script working OK? I mean, no errors...
Title:
Post by: Krysalis on 07 June, 2005, 19:34:51
say to in ten minutes, but semms trouble again
 :(
Title:
Post by: Krysalis on 07 June, 2005, 19:39:01
invitet users cant see what anyone wrote in pm to bot...

same as yesterday
Title:
Post by: jiten on 07 June, 2005, 19:47:18
QuoteOriginally posted by Krysalis
invitet users cant see what anyone wrote in pm to bot...

same as yesterday
I've tested the script a lot of times here and everything is working fine.
Can you tell me what PtokaX version are you using, your default Bot Name for OpChat in PtokaX's GUI and what did you change in the script? It'd help me help you.

Cheers
Title:
Post by: Krysalis on 07 June, 2005, 20:33:18
build 1705

!???SchattenReich?

no changes yet on script ( would not do the work for nothing again ;)


Would u connect and see while running?

hellgate.no-ip.info:8679

Its a temp test hub
Title:
Post by: jiten on 07 June, 2005, 21:04:15
QuoteOriginally posted by Krysalis
build 1705

!???SchattenReich?

no changes yet on script ( would not do the work for nothing again ;)


Would u connect and see while running?

hellgate.no-ip.info:8679

Its a temp test hub
First post updated with the debugged version.
The problem was that you didn't create the "logs" folder. That's why all this happened.
Now, just copy the script again and test it. It should work fine.

Best regards
Title:
Post by: Krysalis on 07 June, 2005, 22:12:19
wait
Title:
Post by: Krysalis on 07 June, 2005, 22:17:12
+read amd +add are not in the script by your last edit?
Title:
Post by: GrinSlaW on 07 June, 2005, 23:52:39
QuoteOriginally posted by jiten
QuoteOriginally posted by GrinSlaW
hello jiten  :))

why can't i change the bot name ? when i do it will not apear i user list  ?(  is it a bug or i just can't change the name ?

cheers  8)
Well, if you renamed the bot to "OpChat", the script will be working fine, but, the botname won't be visible to the non-operators as, that's its default setting, (although the invited users are able to talk). But, with the new PtokaX build there'll be a "small checkbox for profile, to allow opchat".

Best regards

i tried to change the bot name to this [CHAT]OP and when i do it will not work it only work if i have OpChat as bot name it will work. well it work but it will not apear in user list when i enter as a op

hehe do you understand what i mean ?  :rolleyes:
Title:
Post by: Krysalis on 08 June, 2005, 12:21:19
Your last Edit seems to work fine. If u input +read +add and +del again, i think its finished;)
Title:
Post by: jiten on 08 June, 2005, 13:59:00
Did that purposely because I wanted to check if the OpChat script was ok.

Best regards,

jiten
Title:
Post by: Krysalis on 08 June, 2005, 14:45:01
Now i miss the other CMDs (Invite, deinvite, invitelist, talklog)
Why removed this? And can u put in again? I need this function really. ( only master should can invite/deinvite, other cmds for all invitet)


Best Regards
Title:
Post by: jiten on 08 June, 2005, 15:12:30
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
Title:
Post by: Krysalis on 08 June, 2005, 16:28:36
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
Title:
Post by: Krysalis on 08 June, 2005, 18:22:56
understand what i mean, jiten?
Title:
Post by: jiten on 08 June, 2005, 19:51:03
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
Title:
Post by: GrinSlaW on 08 June, 2005, 21:12:36
Hello jiten  :))

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

cheers
Title:
Post by: jiten on 08 June, 2005, 21:21:59
That's what I most like to hear, ups, read :D
Lets see if it's OK with Krysalis too.

Best regards
Title:
Post by: Krysalis on 09 June, 2005, 06:51:22
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*
Title:
Post by: jiten on 09 June, 2005, 11:06:23
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
Title:
Post by: Krysalis on 09 June, 2005, 12:08:43
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
Title:
Post by: jiten on 09 June, 2005, 12:44:53
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
Title:
Post by: Krysalis on 09 June, 2005, 13:15:37
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 ;-)
Title: request jiten
Post by: gemini on 09 June, 2005, 13:22:55
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
Title: excuse me jiten now fuctionally
Post by: gemini on 09 June, 2005, 13:29:15
thanks
cordial greetings jiten
Title:
Post by: jiten on 09 June, 2005, 15:17:42
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
Title: my profile
Post by: gemini on 09 June, 2005, 16:35:21
my profile

netfounder
master
moderator
operator
vip
reg user
user


in zright clicker
SendTo = { --> 1=on/0=off
Title:
Post by: jiten on 09 June, 2005, 16:42:25
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
Title: now return this error
Post by: gemini on 09 June, 2005, 16:55:34
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
Title:
Post by: jiten on 09 June, 2005, 17:09:56
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
Title:
Post by: Krysalis on 09 June, 2005, 20:04:05
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
Title:
Post by: jiten on 09 June, 2005, 20:55:57
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... "?
Title:
Post by: Krysalis on 09 June, 2005, 23:46:50
[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
Title:
Post by: jiten on 10 June, 2005, 08:53:25
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
Title:
Post by: Krysalis on 10 June, 2005, 10:22:38
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
Title:
Post by: jiten on 10 June, 2005, 11:54:57
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
Title:
Post by: Krysalis on 10 June, 2005, 20:57:23
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?
Title:
Post by: jiten on 10 June, 2005, 21:39:00
QuoteOriginally posted by Krysalis
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?
Tested it here and nothing like that happened.
Title:
Post by: Krysalis on 10 June, 2005, 21:48:30
Everytime i restart scripts in hubsoft, i have to invitet all again.

Greets
Title:
Post by: jiten on 10 June, 2005, 21:52:45
QuoteOriginally posted by Krysalis
Everytime i restart scripts in hubsoft, i have to invitet all again.

Greets
It must be a result of some change you made. Do you have the folder "Logs"?
If it still doesn't work, post your script here so that I can have a look.

Cheers
Title:
Post by: Krysalis on 11 June, 2005, 09:03:00
--/ Lua 5 version 1.1a by jiten
-- Translatet to German by Krysalis
-- 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 Krysalis)

--## 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 = "???Heaven?" -- OpChat Bot Name (Set it to everything but "OpChat")
sBot = "???Heaven?" -- 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 = "logs/Releases.tbl" -- File where the Address File is stored
sendCustom = 1 -- 1 = Custom Message to invited user on Hub/Script Restart; 0 = Not
customMsg = "Du bist Member im Heaven. Enjoy your Stay" -- Message sent to them
arrOpLevel = { -- Put here the profile with operator privileges and its respective level
["Master"] = 0,
}
--## END ##--

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

Main = function()
frmHub:RegBot(sOpChat)
if loadfile(fInvite) then dofile(fInvite) end
if loadfile(fLog) then dofile(fLog) end Refresh() if loadfile(fRelease) then dofile(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.." eingeladen von: "..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, "W?hrend du weg warst, hast du was verpasst. Schreib +talklog ums zu lesen.")
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 = "Heaven Members:\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, "Du warst immer online, es gibt keine History f?r dich :).")
else
user:SendPM(sOpChat, "OFFLINE:\r\n\r\n"..arrLog[user.sName]["Talk"])
user:SendPM(sOpChat, "ChatHistory wurde gel?scht.")
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+)%s+(%S+)")
if rel == nil or desc == nil then
user:SendPM(sOpChat,"*** Error: Type +add
")
else
table.insert( Releases, { user.sName, rel, desc, os.date(), } )
SaveToFile(fRelease,Releases,"Releases")
SendPmToOps(sOpChat, user.sName.." hat : "..rel.." eingetragen.")
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\t-=(HeavenFTP Nr. "..i..")=-.\r\n\t["..Releases[i][2].."]\r\n\t"..Releases[i][3].."\r\n\tEingetragen von: "..Releases[i][1].." on "..Releases[i][4].."\r\n" Exists = 1
end
end
if Exists == nil then
user:SendPM(sOpChat,"*** Error: Nix da.")
else
user:SendPM(sOpChat,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 . nick angeben.")
elseif (arrInvite[string.lower(nick)] ~= nil) then
user:SendPM(sOpChat, "User "..nick.." ist bereits hier.")
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.." wurde eingeladen von Master "..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 . Nick angeben.")
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.." ist nicht l?nger unter uns.")
if (GetItemByName(nick) ~= nil) then
GetItemByName(nick):SendPM(sOpChat, "Account aufgehoben von Master "..user.sName)
end
SendPmToOps(sOpChat, ""..nick.." wurde ausgeladen von Master "..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(fRelease,Releases,"Releases")
user:SendPM(sOpChat,"Address "..i..". wurde erfolgreich gel?scht!")
else
user:SendPM(sOpChat,"*** Error: Dieser Eintrag ist nicht vorhanden: "..i..".")
end
else
user:SendPM(sBot,"*** Error: Type +del ")
end
end,

}
if tCmds[cmd] and user.bOperator or arrInvite[string.lower(user.sName)] then
return tCmds[cmd](user,data),1
elseif mCmds[cmd] and user.iProfile == 0 then
return mCmds[cmd](user,data),1
else
return user:SendPM(sBot,"*** Error: Dieser Befehl ist dir nicht gestattet."),1
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, "Du hast in diesem Bereich keinen Zutritt.")
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 aux,aux2,usr,profile
for profile, aux in arrOpLevel do
for aux2, usr in GetUsersByProfile(profile) do
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
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()
 

Take a look. It seems, if the invite.tbl deletet if hub restarts or scripts restarts.

I removed this mkdir function, because i thought it clear .tbl at Start.
Title:
Post by: jiten on 11 June, 2005, 10:05:28
Guess I copied the wrong script on the other day as it had some bugs I had already fixed. But, now I've updated it with the correct one. Where was my head at? :D
Sorry for the trouble.

Cheers
Title:
Post by: Krysalis on 11 June, 2005, 15:29:21
Can i easy fix my version or have i do translatet all again?:(
Title:
Post by: jiten on 11 June, 2005, 19:04:11
QuoteCan i easy fix my version or have i do translatet all again?:(
Yes, you can eheh
Just replace your Main function with this one:
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
That should do it.

Cheers
Title:
Post by: Krysalis on 12 June, 2005, 00:18:58
Absolutily Happy....nothing more to say:)

Runs very stable

Greets
Title:
Post by: Krysalis on 12 June, 2005, 00:50:21
-
-
  Master
  11111111111111111111111111111111
 

-
  Operator
  11111100011001111111111111111000
 

-
  S-Operator
  11111111111111111111111111111111
 

-
  Moderator
  10000000000000000000000000000000
 

-
  S-VIP
  10000000000000000000000000000000
 

-
  VIP
  10000000000000000000000000000000
 

-
  SUser
  10000000000000000000000000000000
 

-
  DUser
  10000000000000000000000000000000
 

-
  Stammie
  10000000000000000000000000000000
 

-
  User
  10000000000000000000000000000000
 

-
  Anw?rter
  10000000000000000000000000000000
 

 


Another little thing. Can u tell me my Profile "Numbers"? In TD 4 i found here...Need exactly Numbers, my thoughts are wrong till now.
Thanks in Advance jiten

Greets
Title:
Post by: GrinSlaW on 12 June, 2005, 00:58:57
Hi jiten i found a litle problem if i want to use the inbuild txt viewer in ptokax i have to dissable the opchat bot why ? if i try to use a txt command i only get this error in main chat: *** Error: You are not allowed to use this command


cheers
Title:
Post by: Krysalis on 12 June, 2005, 01:25:41
Found this Problem at the moment, too. Can u do that the scripts ONLY accept cmds in PM. At the moment I cannot use many other mainchat cmds with + and ! as prefix.

PS: And how can be this came in Main?
[01:50] Private message from :
is a client setting or to do in script?
I want this to come in pm window.
Its on chathistory script....but its my second problem @ the Moment ,-)

Greets
Title:
Post by: jiten on 12 June, 2005, 11:14:00
QuoteOriginally posted by GrinSlaW
Hi jiten i found a litle problem if i want to use the inbuild txt viewer in ptokax i have to dissable the opchat bot why ? if i try to use a txt command i only get this error in main chat: *** Error: You are not allowed to use this command


cheers
QuoteFound this Problem at the moment, too.
Fixed and first post updated :]
QuoteAnd how can be this came in Main?
[01:50] Private message from :
is a client setting or to do in script?
Have you ticked "Popup messages from users that are not online" and unticked "Ignore messages from users that are not online" in File - Settings - Advanced ? Or, is that bot registered?

Best regards
Title:
Post by: Krysalis on 12 June, 2005, 12:03:22
second is unticket, first i doesnt found in 0.674
Bot arent regged. after regged, it works mostly, but sometimes is cames in main too....
Thx ,-)

And also, can u give me the last fix passage hgere to fix manually? u know...the translation *g*

Best Regards
Title:
Post by: jiten on 12 June, 2005, 13:24:51
QuoteOriginally posted by Krysalis
second is unticket, first i doesnt found in 0.674
Bot arent regged. after regged, it works mostly, but sometimes is cames in main too....
Thx ,-)

And also, can u give me the last fix passage hgere to fix manually? u know...the translation *g*

Best Regards
Change to this:
fRelease = "Releases.tbl" -- File where the Address File is stored

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

Best regards
Title:
Post by: Krysalis on 12 June, 2005, 15:10:49
fRelease = "Releases.tbl"
sendCustom = 1 -- 1 = Custom Message to invited user on Hub/Script Restart; 0 = Not
customMsg = "Du bist Member im Heaven. Enjoy your Stay" -- Message sent to them
arrOpLevel = { -- Put here the profile with operator privileges and its respective level
["Master"] = 0,
}
--## 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, "W?hrend du weg warst, hast du was verpasst. Schreib +talklog ums zu lesen.")
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 = "Heaven Members:\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, "Du warst immer online, es gibt keine History f?r dich :).")
else
user:SendPM(sOpChat, "OFFLINE:\r\n\r\n"..arrLog[user.sName]["Talk"])
user:SendPM(sOpChat, "ChatHistory wurde gel?scht.")
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+)%s+(%S+)")
if rel == nil or desc == nil then
user:SendPM(sOpChat,"*** Error: Type +add
")
else
table.insert( Releases, { user.sName, rel, desc, os.date(), } )
SaveToFile(fRelease,Releases,"Releases")
SendPmToOps(sOpChat, user.sName.." hat : "..rel.." eingetragen.")
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\t-=(HeavenFTP Nr. "..i..")=-.\r\n\t["..Releases[i][2].."]\r\n\t"..Releases[i][3].."\r\n\tEingetragen von: "..Releases[i][1].." on "..Releases[i][4].."\r\n" Exists = 1
end
end
if Exists == nil then
user:SendPM(sOpChat,"*** Error: Nix da.")
else
user:SendPM(sOpChat,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 . nick angeben.")
elseif (arrInvite[string.lower(nick)] ~= nil) then
user:SendPM(sOpChat, "User "..nick.." ist bereits hier.")
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.." wurde eingeladen von Master "..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 . Nick angeben.")
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.." ist nicht l?nger unter uns.")
if (GetItemByName(nick) ~= nil) then
GetItemByName(nick):SendPM(sOpChat, "Account aufgehoben von Master "..user.sName)
end
SendPmToOps(sOpChat, ""..nick.." wurde ausgeladen von Master "..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(fRelease,Releases,"Releases")
user:SendPM(sOpChat,"Address "..i..". wurde erfolgreich gel?scht!")
else
user:SendPM(sOpChat,"*** Error: Dieser Eintrag ist nicht vorhanden: "..i..".")
end
else
user:SendPM(sBot,"*** Error: Type +del ")
end
end,

}
[COLOR=red]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[/COLOR]
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, "Du hast in diesem Bereich keinen Zutritt.")
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
 

Changed teh red passage, but there is now syntag error:

heaven.lua:165: expected near `end'
Title:
Post by: GrinSlaW on 12 June, 2005, 15:51:24
it should be like this it works for me  8)

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
Title:
Post by: jiten on 12 June, 2005, 16:04:58
QuoteChanged teh red passage, but there is now syntag error:

heaven.lua:165: expected near `end'
There are two "end" missing after the red part, just like Grinslaw posted ;)

Best regards
Title:
Post by: Krysalis on 12 June, 2005, 17:02:31
argh.....sure *g*

Thanks ;-)
Title:
Post by: Krysalis on 14 June, 2005, 07:41:39
Syntax ...tor\Desktop\0.3.3.0.b17.05.nt.rls\scripts\heaven.lua:45: attempt to index field `?' (a nil value)

received this today. What can it be?

Line 41:
   arrLog[user.sName]["Mode"] = "online"
Line 45:
   arrLog[user.sName]["Mode"] = "offline"

greets
Title:
Post by: jiten on 14 June, 2005, 10:35:17
QuoteOriginally posted by Krysalis
Syntax ...tor\Desktop\0.3.3.0.b17.05.nt.rls\scripts\heaven.lua:45: attempt to index field `?' (a nil value)

received this today. What can it be?

Line 41:
   arrLog[user.sName]["Mode"] = "online"
Line 45:
   arrLog[user.sName]["Mode"] = "offline"

greets
It has to do with this table:
arrOpLevel = { -- Put here the profile with operator privileges and its respective level
["Master"] = 0,
["Operator"] = 1,
}
You should fill it with every profile with Operator privileges and then run the script. If it is incorrectly set up, you will get that kind of syntax error.

Cheers
Title:
Post by: Krysalis on 14 June, 2005, 11:49:36
QuoteOriginally posted by jiten
It has to do with this table:
arrOpLevel = { -- Put here the profile with operator privileges and its respective level
["Master"] = 0,
["Operator"] = 1,
}
You should fill it with every profile with Operator privileges and then run the script. If it is incorrectly set up, you will get that kind of syntax error.

Cheers

With Profiles with Operator Privileges u mean all Profiles with Key? Or all who have the ability to kick?
Title:
Post by: jiten on 14 June, 2005, 12:38:17
QuoteOriginally posted by Krysalis
With Profiles with Operator Privileges u mean all Profiles with Key? Or all who have the ability to kick?
The first one, everyone with the Key ;)

Cheers
Title:
Post by: jiten on 14 June, 2005, 13:13:46
Well, I decided to remove and optimize the arrOpLevel table. Now, there's no need for it.
Last script updated with it.

Cheers
Title:
Post by: Krysalis on 14 June, 2005, 13:21:39
ah...then i know...and now i know also my ProfileNrs....but dont know the right way to find aut which profile is which profile nr.
Can u exlain me this? I would not only bring this to work, i try to understand...but i dont find anything where i can read which Profile has which nr.
Find out with Upgrade script from madman, but this can?t be the right way *g*

Greets
Title:
Post by: Krysalis on 14 June, 2005, 17:32:17
Thats cool. Can i update with change only some parts?
Or are there more changes?
Title:
Post by: Dessamator on 14 June, 2005, 17:54:32
QuoteOriginally posted by Krysalis
ah...then i know...and now i know also my ProfileNrs....but dont know the right way to find aut which profile is which profile nr.
Can u exlain me this? I would not only bring this to work, i try to understand...but i dont find anything where i can read which Profile has which nr.
Find out with Upgrade script from madman, but this can?t be the right way *g*

Greets

try this :
function Main()
for i,v in GetProfiles() do
SendToAll("Profile Name: "..v.."\t\Profile Number : "..GetProfileIdx(v))
end

end


it should show you all ur profile names and the corresponding profile numbers
Title:
Post by: jiten on 14 June, 2005, 20:46:43
QuoteOriginally posted by Krysalis
ah...then i know...and now i know also my ProfileNrs....but dont know the right way to find aut which profile is which profile nr.
Can u exlain me this? I would not only bring this to work, i try to understand...but i dont find anything where i can read which Profile has which nr.
Find out with Upgrade script from madman, but this can?t be the right way *g*

Greets
Check Dessamator's post ;)
QuoteThats cool. Can i update with change only some parts?
Or are there more changes?
Well, delete the arrOpLevel table and replace your Refresh() function with this one:
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
Best regards
Title:
Post by: Krysalis on 14 June, 2005, 22:49:36
Have a urgend wish ;-)
It is to realize to enter adreeses with spacedirs with +add. Maybe with a Special  signed start and end.

As this

+add [Rolling Stones] ftp://00.00.00.00/  / / /  t@/  /

If i typed in this add the moment entry will only be

[Rolling
Stones]
Addy by Krysalis at Date

Would be have like this
[Rolling Stones]
ftp://00.00.00.00/  / / /  t@/  /

Is this possible in any way, jiten?
Title:
Post by: jiten on 15 June, 2005, 10:04:34
QuoteOriginally posted by Krysalis
Have a urgend wish ;-)
It is to realize to enter adreeses with spacedirs with +add. Maybe with a Special  signed start and end.

As this

+add [Rolling Stones] ftp://00.00.00.00/  / / /  t@/  /

If i typed in this add the moment entry will only be

[Rolling
Stones]
Addy by Krysalis at Date

Would be have like this
[Rolling Stones]
ftp://00.00.00.00/  / / /  t@/  /

Is this possible in any way, jiten?
Yes, it is. Last script updated.
Btw, change your add function to this:
["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,
Best regards
Title:
Post by: Krysalis on 15 June, 2005, 22:10:04
you are the best ;-)

Greets
Title:
Post by: Krysalis on 28 June, 2005, 19:43:41
Sorry for taking your time again....why i can change this that only Invitet users can see. no ops and uninvitet.

SendPmToOps(sOpChat, ""..nick.." 's wurde ausgeladen von Master "..user.sName)
and
SendToAll(sBot, user.sName.."  hat : "..rel.." eingetragen")

Please help;-)
Title:
Post by: jiten on 28 June, 2005, 20:07:41
Try using this:
for usr, aux in arrInvite do
if (GetItemByName(usr) ~= nil) then
SendToNick(GetItemByName(usr).sName, "$To: "..GetItemByName(usr).sName.." From: "..x.." $<"..x.."> "msg".")
end
end
Where "x" is the sender's nick (sOpChat or sBot) and "msg" is the message sent to them.

Best regards
Title:
Post by: Krysalis on 28 June, 2005, 20:26:37
Many thanx, m8. Now i got it ;-)
Title:
Post by: Krysalis on 28 June, 2005, 21:11:06
["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: Schreibe +add ")
else
table.insert( Releases, { user.sName, rel, desc, os.date(), } )
SaveToFile(sFolder.."/"..fRelease,Releases,"Releases")
for usr, aux in arrInvite do
if (GetItemByName(usr) ~= nil) then
SendToNick(GetItemByName(usr).sName, "$To: "..GetItemByName(usr).sName.." From: "..sBot.." $<"..sBot.."> "Es wurde was neues eingetragen".")
end
end,


i don?t get it:( can you help me pleas??

Greets
Title:
Post by: jiten on 29 June, 2005, 15:55:01
Try this one:
["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: Schreibe +add ")
else
table.insert( Releases, { user.sName, rel, desc, os.date(), } )
SaveToFile(sFolder.."/"..fRelease,Releases,"Releases")
for usr, aux in arrInvite do
if (GetItemByName(usr) ~= nil) then
SendToNick(GetItemByName(usr).sName, "$To: "..GetItemByName(usr).sName.." From: "..sBot.." $<"..sBot.."> Es wurde was neues eingetragen.")
end
end
end
end,

Cheers
Title:
Post by: Krysalis on 29 June, 2005, 22:50:42
Now its the Final Versio for me really. I thank you for your time you spend to help me :)

Greets
Title:
Post by: jiten on 29 June, 2005, 22:56:18
QuoteOriginally posted by Krysalis
Now its the Final Versio for me really. I thank you for your time you spend to help me :)

Greets
I'm really glad to know that it's the way you expected it to be :))

Cheers
Title:
Post by: kunal on 07 July, 2005, 13:39:30
[17:03] Syntax E:\pto\scripts\op++.lua:51: attempt to index field `?' (a nil value)
[17:03] Syntax E:\pto\scripts\op++.lua:47: attempt to index field `?' (a nil value)

i get this error
pls help
Title:
Post by: jiten on 07 July, 2005, 14:10:48
QuoteOriginally posted by kunal
[17:03] Syntax E:\pto\scripts\op++.lua:51: attempt to index field `?' (a nil value)
[17:03] Syntax E:\pto\scripts\op++.lua:47: attempt to index field `?' (a nil value)

i get this error
pls help
That error has been fixed ;)
Update to the last script I posted (look for it in the third page).

Cheers
Title:
Post by: gander on 09 September, 2005, 08:51:17
Syntax E:\pto\scripts\op++.lua:47: attempt to index field `?' (a nil value)


is still popping up in my soft.... what version of ptokax is it intended with? maybe thats whats wrong

and yes i have used the cript on page 3...but the error still appares
Title:
Post by: kunal on 09 September, 2005, 14:45:57
same error here
Title: Re: OpChat++
Post by: Alexinno on 22 June, 2006, 15:13:13
there is a tricky way to name the bot OpChat or any name you want :)

-first you have to unregister the OpChat name in the Ptokax GUI and name it something else for ex. Op-Chat
then make this changes in the script

--## Settings ##--
sOpChat = "OpChat" -- OpChat Bot Name (Set it to everything but "OpChat")
sBot = "OpChat" -- 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 = 1 -- 1 = Custom Message to invited user on Hub/Script Restart; 0 = Not
customMsg = "Esti invitat pe OpChat,Enjoy!" -- Message sent to them

--## END ##--

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

Main = function()
frmHub:RegBot("OpChat")


-start the script
-change the name for the Opchat in the Ptokax GUI in OpChat and register it

it worked for me

Cheers

Title: Re: OpChat++
Post by: jiten on 22 June, 2006, 20:35:40
Quote from: Alexinno on 22 June, 2006, 15:13:13
there is a tricky way to name the bot OpChat or any name you want :)

This issue was solved in the latest version of this script.
However, I forgot to update it when the board "re-appeared".
Title: Re: OpChat++
Post by: Alexinno on 22 June, 2006, 21:02:51
:P, do that now
Title: OpChat++ v1.1d - LUA 5.0
Post by: jiten on 25 June, 2006, 18:30:40
Quote from: Alexinno on 22 June, 2006, 21:02:51
:P, do that now

As requested, I've updated the first post of this thread with the 'latest' LUA 5.0 OpChat++ version.

I saw the code after a while and have to admit that it requires a rewrite.
I'm planning to do it soon and will also update it to LUA 5.1.

Best regards
Title: Re: OpChat++
Post by: MetalPrincess on 02 July, 2006, 22:28:54
Erm I have probably a really stupid problem but none of the commands work. I'm trying to use the commands at the top of the script and I get nothing. What am I doing wrong? :(


MP
Title: Re: OpChat++
Post by: Dessamator on 03 July, 2006, 10:30:20
You have to send a pm to the bot you set in the settings, and type the commands there.
Title: Re: OpChat++
Post by: MetalPrincess on 04 July, 2006, 13:54:37
Thanks still does not seem to be working but I may see if I can test it out a bit more with the other OPS and stuff first. I'll post back if I still ahve a problem :D

MP
Title: Re: OpChat++
Post by: Dessamator on 04 July, 2006, 14:21:40
If it still doesnt work, try disabling the other scripts and running only that one.
Title: Re: OpChat++
Post by: MetalPrincess on 04 July, 2006, 14:23:49
Will it work without the other ops being around to answer pm's?

MP
Title: Re: OpChat++
Post by: Dessamator on 04 July, 2006, 15:21:02
Indeed it should.
Title: Re: OpChat++
Post by: jiten on 06 July, 2006, 12:00:30
Quote from: MetalPrincess on 02 July, 2006, 22:28:54
Erm I have probably a really stupid problem but none of the commands work. I'm trying to use the commands at the top of the script and I get nothing. What am I doing wrong? :(

As previously stated by Dessamator, the commands must be used in PM to OpChat++'s bot.

And yes, it will work even without the other operators around.

So, any success?
Title: Re: OpChat++
Post by: MetalPrincess on 08 July, 2006, 12:06:27
Nope :( I upgraded my hub software though so this could be part of the problem for now.


MP