Spam Filter in C# - Habboon

Vinny95

Member
Apr 28, 2016
53
1
Hello,
I'm making a Spam Filter for my Hotel, but i have a problem now.
This is the code:

Code:
            if (Message.Length >= 3 && Message.ToString() == "www")
            {
                    if (!Session.GetHabbo().GetPermissions().HasRight("mod_tool"))
                    {
                   
                        Session.SendNotification("Message.");
                        Message = " (no one message) ";
                    }
            }

My problem is that:
How can I tell if this code is WWW written in a sentence must do what the code does?
What is the code? Send an alert to the user saying to never spam only if WWW is written in a sentence, only that at the time when I write www alone then it works, if you write it in a sentence (eg: hello www) the www and the remains' alert does not come out.

I have add this code on: ChatEvents.cs

Thanks for the support.
 

Zodiak

recovering crack addict
Nov 18, 2011
450
411
Code:
if ((Message.Length >= 3) && (Message.ToString().ToLower().Contains("www"))) {
    if (!Session.GetHabbo().GetPermissions().HasRight("mod_tool")) {
        Session.SendNotification("Message.");
        Message = " (no one message) ";
    }
}

?
 

Janzeer

Headmaster Of Hogwart's
Apr 30, 2012
522
47
Try this, maybe because "==" requites having the sentence being 'www' otherwise it returns a false value. Thus to overcome this you could try to see if the message contains 'www'.
Code:
if (Message.Length >= 3 && Message.ToString().Contains("www"))
            {
                    if (!Session.GetHabbo().GetPermissions().HasRight("mod_tool"))
                    {
                   
                        Session.SendNotification("Message.");
                        Message = " (no one message) ";
                    }
            }
 

Users who are viewing this thread

Top