Another nice talkbot !!
 

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

Another nice talkbot !!

Started by BeeR, 15 March, 2005, 17:10:11

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

BeeR

MysBot = "botname"

Mode = 1

function Main()
end

Count = 0


Comments = {
             
   "bla bla bla",
              }   


function DataArrival(curUser,sdata)
if Mode == 1 then
   if string.sub(sdata,1,1) == "<" then
      Count = Count+1   
      if Count == 5 then      
      index = random(1,table.getn(Comments))
      SendToAll(MysBot, Comments[index])
      Count = 0
      end
   end
end
if string.sub(sdata,1,1) == "<" then
   sdata = string.sub(sdata,1,-2)
   local _,_, command = string.find(sdata,"%b<>%s+(%S+)")

   if command =="+"..MysBot.."" and curUser.bOperator then
   local _,_, command,Modes = string.find(sdata,"%b<>%s+(%S+)%s+(%S+)")
   if Modes == nil then
      curUser:SendData(MysBot,"Commandet ?r +(Your name on the bot) . ")   
      return 1
      end
      if Modes == "on" then Mode = 1
      elseif Modes == "off" then Mode = 0 end
      curUser:SendData(MysBot,"Mode on comments sett to "..Modes)
      return 1         
      end
   end
end


Does any1 see whats wrong in this code - i dont =((
A cold BeeR is stunning !!

Pothead

It's in LUA 4 , maybe.

Herodes

#2
The "DataArrival" way of handling user input is decaprecated in the newest Ptxs ... The Scripting-Interface.txt says we must do it in another way .. .
Try the one below ...

MysBot = "botname"
Mode = 1
Count = 0

Comments = {
	"bla bla bla",
	}


function ChatArrival( user, data )
	if Mode == 1 then
		Count = Count+1
		if Count == 5 then
			index = 
			SendToAll(MysBot, Comments[math.random(1,table.getn(Comments))])
			Count = 0
		end
	end
	sdata = string.sub( data , 1, -2)
	local _,_, command = string.find( data, "%b<>%s+(%S+)")
	if command =="+"..MysBot.."" and user.bOperator then
		local _,_, command,Modes = string.find( data, "%b<>%s+(%S+)%s+(%S+)")
		if Modes == nil then
			user:SendData(MysBot,"Commandet ?r +"..MysBot.." . ")
			return 1
		end
		if Modes == "on" then Mode = 1
		elseif Modes == "off" then Mode = 0
		end
		user:SendData(MysBot,"Mode on comments sett to "..Modes)
		return 1
	end
end

jiten

#3
Try this:

--Converted to LUA 5 by jiten
MysBot = "botname" 

Mode = 1 

function Main() 
end 

Count = 0 


Comments = { 

"bla bla bla", 
} 


function ChatArrival(curUser,sdata) 
if Mode == 1 then 
if string.sub(sdata,1,1) == "<" then 
Count = Count+1 
if Count == 5 then 
index = math.random(1,table.getn(Comments)) 
SendToAll(MysBot, Comments[index]) 
Count = 0 
end 
end 
end 
if string.sub(sdata,1,1) == "<" then 
sdata = string.sub(sdata,1,-2) 
local _,_, command = string.find(sdata,"%b<>%s+(%S+)") 

if command =="+"..MysBot.."" and curUser.bOperator then 
local _,_, command,Modes = string.find(sdata,"%b<>%s+(%S+)%s+(%S+)") 
if Modes == nil then 
curUser:SendData(MysBot,"Commandet ?r +(Your name on the bot) . ") 
return 1 
end 
if Modes == "on" then Mode = 1 
elseif Modes == "off" then Mode = 0 end 
curUser:SendData(MysBot,"Mode on comments sett to "..Modes) 
return 1 
end 
end 
end

BeeR

#4
QuoteOriginally posted by Pothead
It's in LUA 4 , maybe.

_________________________________________

tnx for the quick answer
Pothead it was converted to LUA5 :]

it seems to give me some error jiten
scripts\talkbot.lua:23: attempt to index field `table' (a nil value)

and on Herodes:
scripts\talkbot.lua:15: attempt to call global `random' (a nil value)
A cold BeeR is stunning !!

Herodes

QuoteOriginally posted by BeeR and on Herodes:
scripts\talkbot.lua:15: attempt to call global `random' (a nil value)
sorted.... script in my post edited ..

BeeR

QuoteOriginally posted by Herodes
QuoteOriginally posted by BeeR and on Herodes:
scripts\talkbot.lua:15: attempt to call global `random' (a nil value)
sorted.... script in my post edited ..

works perfect now
cheers :]
A cold BeeR is stunning !!

Herodes

#7
QuoteOriginally posted by BeeR
works perfect now
cheers :]
yw Beer :)

jiten

sorted out mine too... there was more than one "table" ;)

SMF spam blocked by CleanTalk