Nick exception on IPBot
 

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

Nick exception on IPBot

Started by user, 18 June, 2005, 18:37:09

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

user

Hello everyone!

Thanks in advance for anyone who could help me with this:

Since some ISP charge heavy download costs from internacional IPs, i can only allow a certain range of IPs to get in.

This script is working fine, but now i need a nick exception - That is, add a line in the code just to prevent certain nicknames from being disconnected, so they could join no matter their IP.

Bot = "Bot-name" 
oAllow={} 
function splittip(IP) 
r,g,a,b,c,d = strfind(IP, "(%d*).(%d*).(%d*).(%d*)") 
d=a.."."..b.."."..c.."."..d 
c=a.."."..b.."."..c..".*" 
b=a.."."..b..".*" 
a=a..".*" 
return a,b,c,d 
end 
function Main() 
frmHub:RegBot(Bot)
oAllow["127.0.0.1"] =1
oAllow["192.168.0.*"] =1
oAllow["62.48.128.*"] =1
oAllow["62.48.134.*"] =1
oAllow["62.48.135.*"] =1
oAllow["62.48.136.*"] =1

and goes.. and goes.... 

oAllow["217.112.207.*"] =1
oAllow["217.129.*"] =1
end 
function NewUserConnected(curUser) 
theIP=curUser.sIP 
local a,b,c,d=splittip(theIP) 
if ((oAllow[a]==1)or(oAllow[b]==1)or(oAllow[c]==1)or(oAllow[d]==1)) then 
else 
curUser:SendPM(Bot,"MESSAGE TO SEND") 
curUser:Disconnect() 
end 
end


Thank you all!

jiten

Give this a try (Lua 4 one):
Bot = "Bot-name" 

oAllow={} 
oAllow["127.0.0.1"] =1
oAllow["192.168.0.*"] =1
oAllow["62.48.128.*"] =1
oAllow["62.48.134.*"] =1
oAllow["62.48.135.*"] =1
oAllow["62.48.136.*"] =1
oAllow["217.112.207.*"] =1
oAllow["217.129.*"] =1

tImmune = { ["nick1"] = 1, ["nick2"] = 1, } -- Immune nicks. Ex: ["nick"] = 1,

Main = function() 
	frmHub:RegBot(Bot)
end 

NewUserConnected = function(curUser) 
	theIP=curUser.sIP 
	local a,b,c,d=splittip(theIP) 
	if not tImmune[curUser.sName] then
		if not ((oAllow[a] == 1) or (oAllow[b] == 1) or (oAllow[c] == 1) or (oAllow[d] == 1)) then 
			curUser:SendPM(Bot,"MESSAGE TO SEND") 
			curUser:Disconnect() 
		end 
	end
end

splittip = function(IP) 
	r,g,a,b,c,d = strfind(IP, "(%d*).(%d*).(%d*).(%d*)") 
	d=a.."."..b.."."..c.."."..d 
	c=a.."."..b.."."..c..".*" 
	b=a.."."..b..".*" 
	a=a..".*" 
	return a,b,c,d 
end

Dessamator

hmm, indeed but that script is messsy, even i cant make heads or tails of it, hehe, no tabs no nothing,

its always better to separate functions from constant variables(in my opinion)

 :)
Ignorance is Bliss.

user

Thank you very much for your useful reply!
I'm using this script and there is no problems at all :)
I just want to change the following:

QuoteOriginally posted by Mutor
I'm not thrilled with populating the table in function Main() but it's easier to see the difference if I leave the script as it was so...

A quick edit...

Bot = "Bot-name" 
oAllow={}
nAllow={} 
function splittip(IP) 
r,g,a,b,c,d = strfind(IP, "(%d*).(%d*).(%d*).(%d*)") 
d=a.."."..b.."."..c.."."..d 
c=a.."."..b.."."..c..".*" 
b=a.."."..b..".*" 
a=a..".*" 
return a,b,c,d 
end 
function Main() 
frmHub:RegBot(Bot)
oAllow["127.0.0.1"] =1
oAllow["192.168.0.*"] =1
oAllow["62.48.128.*"] =1
oAllow["62.48.134.*"] =1
oAllow["62.48.135.*"] =1
oAllow["62.48.136.*"] =1
oAllow["217.112.207.*"] =1
oAllow["217.129.*"] =1
--Add Nicks here
nAllow["UserNick1"] =1
nAllow["UserNick2"] =1
end 
function NewUserConnected(curUser)
if nAllow[curUser.sName] ==1 then return 1 end
theIP=curUser.sIP 
local a,b,c,d=splittip(theIP) 
if ((oAllow[a]==1)or(oAllow[b]==1)or(oAllow[c]==1)or(oAllow[d]==1)) then 
else 
curUser:SendPM(Bot,"MESSAGE TO SEND") 
[COLOR=red]curUser:Disconnect()[/COLOR]
end 
end
How can i make this script REDIRECT or TEMPBAN instead of disconnect ?

My thanks in advance!

Madman

#4
QuoteOriginally posted by user
How can i make this script REDIRECT or TEMPBAN instead of disconnect ?

My thanks in advance!

Relpace the disconnect line with one of thesee

curUser:TempBan() -- The time user gets timebanned for is specified in PtokaX.
curUser:TimeBan(TimeInMinutes) -- The time user gets timebanned for is specified here.
curUser:Redirect(Address, Reason) -- Redirect user to Address, with Reason. Reason is optional.
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

user

QuoteOriginally posted by madman

Relpace the disconnect line with one of thesee

curUser:TempBan() -- The time user gets timebanned for is specified in PtokaX.
curUser:TimeBan(TimeInMinutes) -- The time user gets timebanned for is specified here.
curUser:Redirect(Address, Reason) -- Redirect user to Address, with Reason. Reason is optional.

Can i use both?

Example, i replace the disconnect line with curUser:TempBan() and in the next line curUser:Redirect(Address, Reason)  so the user would get temporary banned AND  redirected.

And if i also want to have a message sent to main chat like "The user NICKNAME  using IP  has been redirected" (replacing Underlined terms by the right ones) how should i do?


Thank you.

Dessamator

hmm, using both im unsure, if u redirect first, there will be no user to ban, and if u ban first there will be no user to redirect(in theory), but u could store the ip and ban it.

for the message thingy write something like this :
SendToOps("bot","The user "..curUser.sName.." using IP : "..curUser.sIP.." has been redirected!")
Ignorance is Bliss.

SMF spam blocked by CleanTalk