Request prefix in description
 

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

Request prefix in description

Started by -PT-B2S, 02 October, 2005, 21:57:21

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

-PT-B2S

Hello.

I want a script that sends a message to the user if he doesn't have a prefix in the discription... The script will have to check if the discription contains this:

[Sapo]           or
[NetCabo]     or
[Clix]             or
[Oni]             or
[NetVis?o]

etc...


If the discription doesn't contain this, then the user will receive a request to put it.

Thnks and good scripts


.

bastya_elvtars

#1
Totally untested. :)

-- needed tag in description
-- bastya_elvtars

opsexcluded=1 -- ops won't be checked, set 0 or 1

Pref=
  {
    "[test]",
    "[test2]",
  }
  
-- do not edit below plz

function MyINFOArrival(user,data)
  if (opsexcluded==1 and user.bOperator) or not user.bConnected then return 1 end -- we stop, if user is op and wanna exclude them
  local_,_,pref=string.find(user.sDescription,"^%b[]") -- find the tag
  if not Prefixes[pref] then -- and see if it is in the needed ones
    user:SendPM(Bot.name,"Please add a prefix to your description, allowed are: \r\n"..table.concat(Pref,"\r\n"))
  end
end

function Main()
  Prefixes=nil
  collectgarbage(); io.flush()
  Prefixes={} -- we empty the bun and clooect the garbage
  for _,v in ipairs(Pref) do
    Prefixes[v]=1 -- adding to a table ---> very fast lookup on myinfo arrival
  end
end

-- // Edit

Added so only logged in users' myinfos count (thus, not the 1 or 2 ones sent on login).
Everything could have been anything else and it would have just as much meaning.

-PT-B2S

Thanks bastya_elvtars

How do i do to send this messages periodically, (like 5 in five minutes) ?

Props

bastya_elvtars

QuoteOriginally posted by -PT-B2S
Thanks bastya_elvtars

How do i do to send this messages periodically, (like 5 in five minutes) ?

Props

It sends everytime a MyINFO arrives. The timer way would kill the hub PC. :)
Everything could have been anything else and it would have just as much meaning.

-PT-B2S

#4
hi again,

I put this:

-- needed tag in description
-- bastya_elvtars

sBot = "[BOT]Hahn?Team"

Pref=
  {
    "[Sapo]",
    "[NetCabo]",
    "[NetVis?o]",
    "[OniNet]",
    "[Clix]", 
  }
  
-- do not edit below plz

function MyINFOArrival(user,data)
	local_,_,pref=string.find(user.sDescription,"^%b[]") -- find the tag
	if not Prefixes[pref] then -- and see if it is in the needed ones
		user:SendPM(sBot,"\r\n\r\n\tPor favor p?e o nome do teu ISP na tua descri??o. \r\n\tP?e da seguinte forma para que n?o sejas avisado de novo : \r\n\r\n\t[NetCabo] ; [Sapo] ; [NetVis?o] ; [Clix] ; [OniNet] ; etc... \r\n\r\n\tSe n?o tiveres desta forma, estar?s sempre a ser avisado! Obrigado!")
	end
end

function Main()
  Prefixes=nil
  collectgarbage(); io.flush()
  Prefixes={} -- we empty the bun and clooect the garbage
  for _,v in ipairs(Pref) do
    Prefixes[v]=1 -- adding to a table ---> very fast lookup on myinfo arrival
  end
end



The script sends me the message 2 times when i enter the hub, even if i have [NetCabo] in the discription.

Maybe this one could give you an help:

--=[ Nome dos Bots ]=- 
 
sBot = "--=( DvdRip )=--"  
 
sOpChatName = "--=( Opchat )=--" 
 
 
	--=[ Configura??o ]=- 
 
	--=[ Insere aqui os prefixos ]=- 
  
sPrefix = { "[CV]" ,} 
 
	--=[ Insere aqui as rangs dos users CV ]=- 
 
arrIP = {  
   ["10.6.0.0"] = "10.6.0.30", 
   ["84.90.0.0"] = "84.91.255.255",      --  Cabovisao,SA 
   ["213.228.128.0"] = "213.228.191.255",   --  Cabovisao,SA 
   ["217.129.0.0"] = "217.129.255.255",      --  Cabovisao,SA 
} 
 
	--=[ C?digo ]=- 
 
function Main() 
	frmHub:RegBot(sBot)  
end  
 
function NewUserConnected(user)  
	if (CheckUserPrefix(user) == nil) and not (isGoodIP(user.sIP) == nil) then  
		user:SendPM(sBot, "\r\n\r\n        ---={}=-- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- --={}=---\r\n\r\n                       DvdRip.sytes.net:411\r\n\r\n                       Boas caro utilizador.\r\n                       Vimos por este meio informar que foram postam novas regras em vigor no Hub.\r\n                       Ter?s que acrescentar o prefixo [CV] no teu nickname para puderes efectuar downloads no Hub.\r\n\r\n                          Ex: [CV]user\r\n\r\n                       Estar?s a perguntar a ti mesmo porque temos tal regras no hub. Mas eu explico.\r\n                       Todos sabemos que temos uns fornecedores de Internet [ ISP?s ] muito fatelas, \r\n                      pagamos servi?os que n?o uzamos entre outras injusti?as.\r\n                       No caso do Fornecedor SAPO Adsl ? bastante grave porque todos os downloads que eles fazem\r\n                      dos utilizadores CaboVis?o ou Telepac contam como internacional.\r\n                       Dai existir tal regra. Se todos os Utilizadores usarem uma TAG a mencionar o Fornecedor \r\n                      de Internet [ ISP ] que utiliza, os users podem gerir os seus downloads e tb ter certezas\r\n                      da fonte dos mesmos.\r\n\r\n                       Esta regra ? para ser aplicada. Aviza-mos que quem n?o a cumprir ser? Banido do Hub.\r\n\r\n                       Colaborem n?o custa nada.\r\n\r\n                       DvdRip.sytes.net  -? N?o somos melhores nem piores. Apenas difer?ntes ?-\r\n\r\n                       ---={}=--  Bons Downloads  --={}=---\r\n\r\n        ---={}=-- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- --={}=---\r\n") 
		SendPmToOps(sOpChatName, "	--=( O utilizador "..user.sName.." foi requisitado para usar o prefixo [CV] )=--") 
	end  
end  
 
OpConnected = NewUserConnected  
 
function ConnectToMeArrival(user,data) 
	if (CheckUserPrefix(user) == nil) and (isGoodIP(user.sIP) ~= nil) then  
		user:SendData(sBot, "\r\n\r\n        ---={}=-- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- --={}=---\r\n\r\n                       DvdRip.sytes.net:411\r\n\r\n                       Boas caro utilizador.\r\n                       Vimos por este meio informar que foram postam novas regras em vigor no Hub.\r\n                       Ter?s que acrescentar o prefixo [CV] no teu nickname para puderes efectuar downloads no Hub.\r\n\r\n                          Ex: [CV]user\r\n\r\n                       Enquanto n?o o fizeres, ficas impossibilitado de efectuar downloads no Hub.\r\n\r\n        ---={}=-- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- --={}=---.") 
		return 1 
	end 
end 
 
RevConnectToMeArrival = ConnectToMeArrival 
 
function CheckUserPrefix(user) 
	for key,pre in sPrefix do  
		if string.find(string.lower(user.sName), string.lower(pre),1,1) then  
			return 1  
		end  
	end  
end 
 
function isGoodIP(sIP)  
	sIP = ipToNumber(sIP)  
	local iFirst,iLast  
	for iFirst, iLast in arrIP do  
		if (sIP >= ipToNumber(iFirst) and sIP <= ipToNumber(iLast)) then  
			return 1  
		end  
	end  
	return nil  
end  
 
function ipToNumber(sIP)  
	iAux = ""  
	string.gsub(sIP,"(%d+)", function(w)  
		w = tonumber(w)  
		if (w < 10) then  
			iAux = iAux.."00"..w  
		elseif (w < 100) then  
			iAux = iAux.."0"..w  
		else  
			iAux = iAux..w  
		end  
	end)  
	return tonumber(iAux)  
end
 

Thanks and props


.

bastya_elvtars

Edited the above post, now accepts myinfos from logged-in users only.
Everything could have been anything else and it would have just as much meaning.

SMF spam blocked by CleanTalk