[SOLVED]Spamfilter/chatfilter
Hello! The EMU I'm using does not have a working chatfilter, so I searched it up, and found codes I could use.
However, its still not working for me, so I wonder if anyone know if there is any other filters I could use?
The database is working, I got no errors on the emulator not finding the database "room_swearword_filter"
This is my "LanguageLocale.cs"
Code:
namespace Butterfly.Core
{
using Butterfly;
using Database_Manager.Database.Session_Details.Interfaces;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Windows.Forms;
using Database_Manager.Database;
internal class LanguageLocale
{
private static List<string> swearwords;
private static Dictionary<string, string> values;
internal static string welcomeAlert;
internal static bool welcomeAlertEnabled;
internal static string FilterSwearwords(string original)
{
foreach (string str in swearwords)
{
original = ReplaceEx(original, str, "bobba");
}
return original;
}
internal static string GetValue(string value)
{
if (!values.ContainsKey(value))
{
throw new MissingLocaleException("Missing language locale for [" + value + "]");
}
return values[value];
}
internal static void Init()
{
values = IniReader.ReadFile(Path.Combine(Application.StartupPath, "System/locale.ini"));
InitWelcomeMessage();
}
internal static void InitSwearWord()
{
DataTable table;
swearwords = new List<string>();
using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
{
adapter.setQuery("SELECT word FROM room_swearword_filter");
table = adapter.getTable();
}
foreach (DataRow row in table.Rows)
{
string item = (string)row[0];
swearwords.Add(item);
}
}
private static void InitWelcomeMessage()
{
welcomeAlertEnabled = IniReader.ReadFile(Path.Combine(Application.StartupPath, "System/welcome_config.ini"))["welcome.alert.enabled"] == "true";
if (welcomeAlertEnabled)
{
welcomeAlert = File.ReadAllText(Path.Combine(Application.StartupPath, "System/welcome_message.ini"));
}
}
private static string ReplaceEx(string original, string pattern, string replacement)
{
int count, position0, position1;
count = position0 = position1 = 0;
string upperString = original.ToUpper();
string upperPattern = pattern.ToUpper();
int inc = (original.Length / pattern.Length) * (replacement.Length - pattern.Length);
char[] chars = new char[original.Length + Math.Max(0, inc)];
while ((position1 = upperString.IndexOf(upperPattern, position0)) != -1)
{
for (int i = position0; i < position1; ++i)
chars[count++] = original[i];
for (int i = 0; i < replacement.Length; ++i)
chars[count++] = replacement[i];
position0 = position1 + pattern.Length;
}
if (position0 == 0) return original;
for (int i = position0; i < original.Length; ++i)
chars[count++] = original[i];
return new string(chars, 0, count);
}
}
}
Do anyone know a fix for this? Also tried to enable safechat in "external_variables" but it crashes the client.
Also if its any other method like getting the wordfilter from a file, I would use that too.
I'm using Leon/Leenster's edit of BcStorm.
Re: Spamfilter/chatfilter
Use swift :D
I find a swift fix for it in ragezone, I don't remember, and IDK if it work in BCstorm.
Re: Spamfilter/chatfilter
This only loads up the words from the database.
I dont know if there is a function that loops through it every time someone talks.
Re: Spamfilter/chatfilter
Damn it was easy to fix.
If any of you have the same problem, go to: BcStorm>Butterfly>HabboHotel>Rooms and then open RoomsUsers.cs and go to line 209 and uncomment
Code:
Message = LanguageLocale.FilterSwearwords(Message);
Thanks for help!
This can now be locked.