[Mod] Temp Privs [temp_privs]

Post Reply
User avatar
ChimneySwift
Member
Posts: 320
Joined: Fri Sep 22, 2017 06:46
GitHub: ChimneySwift
IRC: ChimneySwift
In-game: ChimneySwift
Location: 127.0.0.1

[Mod] Temp Privs [temp_privs]

by ChimneySwift » Post

Temp Privs

Overwrites the default grant, grantme and revoke chatcommands to add revoke or grant expiration.

GitHub
ZIP Download

Code license: MIT

Dependencies: None

Usage

The default commands still work for permanant grants and revokes, however you can optionally select a time period whereby the revoke/granting will be reverted.

grant <playername> <time-optional> <privstring>
grantme <time-optional> <privstring>
revoke <playername> <time-optional> <privstring>

<time> syntax:
  • 1s - one second.
  • 1m - one minute.
  • 1h - one hour.
  • 1D - one day (24 hours).
  • 1W - one week (7 days).
  • 1M - one month (30 days).
  • 1Y - one year (360 days).
A spoon is basically a tiny bowl with a stick on it

User avatar
KatzEyez
Member
Posts: 52
Joined: Tue Aug 08, 2017 18:24
GitHub: KatzPetz
IRC: LadyK
In-game: LadyK
Location: (IG: Depends) (RL: USA)

Re: [Mod] Temp Privs [temp_privs]

by KatzEyez » Post

I like this one, because there have been times where I forgot to revoke spill on a player after granting it to them temporarily. I could just say "/grant <player> 1h spill" and not have to worry about making sure I remember to revoke it later on.
I can see it working well the other way too. If two players are arguing with one another, instead of banning them, you would give them a time out by suspending their privs temporarily perhaps. "/revoke <player> 10m shout". Once they're allowed to talk again, if the situation continues or escalates, then you can move forward with other punishments as you normally would. This strengthens warnings as well as allows mods/admins to take control of a situation in a different way.
I don't understand the coding, so I'm curious if this will also tell the player that this isn't a permanent action and how long it will last?
Why wish upon a star when you can pray to the one who created it.

User avatar
Lone_Wolf
Member
Posts: 2595
Joined: Sun Apr 09, 2017 05:50
GitHub: LoneWolfHT
IRC: LandarVargan
In-game: LandarVargan

Re: [Mod] Temp Privs [temp_privs]

by Lone_Wolf » Post

Great for servers +(infinity)
My ContentDB -|- Working on CaptureTheFlag -|- Minetest Forums Dark Theme!! (You need it)

User avatar
ChimneySwift
Member
Posts: 320
Joined: Fri Sep 22, 2017 06:46
GitHub: ChimneySwift
IRC: ChimneySwift
In-game: ChimneySwift
Location: 127.0.0.1

Re: [Mod] Temp Privs [temp_privs]

by ChimneySwift » Post

KatzEyez wrote:I don't understand the coding, so I'm curious if this will also tell the player that this isn't a permanent action and how long it will last?
It modifies the granting/revoking messages so on the end it will add how long the grant/revoke was for.

For example:
  • ChimneySwift granted you privileges: kick for: 1h
  • ChimneySwift revoked privileges from you: kick for: 1h
  • ChimneySwift granted you privileges: fly for: indefinitely
That string also shows up in the logs and in the message sent to the kicker/revoker.

If the player is online at the time their temporary grant/revoke expires, they will be sent a message like this:
  • Revoked privileges from you: fast (expired)
A spoon is basically a tiny bowl with a stick on it

User avatar
ThomasMonroe
Member
Posts: 286
Joined: Tue Apr 04, 2017 16:21
GitHub: ThomasMonroe314
IRC: ThomasMonroe TMcSquared
In-game: ThomasMonroe TMcSquared
Location: Wherever I am at

Re: [Mod] Temp Privs [temp_privs]

by ThomasMonroe » Post

This will come in handy for Legends Of Survival! :)
I don't make messes, I just, er...disturb the local entropy!

User avatar
ChimneySwift
Member
Posts: 320
Joined: Fri Sep 22, 2017 06:46
GitHub: ChimneySwift
IRC: ChimneySwift
In-game: ChimneySwift
Location: 127.0.0.1

Re: [Mod] Temp Privs [temp_privs]

by ChimneySwift » Post

Fixed an issue where /revoke <playername> <time-optional> all didn't work.

Also resolved a bug where revoking a privilege the user didn't have for an amount of time would cause that privilege to be granted to them after the time ran out.
A spoon is basically a tiny bowl with a stick on it

User avatar
ManElevation
Member
Posts: 896
Joined: Tue Aug 02, 2016 22:04
GitHub: ManElevation
IRC: ManElevation
In-game: ManElevation
Location: Madrid,Spain

Re: [Mod] Temp Privs [temp_privs]

by ManElevation » Post

+1
My Public Mods! Discord: Rottweiler Games#3368

User avatar
Linuxdirk
Member
Posts: 3231
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

Re: [Mod] Temp Privs [temp_privs]

by Linuxdirk » Post

ChimneySwift wrote:Overwrites the default […]
Don’t do that.

User avatar
ChimneySwift
Member
Posts: 320
Joined: Fri Sep 22, 2017 06:46
GitHub: ChimneySwift
IRC: ChimneySwift
In-game: ChimneySwift
Location: 127.0.0.1

Re: [Mod] Temp Privs [temp_privs]

by ChimneySwift » Post

Linuxdirk wrote:
ChimneySwift wrote:Overwrites the default […]
Don’t do that.
I'm sorry but you didn't exactly elaborate to tell me exactly what not to do or why not to do it.

The default commands still work exactly the same as they do in default Minetest, and much of the code which handles the revoking and granting of privileges is derived from default Minetest.
A spoon is basically a tiny bowl with a stick on it

ShadMOrdre
Member
Posts: 1118
Joined: Mon Dec 29, 2014 08:07
Location: USA

Re: [Mod] Temp Privs [temp_privs]

by ShadMOrdre » Post

When granting a user multiple privs in one shot, ie, /grant UserName fast, fly, home, this mod fails. It attempts to grant fly and home privs for "fast" length of time.

Since the time param is optional, this will always fail. So my recommendation is that you use some identifier to specify indefinite, instead of relying on the absense of the time param. And yes, since you override builtin for this, you might want to make sure that privs checks are done, and enforced, on the user granting said privs. You might want to consider figuring out a way to add to builtin instead of override, or as suggested above, send a PR to have this added to builtin.

EDIT: On second thought, maybe just a different chatcommand, say, /grant_temp, so that you don't have to override builtin. This should be considered if PR to add this to builtin is denied.

I like this concept alot, so thanks for making this mod. Please consider above comments.

Shad

User avatar
ChimneySwift
Member
Posts: 320
Joined: Fri Sep 22, 2017 06:46
GitHub: ChimneySwift
IRC: ChimneySwift
In-game: ChimneySwift
Location: 127.0.0.1

Re: [Mod] Temp Privs [temp_privs]

by ChimneySwift » Post

ShadMOrdre wrote:When granting a user multiple privs in one shot, ie, /grant UserName fast, fly, home, this mod fails. It attempts to grant fly and home privs for "fast" length of time.

Since the time param is optional, this will always fail. So my recommendation is that you use some identifier to specify indefinite, instead of relying on the absense of the time param. And yes, since you override builtin for this, you might want to make sure that privs checks are done, and enforced, on the user granting said privs. You might want to consider figuring out a way to add to builtin instead of override, or as suggested above, send a PR to have this added to builtin.
Sounds like a definite issue, have you tried entering the priv string without spaces? I'm pretty sure I tested with multiples but I never used spaces.

I will definitely investigate, if this works with the default commands it should work with this mod too.
ShadMOrdre wrote: EDIT: On second thought, maybe just a different chatcommand, say, /grant_temp, so that you don't have to override builtin. This should be considered if PR to add this to builtin is denied.
I don't personally like having multiple commands for this, but I guess if I can't get it to work exactly like default with or without the time I'll have to consider it.

Above all thank you for submitting this issue.
A spoon is basically a tiny bowl with a stick on it

User avatar
Linuxdirk
Member
Posts: 3231
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

Re: [Mod] Temp Privs [temp_privs]

by Linuxdirk » Post

ChimneySwift wrote:The default commands still work exactly the same as they do in default Minetest, …
Obviously they don’t. This is one of the reasons not to override defaults.

User avatar
ChimneySwift
Member
Posts: 320
Joined: Fri Sep 22, 2017 06:46
GitHub: ChimneySwift
IRC: ChimneySwift
In-game: ChimneySwift
Location: 127.0.0.1

Re: [Mod] Temp Privs [temp_privs]

by ChimneySwift » Post

Linuxdirk wrote:
ChimneySwift wrote:The default commands still work exactly the same as they do in default Minetest, …
Obviously they don’t. This is one of the reasons not to override defaults.
Yes, that's obviously a bug, this is still a WIP mod and thus not guaranteed to work as advertised, the "final" version won't have this issue.
A spoon is basically a tiny bowl with a stick on it

User avatar
ChimneySwift
Member
Posts: 320
Joined: Fri Sep 22, 2017 06:46
GitHub: ChimneySwift
IRC: ChimneySwift
In-game: ChimneySwift
Location: 127.0.0.1

Re: [Mod] Temp Privs [temp_privs]

by ChimneySwift » Post

ShadMOrdre wrote:When granting a user multiple privs in one shot, ie, /grant UserName fast, fly, home, this mod fails. It attempts to grant fly and home privs for "fast" length of time.
This issue is now resolved.

If the time value cannot be converted to seconds via the parse_time() function, it will act as though the time value is part of the priv string.
A spoon is basically a tiny bowl with a stick on it

Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 6 guests