Author Topic: Help with AsciiTexter Bot  (Read 5275 times)

0 Members and 1 Guest are viewing this topic.

Offline Re@SoN

  • Fulll Member
  • ****
  • Posts: 62
  • Karma: +0/-0
Help with AsciiTexter Bot
« on: 28 October, 2005, 15:08:15 »
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!


Code: [Select]
-- 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

PtokaX forum

Help with AsciiTexter Bot
« on: 28 October, 2005, 15:08:15 »

Offline Re@SoN

  • Fulll Member
  • ****
  • Posts: 62
  • Karma: +0/-0
(No subject)
« Reply #1 on: 29 October, 2005, 16:00:11 »
tks a lot American Idiot!...;)
with that simple line in the end...now works!!! :)

best regards,
Re@SoN

Offline Re@SoN

  • Fulll Member
  • ****
  • Posts: 62
  • Karma: +0/-0
(No subject)
« Reply #2 on: 07 November, 2005, 00:45:17 »
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

Offline Re@SoN

  • Fulll Member
  • ****
  • Posts: 62
  • Karma: +0/-0
(No subject)
« Reply #3 on: 07 November, 2005, 14:55:21 »
hi!

American Idiot, 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.


Code: [Select]
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

Offline Re@SoN

  • Fulll Member
  • ****
  • Posts: 62
  • Karma: +0/-0
(No subject)
« Reply #4 on: 08 November, 2005, 18:04:19 »
hi!
sorry American Idiot 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
« Last Edit: 08 November, 2005, 21:13:37 by Re@SoN »

Offline Re@SoN

  • Fulll Member
  • ****
  • Posts: 62
  • Karma: +0/-0
(No subject)
« Reply #5 on: 10 November, 2005, 19:52:31 »
hi!

American Idiot, 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:

Code: [Select]
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

Offline Re@SoN

  • Fulll Member
  • ****
  • Posts: 62
  • Karma: +0/-0
(No subject)
« Reply #6 on: 11 November, 2005, 19:05:46 »
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

Offline 6Marilyn6Manson6

  • Scripter
  • King
  • ******
  • Posts: 869
  • Karma: +47/-35
    • http://www.marilynmanson986.altervista.org
(No subject)
« Reply #7 on: 11 November, 2005, 19:25:13 »
Quote
Originally 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:

Code: [Select]
-- 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

Offline Re@SoN

  • Fulll Member
  • ****
  • Posts: 62
  • Karma: +0/-0
(No subject)
« Reply #8 on: 12 November, 2005, 01:53:15 »
hi!

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

Code: [Select]
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

Offline 6Marilyn6Manson6

  • Scripter
  • King
  • ******
  • Posts: 869
  • Karma: +47/-35
    • http://www.marilynmanson986.altervista.org
(No subject)
« Reply #9 on: 12 November, 2005, 10:56:11 »
Quote
Originally posted by American Idiot
This

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

Should be this

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


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

Code: [Select]
User:SendPM (AsciiBotName, "<"..curUser.sName..">\r\n"..TempAsciifile)
with

Code: [Select]
curUser:SendPM (AsciiBotName, "<"..curUser.sName..">\r\n"..TempAsciifile)
LoL c ya

Offline 6Marilyn6Manson6

  • Scripter
  • King
  • ******
  • Posts: 869
  • Karma: +47/-35
    • http://www.marilynmanson986.altervista.org
(No subject)
« Reply #10 on: 12 November, 2005, 15:36:35 »
Quote
Originally posted by American Idiot
I know

Okiz.. nice :p

Offline Re@SoN

  • Fulll Member
  • ****
  • Posts: 62
  • Karma: +0/-0
(No subject)
« Reply #11 on: 12 November, 2005, 17:23:42 »
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 American Idiot, for all the help you guys give me with the script! :))  ;)

Best regards,
Re@SoN

Offline 6Marilyn6Manson6

  • Scripter
  • King
  • ******
  • Posts: 869
  • Karma: +47/-35
    • http://www.marilynmanson986.altervista.org
(No subject)
« Reply #12 on: 12 November, 2005, 20:21:42 »
Quote
Originally 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 American Idiot, 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

Offline kash?

  • Double Ace
  • *
  • Posts: 101
  • Karma: +0/-1
(No subject)
« Reply #13 on: 17 November, 2005, 17:37:26 »
Nice script, Can you plz make it without prefix
I dont want prefix actually

Regards

Offline [ vAiBhAv?]

  • Member
  • ***
  • Posts: 27
  • Karma: +0/-22
ASCII TEXTER
« Reply #14 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 !

Offline Psycho_Chihuahua

  • Systemspecialist IT
  • Emperor
  • **
  • Posts: 1 054
  • Karma: +112/-1
  • I am wherever i want to be
    • PtokaX Luaboard
Re: ASCII TEXTER
« Reply #15 on: 31 May, 2009, 16:44:06 »
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

PtokaX forum

Re: ASCII TEXTER
« Reply #15 on: 31 May, 2009, 16:44:06 »