-- Very Simple(I am lying) ChatBot by piglja - 24/04/03 till 27/04/03
-- and lots of kisses for the sweet aMutex for his help by piglja 24/04/03 till 27/04/03
-- An update with +join and +part by piglja - 28/04/03
botname = "-VIPCHATS-"
fname = "table.tbl" --------------table VIP members
FFile = "MEGA.lst" --------------table OP's
nick={}
name={}
function Main()
Restart()
frmHub:RegBot(botname)
end
function DataArrival(user, data)
if(strsub(data, 1, 4) == "$To:") then
data=strsub(data,1,strlen(data)-1)
s,e,whoTo,from,msg = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(.+)")
if (whoTo == botname) then
if nick[user.sName] ~= nil then
nick[user.sName] = nil
SaveToFile(user.sName,fname,nick)
PmToAStupidTablesGrrrButIAmStartingToLikeThemLOL(msg,from,user.sName)
nick[user.sName]=user.sName
SaveToFile(user.sName,fname,nick)
else
user:SendPM(botname,"You're not a member here.!!!")
end
end
end
end
function PmToAStupidTablesGrrrButIAmStartingToLikeThemLOL(msg,user,one)
for i,v in nick do
SendPmToNick(i,botname,"<"..one..">"..msg)
end
end
function Restart()
local handle = openfile(FFile, "r")
if (handle ~= nil) then
local line = read(handle)
while line do
nick[line]=line
SaveToFile(line,fname,nick)
line = read(handle)
end
closefile(handle)
end
end
-------------------------
function SaveToFile(arg,file,table)
local aString = pickle(table)
writeto(file)
write(aString)
writeto()
end
function pickle(t)
return Pickle:clone():pickle_(t)
end
Pickle = {
clone = function (t) local nt={}; for i, v in t do nt=v end return nt end
}
function Pickle:pickle_(root)
if type(root) ~= "table" then
error("can only pickle tables, not ".. type(root).."s")
end
self._tableToRef = {}
self._refToTable = {}
local savecount = 0
self:ref_(root)
local s = ""
while getn(self._refToTable) > savecount do
savecount = savecount + 1
local t = self._refToTable[savecount]
s = s.."\n"
for i, v in t do
s = format("%s%s\n", s, self:value_(i), self:value_(v))
end
s = s--.."\n"
end
return format("%s", s)
end
function Pickle:value_(v)
local vtype = type(v)
if vtype == "string" then return format("%s", v)
elseif vtype == "number" then return v
elseif vtype == "table" then return "{"..self:ref_(v).."}"
else
end
end
function Pickle:ref_(t)
local ref = self._tableToRef[t]
if not ref then
if t == self then error("can't pickle the pickle class") end
tinsert(self._refToTable, t)
ref = getn(self._refToTable)
self._tableToRef[t] = ref
end
return ref
end
function unpickle(s)
if type(s) ~= "string" then
error("can't unpickle a "..type(s)..", only strings")
end
local tables = dostring("return "..s)
for tnum = 1, getn(tables) do
local t = tables[tnum]
local tcopy = {}; for i, v in t do tcopy = v end
for i, v in tcopy do
local ni, nv
if type(i) == "table" then ni = tables[i[1]] else ni = i end
if type(v) == "table" then nv = tables[v[1]] else nv = v end
t[ni] = nv
end
end
return tables[1]
end
------------------------------------
owner for Latvian hub Alfa
Sorry , not convert this script, I am use new NightLitch
script - *** Simple VipChat ***