{"id":17260279,"url":"https://github.com/rubbaboy/chatfilter","last_synced_at":"2025-07-14T16:06:15.726Z","repository":{"id":97465863,"uuid":"204046951","full_name":"RubbaBoy/ChatFilter","owner":"RubbaBoy","description":"The advanced chat filter for Craftathon","archived":false,"fork":false,"pushed_at":"2019-08-28T21:36:54.000Z","size":160,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-07-04T08:03:40.611Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RubbaBoy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-23T18:02:56.000Z","updated_at":"2019-08-28T21:36:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"ab2fd732-9245-40e3-8be2-9d8f44c47fd0","html_url":"https://github.com/RubbaBoy/ChatFilter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/RubbaBoy/ChatFilter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubbaBoy%2FChatFilter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubbaBoy%2FChatFilter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubbaBoy%2FChatFilter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubbaBoy%2FChatFilter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RubbaBoy","download_url":"https://codeload.github.com/RubbaBoy/ChatFilter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubbaBoy%2FChatFilter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265314418,"owners_count":23745264,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T07:47:45.112Z","updated_at":"2025-07-14T16:06:15.329Z","avatar_url":"https://github.com/RubbaBoy.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"## ChatFilter v3\n\nThis is the official chat filter of [Craftathon](https://craftathon.org/), copied from the [Craftathon](https://github.com/Craftathon/) GitHub organization, originally made in mid-late December of 2018. This could be improved and may be later on. This is the third rewrite of the filter, and a full feature specification document may be found [here](https://github.com/RubbaBoy/ChatFilter/blob/master/Specifications.md) ([or on Google Docs](https://docs.google.com/document/d/1AangW6Jv_X2TmRq8W-VM0TtWohxPGtAXCM7xruTTTjU/edit?usp=sharing)), which is highly recommended if you are interested in this.\n\n- [Benchmarks](#Benchmarks)\n- [Filter Examples](#Filter-Examples)\n- [Code Examples](#Code-Examples)\n\n## Benchmarks\n\nJust before releasing this repo I made some (very) small optimizations, and also added a benchmarking test to it. It is tested with SwearIpsum ([Example](https://rubbaboy.me/code/s82d84j)) generated in the [SwearIpsum](https://github.com/RubbaBoy/ChatFilter/blob/master/benchmark/src/main/java/com/craftathon/chatfilter3/utils/SwearIpsum.java#L39) class. The current results are below, the long and short message lines are below respectively:\n\n```\nbiᾰὰáṱṯcch ante ipsum bbbo¤ḡ horny chhỗợoḋȅ pu➎şi ẉwaặﬡk hoⓡnie ultrices sἤἥἤὴiｔ ｍủuứṻfｆ Curae; Aenean neὲgｇrổ wᾧaaἅanｎk @ậ➍s５５ lube lacinia fửccck tincidunt vitae\n```\n\n```\ncoccc¢k cṻnt ultrices nibh\n```\n\nAnd the results (20 warmups and 40 iterations)\n\n```\n# Run complete. Total time: 00:04:05\n\nBenchmark                              Mode  Cnt     Score    Error  Units\nBenchmarkChatFilter.filterSingleLong   avgt   40  4724.346 ± 24.654  us/op\nBenchmarkChatFilter.filterSingleShort  avgt   40   892.203 ± 16.233  us/op\n```\n\n## Filter Examples\n\nThe following are some examples of filtered text, before and with the `ChatFilter#blockFullWord(boolean)` option enabled/disabled. Some are labeled with more specific features being demonstrated.\n\n```diff\n- Test of a fucking sh1tty @ss filter\n+ Test of a ******* ****** *** filter\n+ Test of a ****ing *****y *** filter\n```\n\n### Word Priorities\n\nThe word `ass` has a priority of 0, meaning it can't start with the word, but may contain it.\n```diff\n- Your @s5 is grass and i'm a lawnmower\n+ Your *** is grass and i'm a lawnmower\n+ Your *** is grass and i'm a lawnmower\n```\n\nThe word `fuck` has a priority of 1, meaning it can't be contained within a word at all.\n```diff\n- That really oofuckingdd sucks\n+ That really *********** sucks\n+ That really oo****ingdd sucks\n```\n\n### No Separation\n\nWords may be separated by spaces by default, unless set in the word list. An example is `sex`, which is set by default to be able to be separated by a space in between the `e` and `s`. A future addition to this feature (As it is still a bit buggy) is ensuring the word is encased in other letters.\n\n```diff\n- Give sex to me\n+ Give *** to me\n+ Give *** to me\n```\n\nThe word `sex` with a space separating the `s` and `e`:\n```diff\n- His extra pizza\n+ His extra pizza\n+ His extra pizza\n```\n\n### Number Filter\n\nBy default, words are considered unrecognizable if consisting of 75% or more numbers.\n\n33% number:\n```diff\n- 4ss\n+ ***\n+ ***\n```\n\n100% number:\n\n```diff\n- 455\n+ 455\n+ 455\n```\n\n\n\n## Code Examples\n\nUsing the filter is pretty simple. Soon the repo will probably be on Central, though right now it's just on JitPack. To obtain the rep, simply put\n\n```groovy\nrepositories {\n\tmaven { url 'https://jitpack.io' }\n}\n```\n\nAnd\n\n```groovy\ndependencies {\n\timplementation 'com.github.RubbaBoy:ChatFilter:master-SNAPSHOT'\n}\n```\n\nTo your build.gradle. To use it with maven, just look [here](https://jitpack.io/#RubbaBoy/ChatFilter/master-SNAPSHOT) because I can't be fucked to fill half this readme with the verbose shit maven is.\n\nTo use the filter, you need to get an instance of `ChatFilter` via\n\n```java\nvar chatFilter = new DefaultChatFilter();\nchatFilter.init();\n```\n\nThen to filter words, just do\n\n```java\nvar cleaned = chatFilter.clean(\"A fuucking string shiiiittt right here.\");\n```\n\nAnd you can use whatever string you want. This string results in `A ******** string ********* right here.`.\n\nTo add custom bad words, you can get the default HashMap of them and just add to that, or give it a custom map. The method below gets the default bad words, and adds the given map to a copy of them.\n\n```java\nchatFilter.init(DefaultChatFilter.getBlocked(Map.of(\"dog\", 1)));\n```\n\nThis acts as expected, with the following code and output after being initialized with that\n\n```java\nvar cleaned = chatFilter.clean(\"I like dogs, really any king of d0g.\");\n```\n\n```\nI like ***** really any king of ****\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubbaboy%2Fchatfilter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubbaboy%2Fchatfilter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubbaboy%2Fchatfilter/lists"}