Valhalla Legends Forums Archive | Java Programming | UnCensor() Method Code

AuthorMessageTime
JoeTheOdd
I just ported this to Java from LoRd[nK]'s Unknown Bot source code. This is untested, and I don't know if I did replace right, but I belive I did.

EDIT 3/20/05 10:02PM: Alphabetized list, removed duplicates, added more words I found from searching forums.

[code]    //author JoeTheOdd
    //removes censoring from messages in public Bnet channels
    //@arg message - message recieved from Bnet
    //@return - uncensored message
    public static String uncensor(String message)
    {
        message = message.replaceAll("@$%!@%&",  "asshole");
        message = message.replaceAll("@$%!@!&",  "asswipe");
        message = message.replaceAll("#@%$!",    "bitch");
        message = message.replaceAll("$!@!$",    "chink");
        message = message.replaceAll("$%@%",      "clit");
        message = message.replaceAll("$!$%",      "cock");
        message = message.replaceAll("$&!%",      "cunt");
        message = message.replaceAll("%@$%",      "dick");
        message = message.replaceAll("%@%&!",    "dildo");
        message = message.replaceAll("&#&$%",    "erect");
        message = message.replaceAll("!@!@!%",    "faggot");
        message = message.replaceAll("!&$%",      "fuck");
        message = message.replaceAll("!@!$",      "gook");
        message = message.replaceAll("$@$&",      "kike");
        message = message.replaceAll("$%$",      "kkk");
        message = message.replaceAll("$%&!",      "klux");
        message = message.replaceAll("%&$#@#!",  "lesbian");
        message = message.replaceAll("&@$%&#$@%", "masturbat");
        message = message.replaceAll("!@!@#",    "nigga");
        message = message.replaceAll("!@!@&#",    "nigger");
        message = message.replaceAll("!@!@%&",    "nipple");
        message = message.replaceAll("!#!@$&",    "orgasm");
        message = message.replaceAll("!&!@$",    "penis");
        message = message.replaceAll("!&$%@",    "pussy");
        message = message.replaceAll("$!@%",      "shit");
        message = message.replaceAll("$%&%",      "slut");
        message = message.replaceAll("!@!@!@",    "vagina");
        message = message.replaceAll("!@!#&",    "whore");
        return message;
    }[/code]
March 21, 2005, 2:46 AM
kamakazie
One thing you'll want to becareful of is ordering of each replace.  For example, if you ran "!&$%@ !&$%" through this, it should ouput "fuck@ fuck" when it should ouput "pussy fuck."  Because "!&$%" is replaced first before "!&$%@", this happens. Other things to pay attention to would be only replacing whole words although I am not quite sure if battle.net partially replaces words (e.g. "fuckface" => "!&$%face" then it wouldn't be a problem).
March 21, 2005, 4:18 AM
JoeTheOdd
Whoops, guess alphabetizing it wasn't the best decision then, eh? I'll have to fix that after school.
March 21, 2005, 1:05 PM
iago
Another thing I'd do is:

[code]if(message.indexOf('$') >= 0 || message.indexOf('!') >= 0)
{
  ... do everything
}[/code]

That way it won't run all those replaces EVERY time.  And yes, I checked, every one of them has a $ or ! in it.
March 21, 2005, 5:39 PM
JoeTheOdd
Hmph. iago just loves optimization. VB programmers don't like that.

Fixed ordering and ported to C++ and VB.

Java:
[code]//removes censoring from messages in public Bnet channels
//@arg message - message recieved from Bnet
//@return - uncensored message
public static String uncensor(String message)
{
    message = message.replaceAll("@$%!@%&",  "asshole");
    message = message.replaceAll("@$%!@!&",  "asswipe");
    message = message.replaceAll("#@%$!",    "bitch");
    message = message.replaceAll("$!@!$",    "chink");
    message = message.replaceAll("$%@%",      "clit");
    message = message.replaceAll("$!$%",      "cock");
    message = message.replaceAll("$&!%",      "cunt");
    message = message.replaceAll("%@$%",      "dick");
    message = message.replaceAll("%@%&!",    "dildo");
    message = message.replaceAll("&#&$%",    "erect");
    message = message.replaceAll("!@!@!%",    "faggot");
    message = message.replaceAll("!&$%@",    "pussy");
    message = message.replaceAll("!&$%",      "fuck");
    message = message.replaceAll("!@!$",      "gook");
    message = message.replaceAll("$@$&",      "kike");
    message = message.replaceAll("$%$",      "kkk");
    message = message.replaceAll("$%&!",      "klux");
    message = message.replaceAll("%&$#@#!",  "lesbian");
    message = message.replaceAll("&@$%&#$@%", "masturbat");
    message = message.replaceAll("!@!@#",    "nigga");
    message = message.replaceAll("!@!@&#",    "nigger");
    message = message.replaceAll("!@!@%&",    "nipple");
    message = message.replaceAll("!#!@$&",    "orgasm");
    message = message.replaceAll("!&!@$",    "penis");
    message = message.replaceAll("$!@%",      "shit");
    message = message.replaceAll("$%&%",      "slut");
    message = message.replaceAll("!@!@!@",    "vagina");
    message = message.replaceAll("!@!#&",    "whore");
    return message;
}[/code]

C++:
[code]//removes censoring from messages in public Bnet channels
//@arg *txt - message recieved from Bnet
//@return - uncensored message
//
//I don't know C++ very well, but this doesn't
//appear to return anything, from my knoledge of the language.
//Thanks to Grok[vL] for help with this (indirectly, but still..)
void decensor(char *txt)
{
    replace(txt, "@$%!@%&",  "asshole");
    replace(txt, "@$%!@!&",  "asswipe");
    replace(txt, "#@%$!",    "bitch");
    replace(txt, "$!@!$",    "chink");
    replace(txt, "$%@%",      "clit");
    replace(txt, "$!$%",      "cock");
    replace(txt, "$&!%",      "cunt");
    replace(txt, "%@$%",      "dick");
    replace(txt, "%@%&!",    "dildo");
    replace(txt, "&#&$%",    "erect");
    replace(txt, "!@!@!%",    "faggot");
    replace(txt, "!&$%@",    "pussy");
    replace(txt, "!&$%",      "fuck");
    replace(txt, "!@!$",      "gook");
    replace(txt, "$@$&",      "kike");
    replace(txt, "$%$",      "kkk");
    replace(txt, "$%&!",      "klux");
    replace(txt, "%&$#@#!",  "lesbian");
    replace(txt, "&@$%&#$@%", "masturbat");
    replace(txt, "!@!@#",    "nigga");
    replace(txt, "!@!@&#",    "nigger");
    replace(txt, "!@!@%&",    "nipple");
    replace(txt, "!#!@$&",    "orgasm");
    replace(txt, "!&!@$",    "penis");
    replace(txt, "$!@%",      "shit");
    replace(txt, "$%&%",      "slut");
    replace(txt, "!@!@!@",    "vagina");
    replace(txt, "!@!#&",    "whore");
}[/code]

VB:
[code]'//removes censoring from messages in public Bnet channels
'//@arg message - message recieved from Bnet
'//@return - uncensored message
Public Function uncensor(message As String) As String
    message = Replace(message, "@$%!@%&",  "asshole")
    message = Replace(message, "@$%!@!&",  "asswipe")
    message = Replace(message, "#@%$!",    "bitch")
    message = Replace(message, "$!@!$",    "chink")
    message = Replace(message, "$%@%",      "clit")
    message = Replace(message, "$!$%",      "cock")
    message = Replace(message, "$&!%",      "cunt")
    message = Replace(message, "%@$%",      "dick")
    message = Replace(message, "%@%&!",    "dildo")
    message = Replace(message, "&#&$%",    "erect")
    message = Replace(message, "!@!@!%",    "faggot")
    message = Replace(message, "!&$%@",    "pussy")
    message = Replace(message, "!&$%",      "fuck")
    message = Replace(message, "!@!$",      "gook")
    message = Replace(message, "$@$&",      "kike")
    message = Replace(message, "$%$",      "kkk")
    message = Replace(message, "$%&!",      "klux")
    message = Replace(message, "%&$#@#!",  "lesbian")
    message = Replace(message, "&@$%&#$@%", "masturbat")
    message = Replace(message, "!@!@#",    "nigga")
    message = Replace(message, "!@!@&#",    "nigger")
    message = Replace(message, "!@!@%&",    "nipple")
    message = Replace(message, "!#!@$&",    "orgasm")
    message = Replace(message, "!&!@$",    "penis")
    message = Replace(message, "$!@%",      "shit")
    message = Replace(message, "$%&%",      "slut")
    message = Replace(message, "!@!@!@",    "vagina")
    message = Replace(message, "!@!#&",    "whore")
    uncensor = message
End Function[/code]
March 21, 2005, 10:27 PM
LoRd
[quote author=Joey link=topic=10986.msg104743#msg104743 date=1111373214]
I just ported this to Java from LoRd[nK]'s Unknown Bot source code. This is untested, and I don't know if I did replace right, but I belive I did.

EDIT 3/20/05 10:02PM: Alphabetized list, removed duplicates, added more words I found from searching forums.

[code]    //author JoeTheOdd
    //removes censoring from messages in public Bnet channels
    //@arg message - message recieved from Bnet
    //@return - uncensored message
    public static String uncensor(String message)
    {
        message = message.replaceAll("@$%!@%&",  "asshole");
        message = message.replaceAll("@$%!@!&",  "asswipe");
        message = message.replaceAll("#@%$!",    "bitch");
        message = message.replaceAll("$!@!$",    "chink");
        message = message.replaceAll("$%@%",      "clit");
        message = message.replaceAll("$!$%",      "cock");
        message = message.replaceAll("$&!%",      "cunt");
        message = message.replaceAll("%@$%",      "dick");
        message = message.replaceAll("%@%&!",    "dildo");
        message = message.replaceAll("&#&$%",    "erect");
        message = message.replaceAll("!@!@!%",    "faggot");
        message = message.replaceAll("!&$%",      "fuck");
        message = message.replaceAll("!@!$",      "gook");
        message = message.replaceAll("$@$&",      "kike");
        message = message.replaceAll("$%$",      "kkk");
        message = message.replaceAll("$%&!",      "klux");
        message = message.replaceAll("%&$#@#!",  "lesbian");
        message = message.replaceAll("&@$%&#$@%", "masturbat");
        message = message.replaceAll("!@!@#",    "nigga");
        message = message.replaceAll("!@!@&#",    "nigger");
        message = message.replaceAll("!@!@%&",    "nipple");
        message = message.replaceAll("!#!@$&",    "orgasm");
        message = message.replaceAll("!&!@$",    "penis");
        message = message.replaceAll("!&$%@",    "pussy");
        message = message.replaceAll("$!@%",      "shit");
        message = message.replaceAll("$%&%",      "slut");
        message = message.replaceAll("!@!@!@",    "vagina");
        message = message.replaceAll("!@!#&",    "whore");
        return message;
    }[/code]
[/quote]

Note that you're not the author of a piece of code if all you did was port it.
March 21, 2005, 10:46 PM
Newby
If I remember correctly, that function came from a bot made way before Unknown Bot.

Or one similar to it did, anyhow.
March 22, 2005, 12:07 AM
Myndfyr
[quote author=Joey link=topic=10986.msg104819#msg104819 date=1111444027]
Hmph. iago just loves optimization. VB programmers don't like that.
[/quote]
...unless you're actually a GOOD programmer trying to write GOOD code, in which case you DO like that.  You know, like professionals would?

Instead of making a scornful remark, why don't you attempt to LEARN from someone who is knowledgeable and experienced?
March 22, 2005, 12:29 AM
iago
[quote author=MyndFyre link=topic=10986.msg104844#msg104844 date=1111451375]
Instead of making a scornful remark
[/quote]

I'd call it a "joke".  He's said the same thing to me before :)
March 22, 2005, 12:33 AM
Myndfyr
[quote author=iago link=topic=10986.msg104846#msg104846 date=1111451620]
[quote author=MyndFyre link=topic=10986.msg104844#msg104844 date=1111451375]
Instead of making a scornful remark
[/quote]

I'd call it a "joke".  He's said the same thing to me before :)
[/quote]

I would generally agree, except that he didn't actually incorporate your suggested change, which I think would have been, mm, 6 lines?  :P
March 22, 2005, 12:36 AM
Lenny
I find it rather strange battle.net replaces a different set of censors on different words.  Almost makes me think some sort of formula was followed.

There appears to be some patterns, but nothing consistent from my first glance.  But if you notice, the length of each word does match its replacement...



March 22, 2005, 1:41 AM
Ban
Or perhaps they just bashed random shift-numbers until they came up with a string of similiar length. If they had changed the length of the string the point of the original message would have never been gotten across; some things are needed to properly understand some sentences/messages
March 22, 2005, 3:38 PM
Adron
[quote author=Ban link=topic=10986.msg104932#msg104932 date=1111505919]
Or perhaps they just bashed random shift-numbers until they came up with a string of similiar length. If they had changed the length of the string the point of the original message would have never been gotten across; some things are needed to properly understand some sentences/messages
[/quote]

Or if they had changed the length of the message, they would have had to copy the resultant string to a new position in memory, incurring a performance loss. By ensuring that the replacement strings are the same length as the original strings, they can just overwrite the censored words inplace.
March 22, 2005, 5:05 PM
iago
If they really wanted to hide it, they could have done "penis"->"*****", etc.  But they didn't, so they must have had some intention of letting people decode them :-/
March 22, 2005, 6:30 PM
Lenny
This is one of the reasons I believe they could have went through a formula to censor the text.  Perhaps the obscenities are categorized, it just seems as if a pattern exists.  But it might only appear so because of the small character range given.

As far as performance goes, it would probably be best if the text wasn't censored at all, eliminating the need to filter every message passed to the server.  But since it is, optimizing it as much as possible would seem logical.

March 22, 2005, 8:01 PM
Ban
[quote author=Adron link=topic=10986.msg104947#msg104947 date=1111511122]
[quote author=Ban link=topic=10986.msg104932#msg104932 date=1111505919]
Or perhaps they just bashed random shift-numbers until they came up with a string of similiar length. If they had changed the length of the string the point of the original message would have never been gotten across; some things are needed to properly understand some sentences/messages
[/quote]

Or if they had changed the length of the message, they would have had to copy the resultant string to a new position in memory, incurring a performance loss. By ensuring that the replacement strings are the same length as the original strings, they can just overwrite the censored words inplace.
[/quote]

Good point, I failed to consider that.

[quote]
But it might only appear so because of the small character range given.
[/quote]

I would think that is more than likely,  as there are only 6 characters used in the replacements...
March 23, 2005, 1:25 PM
R.a.B.B.i.T
To solve replacement issues: replace the longest words first.

@Lenny: You only need to check in public channels, which cuts the actual amount of filtering down.
March 24, 2005, 10:28 PM
Adron
[quote author=rabbit link=topic=10986.msg105356#msg105356 date=1111703301]
To solve replacement issues: replace the longest words first.
[/quote]

Hmm, so this would work?

[code]
        message = message.replaceAll("&@$%&#$@%", "masturbat");
        message = message.replaceAll("@$%!@%&",  "asshole");
        message = message.replaceAll("@$%!@!&",  "asswipe");
        message = message.replaceAll("%&$#@#!",  "lesbian");

        message = message.replaceAll("!@!@!%",    "faggot");
        message = message.replaceAll("!@!@&#",    "nigger");
        message = message.replaceAll("!@!@%&",    "nipple");
        message = message.replaceAll("!#!@$&",    "orgasm");
        message = message.replaceAll("!@!@!@",    "vagina");

        message = message.replaceAll("#@%$!",    "bitch");
        message = message.replaceAll("$!@!$",    "chink");
        message = message.replaceAll("%@%&!",    "dildo");
        message = message.replaceAll("&#&$%",    "erect");
        message = message.replaceAll("!@!@#",    "nigga");
        message = message.replaceAll("!&!@$",    "penis");
        message = message.replaceAll("!&$%@",    "pussy");
        message = message.replaceAll("!@!#&",    "whore");

        message = message.replaceAll("$%@%",      "clit");
        message = message.replaceAll("$!$%",      "cock");
        message = message.replaceAll("$&!%",      "cunt");
        message = message.replaceAll("%@$%",      "dick");
        message = message.replaceAll("!&$%",      "fuck");
        message = message.replaceAll("!@!$",      "gook");
        message = message.replaceAll("$@$&",      "kike");
        message = message.replaceAll("$%&!",      "klux");
        message = message.replaceAll("$!@%",      "shit");
        message = message.replaceAll("$%&%",      "slut");

        message = message.replaceAll("$%$",      "kkk");
[/code]

Try it on "vaginaerect"?
March 24, 2005, 10:56 PM
Lenny
Regardless, it would still be a waste of server perfomance.  And if Adron is correct, they're trying to optimize something that isn't necessary.

But I personally think an 'uncensor()' method is a novelty feature that bots need not have. 

Why battle.net chose to have a distinct censor pattern for each word is beyond me. 

March 24, 2005, 10:59 PM
Quarantine
What would be funny is if they just put random letters together and some of you are boggling your minds for nothing :P
March 24, 2005, 11:11 PM
JoeTheOdd
[quote author=MyndFyre link=topic=10986.msg104848#msg104848 date=1111451817]
[quote author=iago link=topic=10986.msg104846#msg104846 date=1111451620]
[quote author=MyndFyre link=topic=10986.msg104844#msg104844 date=1111451375]
Instead of making a scornful remark
[/quote]

I'd call it a "joke".  He's said the same thing to me before :)
[/quote]

I would generally agree, except that he didn't actually incorporate your suggested change, which I think would have been, mm, 6 lines?  :P
[/quote]

Thats because I haven't had time. 3rd quarter just ended at my school, and I had about a month's worth of homework (I never did any of it when it was asigned) over the past few days. I was just joking, and I asumed that nobody would take it as a "scornful remark". Its just the kind of thing iago and I do.


@LoRd[nK]: Good to know you have nothing better to do than to try to shit on the little guy's day. Atleast I give credit for other's work incorporated into mine. Also, my code is nicely tabbed and easy to follow, unlike your wonderful code.
March 25, 2005, 2:20 AM
iago
[quote author=Joey link=topic=10986.msg105421#msg105421 date=1111717246]
I was just joking, and I asumed that nobody would take it as a "scornful remark". Its just the kind of thing iago and I do.
[/quote]
That's what I said :P

[quote]@LoRd[nK]: Good to know you have nothing better to do than to try to shit on the little guy's day. Atleast I give credit for other's work incorporated into mine. Also, my code is nicely tabbed and easy to follow, unlike your wonderful code.
[/quote]
Let's be nice here, children; if you want to be mad then take it to PM.
March 25, 2005, 2:34 AM
JoeTheOdd
I'll shut my mouth if he shuts his. I'm done for now. I just wanted to remind him he hasn't exactly perfect either.

Due to the emmence ammount of work it takes to post every single update at a good 5 forums, the code updates will only be posted here. Thanks to everyone for their suggestions.
March 25, 2005, 2:51 AM
iago
[quote author=Joey link=topic=10986.msg105435#msg105435 date=1111719096]
I'll shut my mouth if he shuts his. I'm done for now. I just wanted to remind him he hasn't exactly perfect either.
[/quote]

Far from it, but this is the wrong place to get into it.
March 25, 2005, 3:03 AM

Search