Info bot no longer works...
 

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

Info bot no longer works...

Started by Reefa, 22 March, 2005, 02:30:14

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Reefa

Hi peeps,

We had a small 'info bot' in our hub which worked fine before changing over to the new ptoka and robo, it was converted to lua5 but it doesn't seem to work anymore...

Can anyone shed any light on the matter?

Quotebotname = "-=Info-Bot=-"
bot_descr = "? Type !goactive and !forbidden ?"
bot_speed = "Sonic"
bot_email = "hiphophub@hotmail.com"
bot_share_size = 0

my_info_string = "$MyINFO $ALL "..botname.." "..bot_descr.."$ $"..bot_speed..string.char( 1 ).."$"..bot_email

v1 = "Information"

file1 = "info/active_info.txt"
file2 = "info/forbidden.txt"
file3 = "info/cleaner_help.txt"
file4 = "info/bantime.txt"

function Main()
frmHub:RegBot(botname)
my_info_string = "$MyINFO $ALL "..botname.." "..bot_descr.."$ $"..bot_speed..string.char( 1 ).."$"..bot_email.."$"..bot_share_size.."$"
SendToAll( my_info_string )
end

function DataArrival(user, data)
if (string.sub(data, 1, 1) == "<" ) then
data=string.sub(data,1,string.len(data)-1)
_,_,cmd=string.find(data, "%b<>%s+(%S+)")

if (cmd=="!goactive") then
ReadGoActive(user, data, cmd)
return 1
elseif (cmd=="!forbidden") then
ReadForbidText(user, data, cmd)
return 1
elseif user.bOperator then
if (cmd=="!cleaner") then
ReadCleanerHelp(user, data, cmd)
return 1
elseif (cmd=="!time") then
ReadBanTime(user, data, cmd)
return 1
end
end
end
end

--------------------------------------------------------------------------
function ReadGoActive(user, data, cmd)
local release = ""
readfrom(file1)
while 1 do

if (line == nil) then
break
else
release = release..""..line.."\r\n"
end
end
user:SendPM(botname, "\r\n\r\n"..release)
readfrom()
end
--------------------------------------------------------------------------
function ReadForbidText(user, data, cmd)
local release = ""
readfrom(file2)
while 1 do

if (line == nil) then
break
else
release = release..""..line.."\r\n"
end
end
user:SendPM(botname, "\r\n\r\n"..release)
readfrom()
end
--------------------------------------------------------------------------
function ReadCleanerHelp(user, data, cmd)
local release = ""
readfrom(file3)
while 1 do

if (line == nil) then
break
else
release = release..""..line.."\r\n"
end
end
user:SendPM(botname, "\r\n\r\n"..release)
readfrom()
end
--------------------------------------------------------------------------
function ReadBanTime(user, data, cmd)
local release = ""
readfrom(file4)
while 1 do

if (line == nil) then
break
else
release = release..""..line.."\r\n"
end
end
user:SendPM(botname, "\r\n\r\n"..release)
readfrom()
end

Many thanks!

Herodes

#1
try this..
--- conv to Lua5 by Herodes

botname = "-=Info-Bot=-"
bot_descr = "Type !goactive and !forbidden"
bot_email = "hiphophub@hotmail.com" 

function Main() 
	frmHub:RegBot(botname, 1, bot_descr, bot_email)
end 

function ChatArrival(user, data) 
	local _,_,cmd=string.find(data, "%b<>%s+(%S+)|") 
	if (cmd=="!goactive") then 
		user:SendPM(botname, ReadFile("info/active_info.txt"))
		return 1
	elseif (cmd=="!forbidden") then
		user:SendPM(botname, ReadFile( "info/forbidden.txt"))
		return 1
	elseif user.bOperator then
		if (cmd=="!cleaner") then
			user:SendPM(botname, ReadFile( "info/cleaner_help.txt"))
			return 1
		elseif (cmd=="!time") then
			SendToAll(botname, ReadFile( "time.txt"))
			return 1
		end
	end
end

function ReadFile(filename)
	local file, msg = io.open(filename, "r"), ""
	if file then
		for line in file:lines() do msg = msg..line.."\n" end
		file:close()
		return msg
	else
		return filename.." doesnt exist"
	end
end
[*edit*] My friends tell I should shoot scripts at night ...
[*edit*] My friends dont know that I need to be 35% wake to script...
[*edit*] My friends worry no more .. those bugs had nothing to do with my bed...

jiten

Herodes, shouldn't it be:

function DataArrival(user, data)

replaced with this:

function ChatArrival(user, data)

so, all the code would be like this:

--- conv to Lua5 by Herodes

botname = "-=Info-Bot=-"
bot_descr = "? Type !goactive and !forbidden ?"
bot_email = "hiphophub@hotmail.com" 

function Main() 
	frmHub:RegBot(botname, 1, bot_descr, bot_email)
end 

function ChatArrival(user, data) 
	if (string.sub(data, 1, 1) == "<" ) then 
		data=string.sub(data,1,string.len(data)-1) 
		_,_,cmd=string.find(data, "%b<>%s+(%S+)") 

		if (cmd=="!goactive") then 
			ReadFile("info/active_info.txt")
			return 1
		elseif (cmd=="!forbidden") then
			ReadFile( "info/forbidden.txt")
			return 1
		elseif user.bOperator then
			if (cmd=="!cleaner") then
				ReadFile( "info/cleaner_help.txt")
				return 1
			elseif (cmd=="!time") then
				ReadFile( "info/bantime.txt")
				return 1
			end
		end
	end
end

function ReadFile(filename)
	local msg = ""
	io.input(filename)
	for line in io:lines() do
		msg = msg..line.."\n"
	end
	io.input()
	return msg
end


Best regards.

bastya_elvtars

Yes, and the red lines should be removed.

[color=#FF0000]if (string.sub(data, 1, 1) == "<" ) then[/color] 
		data=string.sub(data,1,string.len(data)-1) 
		_,_,cmd=string.find(data, "%b<>%s+(%S+)") 
		if (cmd=="!goactive") then 
			ReadFile("info/active_info.txt")
			return 1
		elseif (cmd=="!forbidden") then
			ReadFile( "info/forbidden.txt")
			return 1
		elseif user.bOperator then
			if (cmd=="!cleaner") then
				ReadFile( "info/cleaner_help.txt")
				return 1
			elseif (cmd=="!time") then
				ReadFile( "info/bantime.txt")
				return 1
			end
		[color=#FF0000]end[/color]
	end
Everything could have been anything else and it would have just as much meaning.

Herodes

I apologised for the "shoot-out-a-script,before-go-to-bed" attitude I exempled last night :)

its okie now .. 1st post of mine edited ..
Thx a lot guys ..
(no wonder I woke up from a nightmare)

Reefa

Dayam, you guys are quick!

Just tried the script and no joy, still doesn't post the info.

I've scanned over it and everything seems to be in place so I'm not too sure why it's not working  ?(

Any ideas?

Herodes

QuoteOriginally posted by Reefa
Dayam, you guys are quick!

Just tried the script and no joy, still doesn't post the info.

I've scanned over it and everything seems to be in place so I'm not too sure why it's not working  ?(

Any ideas?
Yep .. saw it fixed it.. the ReadIt func was reading the file .. I hadnt told the script to send what it read to the user ... now its done.
1st post of mine on this updated ...

Reefa

Hehe! Still not enough sleep huh? ;)

Just tried it again and no luck, everyone was wondering why I was typing !forbidden so many times, and then !shit, !shit, !shit.

Have you managed to get it working with a test text file?

jiten

QuoteOriginally posted by Reefa
Hehe! Still not enough sleep huh? ;)

Just tried it again and no luck, everyone was wondering why I was typing !forbidden so many times, and then !shit, !shit, !shit.

Have you managed to get it working with a test text file?

Try this one:

--- conv to Lua5 by Herodes and debugged by jiten and bastya_elvtars

botname = "-=Info-Bot=-"
bot_descr = "? Type !goactive and !forbidden ?"
bot_email = "hiphophub@hotmail.com" 

function Main() 
	frmHub:RegBot(botname, 1, bot_descr, bot_email)
end 

function ChatArrival(user, data) 
	local data=string.sub(data,1,string.len(data)-1) 
	local _,_,cmd=string.find(data, "%b<>%s+(%S+)") 
	if (cmd=="!goactive") then 
		user:SendPM(botname, ReadFile("info/active_info.txt"))
		return 1
	elseif (cmd=="!forbidden") then
		user:SendPM(botname, ReadFile( "info/forbidden.txt"))
		return 1
	elseif user.bOperator then
		if (cmd=="!cleaner") then
			user:SendPM(botname, ReadFile( "info/cleaner_help.txt"))
			return 1
		elseif (cmd=="!time") then
			user:SendPM(botname, ReadFile( "info/bantime.txt"))
			return 1
		end
	end
end

function ReadFile(filename)
	local file = io.open(filename, "r") -- "r" read
	local msg = ""
	for line in file:lines() do
		msg = msg..line.."\n"
	end
	file:close()
	return msg
end


Best regards,

jiten

Herodes

#9
done .. cooked and tasted .. sry for the delays .. everyting was caused be an overlooked badly written string.find ...
my 1st post on this updated once more ..

Reefa

Thanks for all your help guys, it works fine now!!!  :]

jiten


SMF spam blocked by CleanTalk