1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Anti Chat Spam

Discussion in 'Feature Requests' started by Mr. Bean ✅, Apr 19, 2018.

  1. Mr. Bean ✅
    Offline

    Mr. Bean ✅ Member Member

    Joined:
    Mar 3, 2017
    Messages:
    55
    Likes Received:
    5
    Hi, I was wondering if someone could make a plugin that stops people from spamming chat because it can get annoying or really lag people.

    Thanks.
     
    #1
  2. ice cold
    Offline

    ice cold Plugin Developer Plugin Developer

    Joined:
    Oct 24, 2016
    Messages:
    672
    Likes Received:
    67
    salva and me are currently working on one which supports automute and some more cool stuff

    btw next time post an request here https://fougerite.com/forums/requests.12/
     
    #2
  3. Mr. Bean ✅
    Offline

    Mr. Bean ✅ Member Member

    Joined:
    Mar 3, 2017
    Messages:
    55
    Likes Received:
    5
    Oh, nice. I am looking forward to it :)
     
    #3
  4. DreTaX
    Offline

    DreTaX Probably knows the answer... Administrator

    Joined:
    Jun 29, 2014
    Messages:
    3,927
    Likes Received:
    705
    #4
    • Like Like x 1
  5. Mr. Bean ✅
    Offline

    Mr. Bean ✅ Member Member

    Joined:
    Mar 3, 2017
    Messages:
    55
    Likes Received:
    5
  6. ice cold
    Offline

    ice cold Plugin Developer Plugin Developer

    Joined:
    Oct 24, 2016
    Messages:
    672
    Likes Received:
    67
    Event better

    Code (Python):
    __author__ = 'DreTaX'
    __version__ = '1.0'

    import clr
    clr.AddReferenceByPartialName("Fougerite")

    import Fougerite
    import System
    from System import *

    Cooldown = {}
    Detection = {}
    # Seconds that must pass after a player's message before he can send another one.
    FloodSeconds = 3

    class AntiSpam:

        def On_Chat(self, Player, ChatEvent):
            if Player.UID not in Cooldown:
                Cooldown[Player.UID] = TimeSpan.FromTicks(DateTime.Now.Ticks).TotalSeconds
            else:
                calc = TimeSpan.FromTicks(DateTime.Now.Ticks).TotalSeconds - Cooldown[Player.UID]
                if calc < FloodSeconds:
                    ChatEvent.NewText = "    "
                    Player.Message("[color red]PLEASE DONT SPAM")
                    Detection[Player.UID] = Detection[Player.UID] + 1
                    if Detection[Player.UID] == 3:
                        Player.Disconnect()
                        Server.BroadcastNotice(Player.Name + " Has been auto kicked for spamming")
                else:
                    Cooldown[Player.UID] = TimeSpan.FromTicks(DateTime.Now.Ticks).TotalSeconds
                    Detection[Player.UID] = 0

        def On_PlayerDisconnected(self, Player):
            if Player.UID in Cooldown.keys():
                Cooldown.pop(Player.UID)
     
    #6
    • Like Like x 1
  7. Mr. Bean ✅
    Offline

    Mr. Bean ✅ Member Member

    Joined:
    Mar 3, 2017
    Messages:
    55
    Likes Received:
    5


    Great plugin :)
     
    #7
  8. Mr. Bean ✅
    Offline

    Mr. Bean ✅ Member Member

    Joined:
    Mar 3, 2017
    Messages:
    55
    Likes Received:
    5
    All of a sudden I'm not sure why it is not working? I haven't modified it at all and it says error.


    [5/14/2018 7:04:06 AM] [Error] [IronPython] Error in plugin AntiSpam:
    [5/14/2018 7:04:06 AM] [Error] Traceback (most recent call last):
    File "<string>", line 26, in On_Chat
    KeyError: player's user id.

    Do you know when your 'proper' one will be ready because you said you were making one with Juli?
     
    #8
  9. DreTaX
    Offline

    DreTaX Probably knows the answer... Administrator

    Joined:
    Jun 29, 2014
    Messages:
    3,927
    Likes Received:
    705
    Is this from ice's modification?
     
    #9
  10. Mr. Bean ✅
    Offline

    Mr. Bean ✅ Member Member

    Joined:
    Mar 3, 2017
    Messages:
    55
    Likes Received:
    5
    Both of them for some reason don't seem to work properly,
     
    #10
  11. ice cold
    Offline

    ice cold Plugin Developer Plugin Developer

    Joined:
    Oct 24, 2016
    Messages:
    672
    Likes Received:
    67
    It works for me
     
    #11
  12. DreTaX
    Offline

    DreTaX Probably knows the answer... Administrator

    Joined:
    Jun 29, 2014
    Messages:
    3,927
    Likes Received:
    705
    In @ice cold 's version the error is this: Detection[Player.UID]= Detection[Player.UID] + 1
    Because there is null at the dictionary first.

    On my end, idunno. What exactly is happening?
     
    #12
  13. Mr. Bean ✅
    Offline

    Mr. Bean ✅ Member Member

    Joined:
    Mar 3, 2017
    Messages:
    55
    Likes Received:
    5
    Can you plz change the code to fix it?
    Code (Python):
    __author__ = 'DreTaX'
    __version__ = '1.0'

    import clr
    clr.AddReferenceByPartialName("Fougerite")

    import Fougerite
    import System
    from System import *

    Cooldown = {}
    Detection = {}
    # Seconds that must pass after a player's message before he can send another one.
    FloodSeconds = 3

    class AntiSpam:

        def On_Chat(self, Player, ChatEvent):
            if Player.UID not in Cooldown:
                Cooldown[Player.UID] = TimeSpan.FromTicks(DateTime.Now.Ticks).TotalSeconds
            else:
                calc = TimeSpan.FromTicks(DateTime.Now.Ticks).TotalSeconds - Cooldown[Player.UID]
                if calc < FloodSeconds:
                    ChatEvent.NewText = "    "
                    Player.Message("[color red]PLEASE DONT SPAM")
                    Detection[Player.UID] = Detection[Player.UID] + 1
                    if Detection[Player.UID] == 3:
                        Player.Disconnect()
                        Server.BroadcastNotice(Player.Name + " Has been auto kicked for spamming")
                else:
                    Cooldown[Player.UID] = TimeSpan.FromTicks(DateTime.Now.Ticks).TotalSeconds
                    Detection[Player.UID] = 0

        def On_PlayerDisconnected(self, Player):
            if Player.UID in Cooldown.keys():
                Cooldown.pop(Player.UID)
     
    #13
  14. DreTaX
    Offline

    DreTaX Probably knows the answer... Administrator

    Joined:
    Jun 29, 2014
    Messages:
    3,927
    Likes Received:
    705
  15. aliesmaili
    Offline

    aliesmaili Member Member

    Joined:
    Nov 23, 2017
    Messages:
    61
    Likes Received:
    1
    #15
  16. DreTaX
    Offline

    DreTaX Probably knows the answer... Administrator

    Joined:
    Jun 29, 2014
    Messages:
    3,927
    Likes Received:
    705
    AntiSpam is supposed to be the plugin name m8..
     
    #16
  17. aliesmaili
    Offline

    aliesmaili Member Member

    Joined:
    Nov 23, 2017
    Messages:
    61
    Likes Received:
    1
    i know !
    i dont know what is error : unexpected indent
    can you help me what is this error and how fix ?
    i have 3 best plugin and have this error
    tanx
     
    #17
  18. ice cold
    Offline

    ice cold Plugin Developer Plugin Developer

    Joined:
    Oct 24, 2016
    Messages:
    672
    Likes Received:
    67
    unexpected indent means that there is a space somewhere where it shouldnt be

    and please make a thread here https://fougerite.com/forums/general-discussion.13/ and post the code of you plugin there so its easier for us to sort out your problems :)

    to prevent things going offtopic
     
    #18
  19. aliesmaili
    Offline

    aliesmaili Member Member

    Joined:
    Nov 23, 2017
    Messages:
    61
    Likes Received:
    1
    i know for space and 99999999 checked ! and dont find :|
     
    #19

Share This Page