[Help Needed] Spam blocker

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

[Help Needed] Spam blocker

by rubenwardy » Fri Aug 10, 2012 21:23

I want to make a server side mod that will read users posts and see if it contains any banned words or is too long (over 1 line)

If it is the player will either recieve a caution or will have shout priv removed.

What i need to do:

1) Register chat send (is there a function for this?)

2) Check if the string contains/contains excessivly ammounts of keywords (strfind (str, substr, [init, [end]])?)

3) Deal punishment accordingly. (something like server.banprivs(player,"shout");)
Last edited by rubenwardy on Fri May 10, 2013 13:44, edited 1 time in total.
 

User avatar
sfan5
Member
 
Posts: 3636
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5

by sfan5 » Fri Aug 10, 2012 21:27

1) yes
3) you mean revoking shout privs
Mods: Mesecons | WorldEdit | Nuke
Minetest builds for Windows (32-bit & 64-bit)
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Sat Aug 11, 2012 10:33

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_on_chat_message(function(name, message)
  local bool = false
  for _,str in ipairs(unalowed_strings) do
    if string.find(message, str) then
      bool = true
      break
    end
  end
  if bool then
    local privs = minetest.get_player_privs(name)
    privs.shout = false
    minetest.set_player_privs(name, privs)
  end
end)

You only have to define a table like this (over the function):
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local unalowed_strings = {"Minecraft", "shit"}


Warning: This code is untested.
 

User avatar
Topywo
Member
 
Posts: 1718
Joined: Fri May 18, 2012 20:27

by Topywo » Sat Aug 11, 2012 10:38

PilzAdam wrote:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local unalowed_strings = {"Minecraft", "shit"}


Lol
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

by rubenwardy » Mon Aug 13, 2012 16:33

Thank you.

Is there a way to cancel the chat message?
Last edited by rubenwardy on Mon Aug 13, 2012 16:34, edited 1 time in total.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

by rubenwardy » Mon Aug 13, 2012 17:19

Here is the code:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local unalowed_strings = {"Minecraft", "shit"}

minetest.register_on_chat_message(function(name, message)
    local count = 0
    for _,str in ipairs(unalowed_strings) do
        if string.find(message, str) then
            count = count +1
            print("SpamBlocker: Banned word found")
        end
    end

    print(string.len(message))

     if string.len(message)>100 then
        print("SpamBlocker: Bigger than allowed")
           count=100
    end

    if count > 2 then
        local privs = minetest.get_player_privs(name)
        privs.shout = false
        minetest.set_player_privs(name, privs)
        print("SpamBlocker: Players privs taken away")
    end
end)
Last edited by rubenwardy on Sat Dec 01, 2012 15:38, edited 1 time in total.
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 28 guests