Prefix/tag checker
 

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

Prefix/tag checker

Started by miago, 12 January, 2007, 12:03:44

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

miago

Hi everybody.

I have been looking around everywhere but havent found any script that does the things that I would like, so I would be really glad if someone could help me out (or tell me if there's a script like this that i havent found that maybe can be modified).

I'm using Ptokax 0.3.5.2 with Robocop 10.023.

This is what I would like the script to do.

When a user connects to the hub, the script checks the nickprefix and tag settings according to the rules set for that nickprefix ( [1Mbit]nick or [10Mbit]nick and so on)
If the check shows that the user hasent slots/hubs settings according to the rules, they will be kicked with a message and the op-chat will also receive info about the kick.

Example of rulessettings for the nickprefixes:

Prefix         Min/max slots        Max hubs
[1Mbit]       1/2                     2
[2Mbit]       2/3                     4

and so on

I know ynhub has the options of profilesettings and rules, but we just love ptokax so there wont be any hubsoft changes :D

If any1 feels to help me with this I would be really really happy =D

Thx in advance // Miago

Edit: Forgot, it should only check users with the profile "reg"
Being a biatch aint easy ;)

Caali

Since i'm also using Ptokax too i would like a script like that miago said. Would be super nice if someone could make it :)

// Caali

miago

Thx Mutor for your answer :)

QuoteAFAIK, Robocop already has these options per profile.
If not using RC, these scripts already exist.

Yes we are using RC, but it's not per profile-level that I want this check done but on the nickprefix (we already have different rules per profile regarding slots/hubs and share)

QuoteExample of rulessettings for the nickprefixes:

Prefix        Min/max slots        Max hubs
[1Mbit]      1/2                     2
[2Mbit]      2/3                     4

and so on

I would like this check to be done on only RC's reg-profile (and for reg-profile I would like to have different rules on hub/slot settings according to the nick-prefix as I tried to explain above).

Maybe I'm not good at explaining ...  :-[

Thx again for all your help
//miago
Being a biatch aint easy ;)

miago

Hi again.

Thank you for clearing me out  ;)

I think you can be right about the tag-conflict, but since I'm no scripter I have no clue.
I know You guys are awsome and maybe this is not possible to do, so, if that's the case our operators will just have to work manually  ;D

Thank you again
// "miss" miago   ;)

Being a biatch aint easy ;)

CrazyGuy

It's not that it's not possible, but it won't be easy.
Besides that, I do also think it will conflict with RoboCop sooner or later.
Maybe if the script runs above RoboCop it could work, but then again, we won't know til we try

miago

Thanx for the reply =)

If any of You guys have the will and lust and time to try to make this script, I sure will test it inside-out and upside-down :D
But, don't do it unless You think it's worth while..

Many Thx again
//miago
Being a biatch aint easy ;)

miago

Thx Mutor!!

Gonna try it now...  :D

Will be back with comments and so on as soon as I can..

//miago   :-*
Being a biatch aint easy ;)

miago

When trying to start the script in ptokax I got this:

[22:05] Syntax [string "--[[..."]:79: unfinished long comment near '<eof>'

Being a biatch aint easy ;)

miago

Mutor...You are GREAT!!!!

It works :D

When a user connects with to many slots this comes up in opchat:
[22:41:04] <-opchat-> <TagCheck> [1Mbit]nick has too many slots open. [1Mbit]'s are required to have a maximum of 2 slots open. [1Mbit]nick has 4
[22:41:04] <-opchat-> <TagCheck> [1Mbit]nick has been removed from the hub.

In mainchat u can see this:
[22:46:19] <-Hub-bot-> *** [1Mbit]nick with IP XXX.XXX.XXX.XXX was kicked by TagCheck because: You have too many slots open. [1Mbit]'s are required to have a maximum of 2 slots open. You have 4

The user gets this when trying to connect:
*** Connecting to XXXXXXX...
[22:44] *** Connected
[22:44] *** Stored password sent...
[22:44] <TagCheck> You have too many slots open. [1Mbit]'s are required to have a maximum of 2 slots open. You have 4
[22:44] <-Hub-bot-> You are being kicked because: You have too many slots open. [1Mbit]'s are required to have a maximum of 2 slots open. You have 4
[22:44] *** Disconnected

If a user is already connected and then increases the amount of slots he/she gets the same as above and op-chat gets it and its shown in main (for op and above only ofcourse).

Soooooo great!!!!!!  :D :D

The only strange thing is that this appears now and then in mainchat:
[22:45:22] <TagCheck> [1Mbit]
[22:48:35] <TagCheck> [1Mbit]

I haven't had time to check to few slots and hubs, but I'll try to do that tomorrow, the bed is calling for me now :)

Thx and thx again for all the help!!!

//Happy miss-miago   :-*

Being a biatch aint easy ;)

miago

Thx again...

Not so easy for a non-scripter :D

Too few slots tested and works fine...now only too many hubs left to test...but that will have to wait to tomorrow...

Again, thanks Mutor!!!!!!!!!

Wish U a good nights sleep now   :D

//miago
Evening everybody.

All settings are tested and works really really fine  :D

I was just wondering, is it possible to change the "Kick" to "Disconnect" or "Drop" or something maybe? Users are often fast in changing to the according slot/hubs, so it feels a little bit hard to have them being kicked for 20 min or whatever one has in the settings.

Maybe this is easy fixed by just replacing some words but as before, this is really not my field   :)

Have a nice fridayevening  :)

//Miago
Being a biatch aint easy ;)

miago

Thx Mutor.

Gonna try it out.

:D

//Miago

Edit: Works fine. Thank you again. Great as always :)
Hi again...me here =D

One question...is there a way to put in a parameter/variable in the beginning of the script that states that it looks/checks at the prefix of the user no matter if there are capitals (is that the word in english? I mean like T or M or I and so on ) or versals (dont know if thats the right word, but like t or m or i and so on)? 
Eg:
1Mbit or 1mbit or 1mbIt or 1mbiT and so on....

Thanx in advance...again...miago  =D

PS sorry for my poor english...
Being a biatch aint easy ;)

bastya_elvtars

#11
A fast hack, untested...

--[[

	TagCheck 1.0 LUA 5.1
	By Mutor	01/21/07
	
	Requested by miago
	
	Checks min/max slots and max hubs for specified reg prefix tags
	
]]
-- case insensivity by bastya_elvtars, 08/02/07
-- fixed a possible nil bug when the preconfigged nick is offline by bastya_elvtars, 08/02/07

--Script configuration
Cfg = {
-- Admin's nick for status / error messages
OpNick = "Mutor",
-- Name for bot
Bot = "TagCheck",
-- Profile to check
Profile = 3,
--["Tag"] = {minslots,maxslots,maxhubs}.
--Tag is case insensitive // b_e
Params = {
	["[1Mbit]"] = {2,2,2},
	["[2Mbit]"] = {2,3,4},
	},
}

Main=function()
  for k,v in pairs(Cfg.Params) do
    Cfg.Params[k:lower()]=v
    Cfg.Params[k]=nil
  end
end

OnError = function(msg)
  local c=GetItemByName(Cfg.OpNick)
  if c then c:SendData(Cfg.Bot, msg) end
end

MyINFOArrival = function(user,data)
	if user.iProfile == Cfg.Profile then
		local s,e,tag = string.find(user.sName,"^(%b[]).+")
		if tag then
			OnError(tag)
			if Cfg.Params[tag] then
				CheckUser(user,string.lower(tag))
			else
				OnError(GetProfileName(user.iProfile).." "..user.sName.." is using an invalid prefix tag")
			end
		else
			OnError(GetUserProfile(user.sName).." "..user.sName.." is missing a prefix tag")
		end
	end
end

CheckUser = function(user,tag)
	local Msg,Kick = "",false
	for i,v in ipairs(Cfg.Params[tag]) do
		if i == 1 and user.iSlots < v then
			Msg = Msg.."You have too few slots open. "..tag.."'s are required to have a minimum of "..
			v.." slots open. You have only "..user.iSlots
			Kick = true
			break
		elseif i == 2 and user.iSlots > v then
			Msg = Msg.."You have too many slots open. "..tag.."'s are required to have a maximum of "..
			v.." slots open. You have "..user.iSlots
			Kick = true
			break
		elseif i == 3 and user.iHubs > v then
			Msg = Msg.."You are in too many hubs. "..tag.."'s are required to have a maximum of "..
			v.." hub connections. You are connected to "..user.iHubs
			Kick = true
			break
		end
	end
	if Kick then
		local nick = user.sName
		local OpMsg = string.gsub(Msg,"You have", user.sName.." has")
		OpMsg = string.gsub(OpMsg,"You are", user.sName.." is")
		SendToOpChat("<"..Cfg.Bot.."> "..OpMsg)
		user:SendData(Cfg.Bot,Msg)
		user:Kick(Cfg.Bot,Msg)
		if not GetItemByName(nick) then
			SendToOpChat("<"..Cfg.Bot.."> "..nick.." has been removed from the hub.")
		end
	end
end
Everything could have been anything else and it would have just as much meaning.

bastya_elvtars

1) Your OnError() is still flawed, I recommend introducing a nil check, else the script will stop if the preconfigured nick is offline.
2) I have addressed the lowercase problem by simply converting all keys to lowercase in the table on Main(). Therefore the string.lower()'d prefix is always OK with the table, whatever format it is added in.
Everything could have been anything else and it would have just as much meaning.

bastya_elvtars

Quote from: Mutor on 09 February, 2007, 02:29:13
The original OnError function [offered by NightLitch] is flawed
in that a nil error will be raised if nick is offline. This was a test for that statement.
My current is not flawed as Px will not propagate an error if nick is offline.
It did for me.
Quote from: Mutor on 09 February, 2007, 02:29:13
I'm well aware of your intent with string.lower in main.
I still find it better/easier to just use lower case indices.
As well as less code. To each his own.
My way ensures less need for end-user brain power. ;)
Everything could have been anything else and it would have just as much meaning.

bastya_elvtars

Quote from: Mutor on 09 February, 2007, 03:18:07
Yes it does and it is the grander method.
I did say my alternate was the simple one.
SendToNick does not propagate an error for me.
GetItemByName certainly will.

Sorry, overlooked.
Everything could have been anything else and it would have just as much meaning.

miago

Thank You very very much guys!!!
*me happy*  :D

//Miago
Being a biatch aint easy ;)

SMF spam blocked by CleanTalk