Help with AsciiTexter Bot
 

News:

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

Help with AsciiTexter Bot

Started by Re@SoN, 28 October, 2005, 15:08:15

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Re@SoN

hi folks!
can anyone help me with this script plz...

the problem is:
when i config the reg profile to "1" in "SendTo = ",  the right click menu don't appear to reg users like it should be...in others profiles it works(vip, op, netfounder,etc).
if anyone could help i'll be apreciated.   :)  ;)
tks!


-- Yet another version AsciiTexter Bot
--  By ??????Hawk?????? 03/07/2005
-- Create an   ascii folder within the scripts folder and copy all your ascii files in.

AsciiBotName = " M ? ? ?  ? - ?  ? ? ? ? ? ?"	--// Set Bot name here 

SendTo = { --> 1=on/0=off 
[0] = 0, -- Masters 
[1] = 1, -- Operators 
[2] = 1, -- Vips 
[COLOR=red][3] = 1, -- Regs [/COLOR]  
[4] = 0, -- Moderator 
[5] = 1, -- NetFounder 
[-1] = 0, -- Users 
}   



function ChatArrival(curUser, data) 
	data = string.sub(data,1,string.len(data)-1)
	local _,_,PRFX,text = string.find( data, "%b<>%s+(%S)(%S+).*" )	
		if PRFX == Prefix and text and AsciiTable[text] then			
				local handle,Er = io.open("ascii/"..text..".txt", "r")
				if handle then								
					local line = handle:read("*l")
					TempAsciifile = "\r\n"
						while line do 
							TempAsciifile = TempAsciifile.."\r\n"..line
							line =handle:read("*l")
						end 
					handle:close() 
				end
				SendToAll(AsciiBotName, "<"..curUser.sName..">\r\n"..TempAsciifile)
			return 1
		end 
end



function Main()
	Prefix = "!"
	AsciiTable = {}
	local sDirectory = "ascii"
   	local sFileName = "Alisting.txt"
   	local sLine = nil;
   	os.execute("dir /b /a-d \""..sDirectory.."\" > \""..sFileName.."\"");
   	local ahFile,e = io.open(sFileName,"r")  
   	sLine = ahFile:read("*l");
	sLine = string.sub(sLine, 1, (string.len(sLine)-4))
	AsciiTable[sLine] = 1
   		while ( sLine ) do
      		sLine = ahFile:read("*l");
				if sLine ~= nil then
					sLine = string.sub(sLine, 1, (string.len(sLine)-4))
					AsciiTable[sLine] = 1
				end
   		end
		ahFile:close()
   		os.remove(sFileName);
end

NewUserConnected = OpConnected

function OpConnected(curUser) 
	 if SendTo[curUser.iProfile] == 1 then 
		curUser:SendData("$UserCommand 255 ") -- clear
		for STCommand,q in AsciiTable do
				curUser:SendData("$UserCommand 1 3 "..AsciiBotName.."\\"..STCommand.."$<%[mynick]> !"..STCommand.."|")
		end
	end 
end


best regards,
Re@SoN

Re@SoN

tks a lot Mutor!...;)
with that simple line in the end...now works!!! :)

best regards,
Re@SoN

Re@SoN

hi!
it's also possible to put that script, acepting special caracters, like spaces?...because i need to use them in  the names of the txt files...
whem i put a space or someone other special caracter on the name of any txt file the script simply don't read the file.

best regards,
Re@SoN

Re@SoN

hi!

Mutor, i change the line you said, but still keeping not acepting spaces in the name of txt files...
i tried to chaged the prefix, and use several other diferent carecters, and nothing...now the comand apeears in mainchat but the ascii don't apeear...
i'm using robo and 2 other scripts with rightclick menu, can it be for that reason!?
i just like to use spaces, nothing more.
for ex. i want to put 1 of the txt file with this name: Links de diversao
and the txt file shows the ascii with the links.


function ChatArrival(curUser, data) 
	data = string.sub(data,1,string.len(data)-1)
          [COLOR=red] local _,_,PRFX,text = string.find( data, "^%b<>%s+(%p)(.+)$" )[/COLOR] 
		if PRFX == Prefix and text and AsciiTable[text] then			
				local handle,Er = io.open("ascii/"..text..".txt", "r")
				if handle then								
					local line = handle:read("*l")
					TempAsciifile = "\r\n"
						while line do 
							TempAsciifile = TempAsciifile.."\r\n"..line
							line =handle:read("*l")
						end 
					handle:close() 
				end
				SendToPm(AsciiBotName, "<"..curUser.sName..">\r\n"..TempAsciifile)
			return 1
		end 
end

Re@SoN

#4
hi!
sorry Mutor for spending your pacience... i changed the line.
but still not working, this is the error that apeears in ptokax:

scripts\AsciiTexter.lua:23: invalid capture index


i'm not typing the txt extention...
like in the other times, i try to execute the comands by right click menu that triggs the txt files...and not typing the comand by main. if is that you want to mean..

sorry for my ignorance, but if you still have the pacience to trying solve the error, i'll be greatfull.


best regrads,
Re@SoN

Re@SoN

hi!

Mutor, now work perfectly!!!
an excelent work...
tks a lot!  :]  ;)

but only now that i tested the script, i figured out that floods me the main...:S
and that i haven't thinking befor....lol
i try my self to change the script so the msg can apear in pvt but didn't make it.
for the script do that, i think that the change it's minimum, maybe something like SendToPm, but here i change that...i don't know....i've tried in here:

function OpConnected(curUser) 
	[COLOR=red] if SendToPm[curUser.iProfile] == 1 then [/COLOR]
  		  curUser:SendData("$UserCommand 255 ") -- clear
		  for STCommand,q in AsciiTable do
				 curUser:SendData("$UserCommand 1 3 "..AsciiBotName.."\\"..STCommand.."$<%[mynick]> !"..STCommand.."|")
		end
	end 
end

since i don't now lua, was by atempts..:)


best regards,
Re@SoN

Re@SoN

humm..now i understand...after all, i was far away to solved the probl...heh

copy,paste, like in here:
error:scripts\AsciiTexter.lua:67: attempt to index global `user' (a nil value)

and this time i don't even tryed to fix it...i only have some notions about lua, but i'm always learning...:)


Best regards,
Re@SoN

6Marilyn6Manson6

QuoteOriginally posted by Re@SoN
humm..now i understand...after all, i was far away to solved the probl...heh

copy,paste, like in here:
error:scripts\AsciiTexter.lua:67: attempt to index global `user' (a nil value)

and this time i don't even tryed to fix it...i only have some notions about lua, but i'm always learning...:)


Best regards,
Re@SoN


Try this:

-- Yet another version AsciiTexter Bot
--  By ??????Hawk?????? 03/07/2005
-- Create an   ascii folder within the scripts folder and copy all your ascii files in.
-- error:scripts\AsciiTexter.lua:67: attempt to index global `user' (a nil value) / fixed by 6Marilyn6Manson6

AsciiBotName = "ASCII-Reader" 	--// Set Bot name here 

SendTo = { --> 1=on/0=off 
[0] = 0, -- Masters 
[1] = 1, -- Operators 
[2] = 1, -- Vips 
[3] = 1, -- Regs   
[4] = 0, -- Moderator 
[5] = 1, -- NetFounder 
[-1] = 0, -- Users 
}   

function Main()
	if AsciiBotName ~= frmHub:GetHubBotName() then
		frmHub:RegBot(AsciiBotName, 1, "ASCII Reader bot", "")
	end 
	Prefix = "?"
	AsciiTable = {}
	local sDirectory = "ascii"
   	local sFileName = "Alisting.txt"
   	local sLine = nil;
   	os.execute("dir /b /a-d \""..sDirectory.."\" > \""..sFileName.."\"");
   	local ahFile,e = io.open(sFileName,"r")  
   	sLine = ahFile:read("*l");
	sLine = string.sub(sLine, 1, (string.len(sLine)-4))
	AsciiTable[sLine] = 1
   		while ( sLine ) do
      		sLine = ahFile:read("*l");
				if sLine ~= nil then
					sLine = string.sub(sLine, 1, (string.len(sLine)-4))
					AsciiTable[sLine] = 1
				end
   		end
		ahFile:close()
   		os.remove(sFileName);
end

function OpConnected(curUser) 
	 if SendTo[curUser.iProfile] == 1 then 
		curUser:SendData("$UserCommand 255 ") -- clear
		for STCommand,q in AsciiTable do
				curUser:SendData("$UserCommand 1 3 "..AsciiBotName.."\\"..STCommand.."$<%[mynick]> !"..STCommand.."|")
		end
	end 
end

NewUserConnected = OpConnected

function ChatArrival(curUser, data) 
	data = string.sub(data,1,string.len(data)-1)
	local _,_,prefix,text = string.find( data, "%b<>%s+(%p)(.+)" )	
		if prefix == Prefix and text and AsciiTable[text] then			
				local handle,error = io.open("ascii/"..text..".txt", "r")
				if handle then								
					local line = handle:read("*l")
					TempAsciifile = "\r\nDisplaying "..text..".txt:\r\n"
						while line do 
							TempAsciifile = TempAsciifile.."\r\n"..line
							line =handle:read("*l")
						end 
					handle:close() 
				end
				curUser:SendPM (AsciiBotName, "<"..curUser.sName..">\r\n"..TempAsciifile)
			return 1
		end 
end

C ya

Re@SoN

hi!

6Marilyn6Manson6, don't work...the same error in line 67:

NewUserConnected = OpConnected

function ChatArrival(curUser, data) 
	data = string.sub(data,1,string.len(data)-1)
	local _,_,prefix,text = string.find( data, "%b<>%s+(%p)(.+)" )	
		if prefix == Prefix and text and AsciiTable[text] then			
				local handle,error = io.open("ascii/"..text..".txt", "r")
				if handle then								
					local line = handle:read("*l")
					TempAsciifile = "\r\nDisplaying "..text..".txt:\r\n"
						while line do 
							TempAsciifile = TempAsciifile.."\r\n"..line
							line =handle:read("*l")
						end 
			             [COLOR=red]handle:close() [/COLOR]  
				end
				user:SendPM (AsciiBotName, "<"..curUser.sName..">\r\n"..TempAsciifile)
			return 1
		end 
end

i iven tryed without spaces in the names off the txt files...just in case...

best regards,
Re@SoN

6Marilyn6Manson6

QuoteOriginally posted by Mutor
This

[COLOR=red]user:SendPM [/COLOR](AsciiBotName, "<"..curUser.sName..">\r\n"..TempAsciifile)


Should be this

[COLOR=red]curUser:SendPM[/COLOR](AsciiBotName, "<"..curUser.sName..">\r\n"..TempAsciifile)


Yeah Mutor.. infact in my post I have change only this line

User:SendPM (AsciiBotName, "<"..curUser.sName..">\r\n"..TempAsciifile)

with

curUser:SendPM (AsciiBotName, "<"..curUser.sName..">\r\n"..TempAsciifile)

LoL c ya

6Marilyn6Manson6

QuoteOriginally posted by Mutor
I know

Okiz.. nice :p

Re@SoN

hi guys!

now works better than great...iven accept special charachters in the name(i tested)...better than this is impossible!!!
tks 6Marilyn6Manson6 and specially you Mutor, for all the help you guys give me with the script! :))  ;)

Best regards,
Re@SoN

6Marilyn6Manson6

QuoteOriginally posted by Re@SoN
hi guys!

now works better than great...iven accept special charachters in the name(i tested)...better than this is impossible!!!
tks 6Marilyn6Manson6 and specially you Mutor, for all the help you guys give me with the script! :))  ;)

Best regards,
Re@SoN

Welcome Re@SoN... we are here for help all :D

kash?

Nice script, Can you plz make it without prefix
I dont want prefix actually

Regards

[ vAiBhAv?]

actually i am in search of a script kalled ascii bot.. there are many ascii arts in it.. eg. explode. on clicking on explode in right click menu,  an ascii of explosion is seen on the main chat and below it "..Nick.." just exploded !

Psycho_Chihuahua

Quote from: [ vAiBhAv?] on 31 May, 2009, 13:33:16
actually i am in search of a script kalled ascii bot.. there are many ascii arts in it.. eg. explode. on clicking on explode in right click menu,  an ascii of explosion is seen on the main chat and below it "..Nick.." just exploded !


1. If you use the Search Function of this Forum wisely you WILL find what you are looking for
2. and more important: Think about upgrading your hub to the new API and you will most surely find what you seek

thats all i have to say
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

SMF spam blocked by CleanTalk