SendToVips ?
 

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

SendToVips ?

Started by jiten, 02 March, 2005, 20:44:30

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jiten

Well, I have a question. How do I convert this code to LUA 5 ? The problem is that the SendToVips isn't working anymore.

BotName = "?bot?" 

controltrigs={["join"]=1,["login"]=2,["hub"]=3}

supervip = {}
fSuperVip = "logs/svip.txt"	-- Path of file that contains SuperVips

function ChatArrival(user,data)
	if not user.bOperator then
		LoadFromFile(fSuperVip)
		for key, value in controltrigs do
			if( string.find( string.lower(data), key) ) then
				s,e,onlymes = string.find(data, "%b<> (.*)")
				SendPmToOps (BotName, "Control: <"..user.sName.."> ("..user.sIP..") told in main: "..onlymes.."")
				SendToVips("Control: <"..user.sName.."> ("..user.sIP..") told in main: "..onlymes) 
			end
		end
	end
end

function ToArrival(user,data)
	local _, _, to, from, msg = string.find(data, "^%$To:%s+(%S+)%s+From:%s+(%S+)%s-%$%b<>%s+(.*)|")
	local nick = GetItemByName(to)
	if not user.bOperator then
		for key, value in controltrigs do
			if( string.find( string.lower(data), key) ) then
				s,e,whoTo,from,mes = string.find(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(.*)")  
				SendPmToOps (BotName, "Control: <"..user.sName.."> ("..user.sIP..") said to <"..to.."> in PVT this: "..mes.."")
				SendToVips("Control: <"..user.sName.."> ("..user.sIP..") said to <"..to.."> in PVT this: "..mes) 
			end
		end
	end
end

function SendToVips(msg)
	local usr,aux
	for usr, aux in supervip do
		if (GetItemByName(usr) ~= nil) then
			GetItemByName(usr):SendPM(BotName, msg)
		end
	end
end

function LoadFromFile(file)
	local f,e = io.open( file, "r" )
	if f then
		local r = f:read( "*a" )
		f:close()
		return r
	else
		return nil,"loadfile failed: "..e
	end
end


Thanks in advance.
Best regards,

jiten

NightLitch

here you go:

SendToVips = function(from,message)
	for _,Users in GetUsersByProfile("VIP") do
		SendToNick(Users, "<"..from.."> "..message)
	end
end

SendPmToVips = function(from,message)
	for _,Users in GetUsersByProfile("VIP") do
		SendPmToNick(Users, from, message)
	end
end

I guess I should work... not tested by Am pretty sure it should work.

// NL
//NL

jiten

Hi there NL. Well, I guess i didn't explain exactly what this script was meant for, so I'm going to post all of the script (the first post is edited).
This script warns the Operators and the KVIPs about certain triggers. The KVIP nicks are stored in a file - logs/svip.txt - like this:

supervip = {["kviptest"]=1,}


Thanks in advance.
Best regards,

jiten

Herodes

Please add a "SendToLevel" and a "SendPmToLevel" function.
As you can see sacrifices have already begun ...

( Ooh and a way to get a table of all the connected userobjects too pretty pls ;)

jiten

Hi there...
Well, I tried to use NL's SendToVips and SendPmToVips but I get this error when typing any of the triggers:

Syntax ...ktop\16.04rls\scripts\warnvip.lua_5.0.lua:165: attempt to concatenate local `message' (a nil value)


Thanks in advance.
Best regards,

jiten

NightLitch

QuoteOriginally posted by jiten
Hi there...
Well, I tried to use NL's SendToVips and SendPmToVips but I get this error when typing any of the triggers:

Syntax ...ktop\16.04rls\scripts\warnvip.lua_5.0.lua:165: attempt to concatenate local `message' (a nil value)


Thanks in advance.
Best regards,

jiten

By the look of my code there should be no problem, have you used the function correct ???

SendToVips(BotName, "Your Message to VIP's here")

SendPmToVips(BotName, "Your Message to VIP's here")
//NL

jiten

#6
Oops! The code was OK. Guess I was in the moon  ;)
But, there's one problem. The message should be sent to the users stored in this file, so called KVIPs: "logs/svip.txt" and not to every VIP.
Best regards.

Dessamator

yah, i tried it also doesnt seem to b able to read nicks in a table something to do with the
Quotefor _,Users in supervip do
, dunno mayb im wrong
Ignorance is Bliss.

nErBoS

Hi,

The problem is on the LoadFile function, you are only reading the file not loading the code...

BotName = "?bot?" 

controltrigs={["join"]=1,["login"]=2,["hub"]=3}

supervip = {}
fSuperVip = "logs/svip.txt"	-- Path of file that contains SuperVips

function ChatArrival(user,data)
	if not user.bOperator then
		LoadFromFile(fSuperVip)
		for key, value in controltrigs do
			if( string.find( string.lower(data), key) ) then
				s,e,onlymes = string.find(data, "%b<> (.*)")
				SendPmToOps (BotName, "Control: <"..user.sName.."> ("..user.sIP..") told in main: "..onlymes.."")
				SendToVips("Control: <"..user.sName.."> ("..user.sIP..") told in main: "..onlymes) 
			end
		end
	end
end

function ToArrival(user,data)
	local _, _, to, from, msg = string.find(data, "^%$To:%s+(%S+)%s+From:%s+(%S+)%s-%$%b<>%s+(.*)|")
	local nick = GetItemByName(to)
	if not user.bOperator then
		for key, value in controltrigs do
			if( string.find( string.lower(data), key) ) then
				s,e,whoTo,from,mes = string.find(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(.*)")  
				SendPmToOps (BotName, "Control: <"..user.sName.."> ("..user.sIP..") said to <"..to.."> in PVT this: "..mes.."")
				SendToVips("Control: <"..user.sName.."> ("..user.sIP..") said to <"..to.."> in PVT this: "..mes) 
			end
		end
	end
end

function SendToVips(msg)
	local usr,aux
	for usr, aux in supervip do
		if (GetItemByName(usr) ~= nil) then
			GetItemByName(usr):SendPM(BotName, msg)
		end
	end
end

function LoadFromFile(file)
	local handle = io.open(file,"r")
        if (handle ~= nil) then
                dofile(file)
		handle:flush()
		handle:close()
        end
end

Best regards, nErBoS
--## nErBoS Spot ##--

Dessamator

yap nerbos u were right, it works perfectly now, thanks  :D
Ignorance is Bliss.

jiten

Thanks for the help, nErBoS.
Now it's working perfectly.

SMF spam blocked by CleanTalk