Script PMs...
 

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

Script PMs...

Started by nErBoS, 15 May, 2004, 00:45:05

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

nErBoS

Hi,

Question...

Does SendPmToNick or user:SendPM() by pass in the DataArrival() ??? I have tried to block PMs from Bots and no success, made a fullsearch data and it seens not to pass. Can anyone explain why ??

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

NotRabidWombat

Outgoing script messages do not have a loopback. So SendPM does bypass.

Having them loopback adds a complexity to scripts.
Do you send to all scripts or just the ones in order? Do you send it to the originating script?
It could also result in an infinite loop of sending messages.

-NotRabidWombat


I like childish behavior. Maybe this post will be deleted next.

nErBoS

Hi,

The script in cause...

--Requested by Bladerunneruk
--Made by nErBoS

sBot = "The Hider"

hide = {}
hidesv = "hide.dat"

function Main()
	frmHub:RegBot(sBot)
	frmHub:EnableFullData(1)
	LoadFromFile(hidesv)
	RefreshHide()
end

function OnExit()
	SaveToFile(hidesv , hide , "hide")
end

function OpDisconnect(user, data)
	if (user.iProfile == 0) then
		hide[user.sName] = nil
		frmHub:UnregBot(user.sName)
	end
end

function DataArrival(user, data)
	if (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot) then
		data = strsub(data,1,strlen(data)-1)
		s,e,cmd = strfind(data, "%b<>%s+(%S+)")
		if (cmd == "!hide" and user.iProfile == 0) then
			if (hide[user.sName] == nil) then
				hide[user.sName] = 1
				frmHub:UnregBot(user.sName)
				user:SendPM(sBot, "You are now hide from the user list")
			else
				user:SendPM(sBot, "You are already hide from the user list")
			end
			return 1
		elseif (cmd == "!unhide" and user.iProfile == 0) then
			if (hide[user.sName] ~= nil) then
				hide[user.sName] = nil
				frmHub:RegBot(user.sName)
				user:SendPM(sBot, "You are now back to the user list")
			else
				user:SendPM(sBot, "You are not hide from the Hub")
			end
			return 1
		end
	end
	if (strsub(data,1,12) == "$GetNickList") then
		RefreshHide()
	end
	if (strsub(data,1,5) == "$To: ") then
		local s,e,usr = strfind(data, "$To:%s+(%S+)")
		if (hide[usr] ~= nil) then
			return 1
		end
	end
end

function RefreshHide()
	local usr,aux
	for usr, aux in hide do
		frmHub:UnregBot(usr)
	end
end

function Serialize(tTable, sTableName, sTab)
	assert(tTable, "tTable equals nil");
	assert(sTableName, "sTableName equals nil");

	assert(type(tTable) == "table", "tTable must be a table!");
	assert(type(sTableName) == "string", "sTableName must be a string!");

	sTab = sTab or "";
	sTmp = ""

	sTmp = sTmp..sTab..sTableName.." = {\n"

	for key, value in tTable do
		local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);

		if(type(value) == "table") then
			Serialize(value, sKey, sTab.."\t");
		else
			local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
			sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
		end

		sTmp = sTmp..",\n"
	end

	sTmp = sTmp..sTab.."}"
	return sTmp
end

function SaveToFile(file , table , tablename)
	writeto(file)
	write(Serialize(table, tablename))
	writeto()
end

function LoadFromFile(file)
	if (readfrom(file) ~= nil) then
		readfrom(file)
		dostring(read("*all"))
		readfrom()
	end
end

This script will block any PM if the user chooses to hide, but the others script PM are by passing.

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

Stravides

#3
Ok to piggyback on the back of this thread..

I want to be able to block all users PM's

UNLESS it is OP - User or User to OP
is that possible ?

Pseudo code

if [B]dataarrival is pm [/B]  then 
	if [B]user an operator[/B] , 
		permit PM
	else [B](if user not operator )[/B]
 		if [B]to = operator [/B]  
			permit
		else
			Block PM
		end
	end
end
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

nErBoS

Hi,

Yes its possible, just do this...

if (strsub(data,1,5) == "$To: ") then
	if (not user.bOperator) then
		local s,e,usr = strfind(data, "$To:%s+(%S+)")
		if (GetItemByName(usr) ~= nil and not GetItemByName(usr).bOperator) then
			return 1
		end
	end
end

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

jiten

hi there nErBoS.
just wanted to ask you something about this hider.
i've tried this one and Phatty's Lance Hider.
the problem is that both of them have bugs.

this one gives the nick taken error, when i try to reconnect, even after doing the !unhide command. so, i always have to restart the hub, to reconnect again.

On ther other hand, Phatty's Lance Hider doesn't give the nick taken error, but, when i hide myself from the userlist, i always reappear after some minutes, and can't stay "invisible" like with yours.

is there a solution for this?
thanks.

jiten

nErBoS

Hi,

My script have some bad inputs, but its has been made one i don't recall who made it, just search in the "Resquest Script" section. Can you post the script of phatty that you use.

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

jiten

here it's:

--Lance Evol v1.01
--Hider Bot, this one does not give the nick taken error ;)
--Written by Phatty 12th December 2k3
--little update today ehmm today issss 14th april 2k4

Bot = "?bot?" ;
Hidden = {}

function NewUserConnected(user)
   if Hidden == nil then
      return 1;   else
      for i,v in Hidden do
         user:SendData( "$Quit "..i ) ;
      end;
   end;
end;

OpConnected = NewUserConnected

function DataArrival(user, data)
   if(strsub(data, 1, 5) == "$Quit") then
      if Hidden[user.sName] == 1 then
         Hidden[user.sName] = nil;
      end
   elseif strsub(data, 1, 1) == "<" then
      local data=strsub(data,1,strlen(data)-1)
      local s,e,cmd = strfind(data,"%b<>%s+(%S+)")
      
      if cmd == "!hide" and user.bOperator then
         SendToAll( "$Quit "..user.sName )
         Hidden[user.sName] = 1;
      return 1

      elseif cmd == "!unhide" and user.bOperator then
         SendToAll( "$Hello "..user.sName )
         Hidden[user.sName] = nil;
      return 1
      end;
   end;
end;

nErBoS

Hi,

Here is the script improved...

--Lance Evol v1.01 
--Hider Bot, this one does not give the nick taken error ;) 
--Written by Phatty 12th December 2k3 
--little update today ehmm today issss 14th april 2k4 
--Update on Saving Table by nErBoS
--User still hide by refresh list by nErBoS

Bot = "?bot?" ; 
Hidden = {} 
fHidden = "hidden.dat"

--## Configuration ##--

uLaterPtokax = 0	-- Choose 0 if your Ptokax Version is 0.3.3.0 or higher
			-- Choose 1 if your Ptokax Version is lower then 0.3.3.0

--## END ##--

function Main()
	frmHub:EnableFullData(1)
	LoadFromFile(fHidden)
end

function OnExit()
	SaveToFile(fHidden , Hidden , "Hidden")
end

function NewUserConnected(user) 
	if (Hidden[user.sName] ~= nil) then
		SendToAll("$Quit "..user.sName)
	end
	if Hidden ~= nil then 
		for i,v in Hidden do 
			user:SendData("$Quit "..i)
		end
	end
	return 1
end

OpConnected = NewUserConnected 

function DataArrival(user, data) 
	if(strsub(data, 1, 5) == "$Quit") then 
		if Hidden[user.sName] == 1 then 
			Hidden[user.sName] = nil
			if (uLaterPtokax == 1) then
				OnExit()
			end
		end 
	elseif strsub(data, 1, 1) == "<" then 
		local data=strsub(data,1,strlen(data)-1) 
		local s,e,cmd = strfind(data,"%b<>%s+(%S+)") 
		if cmd == "!hide" and user.bOperator then 
			SendToAll( "$Quit "..user.sName ) 
			Hidden[user.sName] = 1 
			if (uLaterPtokax == 1) then
				OnExit()
			end
			return 1 
		elseif cmd == "!unhide" and user.bOperator then 
			SendToAll( "$Hello "..user.sName ) 
			Hidden[user.sName] = nil
			if (uLaterPtokax == 1) then
				OnExit()
			end
			return 1 
		end
	elseif strsub(data, 1, 8) == "$GetINFO" then
		local s,e,who = strfind(data, "%$GetINFO%s+(%S+)")
		if (Hidden[who] ~= nil) then
			user:SendData("$Quit "..who )
			return 1
		end
	end
end

function Serialize(tTable, sTableName, sTab)
	assert(tTable, "tTable equals nil");
	assert(sTableName, "sTableName equals nil");

	assert(type(tTable) == "table", "tTable must be a table!");
	assert(type(sTableName) == "string", "sTableName must be a string!");

	sTab = sTab or "";
	sTmp = ""

	sTmp = sTmp..sTab..sTableName.." = {\n"

	for key, value in tTable do
		local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);

		if(type(value) == "table") then
			sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
		else
			local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
			sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
		end

		sTmp = sTmp..",\n"
	end

	sTmp = sTmp..sTab.."}"
	return sTmp
end

function SaveToFile(file , table , tablename)
	writeto(file)
	write(Serialize(table, tablename))
	writeto()
end

function LoadFromFile(file)
	if (readfrom(file) ~= nil) then
		readfrom(file)
		dostring(read("*all"))
		readfrom()
	end
end

It only fails when the user connect or reconnects, but the OP only have to use the Hide command and all will be fixed.

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

nErBoS

Hi,

Mutor by using RegBot() and UnregBot() you will get the same error from my older script "Your nick is already taken". Its better to use $Quit as fake info.

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

nErBoS

Hi.

I have just tried out, try to hide yourself then refresh the userlist then unhide your self, then reconnect (i have tried that with your script and "The nick you are using is reserved for someone other. Change your nick and get back again.")

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

Herodes

Yeah I've been having the same problems with this ....

I solved the problem with what u describe nErBoS but then I got another one .. so no real solution here I am afraid ...

nErBoS

Hi,

Ok you have the problem because you use the RegBot and UnregBot(), try only to use "$Quit" and "$Hello", the only parts that is still missing on the script above edit by me is when the user reconnects it won't hide (since the user is in the hide table).

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

SMF spam blocked by CleanTalk