can some1 make a reg-chat bot plz in lua 5
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
thx m8 :))
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
hi m8
ChatArrival(curUser,data) <---- this is Main chat
try
ToArrival(curUser,data)
Instead..
you can also ditch this function
function isPM(data)
??????Hawk??????
still no good m8 , i get this error now.....
REG CHAT.lua:69: expected near `end'
hi m8 post what youve got ...
remember to use the code tags so its easier to read :p
??????Hawk??????
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
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??????
yep allready try'd that .. got this error...
REG CHAT.lua:69: expected near `end'