reg-chat in lua 5
 

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

reg-chat in lua 5

Started by Tw?sT?d-d?v, 27 February, 2005, 15:52:29

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Tw?sT?d-d?v

can some1 make a reg-chat bot plz   in lua 5

[NL]Pur

most simple example , extend it futher as you wish yourself. ;)


function ChatArrival(curUsermsg)

  
local __cmdpass string.find(msg"%b<>%s+(%S+)%s*([^|]*)%|$")

  if 
cmd == "!regme" then
     AddRegUser
(curUser.sNamepass"REG")
  
end

end 

Tw?sT?d-d?v


Tw?sT?d-d?v

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

??????Hawk??????

#4
hi m8  

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


try

ToArrival(curUser,data)   


Instead..


you can also ditch this function

function isPM(data)

   
??????Hawk??????

Tw?sT?d-d?v

still no good m8 , i get this error now.....

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

??????Hawk??????

hi m8  post what youve got ...


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



??????Hawk??????

Tw?sT?d-d?v

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

??????Hawk??????

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??????

Tw?sT?d-d?v

yep allready try'd that .. got this error...

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

SMF spam blocked by CleanTalk