PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: Tw?sT?d-d?v on 27 February, 2005, 15:52:29

Title: reg-chat in lua 5
Post by: Tw?sT?d-d?v on 27 February, 2005, 15:52:29
can some1 make a reg-chat bot plz   in lua 5
Title:
Post by: [NL]Pur on 27 February, 2005, 16:30:44
most simple example , extend it futher as you wish yourself. ;)


function ChatArrival(curUser, msg)

  local _, _, cmd, pass = string.find(msg, "%b<>%s+(%S+)%s*([^|]*)%|$")

  if cmd == "!regme" then
     AddRegUser(curUser.sName, pass, "REG")
  end

end
Title:
Post by: Tw?sT?d-d?v on 27 February, 2005, 16:53:32
thx m8 :))
Title:
Post by: Tw?sT?d-d?v on 27 February, 2005, 17:28:46
hmm .. can some1 tell me what i done wrong plz .. not working for some reason

BotName = "REG-CHAT"


function Main()
frmHub:RegBot(BotName)
end


function ChatArrival(curUser,data)

local MessageRecognized = 0

if isPM(data)==1 then
whoto,from,message=ParsePM(data)
MessageRecognized=1
end

if MessageRecognized==1 and whoto==BotName then
if (curUser.iProfile>=0 and curUser.iProfile<=4) then
local sus=GetUsersByProfile("Master")
local sops=GetUsersByProfile("Moderator")
local ops=GetUsersByProfile("Operator")
local vips=GetUsersByProfile("VIP")
local regs=GetUsersByProfile("Reg")

for i, n in sops do
if n == curUser.sName then
else
SendPmToNick(n, BotName, from.." -> "..message)
end
end

for i, n in sus do
if n == curUser.sName then
else
SendPmToNick(n, BotName, from.." -> "..message)
end
end

for i, n in ops do
if n == curUser.sName then
else
SendPmToNick(n, BotName, from.." -> "..message)
end
end

for i, n in vips do
if n == curUser.sName then
else
SendPmToNick(n, BotName, from.." -> "..message)
end
end

for i, n in regs do
if n == curUser.sName then
else
SendPmToNick(n, BotName, from.." -> "..message)
end
end
else
curUser:SendPM(BotName, "This chat is for registered users only. Your message has not been sent.")
end
end
end


function ParsePM(data)
s,e,whoTo,from,message = string.find(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(.*)")
message = string.sub(message,1,string.len(message)-1)
return whoTo,from,message
end


function isPM(data)
if( string.sub(data, 1, 3) == "$To" ) then
return 1
else
return 0
end
end
Title:
Post by: ??????Hawk?????? on 27 February, 2005, 17:46:46
hi m8  

 ChatArrival(curUser,data)   <---- this is Main chat


try

ToArrival(curUser,data)   


Instead..


you can also ditch this function

function isPM(data)

   
??????Hawk??????
Title:
Post by: Tw?sT?d-d?v on 27 February, 2005, 18:40:58
still no good m8 , i get this error now.....

 
REG CHAT.lua:69: expected near `end'
Title:
Post by: ??????Hawk?????? on 27 February, 2005, 18:42:51
hi m8  post what youve got ...


remember to use the  code  tags  so its  easier to read  :p



??????Hawk??????
Title:
Post by: Tw?sT?d-d?v on 27 February, 2005, 18:56:36
this is what i got.....it was used in my first hub lua4 and i used mutors converter to alter it .....

BotName = "REG-CHAT"


function Main()
frmHub:RegBot(BotName)
end


function ChatArrival(curUser,data)

local MessageRecognized = 0

if isPM(data)==1 then
whoto,from,message=ParsePM(data)
MessageRecognized=1
end

if MessageRecognized==1 and whoto==BotName then
if (curUser.iProfile>=0 and curUser.iProfile<=4) then
local sus=GetUsersByProfile("Master")
local sops=GetUsersByProfile("Moderator")
local ops=GetUsersByProfile("Operator")
local vips=GetUsersByProfile("VIP")
local regs=GetUsersByProfile("Reg")

for i, n in sops do
if n == curUser.sName then
else
SendPmToNick(n, BotName, from.." -> "..message)
end
end

for i, n in sus do
if n == curUser.sName then
else
SendPmToNick(n, BotName, from.." -> "..message)
end
end

for i, n in ops do
if n == curUser.sName then
else
SendPmToNick(n, BotName, from.." -> "..message)
end
end

for i, n in vips do
if n == curUser.sName then
else
SendPmToNick(n, BotName, from.." -> "..message)
end
end

for i, n in regs do
if n == curUser.sName then
else
SendPmToNick(n, BotName, from.." -> "..message)
end
end
else
curUser:SendPM(BotName, "This chat is for registered users only. Your message has not been sent.")
end
end
end


function ParsePM(data)
s,e,whoTo,from,message = string.find(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(.*)")
message = string.sub(message,1,string.len(message)-1)
return whoTo,from,message
end


function isPM(data)
if( string.sub(data, 1, 3) == "$To" ) then
return 1
else
return 0
end
end




I did the same with my vip & op chat bots and they  works great
Title:
Post by: ??????Hawk?????? on 27 February, 2005, 19:03:21
QuoteOriginally posted by ??????Hawk??????
hi m8  

 ChatArrival(curUser,data)   <---- this is Main chat


try

ToArrival(curUser,data)   


Instead..


you can also ditch this function

function isPM(data)

   
??????Hawk??????
Title:
Post by: Tw?sT?d-d?v on 27 February, 2005, 19:16:16
yep allready try'd that .. got this error...

REG CHAT.lua:69: expected near `end'