chat
 

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

chat

Started by ignazio, 04 June, 2005, 23:47:13

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ignazio

-- 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
-- Modifyed to add users by a file and script restart does not matter by piglja - 02/05/03

botname = "Vip_Chat"
fname = "table.tbl"
FFile = "userlist.txt"
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 do not have a permission to write here anything!!!")
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



Hi Boys I wanted to know you could do me the favor to turn her/it into lua 5???

thanks to everybody  :]

jiten

There are already Lua 5 scripts like these.
Search the forum for "chatroom tezlo" or "chatroom piglja" and hopefuly you'll find them.

Best regards

SMF spam blocked by CleanTalk