TextCommands 1.0c help
 

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

TextCommands 1.0c help

Started by Djdirect, 20 February, 2007, 18:38:03

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Djdirect

Hi all   ;) I would like that this script sends only txt in pm and a the user solely i change this

Code: lua
--[[

	TextCommands 1.0c LUA 5.0/5.1
	
	By Mutor        04/23/06

	Generates a list of text files in the specified folder
	Sends context menus (right click) to specified users.

	**IMPORTANT NOTE: This script requires bluebear's Px extension
	library, PxUtilities. It's available for both Lua 5.0.2 & Lua 5.1
	This script will not work without it, and it's free. With this lib
	we can avoid the dreaded shell pop up.

	Visit http://thewildplace.dk/ for this and many other great
	extensions to the PtokaX hub software.
	


	Changes from 1.0        	04/26/06
		+Added send menu to specified profiles
		
	Changes from 1.0b        	04/30/06
		+Use command on hub tab to send in main, or on user list to send pm to selected nick
		-Removed regbot option, bot must be regged to send pm's
		+Added internal read code, to allow reading by profile
		+No longer for use with PtokaX inbuilt reader
		***Don't use 'texts' folder if Px reader is enabled
		
		
		

]]

TextCfg = {
--Command Menu Name
Menu = "• La Foire Aux Questions",-- frmHub:GetHubName() or "User Commands",
--Command Submenu Name
SubMenu = "• Choisir l'aide",
--Botname
Bot = frmHub:GetHubBotName() or "Command_Bot",
--If registering, does bot have a key?
BotIsOp = 1,
--Bot description
BotDesc = "La Foire Aux Questions",
--Bot Email address
BotMail = "Faq@domain.com",
--Path To Files
Dir = "faq",
--//-- Op's nick for status/error message
OpNick = "Boss",
--//-- Display status messages to OpNick?
Verbose = "on",
-- Who may receive context menu?
Profiles  = {
	[-1] = 1, --Unregistered User
	[0] = 1, --Master
	[1] = 1, --Operator
	[2] = 1, --Vip
	[3] = 1, --Registered User
	[4] = 1, --Moderator
	[5] = 1, --NetFounder
	[6] = 1, --Owner
	}
}

Main = function()
	Texts = {}
	local pxuv = "PxUtilities v."
	if _VERSION == "Lua 5.1" then --Both paths reflect the root of Px per LUA version
		libinit = package.loadlib("PxUtilities_l51.dll", "_libinit")
		gc = "collect"
	else
		libinit = loadlib("../PxUtilities.dll", "_libinit")
		gc = nil
	end
	libinit()
	pxuv = pxuv..PXU.GetVersion().." for ".._VERSION.." loaded."
	OnError(pxuv)
	SetTimer(5 * 60000)
	StartTimer()
	DoList()
	if TextCfg.Bot ~= frmHub:GetHubBotName() or
		TextCfg.Bot == frmHub:GetHubBotName() and not frmHub:GetHubBot() then
		frmHub:RegBot(TextCfg.Bot, TextCfg.BotIsOp, TextCfg.BotDesc, TextCfg.BotMail)
	end
end

OnTimer = function()
	DoList()
end

NewUserConnected = function(user)
	if TextCfg.Profiles[user.iProfile] and TextCfg.Profiles[user.iProfile] == 1 then
		local Prof = GetProfileName(user.iProfile) or "Unregistered User"
		--user:SendData(TextCfg.Bot, "Welcome "..user.sName..", "..Prof.."'s text commands "..
		--"enabled. Right click hub tab or user list for menu.")
		DoCmds(user)
	end
end
OpConnected = NewUserConnected

OnError = function(msg)
	if TextCfg.Verbose == "on" then
		SendToNick(TextCfg.OpNick,"<"..TextCfg.Bot.."> "..msg)
	end
end

ChatArrival = function(user, data)
	if TextCfg.Profiles[user.iProfile] and TextCfg.Profiles[user.iProfile] == 1 then
		local s,e,to = string.find(data,"^$To:%s(%S+)%s+From:")
		local s,e,cmd = string.find( data, "%b<>%s%p(%w+)")
		local s,e,usr = string.find( data, "%b<>%s%p%w+%s(%S+)|$")
		if cmd then
			for i,v in ipairs(Texts) do
				if cmd == v then
					local lines="\r\n\r\n"
					for line in io.lines(TextCfg.Dir.."\\"..v..".txt") do
						lines = lines..line.."\r\n"
					end
					if usr then
						local nick = GetItemByName(usr)
						if nick  then
							SendPmToNick(nick.sName, TextCfg.Bot, lines)
						else
							local reply = "L'user "..usr.." n'est pas "..
							"en ligne, vérifier le pseudo."
							if to and to == TextCfg.Bot then
								user:SendPM(TextCfg.Bot,reply)
							-- else
							--	user:SendData(TextCfg.Bot,reply)
							end
						end
						return 1
					else
						user:SendPM(TextCfg.Bot, lines)
						return 1
					end
				end
			end
		end
	end
end
ToArrival = ChatArrival

DoCmds = function(user)
	local Menu,SubMenu = TextCfg.Menu,TextCfg.SubMenu
	for i,v in ipairs(Texts) do
		user:SendData("$UserCommand 1 1 "..Menu.."\\"..
		SubMenu.."\\"..v.."$<%[mynick]> +"..v.."&#124;")
		user:SendData("$UserCommand 1 2 "..Menu.."\\"..
		SubMenu.."\\"..v.."$<%[mynick]> +"..v.." %[nick]&#124;")
	end
 	collectgarbage(gc)
end

DoList = function()
	Texts = {}
	local FileSize,FileCount = 0,0
	local result = PXU.FindFirstFile(TextCfg.Dir.."\\*.*")
	if result == 0 then
		OnError(TextCfg.Dir.." = "..PXU.GetErrorString(PXU.GetLastError()))
		return 1
	else
		while result ~= 0 do
			result = PXU.FindNextFile()
			if result ~= 0 then
				local FileName = ""
				FileName = FileInfo.cFileName() or FileInfo.cAltFileName()
				if not FileInfo.IsDirectory() then
					if string.find(FileName,"(%.txt)$") then
						FileName = string.gsub(FileName,"(%.txt)$","")
						table.insert(Texts,FileName)
					end
				end
			end
		end
		PXU.CloseFind()
		collectgarbage(gc)
	end
end


i have 4 texts to send   1 go to pm ok 1 go to main chat ?????   :)

bastya_elvtars

Could you please post the whole script using code tags?
(BTW the chunk you posted is... weird).
Everything could have been anything else and it would have just as much meaning.

Djdirect


Djdirect

 thank you Mutor

I know  PM the bot to have the text file returned in PM
Highlight a user to send the text to that user in PM.
Use the hub tab command to send to all in main.
is ok but  i need just in pm   
other if nick have tag ex:[DJH]Djdirect   
-- Who may receive special context menu? 0=no/1=yes
Special  = {
   [DJH]Djdirect = 1,
   Rizzo = 1,
   Nick1 = 1,
   Nick2 = 1,
   Etc = 0,
   },
}
script error line 70

bastya_elvtars

Djdirect, a piece of advice: you should post the exact error message from px.
Everything could have been anything else and it would have just as much meaning.

Djdirect


SMF spam blocked by CleanTalk