Ptokax text commands?
 

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

Ptokax text commands?

Started by d-deeds, 18 November, 2005, 15:49:52

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

d-deeds

Hi,

My hub has been runned by ynhub earlier and i figure out that ptokax woudn't been bad.. :)

Now here's my problem. With Ynhub i could create a text commands that:
- Only shows in main and is broadcasted to everyone..
ex: If someone want's to tell the entire hub in main that his go to bed i had a ASCII picture for that...

Is that possible in ptokax?

Please help me

Deeds

bastya_elvtars

So basically it displays a text file. I. e. +bed show an ASCII art and shows: "Joe is going to bed.", where joe is the actual user's name. Or not?
Everything could have been anything else and it would have just as much meaning.

UwV

a three step plan..

1. enable textfiles support ..
2. put a file named "bedtime.txt" in ptokaxfolder/txt and paste your ascii of the bed in there.
3. use command !bedtime
\NL   The knowledge and skills you have achieved are meant to be forgotten so you can float comfortably in emptiness, without obstruction.
" Holly loves me,...  . "      ;o)

& don't forget, the motto is :
  -- SUPPORT YOUR LOCAL DJ'S --

d-deeds

-----------------------------------
a three step plan..

1. enable textfiles support ..
2. put a file named "bedtime.txt" in ptokaxfolder/txt and paste your ascii of the bed in there.
3. use command !bedtime

-----------------------------------

Well UwV...
It's not that simple,,,, yes now i got the text command.
But it's sent in pm and only to "the one that writing"!

I would like to have it in MAIN and sent to everyone...

Dessamator

There are quite a lot of scripts that do that, just Search the forum
Ignorance is Bliss.

d-deeds

Do you got any good examples that works?

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

QuoteOriginally posted by d-deeds
Do you got any good examples that works?

Yes  we got loads of good Examples ...  


You could too IF only you used the forums Search..

d-deeds

i didn't find very much...
but i find "hawk"s  script with ascii,,, this is probably not what i search for? or isit?

/deeds


-- 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 =  botname   --// Set Bot name here

SendTo = { --> 1=on/0=off
[0] = 1, -- Masters
[1] = 1, -- Operators
[2] = 1, -- Vips
[3] = 1, -- Regs
[4] = 1, -- Moderator
[5] = 1, -- NetFounder
[-1] = 1, -- 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 = "nn.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

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

#8
for your needs you are "probably " best following UwV's suggestion..


QuoteOriginally posted by UwV
a three step plan..

1. enable textfiles support ..
2. put a file named "bedtime.txt" in ptokaxfolder/txt and paste your ascii of the bed in there.
3. use command !bedtime


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

d-deeds

yes but then it's not useful..

the idea is that a person can tell the entire hub something in main with a command...

Uwv's sugestion is very good, but it's sent to the one that writing and in pm... :)

/deeds

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

ahhh  ic  ..  

the script you posted should work for you  ..

create a folder in your scripts folder called  '   ascii  '
and put all your ascii text files in it  ...


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

d-deeds

well... it works...

but i can't get any message in main,,, well,,, nothing happends at all... i can't even see the command i've typed in main +bed

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

QuoteOriginally posted by d-deeds
well... it works...

but i can't get any message in main,,, well,,, nothing happends at all... i can't even see the command i've typed in main +bed

does the file   bed.txt  exist in the ascii folder  ... ?

AND  did you restart scripts when you put the text file in  ..  ?


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

d-deeds


GeceBekcisi

#14
This sample code can show you where to start, because LUA is really very easy and is fun to work with.
-- Reads 'sFile' and sends it to main when command
-- '!bed', '+bed', '?bed', '#bed' is sent to main chat
-- by GeceBekcisi

sBotName = frmHub:GetHubBotName()
sFile = "ascii/bed.txt"

function ChatArrival(curUser, data)
	local data = string.sub(data,1, -2)
	local s,e,cmd = string.find(data, "%b<>%s[%!%+%?%#%+](%S+)")
	if cmd == "bed" then
		local filedata ="\r\n\r\n"
		for line in io.lines(sFile) do
			filedata = filedata..line.."\r\n"
		end
		SendToAll(sBotName, filedata..curUser.sName.." goes to bed and says: Good night all!\r\n")
		return 1
	end
end
Play with code, and please feel free to ask about anything. Best regards
Do you need an advanced user handling script? Download UserBekcisi today (Latest Edit)
Features: User + ISP + GeoIP database, user info + share checking and many more...

d-deeds

THANKS GECEBEKCISI!!!!

That did work just perfect...

Just one tiny little thing...
how do i change in the script so the text "nick goes to bed and says: Good night all! " comes before the ascii? :)


Thank you again VERY MUCH!!
/deeds

GeceBekcisi

You're welcome mate and here it goes: Just change
local filedata ="\r\n\r\n"
		for line in io.lines(sFile) do
			filedata = filedata..line.."\r\n"
		end
		SendToAll(sBotName, filedata[COLOR=red]..curUser.sName.." goes to bed and says: Good night all!\r\n"[/COLOR])
to
local filedata ="\r\n\r\n"[COLOR=red]..curUser.sName.." goes to bed and says: Good night all!\r\n"[/COLOR] 
		for line in io.lines(sFile) do
			filedata = filedata..line.."\r\n"
		end
		SendToAll(sBotName, filedata)
I hope you see how easy it is in fact ;)
Best Regards
Do you need an advanced user handling script? Download UserBekcisi today (Latest Edit)
Features: User + ISP + GeoIP database, user info + share checking and many more...

d-deeds

So if i would use two of them they would look like this:
(but if i use that one, only "+rock" works???)

------------------------------

-- Reads 'sFile' and sends it to main when command
-- '!bed', '+bed', '?bed', '#bed' is sent to main chat
-- by GeceBekcisi

sBotName = frmHub:GetHubBotName()
sFile = "ascii/nn.txt"

function ChatArrival(curUser, data)
   local data = string.sub(data,1, -2)
   local s,e,cmd = string.find(data, "%b<>%s[%!%+%?%#%+](%S+)")
   if cmd == "nn" then
      local filedata ="\r\n\r\n"..curUser.sName.."  Goes to bed, and wish you all.. \r\n"
      for line in io.lines(sFile) do
         filedata = filedata..line.."\r\n"
      end
      SendToAll(sBotName, filedata)
      return 1
   end

end

sBotName = frmHub:GetHubBotName()
sFile = "ascii/rock.txt"

function ChatArrival(curUser, data)
   local data = string.sub(data,1, -2)
   local s,e,cmd = string.find(data, "%b<>%s[%!%+%?%#%+](%S+)")
   if cmd == "rock" then
      local filedata ="\r\n\r\n"..curUser.sName.."  headbangs and hope that the rest of the hub are with him? \r\n"
      for line in io.lines(sFile) do
         filedata = filedata..line.."\r\n"
      end
      SendToAll(sBotName, filedata)
      return 1
   end

end

GeceBekcisi

Hmm first of all, you need to understand you can define unique functions and you must define unique strings only once in a script (unless you need to define a string again), with only one equation mark..

If I type
sString = "StringValue1"
sString will be equal to "StringValue1" whenever I call it in my script. But if I type
sString = "StringValue1"
...
sString = "StringValue2"
sString will be equal to "StringValue2" whenever I call it in my script. And also if I type
sString = "StringValue1"
...
sString = "StringValue1"
sString will be equal to "StringValue1" whenever I call it in my script. So there is no need to write it again.


And also, in a script two functions of same name will confuse PtokaX, so here you go:
-- Reads files and sends it to main when command typed to main chat
-- by GeceBekcisi

sBotName = frmHub:GetHubBotName()
sBedFile = "ascii/nn.txt"
sRockFile = "ascii/rock.txt"

function ChatArrival(curUser, data)
	local data = string.sub(data,1, -2)
	local s,e,cmd = string.find(data, "%b<>%s[%!%+%?%#%+](%S+)" )
	if cmd == "bed" then
		local filedata = "\r\n\r\n"..curUser.sName.." goes to bed and says: Good night all!\r\n"
		for line in io.lines(sBedFile) do
			filedata = filedata..line.."\r\n"
		end
		SendToAll(sBotName, filedata)
		return 1
	end
	if cmd == "rock" then
		local filedata = "\r\n\r\n"..curUser.sName.." headbangs and hope that the rest of the hub are with him? \r\n"
		for line in io.lines(sRockFile) do
			filedata = filedata..line.."\r\n"
		end
		SendToAll(sBotName, filedata)
		return 1
	end
end

And please use [C0DE] and [/C0DE] (and don't forget to replace C0DE with CODE when posting ;)) to wrap script codes when posting.
Best regards.
Do you need an advanced user handling script? Download UserBekcisi today (Latest Edit)
Features: User + ISP + GeoIP database, user info + share checking and many more...

SMF spam blocked by CleanTalk